Ejemplo n.º 1
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!!!
            }
        }