public void Action(MyAI _player)
 {
     active = false;
     if (_player.OtherNanoBotsInfo != null)
     {
         foreach (NanoBotInfo botEnemy in _player.OtherNanoBotsInfo)
         {
             if (!((botEnemy.NanoBotType == NanoBotType.NanoBlocker) || (botEnemy.NanoBotType == NanoBotType.NanoNeedle) || (botEnemy.NanoBotType == NanoBotType.NanoNeuroControler)))
             {
                 if (_player.GeomDist(this.Location, botEnemy.Location) <= Utils.BlockerStrength)
                 {
                     active = true;
                 }
             }
         }
     }
     if (_player.OtherInjectionPointsInfo != null)
     {
         foreach (InjectionPointInfo ip in _player.OtherInjectionPointsInfo)
         {
             if (_player.GeomDist(this.Location, ip.Location) <= Utils.BlockerStrength)
             {
                 active = true;
             }
         }
     }
     if (!active)
     {
         this.ForceAutoDestruction();
     }
 }
        //Отвечает за анализ обстановки и стрельбу.
        //Возвращает ответ на вопрос "Грозит ли AI опасность?"
        public bool Alarm(MyAI _player)
        {
            bool   ahtung = false;
            double Distance;
            double MinDistance;
            Point  ShootAt = new Point();

            //Если в пределах досягаемости кто-то есть, останавливаемся
            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();
                            //И запоминаем, что надо предупредить AI об опасности.
                            ahtung = true;
                        }
                    }
                }
            }

            //Если стоим
            if (this.State == NanoBotState.WaitingOrders)
            {
                //Ищем ближайшую цель
                MinDistance = 1000;
                if (_player.OtherNanoBotsInfo != null)
                {
                    foreach (NanoBotInfo botEnemy in _player.OtherNanoBotsInfo)
                    {
                        if (botEnemy.PlayerID == 0)
                        {
                            Distance = _player.GeomDist(botEnemy.Location, this.Location);
                            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(ahtung);
                }
            }
            return(ahtung);
        }
Beispiel #3
0
        public void Action(MyAI _player, int NextHPnum)
        {
            //Если AI уже сам всё видит, идём дальше
            if (_player.GeomDist(_player.HoshimiPoints[NextHPnum].Location, _player.AI.Location) < Utils.ScanLength + _player.AI.Scan)
            {
                for (int i = 0; i < _player.MyHPs.Count - 1; i++)
                {
                    if (NextHPnum == (int)_player.MyHPs[i])
                    {
                        dest = (int)_player.MyHPs[i + 1];
                        this.StopMoving();
                        this.MoveTo(_player.ePathfinder.FindPath(this.Location, _player.HoshimiPoints[dest].Location));
                        return;
                    }
                }
            }

            if (dest != NextHPnum)
            {
                dest = NextHPnum;
                this.StopMoving();
            }
            this.MoveTo(_player.ePathfinder.FindPath(this.Location, _player.HoshimiPoints[dest].Location));
            return;
        }
 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;
             }
         }
     }
     //Проверяем, где враги
     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;
     }
 }
        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;
                }
            }
        }
        public void Action(MyAI _player)
        {
            //Если цели ещё нет, то запрашиваем её.
            if (this.Target.X == -1)
            {
                this.Target = _player.GetTargetToAtack(this.Location);
            }

            //Проверяем список противников. Если кто-то достаточно близко, останавливаемся.
            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();
                        }
                    }
                }
            }

            if (this.State == NanoBotState.WaitingOrders)
            {
                //Ищем ближайшую цель
                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;
                }

                //Идём к цели.
                if (this.Target != this.Location)
                {
                    //string str = "Atacker[" + this.ID.ToString() +"] X: " + this.Location.X.ToString() + " Y: " + this.Location.Y.ToString() + "\n";
                    //Debugger.Log(2, "Local", str);
                    //MoveTo(Target);
                    MoveTo(_player.Pathfinder.FindPath(this.Location, Target));
                    return;
                }
            }
        }
        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
        }
Beispiel #8
0
        //Основная функция. Управляет всеми движениями конвоя
        public void Action(MyAI _player)
        {
            double Distance;
            double MinDistance;
            Point  ShootAt = new Point();

            //Если конвоя ещё нет, то и делать нечего
            if (State == ConvoyState.UnderConstruction)
            {
                return;
            }

            //Устанавливаем все значения: State, Location, Stock, etc
            SetState(_player);

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

            //Если конвой стоит
            if (State == ConvoyState.Waiting)
            {
                //Если мы не в куче, то собираемся в неё самую
                if (this.NeedGathering())
                {
                    this.Gather(_player);
                    return;
                }

                //Если мы на AZNPoint
                if (this.Location == this.APoint)
                {
                    //Если контейнеры пустые, то заполняем их
                    if (this.Stock == 0)
                    {
                        this.FillContainers();
                        return;
                    }
                    //Если не пустые, то идём к HoshimiPoint
                    else
                    {
                        if (this.Location == this.HPoint)
                        {
                            return;
                        }
                        this.Path = _player.Pathfinder.FindPath(this.Location, this.HPoint);
                        this.Move();
                        return;
                    }
                }

                //Если мы на HoshimiPoint
                if (this.Location == this.HPoint)
                {
                    //Если это валидный HP, то проверяем, наш ли он
                    if (HPNumber >= 0)
                    {
                        //Если нет, то переключаемся на новый
                        if (_player.HoshimiPoints[HPNumber].Needle == 2)
                        {
                            //this.HPoint = _player.GetNearestHPForConvoy(this.Location, ref this.HPNumber);
                            this.HPoint = _player.GetNextHPForConvoy(this.Location, ref this.HPNumber);
                            //Если пустые, то идём за AZN
                            if (this.Stock == 0)
                            {
                                this.APoint = _player.GetNearestAZNPoint(this.Location, this.HPoint);
                                this.Path   = _player.Pathfinder.FindPath(this.Location, this.APoint);
                                this.Move();
                                return;
                            }
                            //Иначе сразу к HP
                            else
                            {
                                if (this.Location == this.HPoint)
                                {
                                    return;
                                }
                                this.Path = _player.Pathfinder.FindPath(this.Location, this.HPoint);
                                this.Move();
                                return;
                            }
                        }
                    }
                    //Проверяем все Needle`ы
                    foreach (NanoBot bot in _player.NanoBots)
                    {
                        //Если находим Needle на этой точке и он полный
                        if ((bot is Needle) && (bot.Stock == bot.ContainerCapacity) && (bot.Location == this.Location))
                        {
                            if (HPNumber >= 0)
                            {
                                //То отмечаем этот факт
                                _player.HoshimiPoints[HPNumber].Full = 1;
                                //Запрашиваем новую HP
                                //this.HPoint = _player.GetNearestHPForConvoy(this.Location, ref this.HPNumber);
                                this.HPoint = _player.GetNextHPForConvoy(this.Location, ref this.HPNumber);
                                //Если пустые, то идём за AZN
                                if (this.Stock == 0)
                                {
                                    this.APoint = _player.GetNearestAZNPoint(this.Location, this.HPoint);
                                    this.Path   = _player.Pathfinder.FindPath(this.Location, this.APoint);
                                    this.Move();
                                    return;
                                }
                                //Иначе сразу к HP
                                else
                                {
                                    if (this.Location == this.HPoint)
                                    {
                                        return;
                                    }
                                    this.Path = _player.Pathfinder.FindPath(this.Location, this.HPoint);
                                    this.Move();
                                    return;
                                }
                            }
                        }
                    }

                    if (HPNumber >= 0)
                    {
                        //Если стоит наш Needle
                        if (_player.HoshimiPoints[HPNumber].Needle == 1)
                        {
                            //И Needle ещё не заполнен
                            //Если мы уже разгрузились, то идём за AZN
                            if (this.Stock == 0)
                            {
                                this.APoint = _player.GetNearestAZNPoint(this.Location, this.HPoint);
                                this.Path   = _player.Pathfinder.FindPath(this.Location, this.APoint);
                                this.Move();
                                return;
                            }
                            //Иначе разгружаемся
                            else
                            {
                                this.Transfert();
                                return;
                            }
                        }
                    }
                }

                //Если мы чёрте где
                //Если пустые, то за AZN
                if (this.Stock == 0)
                {
                    this.APoint = _player.GetNearestAZNPoint(this.Location, this.HPoint);
                    this.Path   = _player.Pathfinder.FindPath(this.Location, this.APoint);
                    this.Move();
                    return;
                }
                //иначе на HP
                else
                {
                    if (this.Location == this.HPoint)
                    {
                        return;
                    }
                    this.Path = _player.Pathfinder.FindPath(this.Location, this.HPoint);
                    this.Move();
                    return;
                }
            }
        }