Example #1
0
        public void Action(MyAI _player)
        {
            //Запоминаем, на каком HP мы стоим
            if (HPNumber == -1)
            {
                for (int i = 0; i < _player.HoshimiPoints.Length; i++)
                {
                    if (_player.HoshimiPoints[i].Location == this.Location)
                    {
                        HPNumber = i;
                    }
                }
            }
            //Проверяем, где враги
            #region old

            /*
             *  MinDistance = 1000;
             * if (_player.OtherNanoBotsInfo != null)
             * {
             *  foreach (NanoBotInfo botEnemy in _player.OtherNanoBotsInfo)
             *  {
             *      if (botEnemy.PlayerID == 0)
             *      {
             *          Distance = _player.GeomDist(botEnemy.Location, this.Location);
             *          if (Distance < MinDistance)
             *          {
             *              MinDistance = Distance;
             *              ShootAt = botEnemy.Location;
             *          }
             *      }
             *  }
             * }
             * //Если кто-то достаточно близко - стреляем
             * if (MinDistance < DefenseDistance)
             * {
             * this.DefendTo(ShootAt, 4);
             * return;
             * }
             * */
            #endregion
            #region new
            MinDistance = 1000;
            if (_player.OtherNanoBotsInfo != null)
            {
                foreach (NanoBotInfo botEnemy in _player.OtherNanoBotsInfo)
                {
                    if (botEnemy.PlayerID == 0)
                    {
                        Distance  = _player.GeomDist(botEnemy.Location, this.Location);
                        Distance += Utils.DefenseLength;
                        if (Distance < MinDistance)
                        {
                            MinDistance = Distance;
                            ShootAt     = botEnemy.Location;
                        }
                    }
                }
            }
            //Если кто-то достаточно близко - стреляем
            if (MinDistance < DefenseDistance + Utils.DefenseLength)
            {
                if (MinDistance < DefenseDistance)
                {
                    this.DefendTo(ShootAt, 3);
                    return;
                }
                else
                {
                    if (MinDistance >= DefenseDistance && MinDistance < DefenseDistance + Utils.DefenseLength)
                    {
                        Point p = _player.GetTargetOnVector(this.Location, ShootAt, DefenseDistance);
                        this.DefendTo(p, 3);
                        return;
                    }
                }
            }
            #endregion
        }