Пример #1
0
        //�������� �� ������ ���������� � ��������.
        //���������� ����� �� ������ "������ �� 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;
        }
Пример #2
0
        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!!!
            }
        }
Пример #3
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
     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;
             }
         }
     }
 }