|
|
@ -8,31 +8,31 @@ import ( |
|
|
|
) |
|
|
|
|
|
|
|
type Robot struct { |
|
|
|
Id string `json:"id"` |
|
|
|
Name string `json:"name"` |
|
|
|
Message string `json:"-"` |
|
|
|
Stats Stats `json:"-"` |
|
|
|
TargetSpeed float32 `json:"-"` |
|
|
|
Speed float32 `json:"speed"` |
|
|
|
Health int `json:"health"` |
|
|
|
RepairCounter float32 `json:"repair"` |
|
|
|
ScanCounter float32 `json:"scan_bonus"` |
|
|
|
ActiveScan bool `json:"-"` |
|
|
|
Position v.Point2d `json:"position"` |
|
|
|
Heading v.Vector2d `json:"heading"` |
|
|
|
DesiredHeading *v.Vector2d `json:"-"` |
|
|
|
MoveTo *v.Point2d `json:"-"` |
|
|
|
FireAt *v.Point2d `json:"-"` |
|
|
|
Scanners []Scanner `json:"scanners"` |
|
|
|
LastFired int `json:"-"` |
|
|
|
Collision bool `json:"collision"` |
|
|
|
Hit bool `json:"hit"` |
|
|
|
Probe *v.Point2d `json:"probe"` |
|
|
|
ProbeResult *ProbeResult `json:"probe_result"` |
|
|
|
gameStats *BotStats `json:-` |
|
|
|
Id string `json:"id"` |
|
|
|
Name string `json:"name"` |
|
|
|
Message string `json:"-"` |
|
|
|
Stats Stats `json:"-"` |
|
|
|
TargetSpeed float32 `json:"-"` |
|
|
|
Speed float32 `json:"speed"` |
|
|
|
Health int `json:"health"` |
|
|
|
RepairCounter float32 `json:"repair"` |
|
|
|
ScanCounter float32 `json:"scan_bonus"` |
|
|
|
ActiveScan bool `json:"-"` |
|
|
|
Position v.Point2d `json:"position"` |
|
|
|
Heading v.Vector2d `json:"heading"` |
|
|
|
DesiredHeading *v.Vector2d `json:"-"` |
|
|
|
MoveTo *v.Point2d `json:"-"` |
|
|
|
FireAt *v.Point2d `json:"-"` |
|
|
|
Scanners []Scanner `json:"scanners"` |
|
|
|
LastFired int `json:"-"` |
|
|
|
Collision *Collision `json:"collision"` |
|
|
|
Hit bool `json:"hit"` |
|
|
|
Probe *v.Point2d `json:"probe"` |
|
|
|
ProbeResult *Collision `json:"probe_result"` |
|
|
|
gameStats *BotStats `json:-` |
|
|
|
} |
|
|
|
|
|
|
|
type ProbeResult struct { |
|
|
|
type Collision struct { |
|
|
|
v.Point2d |
|
|
|
Type string `json:"type"` |
|
|
|
} |
|
|
@ -244,7 +244,7 @@ func (r *Robot) checkCollisions(g *game, probe v.Vector2d) (bool, *v.Point2d, *R |
|
|
|
} |
|
|
|
|
|
|
|
func (r *Robot) Tick(g *game) { |
|
|
|
r.Collision = false |
|
|
|
r.Collision = nil |
|
|
|
r.Hit = false |
|
|
|
r.scan(g) |
|
|
|
|
|
|
@ -310,7 +310,13 @@ func (r *Robot) Tick(g *game) { |
|
|
|
dmg = 1 |
|
|
|
} |
|
|
|
|
|
|
|
r.Collision = true |
|
|
|
r.Collision = &Collision{ |
|
|
|
Point2d: *intersection_point, |
|
|
|
Type: "obstacle", |
|
|
|
} |
|
|
|
if hit_robot != nil { |
|
|
|
r.Collision.Type = "robot" |
|
|
|
} |
|
|
|
if hit_robot != nil { |
|
|
|
hit_robot.Health -= dmg |
|
|
|
hit_robot.Speed = (hit_robot.Speed * 0.5) |
|
|
@ -377,7 +383,7 @@ func (r *Robot) Tick(g *game) { |
|
|
|
probe_vector := r.Probe.Sub(r.Position) |
|
|
|
coll, pos, robo := r.checkCollisions(g, probe_vector) |
|
|
|
if coll { |
|
|
|
r.ProbeResult = &ProbeResult{ |
|
|
|
r.ProbeResult = &Collision{ |
|
|
|
Point2d: *pos, |
|
|
|
Type: "obstacle", |
|
|
|
} |
|
|
|