Exemplo n.º 1
0
        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;
                }
            }
        }