Exemple #1
0
        public override void Handle(Bot bot)
        {
            if (!IsEnemiesNearby(bot, bot.Range))
            {
                bot.State = new Waiting();
            }
            else if (IsEnemiesNearby(bot, bot.Weapon.Range))
            {
                bot.State = new Attacking();
                bot.State.Handle(bot);
            }
            else
            {
                List <WorldObject> enemiesNearby = EnemiesNearby(bot, bot.Range);
                Coord pos        = bot.Position;
                Coord creturePos = enemiesNearby[0].Position;
                Coord distance   = creturePos - pos;

                if (_rnd.Next(0, 2) == 0)
                {
                    bot.Move(pos.AddX(Movement(distance.X)));
                }
                else
                {
                    bot.Move(pos.AddY(Movement(distance.Y)));
                }
            }
        }