public void Action(MyAI _player)
        {
            Fire = false;

            //���� ���� ��� ���, �� ����������� �.
            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 + Utils.DefenseLength)
                        {
                            Fire = true;
                        }
                    }
                }
            }

            if (Fire)
            {
                MinDistance = 1000;
                if (_player.OtherNanoBotsInfo != null)
                {
                    foreach (NanoBotInfo botEnemy in _player.OtherNanoBotsInfo)
                    {
                        if (botEnemy.PlayerID == 0)
                        {
                            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 < DefenseDistance + Utils.DefenseLength)
                {
                    if (MinDistance < DefenseDistance)
                    {
                        this.StopMoving();
                        this.DefendTo(ShootAt, 3);
                        return;
                    }
                    else
                    {
                        if (MinDistance >= DefenseDistance && MinDistance < DefenseDistance + Utils.DefenseLength)
                        {
                            Point p = _player.GetTargetOnVector(this.Location, ShootAt, DefenseDistance);
                            if ((_player.GeomDist(this.Location, p) > DefenseDistance) || (_player.GeomDist(p, ShootAt) >= Utils.DefenseLength))
                            {
                            }
                            else
                            {
                                this.StopMoving();
                                this.DefendTo(p, 3);
                                return;
                            }
                        }
                    }
                }
            }

            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;
                }
                //HARDCODED FOR ROUND2!!!
                _player.NBATACKERTOBUILD = 0;
                this.ForceAutoDestruction();
                //HARDCODED FOR ROUND2!!!
            }
        }
        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)
            {
                NPs = new NavigationPointInfo[_player.UniqueNavPoints.Length];
                _player.UniqueNavPoints.CopyTo(NPs, 0);
                this.NPoint = _player.GetNextCyclicNavPoint(this.NPs, ref this.NPNumber);
                if (this.NPNumber == -10)
                {
                    this.ForceAutoDestruction();
                    return;
                }
            }

            if (NPNumber >= 0)
            {
                //���� �� ����� �� ���� � ������ �����, �� �������� � ��� ����������� � ����������� �����.
                if ((this.Location == this.NPoint)
                        && (_player.CurrentTurn > this.NPs[NPNumber].StartTurn))
                {
                    if (!paused)
                    {
                        paused = true;
                        return;
                    }
                    paused = false;
                    this.NPs[NPNumber].Complete = true;
                    this.NPoint = _player.GetNextCyclicNavPoint(this.NPs, 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;
                    }
                }

                //���� �� �� 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)
 {
     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 + Utils.DefenseLength)
                        {
                            ahtung = true;
                        }
                    }
                }
            }

            //���� �����
            if (ahtung)
            {
                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 + Utils.DefenseLength)
                {
                    if (MinDistance < DefenseDistance)
                    {
                        this.StopMoving();
                        this.DefendTo(ShootAt, 3);
                        return ahtung;
                    }
                    else
                    {
                        if (MinDistance >= DefenseDistance && MinDistance < DefenseDistance + Utils.DefenseLength)
                        {
                            Point p = _player.GetTargetOnVector(this.Location, ShootAt, DefenseDistance);
                            if ((_player.GeomDist(this.Location, p) > DefenseDistance) || (_player.GeomDist(p, ShootAt) >= Utils.DefenseLength))
                            {
                                return false;
                            }
                            this.StopMoving();
                            this.DefendTo(p, 3);
                            return ahtung;
                        }
                    }
                }
                #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 ((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;
                }
                 * */
                #endregion
            }
            return ahtung;
        }
        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)
        {
            //���� ���� ��� ���, �� ����������� �.
            if (this.Target.X == -1)
            {
                this.Target = _player.GetBattleTarget(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 = "Defender[" + this.ID.ToString() +"] X: " + this.Location.X.ToString() + " Y: " + this.Location.Y.ToString() + "\n";
                    //Debugger.Log(2, "Local", str);
                    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
     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 + 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);
                 if ((_player.GeomDist(this.Location, p) > DefenseDistance) || (_player.GeomDist(p, ShootAt) >= Utils.DefenseLength))
                     return;
                 this.DefendTo(p, 3);
                 return;
             }
         }
     }
 }
        //�������� �� ������ ���������� � ��������.
        //���������� ����� �� ������ "������ �� 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;
        }
        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))
                {
                    List<VG.Mission.BaseObjective> mission = _player.Mission.Objectives;
                    for (int i = 0; i < mission.Count; i++)
                    {
                        if (mission[i].ID == 1)
                        {
                            //Navigation
                            VG.Mission.NavigationObjective navObj = (VG.Mission.NavigationObjective)mission[i];
                            for (int j = 0; j < navObj.NavPoints.Count; j++)
                            {
                                if(this.Location == navObj.NavPoints[j].Location && navObj.NavPoints[j].Reached == true)
                                    _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;
                }
            }
        }
Beispiel #10
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, 3);
                        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;
                    }
                }

                //���� �� �� NavPoint
                if (this.Location == this.HPoint)
                {
                    //
                    //���� ����� �� ���� ��� ����������
                    if (_player.CurrentTurn < _player.NavigationPoints[HPNumber].StartTurn)
                    {
                        return;
                    }
                    else if (_player.CurrentTurn >= _player.NavigationPoints[HPNumber].StartTurn
                        && _player.CurrentTurn <= _player.NavigationPoints[HPNumber].EndTurn)
                    {
                        //
                        //��������, ��� ������ ���������
                        List<VG.Mission.BaseObjective> mission = _player.Mission.Objectives;
                        for (int i = 0; i < mission.Count; i++)
                        {
                            if (mission[i].ID == 1)
                            {
                                //Navigation
                                VG.Mission.NavigationObjective navObj = (VG.Mission.NavigationObjective)mission[i];
                                for (int j = 0; j < navObj.NavPoints.Count; j++)
                                {
                                    if (this.Location == navObj.NavPoints[j].Location && navObj.NavPoints[j].Reached == true)
                                        _player.NavigationPoints[HPNumber].Complete = true;
                                }
                            }
                        }
                        //
                        //_player.NavigationPoints[HPNumber].Complete = true;
                        //����������� ����� HP
                        this.HPoint = _player.GetNextHPForConvoyWithBigContainer(this.Location, ref this.HPNumber);
                        if (HPNumber == -10)
                        {
                            this.Delete();
                            this.State = ConvoyState.Deleted;
                            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;
                        }
                    }
                    else
                    {
                        //��������, ��� ������ ���������
                        _player.NavigationPoints[HPNumber].Complete = true;
                        //����������� ����� HP
                        this.HPoint = _player.GetNextHPForConvoyWithBigContainer(this.Location, ref this.HPNumber);
                        if (HPNumber == -10)
                        {
                            this.Delete();
                            this.State = ConvoyState.Deleted;
                            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;
                        }
                    }
                    //
                    /*
                    //���� ����� �� ���� ��� ����������
                    if (_player.CurrentTurn > _player.NavigationPoints[HPNumber].StartTurn)
                    {
                        //��������, ��� ������ ���������
                        _player.NavigationPoints[HPNumber].Complete = true;
                        //����������� ����� HP
                        this.HPoint = _player.GetNextHPForConvoyWithBigContainer(this.Location, ref this.HPNumber);
                        if (HPNumber == -10)
                        {
                            this.Delete();
                            this.State = ConvoyState.Deleted;
                            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;
                        }
                    }
                    */
                }

                //���� �� ����� ���
                //���� ������, �� �� 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;
                }
            }
        }
Beispiel #11
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, 3);
                        return;
                    }
                }
            }

            //���� ������ �����
            if (State == ConvoyState.Waiting)
            {
                //���� �� �� � ����, �� ���������� � �� �����
                if (this.NeedGathering())
                {
                    this.Gather(_player);
                    return;
                }

                //���� �� �� AZNPoint
                if (this.Location == this.APoint)
                {
                    AZNChosen = false;
                    //���� ���������� ������, �� ��������� ��
                    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)
                {
                    //���� ��� �� ����� ���� NavPoint
                    if (NavMission)
                    {
                        //���� ����� �� ���� ��� ����������
                        if (_player.CurrentTurn < _player.NavigationPoints[HPNumber].StartTurn)
                        {
                            return;
                        }
                        else if (_player.CurrentTurn >= _player.NavigationPoints[HPNumber].StartTurn
                            && _player.CurrentTurn <= _player.NavigationPoints[HPNumber].EndTurn)
                        {
                            //
                            //��������, ��� ������ ���������
                            List<VG.Mission.BaseObjective> mission = _player.Mission.Objectives;
                            for (int i = 0; i < mission.Count; i++)
                            {
                                if (mission[i].ID == 1)
                                {
                                    //Navigation
                                    VG.Mission.NavigationObjective navObj = (VG.Mission.NavigationObjective)mission[i];
                                    for (int j = 0; j < navObj.NavPoints.Count; j++)
                                    {
                                        if (this.Location == navObj.NavPoints[j].Location && navObj.NavPoints[j].Reached == true)
                                            _player.NavigationPoints[HPNumber].Complete = true;
                                    }
                                }
                            }
                            //
                            //_player.NavigationPoints[HPNumber].Complete = true;
                            //����������� ���������� HP
                            this.HPoint = _player.GetNextHPForConvoy(this.Location, ref this.HPNumber, ref this.NavMission);
                            //���� ������, �� ��� �� AZN
                            if (this.Stock == 0)
                            {
                                this.APoint = _player.GetNearestAZNPoint(this.Location, this.HPoint);
                                AZNChosen = true;
                                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;
                            }
                        }
                        else
                        {
                            //��������, ��� ������ ���������
                            _player.NavigationPoints[HPNumber].Complete = true;
                            //����������� ���������� HP
                            this.HPoint = _player.GetNextHPForConvoy(this.Location, ref this.HPNumber, ref this.NavMission);
                            //���� ������, �� ��� �� AZN
                            if (this.Stock == 0)
                            {
                                this.APoint = _player.GetNearestAZNPoint(this.Location, this.HPoint);
                                AZNChosen = true;
                                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;
                            }
                        }
                    }

                    //���� ��� �������� HP, �� ���������, ��� �� ��
                    if (HPNumber >= 0)
                    {
                        //���� ���, �� ������������� �� �����
                        if (_player.HoshimiPoints[HPNumber].Needle == 2)
                        {
                            //this.HPoint = _player.GetNearestHPForConvoy(this.Location, ref this.HPNumber);
                            int fafa = HPNumber;
                            this.HPoint = _player.GetNextHPForConvoy(this.Location, ref this.HPNumber, ref this.NavMission);
                            //���� ������, �� ��� �� AZN
                            if (this.Stock == 0)
                            {
                                if (!IsNavigating)
                                {
                                    this.APoint = _player.GetNearestAZNPoint(fafa, HPNumber);
                                }
                                else
                                {
                                    this.APoint = _player.GetNearestAZNPoint(this.Location, this.HPoint);
                                }
                                AZNChosen = true;
                                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);
                                int fafa = HPNumber;
                                this.HPoint = _player.GetNextHPForConvoy(this.Location, ref this.HPNumber, ref this.NavMission);
                                //���� ������, �� ��� �� AZN
                                if (this.Stock == 0)
                                {
                                    if (!IsNavigating)
                                    {
                                        this.APoint = _player.GetNearestAZNPoint(fafa, HPNumber);
                                    }
                                    else
                                    {
                                        this.APoint = _player.GetNearestAZNPoint(this.Location, this.HPoint);
                                    }
                                    AZNChosen = true;
                                    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(HPNumber, HPNumber);
                                AZNChosen = true;
                                this.Path = _player.Pathfinder.FindPath(this.Location, this.APoint);
                                this.Move();
                                return;
                            }
                            //����� ������������
                            else
                            {
                                this.Transfert();
                                return;
                            }
                        }
                    }
                }

                //���� �� ����� ���
                //���� ������, �� �� AZN
                if (this.Stock == 0)
                {
                    if (!AZNChosen)
                    {
                        int fafa = -1;
                        for (int i = 0; i < _player.HoshimiPoints.Length; i++)
                        {
                            if (_player.HoshimiPoints[i].Location == this.Location)
                                fafa = i;
                        }
                        if ((!IsNavigating) && (fafa >= 0))
                        {
                            this.APoint = _player.GetNearestAZNPoint(fafa, HPNumber);
                        }
                        else
                        {
                            this.APoint = _player.GetNearestAZNPoint(this.Location, this.HPoint);
                        }
                        AZNChosen = true;
                    }
                    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;
                }
            }
        }