Ejemplo n.º 1
0
        public void Action(MyAI _player)
        {
            Fire = false;
            //Проверяем список противников. Если кто-то достаточно близко, останавливаемся.
            if (_player.OtherNanoBotsInfo != null)
            {
                foreach (NanoBotInfo botEnemy in _player.OtherNanoBotsInfo)
                {
                    if (botEnemy.PlayerID == 0)
                    {
                        Distance = _player.GeomDist(botEnemy.Location, this.Location);
                        if (Distance < this.DefenseDistance)
                        {
                            this.StopMoving();
                            Fire = true;
                        }
                    }
                }
            }

            //NPNumber == -1 означает, что навигатор только появился, и ему надо назначить цель
            if (this.NPNumber == -1)
            {
                this.NPoint = _player.GetNextUndoneHealPoint(this.Location, ref this.NPNumber);
                if (this.NPNumber == -10)
                {
                    this.ForceAutoDestruction();
                    return;
                }
            }

            if (NPNumber >= 0)
            {
                //Если вдруг обнаруживаем, что цель, к которой идём, уже кем-то посещена, то запрашиваем новую и останавливаемся.
                if (_player.NavigationPoints[NPNumber].Complete == true)
                {
                    this.NPoint = _player.GetNextUndoneHealPoint(this.Location, ref this.NPNumber);
                    if (this.NPNumber == -10)
                    {
                        this.ForceAutoDestruction();
                        return;
                    }
                    this.StopMoving();
                }
            }

            if (NPNumber >= 0)
            {
                //Если мы стоим на цели в нужное время, то помечаем её как выполненную и запрашиваем новую.
                if ((this.Location == this.NPoint) &&
                    (_player.CurrentTurn > _player.NavigationPoints[NPNumber].StartTurn) &&
                    (_player.CurrentTurn < _player.NavigationPoints[NPNumber].EndTurn) &&
                    (this.Stock >= _player.NavigationPoints[NPNumber].Stock))
                {
                    _player.NavigationPoints[NPNumber].Complete = true;
                    this.NPoint = _player.GetNextUndoneHealPoint(this.Location, ref this.NPNumber);
                    if (this.NPNumber == -10)
                    {
                        this.ForceAutoDestruction();
                        return;
                    }
                }
            }

            if (this.State == NanoBotState.WaitingOrders)
            {
                if (Fire)
                {
                    //Ищем ближайшую цель
                    MinDistance = 1000;
                    if (_player.OtherNanoBotsInfo != null)
                    {
                        foreach (NanoBotInfo botEnemy in _player.OtherNanoBotsInfo)
                        {
                            if (botEnemy.PlayerID == 0)
                            {
                                this.Distance = _player.GeomDist(botEnemy.Location, this.Location);
                                //Если вражеский AI достаточно близко, то он пользуется абсолютным приоритетом!
                                if ((botEnemy.NanoBotType == NanoBotType.NanoAI) && (Distance < this.DefenseDistance))
                                {
                                    MinDistance = -1;
                                    ShootAt     = botEnemy.Location;
                                }
                                if (Distance < MinDistance)
                                {
                                    MinDistance = Distance;
                                    ShootAt     = botEnemy.Location;
                                }
                            }
                        }
                    }
                    //Если противник близко, то стреляем в него.
                    if (MinDistance < this.DefenseDistance)
                    {
                        this.DefendTo(ShootAt, 3);
                        return;
                    }
                }

                //Если все NP посещены, то стоим
                if (this.NPNumber == -10)
                {
                    this.ForceAutoDestruction();
                    return;
                }

                //Если мы на AZNPoint и нужна дозаправка, то дозаправляемся
                if (this.Location == this.APoint)
                {
                    if (this.Stock == 0)
                    {
                        CollectFrom(Location, this.ContainerCapacity / this.CollectTransfertSpeed);
                        return;
                    }
                }
                //Если пустые, то находим AZN и идём за ним
                if (Stock == 0)
                {
                    this.APoint = _player.GetNearestAZNPoint(this.Location, this.NPoint);
                    MoveTo(_player.Pathfinder.FindPath(this.Location, this.APoint));
                    return;
                }
                else
                {
                    MoveTo(_player.Pathfinder.FindPath(this.Location, this.NPoint));
                    return;
                }
            }
        }