public override bool Live(Universe.Map map) { StopAnyMovement(); if (closest != null) { if ((body.position - closest).Length > navigator.MaximumDistance || !map.ClearSight(body.position, closest)) { Move(map); } else { if ((body.position - closest).Length > (navigator.MaximumDistance + navigator.MinimumDistance) / 2 || (body.position - closest).Length < navigator.MaximumDistance) { Move(map); } Attack(); } } closest = null; return(base.Live(map)); }
public MagicBullet(Vector position, Universe.Map map, MagicBulletData data) { this.data = data; this.map = map; body = new Thing(data.modelID, position + Vector.FromAngle(angle) * data.radius); angle = 0; }
public VolleyBullet(Vector direction, VolleyBulletData data, Universe.Map map) { this.direction = direction; this.data = data; shootsLeft = data.bulletsNumber; this.map = map; }
public Grenade(Vector position, Vector direction, GrenadeData grenadeData, Universe.Map map) : base(position, direction, grenadeData, map) { shrapnelsData = grenadeData.shrapnelsData; this.map = map; isBombing = false; }
virtual public void Shoot(Vector position, Vector direction, Universe.Map map) { if (delayCounter == delay && direction.Length > 0) { Launch(data.GetBullet(position, direction, map)); delayCounter = 0; } }
public IBullet GetBullet(Vector position, Vector direction, Universe.Map map) { double t = map.Clash(new Rect(position, new Vector(1, size.y), null, direction.Angle), direction * size.x); Rect body = new Rect(position + direction * size.x * t / 2, new Vector(size.x * t, size.y), texture, direction.Angle); return(new LongBullet(body, direction, this)); }
public override void Live(Universe.Map map, Vector position) { base.Live(map, position); if (delayCounter < delay) { ++delayCounter; } }
public void Live(Universe.Map map, Vector position) { foreach (Weapon weapon in weapons) { weapon.Live(map, position); } launcher.Live(map, position); }
public SimpleBullet(Vector position, Vector direction, SimpleBulletData data, Universe.Map map) { body = new Thing(data.modelID, position); this.direction = (direction / direction.Length) * data.speed; body.angle = direction.Angle; this.data = data; rangeCounter = 0; this.map = map; }
public virtual void Live(Universe.Map map, Vector position) { for (int i = 0; i < bullets.Count; ++i) { if (!bullets[i].Live(this, position)) { bullets.RemoveAt(i--); } } }
protected void Move(Universe.Map map, Vector movement) { for (int i = 0; i < Constants.Dimentions; ++i) { double t = map.Clash(body, movement.Just(i)); if (t > Constants.Epsilon) { body.position += movement.Just(i) * t; } else { knockBack[i] = -knockBack[i]; } } }
public void StartNavigation(Vector start, Vector target, Universe.Map map) { queue = new SimplePriorityQueue <Vector>(); values = new Dictionary <Vector, Tuple <Vector, double, double> >(500); targetPosition = target; start = (map.FromBlockPosition(start) - new Vector(0.5, 0.5)).Round(); target = (map.FromBlockPosition(target) - new Vector(0.5, 0.5)).Round(); this.target = target; this.map = map; best = start; values[start] = new Tuple <Vector, double, double>(null, 0, Heuristic(start)); queue.Enqueue(start, (float)values[start].Item3); }
/* returns whether or not the entity is still alive or not */ public virtual bool Live(Universe.Map map) { if (agentActions['Q'] == State.FirstTimeDown) { bag.Swap(); } Vector currentKB = knockBack / 20; double t = body.angle; body.angle = agentActions.lookDirection.Angle; if (map.Clash(body, new Vector()) < Constants.Epsilon) { body.angle = t; //we can't change the angle due to the collision } Vector movement = agentActions.MovementDirection * 2.5 + currentKB; //add speed Move(map, movement); knockBack -= currentKB; if (agentActions[Mouse.Left] != State.Up) { bag.Primary.Shoot(body.position, Vector.FromAngle(body.angle), map); } bag.Live(map, body.position); agentActions.Live(); if (hp <= 0) { return(false); } return(true); }
public IBullet GetBullet(Vector position, Vector direction, Universe.Map map) { return(new MagicBullet(position, map, this)); }
public IBullet GetBullet(Vector position, Vector direction, Universe.Map map) { return(new VolleyBullet(direction, this, map)); }
public override IBullet GetBullet(Vector position, Vector direction, Universe.Map map) { return(new Grenade(position, direction, this, map)); }
void Move(Universe.Map map) { if (!navigator.Navigating) { if (path == null || (path.Count == 0 && (body.position - closest).Length > navigator.MinimumDistance) || (path.Count > 0 && !map.ClearSight(body.position, path.First.Value)) || (navigator.Target - closest).Length > 100) { navigator.StartNavigation(body.position, closest, map); path = navigator.Navigate(50); } } else { path = navigator.Navigate(50); } if (path != null && path.Count > 0) { while (path.Count > 1) { if (map.ClearSight(path.First.Next.Value, body.position)) { path.RemoveFirst(); } else { break; } } Vector target = path.First.Value; Vector movement = target - body.position; if (movement.y < -2) { agentActions.KeyDown(Constants.North); } if (movement.y > 2) { agentActions.KeyDown(Constants.South); } if (movement.x < -2) { agentActions.KeyDown(Constants.West); } if (movement.x > 2) { agentActions.KeyDown(Constants.East); } if ((body.position - target).Length < 5) { path.RemoveFirst(); } else { agentActions.lookDirection = agentActions.MovementDirection; } } }
public virtual IBullet GetBullet(Vector position, Vector direction, Universe.Map map) { return(new SimpleBullet(position, direction, this, map)); }