public void Update(GameTime gameTime, Enemy enemy) { int selection = RandomGenerator.Random.Next(0, enemy.ActionComponents.Count); IAIComponent component = enemy.ActionComponents.Values.ElementAt(selection); component.SetUp(enemy); enemy.ActiveComponent = component.Update; }
public void Update(Microsoft.Xna.Framework.GameTime gameTime, Enemy enemy) { if (current > 0) { current -= gameTime.ElapsedGameTime.Milliseconds; life -= gameTime.ElapsedGameTime.Milliseconds; enemy.Position = enemy.Position + enemy.Velocity; if (life < 0) enemy.ActionComplete(); } else { current = max; } }
public void Update(GameTime gameTime, Enemy enemy) { if (currentWalkDistance <= 0) { int r = RandomGenerator.Random.Next(0, 4); currentWalkDistance = randomWalkDistance; Vector2 velocityAbsolute = new Vector2(Math.Abs(enemy.Velocity.X), Math.Abs(enemy.Velocity.Y)); switch (r) { case 0: velocity = new Vector2(velocityAbsolute.X, 0); enemy.CurrentSprite.CurrentAnimation = AnimationKey.Right; break; case 1: velocity = new Vector2(-velocityAbsolute.X, 0); enemy.CurrentSprite.CurrentAnimation = AnimationKey.Left; break; case 2: velocity = new Vector2(0, velocityAbsolute.Y); enemy.CurrentSprite.CurrentAnimation = AnimationKey.Down; break; case 3: velocity = new Vector2(0, -velocityAbsolute.Y); enemy.CurrentSprite.CurrentAnimation = AnimationKey.Up; break; } } else { if (!enemy.HandleCollisions(velocity).IsColliding) { enemy.Position = enemy.Position + velocity; currentWalkDistance -= Math.Abs((velocity.X + velocity.Y) / 2); } else { currentWalkDistance = 0; } if (enemy.HasPlayerInSight) enemy.ActionComplete(); } }
public void SetUp(Enemy enemy) { life = 3000; }
public void SetUp(Enemy enemy) { }
public void SetUp(Enemy enemy) { throw new NotImplementedException(); }