예제 #1
0
 public AStarPathfinder(MyAI _player)
 {
     Xdim = _player.Tissue.Width;
     Ydim = _player.Tissue.Height;
     Map = new node[Xdim, Ydim];
     States = new int[Xdim, Ydim];
     fs = new double[Xdim, Ydim];
     GetMap(Xdim, Ydim, _player);
 }
예제 #2
0
        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;
                }
            }
        }
예제 #3
0
 //��� ������� �������� ����� ��� ����������� ��������� � ������
 public void SetConvoyNumber(MyAI _player)
 {
     ConvoyNumber = _player.GetConvoyNumberForConvoyWithBigContainer();
     if (ConvoyNumber != -1)
     {
         _player.BigConvoys[ConvoyNumber].Defenders++;
         _player.BigConvoys[ConvoyNumber].AddBot(this);
     }
     //string str = "Defender belongs to convoy " + this.ConvoyNumber.ToString() + "\n";
     //Debugger.Log(2, "Local", str);
 }
예제 #4
0
        public void Action(MyAI _player)
        {
            if (this.HPNumber == -1)
            {
                this.HPoint = _player.GetNextHoshimiPoint(this.Location, ref this.HPNumber);
            }

            if (this.HPNumber == -10)
            {
                this.HPoint = _player.GetNearestUnfilledHP(this.Location, ref this.HPNumber);
            }

            if (HPNumber >= 0)
            {
                if (_player.HoshimiPoints[HPNumber].Full == 1)
                {
                    this.HPoint = _player.GetNearestUnfilledHP(this.Location, ref this.HPNumber);
                    this.StopMoving();
                }
            }

            if (this.State == NanoBotState.WaitingOrders)
            {
                if (this.Location == this.APoint)
                {
                    if (this.Stock == 0)
                    {
                        //Collect
                        CollectFrom(Location, this.ContainerCapacity / this.CollectTransfertSpeed);
                        return;
                    }
                    else
                    {
                        //Go Hoshimi point
                        //MoveTo(this.HPoint);
                        //string str = "Collector[" + this.ID.ToString() + "] at AP X: " + this.Location.X.ToString() + " Y: " + this.Location.Y.ToString() + "\n";
                        //Debugger.Log(2, "Local", str);
                        MoveTo(_player.Pathfinder.FindPath(this.Location, this.HPoint));
                        return;
                    }
                }
                if (this.Location == this.HPoint)
                {
                    foreach (NanoBot bot in _player.NanoBots)
                    {
                        if ((bot is Needle) && (bot.Stock == bot.ContainerCapacity) && (bot.Location == this.Location))
                        {
                            if (HPNumber >= 0)
                            {
                                _player.HoshimiPoints[HPNumber].Full = 1;
                                this.HPoint = _player.GetNearestUnfilledHP(this.Location, ref this.HPNumber);
                                //�������� ����������� "����������"!!!
                                if (Stock == 0)
                                {
                                    this.APoint = _player.GetNearestAZNPoint(this.Location, this.HPoint);
                                    //MoveTo(this.APoint);
                                    //string str = "Empty collector[" + this.ID.ToString() +"] at finished HP X: " + this.Location.X.ToString() + " Y: " + this.Location.Y.ToString() + "\n";
                                    //Debugger.Log(2, "Local", str);
                                    MoveTo(_player.Pathfinder.FindPath(this.Location, this.APoint));
                                    return;
                                }
                                else
                                {
                                    //this.MoveTo(this.HPoint);
                                    //string str = "Not empty collector[" + this.ID.ToString() +"] at finished HP X: " + this.Location.X.ToString() + " Y: " + this.Location.Y.ToString() + "\n";
                                    //Debugger.Log(2, "Local", str);
                                    MoveTo(_player.Pathfinder.FindPath(this.Location, this.HPoint));
                                    return;
                                }
                            }
                        }
                    }
                    if (Stock == 0)
                    {
                        //return to azn
                        this.APoint = _player.GetNearestAZNPoint(this.Location, this.HPoint);
                        //MoveTo(this.APoint);
                        //string str = "Empty collector[" + this.ID.ToString() +"] at HP X: " + this.Location.X.ToString() + " Y: " + this.Location.Y.ToString() + "\n";
                        //Debugger.Log(2, "Local", str);
                        MoveTo(_player.Pathfinder.FindPath(this.Location, this.APoint));
                        return;
                    }
                    else
                    {
                        //transfert
                        TransferTo(Location, this.Stock / this.CollectTransfertSpeed);
                        return;
                    }
                }
                //�������� ����������� "����������"!!!
                if (Stock == 0)
                {
                    //string str = "Empty collector[" + this.ID.ToString() +"] somewhere X: " + this.Location.X.ToString() + " Y: " + this.Location.Y.ToString() + "\n";
                    //Debugger.Log(2, "Local", str);
                    this.APoint = _player.GetNearestAZNPoint(this.Location, this.HPoint);
                    //this.MoveTo(this.APoint);
                    MoveTo(_player.Pathfinder.FindPath(this.Location, this.APoint));
                    return;
                }
                else
                {
                    //this.HPoint = _player.GetNearestUnfilledHP(this.Location, ref this.HPNumber);
                    //this.MoveTo(this.HPoint);
                    //string str = "Not empty collector[" + this.ID.ToString() +"] somewhere X: " + this.Location.X.ToString() + " Y: " + this.Location.Y.ToString() + "\n";
                    //Debugger.Log(2, "Local", str);
                    MoveTo(_player.Pathfinder.FindPath(this.Location, this.HPoint));
                    return;
                }
            }
        }
예제 #5
0
        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;
                }
            }
        }
예제 #6
0
 private bool GetMap(int X_dimension, int Y_dimension, MyAI _player)
 {
     Point p = new Point();
     for (int i = 0; i < X_dimension; i++)
     {
         for (int j = 0; j < Y_dimension; j++)
         {
             p.X = i;
             p.Y = j;
             Map[i, j].Location = p;
             Map[i, j].g = -1;
             Map[i, j].h = -1;
             Map[i, j].f = -1;
             Map[i, j].Number = i * X_dimension + j;
             Map[i, j].parent = -1;
             switch ((int)_player.Tissue[i, j].AreaType)
             {
                 case 0:
                     {
                         Map[i, j].costDown = 2;
                         Map[i, j].costLeft = 2;
                         Map[i, j].costRight = 2;
                         Map[i, j].costUp = 2;
                         Map[i, j].terrain = 2;
                         break;
                     }
                 case 1:
                     {
                         Map[i, j].costDown = 3;
                         Map[i, j].costLeft = 3;
                         Map[i, j].costRight = 3;
                         Map[i, j].costUp = 3;
                         Map[i, j].terrain = 3;
                         break;
                     }
                 case 2:
                     {
                         Map[i, j].costDown = 4;
                         Map[i, j].costLeft = 4;
                         Map[i, j].costRight = 4;
                         Map[i, j].costUp = 4;
                         Map[i, j].terrain = 4;
                         break;
                     }
                 case 3:
                     {
                         Map[i, j].costDown = 6;
                         Map[i, j].costLeft = 6;
                         Map[i, j].costRight = 6;
                         Map[i, j].costUp = 6;
                         Map[i, j].terrain = 6;
                         break;
                     }
                 default:
                     {
                         Map[i, j].costDown = -1;
                         Map[i, j].costLeft = -1;
                         Map[i, j].costRight = -1;
                         Map[i, j].costUp = -1;
                         Map[i, j].terrain = -1;
                         break;
                     }
             }
             if (Map[i, j].terrain != -1)
             {
                 switch (GetStreamDirection(_player, p))
                 {
                     case 0:
                         {
                             //NorthSouth
                             if (Map[i, j].terrain != 2)
                             {
                                 Map[i, j].costLeft -= 2;
                                 Map[i, j].costRight -= 2;
                                 Map[i, j].costUp -= 2;
                                 Map[i, j].costDown += 2;
                             }
                             else
                             {
                                 Map[i, j].costLeft -= 1;
                                 Map[i, j].costRight -= 1;
                                 Map[i, j].costUp -= 1;
                                 Map[i, j].costDown += 2;
                             }
                             break;
                         }
                     case 1:
                         {
                             //SouthNorth
                             if (Map[i, j].terrain != 2)
                             {
                                 Map[i, j].costLeft -= 2;
                                 Map[i, j].costRight -= 2;
                                 Map[i, j].costUp += 2;
                                 Map[i, j].costDown -= 2;
                             }
                             else
                             {
                                 Map[i, j].costLeft -= 1;
                                 Map[i, j].costRight -= 1;
                                 Map[i, j].costUp += 2;
                                 Map[i, j].costDown -= 1;
                             }
                             break;
                         }
                     case 2:
                         {
                             //WestEst
                             if (Map[i, j].terrain != 2)
                             {
                                 Map[i, j].costLeft += 2;
                                 Map[i, j].costRight -= 2;
                                 Map[i, j].costUp -= 2;
                                 Map[i, j].costDown -= 2;
                             }
                             else
                             {
                                 Map[i, j].costLeft += 2;
                                 Map[i, j].costRight -= 1;
                                 Map[i, j].costUp -= 1;
                                 Map[i, j].costDown -= 1;
                             }
                             break;
                         }
                     case 3:
                         {
                             //EstWest
                             if (Map[i, j].terrain != 2)
                             {
                                 Map[i, j].costLeft -= 2;
                                 Map[i, j].costRight += 2;
                                 Map[i, j].costUp -= 2;
                                 Map[i, j].costDown -= 2;
                             }
                             else
                             {
                                 Map[i, j].costLeft -= 1;
                                 Map[i, j].costRight += 2;
                                 Map[i, j].costUp -= 2;
                                 Map[i, j].costDown -= 2;
                             }
                             break;
                         }
                     default:
                         {
                             //NoStream
                             break;
                         }
                 }
             }
         }
     }
     return true;
 }
예제 #7
0
        //���������� ������� ��������� ������
        private void SetState(MyAI _player)
        {
            //��������, ���� �� ����
            if (MyDefender != null && MyDefender.HitPoint <= 0)
                MyDefender = null;
            if (MyContainer[0] != null && MyContainer[0].HitPoint <= 0)
                MyContainer[0] = null;
            if (MyContainer[1] != null && MyContainer[1].HitPoint <= 0)
                MyContainer[1] = null;

            //���� ����� ���, �� ������ ���������
            if (MyDefender == null && MyContainer[0] == null && MyContainer[1] == null)
            {
                this.State = ConvoyState.UnderConstruction;
                this.MyDefender = null;
                this.MyContainer[0] = null;
                this.MyContainer[1] = null;
                this.DefendersNumber = 0;
                this.ContainersNumber = 0;
                this.HPNumber = -1;
                return;
            }

            //��������� ������ ��� Stock � Location
            this.Stock = 0;
            if (MyDefender != null)
            {
                this.Location = MyDefender.Location;
            }
            if (MyContainer[0] != null)
            {
                this.Location = MyContainer[0].Location;
                this.Stock += MyContainer[0].Stock;
            }
            if (MyContainer[1] != null)
            {
                this.Location = MyContainer[1].Location;
                this.Stock += MyContainer[1].Stock;
            }

            //���� HP �� ��������, �� ����������
            if (this.HPNumber == -1)
            {
                //this.HPoint = _player.GetNearestHPForConvoy(this.Location, ref HPNumber);

                this.HPoint = _player.GetNextHPForConvoy(this.Location, ref this.HPNumber, ref this.NavMission);
            }

            //���� HP ����� ����������� ��� ��������, ����������� �����
            if (HPNumber >= 0)
            {
                if ((_player.HoshimiPoints[HPNumber].Needle == 2) || (_player.HoshimiPoints[HPNumber].Full == 1))
                {
                    //this.HPoint = _player.GetNearestHPForConvoy(this.Location, ref HPNumber);

                    this.HPoint = _player.GetNextHPForConvoy(this.Location, ref this.HPNumber, ref this.NavMission);                    this.Stop();
                }
            }

            //���� Defender � ���, �� ������ � ������ � ���
            if (MyDefender != null && MyDefender.State == NanoBotState.Defending)
            {
                this.State = ConvoyState.Fighting;
                return;
            }

            //������-������ ���������� ��-�� ����, ��� ������, ��� ���, � ��� deadlink
            if (MyDefender != null)
            {
                if (MyContainer[0] != null && MyContainer[1] != null)
                {
                    if ((MyDefender.State == NanoBotState.WaitingOrders)
                        && (MyContainer[0].State == NanoBotState.WaitingOrders)
                        && (MyContainer[1].State == NanoBotState.WaitingOrders))
                    {
                        this.State = ConvoyState.Waiting;
                    }
                    if ((MyDefender.State == NanoBotState.Moving)
                        || (MyContainer[0].State == NanoBotState.Moving)
                        || (MyContainer[1].State == NanoBotState.Moving))
                    {
                        this.State = ConvoyState.Moving;
                    }
                    if ((MyContainer[0].State == NanoBotState.Collecting)
                        || (MyContainer[1].State == NanoBotState.Collecting))
                    {
                        this.State = ConvoyState.CollectingAZN;
                    }
                    if ((MyContainer[0].State == NanoBotState.TransferingStock)
                        || (MyContainer[1].State == NanoBotState.TransferingStock))
                    {
                        this.State = ConvoyState.TransferingAZN;
                    }
                }
                else if (MyContainer[0] != null && MyContainer[1] == null)
                {
                    if ((MyDefender.State == NanoBotState.WaitingOrders)
                        && (MyContainer[0].State == NanoBotState.WaitingOrders))
                    {
                        this.State = ConvoyState.Waiting;
                    }
                    if ((MyDefender.State == NanoBotState.Moving)
                        || (MyContainer[0].State == NanoBotState.Moving))
                    {
                        this.State = ConvoyState.Moving;
                    }
                    if (MyContainer[0].State == NanoBotState.Collecting)
                    {
                        this.State = ConvoyState.CollectingAZN;
                    }
                    if (MyContainer[0].State == NanoBotState.TransferingStock)
                    {
                        this.State = ConvoyState.TransferingAZN;
                    }
                }
                else if (MyContainer[0] == null && MyContainer[1] != null)
                {
                    if ((MyDefender.State == NanoBotState.WaitingOrders)
                        && (MyContainer[1].State == NanoBotState.WaitingOrders))
                    {
                        this.State = ConvoyState.Waiting;
                    }
                    if ((MyDefender.State == NanoBotState.Moving)
                        || (MyContainer[1].State == NanoBotState.Moving))
                    {
                        this.State = ConvoyState.Moving;
                    }
                    if (MyContainer[1].State == NanoBotState.Collecting)
                    {
                        this.State = ConvoyState.CollectingAZN;
                    }
                    if (MyContainer[1].State == NanoBotState.TransferingStock)
                    {
                        this.State = ConvoyState.TransferingAZN;
                    }
                }
                else if (MyContainer[0] == null && MyContainer[1] == null)
                {
                    if (MyDefender.State == NanoBotState.WaitingOrders)
                    {
                        this.State = ConvoyState.Waiting;
                    }
                    if (MyDefender.State == NanoBotState.Moving)
                    {
                        this.State = ConvoyState.Moving;
                    }
                }
            }
            else
            {
                if (MyContainer[0] != null && MyContainer[1] != null)
                {
                    if ((MyContainer[0].State == NanoBotState.WaitingOrders)
                        && (MyContainer[1].State == NanoBotState.WaitingOrders))
                    {
                        this.State = ConvoyState.Waiting;
                    }
                    if ((MyContainer[0].State == NanoBotState.Moving)
                        || (MyContainer[1].State == NanoBotState.Moving))
                    {
                        this.State = ConvoyState.Moving;
                    }
                    if ((MyContainer[0].State == NanoBotState.Collecting)
                        || (MyContainer[1].State == NanoBotState.Collecting))
                    {
                        this.State = ConvoyState.CollectingAZN;
                    }
                    if ((MyContainer[0].State == NanoBotState.TransferingStock)
                        || (MyContainer[1].State == NanoBotState.TransferingStock))
                    {
                        this.State = ConvoyState.TransferingAZN;
                    }
                }
                else if (MyContainer[0] != null && MyContainer[1] == null)
                {
                    if (MyContainer[0].State == NanoBotState.WaitingOrders)
                    {
                        this.State = ConvoyState.Waiting;
                    }
                    if (MyContainer[0].State == NanoBotState.Moving)
                    {
                        this.State = ConvoyState.Moving;
                    }
                    if (MyContainer[0].State == NanoBotState.Collecting)
                    {
                        this.State = ConvoyState.CollectingAZN;
                    }
                    if (MyContainer[0].State == NanoBotState.TransferingStock)
                    {
                        this.State = ConvoyState.TransferingAZN;
                    }
                }
                else if (MyContainer[0] == null && MyContainer[1] != null)
                {
                    if (MyContainer[1].State == NanoBotState.WaitingOrders)
                    {
                        this.State = ConvoyState.Waiting;
                    }
                    if (MyContainer[1].State == NanoBotState.Moving)
                    {
                        this.State = ConvoyState.Moving;
                    }
                    if (MyContainer[1].State == NanoBotState.Collecting)
                    {
                        this.State = ConvoyState.CollectingAZN;
                    }
                    if (MyContainer[1].State == NanoBotState.TransferingStock)
                    {
                        this.State = ConvoyState.TransferingAZN;
                    }
                }
                else if (MyContainer[0] == null && MyContainer[1] == null)
                {
                    this.State = ConvoyState.UnderConstruction;
                    this.MyDefender = null;
                    this.MyContainer[0] = null;
                    this.MyContainer[1] = null;
                    this.ContainersNumber = 0;
                    this.DefendersNumber = 0;
                    this.HPNumber = -1;
                }
            }
        }
예제 #8
0
        //���������� ������� ��������� ������
        private void SetState(MyAI _player)
        {
            if (State == ConvoyState.Deleted)
                return;

            //��������, ���� �� ����
            if (MyDefender != null && MyDefender.HitPoint <= 0)
                MyDefender = null;
            if (MyContainer != null && MyContainer.HitPoint <= 0)
                MyContainer = null;

            //���� ����� ���, �� ������ ���������
            if (MyDefender == null && MyContainer == null)
            {
                this.State = ConvoyState.UnderConstruction;
                this.MyDefender = null;
                this.MyContainer = null;
                this.DefendersNumber = 0;
                this.ContainersNumber = 0;
                this.HPNumber = -1;
                return;
            }

            //��������� ������ ��� Stock � Location
            this.Stock = 0;
            if (MyDefender != null)
            {
                this.Location = MyDefender.Location;
            }
            if (MyContainer != null)
            {
                this.Location = MyContainer.Location;
                this.Stock += MyContainer.Stock;
            }

            //���� HP �� ��������, �� ����������
            if (this.HPNumber == -1)
            {
                //this.HPoint = _player.GetNearestHPForConvoy(this.Location, ref HPNumber);

                this.HPoint = _player.GetNextHPForConvoyWithCollector(this.Location, ref this.HPNumber);
                if (HPNumber == -10)
                {
                    this.Delete();
                    this.State = ConvoyState.Deleted;
                    return;
                }
            }

            if (HPNumber >= 0)
            {
                if (_player.NavigationPoints[HPNumber].Complete == true)
                {
                    this.HPoint = _player.GetNextHPForConvoyWithCollector(this.Location, ref this.HPNumber);
                    if (HPNumber == -10)
                    {
                        this.Delete();
                        this.State = ConvoyState.Deleted;
                        return;
                    }
                    this.Stop();
                }
            }

            //���� Defender � ���, �� ������ � ������ � ���
            if (MyDefender != null && MyDefender.State == NanoBotState.Defending)
            {
                this.State = ConvoyState.Fighting;
                return;
            }

            //������-������ ���������� ��-�� ����, ��� ������, ��� ���, � ��� deadlink
            if (MyDefender != null)
            {
                if (MyContainer != null)
                {
                    if ((MyDefender.State == NanoBotState.WaitingOrders)
                        && (MyContainer.State == NanoBotState.WaitingOrders))
                    {
                        this.State = ConvoyState.Waiting;
                    }
                    if ((MyDefender.State == NanoBotState.Moving)
                        || (MyContainer.State == NanoBotState.Moving))
                    {
                        this.State = ConvoyState.Moving;
                    }
                    if ((MyContainer.State == NanoBotState.Collecting))
                    {
                        this.State = ConvoyState.CollectingAZN;
                    }
                    if ((MyContainer.State == NanoBotState.TransferingStock))
                    {
                        this.State = ConvoyState.TransferingAZN;
                    }
                }
            }
            else
            {
                if (MyContainer != null)
                {
                    if ((MyContainer.State == NanoBotState.WaitingOrders))
                    {
                        this.State = ConvoyState.Waiting;
                    }
                    if ((MyContainer.State == NanoBotState.Moving))
                    {
                        this.State = ConvoyState.Moving;
                    }
                    if ((MyContainer.State == NanoBotState.Collecting))
                    {
                        this.State = ConvoyState.CollectingAZN;
                    }
                    if ((MyContainer.State == NanoBotState.TransferingStock))
                    {
                        this.State = ConvoyState.TransferingAZN;
                    }
                }
                else if (MyContainer == null)
                {
                    this.State = ConvoyState.UnderConstruction;
                    this.MyDefender = null;
                    this.MyContainer = null;
                    this.ContainersNumber = 0;
                    this.DefendersNumber = 0;
                    this.HPNumber = -1;
                }
            }
        }
예제 #9
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;
        }
예제 #10
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
            #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
        }
예제 #11
0
        public void Action(MyAI _player)
        {
            //NPNumber == -10 ��������, ��� ��� NavigationObjectives ��� ���������
            if (this.NPNumber == -10)
            {
                this.ForceAutoDestruction();
                return;
            }

            //NPNumber == -1 ��������, ��� ��������� ������ ��������, � ��� ���� ��������� ����
            if (this.NPNumber == -1)
            {
                //this.NPoint = _player.GetNearestUndoneNavPoint(this.Location, ref this.NPNumber);
                this.NPoint = _player.GetNextUndoneNavPoint(this.Location, ref this.NPNumber);
                if (this.NPNumber == -10)
                {
                    this.ForceAutoDestruction();
                    return;
                }
            }

            //���� ����� ������������, ��� ����, � ������� ���, ��� ���-�� ��������, �� ����������� ����� � ���������������.
            if (_player.NavigationPoints[NPNumber].Complete == true)
            {
                //this.NPoint = _player.GetNearestUndoneNavPoint(this.Location, ref this.NPNumber);
                this.NPoint = _player.GetNextUndoneNavPoint(this.Location, ref this.NPNumber);
                if (this.NPNumber == -10)
                {
                    this.ForceAutoDestruction();
                    return;
                }
                this.StopMoving();
            }

            //���� �� ����� �� ���� � ������ �����, �� �������� � ��� ����������� � ����������� �����.
            if ((this.Location == this.NPoint)
                    && (_player.CurrentTurn > _player.NavigationPoints[NPNumber].StartTurn)
                    && (_player.CurrentTurn < _player.NavigationPoints[NPNumber].EndTurn))
            {
                _player.NavigationPoints[NPNumber].Complete = true;
                this.NPoint = _player.GetNextUndoneNavPoint(this.Location, ref this.NPNumber);
                if (this.NPNumber == -10)
                {
                    this.ForceAutoDestruction();
                    return;
                }
            }

            //���� �� �����, ������ �� �� ����� ������� ����, �� ��� � ��� �����.
            if (this.State == NanoBotState.WaitingOrders)
            {
                if (this.Location != this.NPoint)
                {
                    //MoveTo(NPoint);
                    MoveTo(_player.ePathfinder.FindPath(this.Location, NPoint));
                    return;
                }
            }
        }
예제 #12
0
 public void Action(MyAI _player)
 {
     this.MoveTo(_player.AI.Location);
 }
예제 #13
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;
             }
         }
     }
     //���������, ��� �����
     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;
     }
 }
예제 #14
0
 private int GetStreamDirection(MyAI _player, Point p)
 {
     BloodStream stream = _player.Tissue.IsInStream(p.X, p.Y);
     if (stream != null)
     {
         return (int)stream.Direction;
     }
     return -1;
 }
예제 #15
0
        public void Action(MyAI _player)
        {
            if (this.NPNumber == -1)
            {
                this.NPoint = _player.GetNextUndoneNavPoint(this.Location, ref this.NPNumber);
            }

            if (_player.NavigationPoints[NPNumber].Complete == true)
            {
                this.NPoint = _player.GetNextUndoneNavPoint(this.Location, ref this.NPNumber);
                this.StopMoving();
            }

            if ((this.Location == this.NPoint)
                    && (_player.CurrentTurn > _player.NavigationPoints[NPNumber].StartTurn)
                    && (_player.CurrentTurn < _player.NavigationPoints[NPNumber].EndTurn))
            {
                _player.NavigationPoints[NPNumber].Complete = true;
            }

            if (this.State == NanoBotState.WaitingOrders)
            {
                if (this.Location != this.NPoint)
                {
                    this.MoveTo(NPoint);
                    //this.MoveTo(_player.ePathfinder.FindPath(this.Location,this.NPoint));
                    return;
                }
            }
        }
예제 #16
0
 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();
 }
예제 #17
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)
                        {
                            //��������, ��� ������ ���������
                            _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;
                }
            }
        }
예제 #18
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)
                        {
                            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;
        }
예제 #19
0
 //��������� ������, ���� �� �����-�� �������� ��-���� �����������.
 //������������ �� �����. ����� ������������ ������ � ������ �����,
 //���� ����� ����� ������ �������, � ����� ���.
 private void Gather(MyAI _player)
 {
     if (MyDefender != null)
     {
         MyDefender.StopMoving();
         MyDefender.MoveTo(_player.Pathfinder.FindPath(MyDefender.Location, this.Location));
     }
     if (MyContainer[0] != null)
     {
         MyContainer[0].StopMoving();
         MyContainer[0].MoveTo(_player.Pathfinder.FindPath(MyContainer[0].Location, this.Location));
     }
     if (MyContainer[1] != null)
     {
         MyContainer[1].StopMoving();
         MyContainer[1].MoveTo(_player.Pathfinder.FindPath(MyContainer[1].Location, this.Location));
     }
 }
예제 #20
0
        public void Action(MyAI _player)
        {
            if (this.HPNumber == -1)
            {
                this.HPoint = _player.GetNextHoshimiPoint(this.Location, ref this.HPNumber);
            }

            if (this.HPNumber == -10)
            {
                this.HPoint = _player.GetNearestUnfilledHP(this.Location, ref this.HPNumber);
            }

            if (HPNumber >= 0)
            {
                if (_player.HoshimiPoints[HPNumber].Full == 1)
                {
                    this.HPoint = _player.GetNearestUnfilledHP(this.Location, ref this.HPNumber);
                    this.StopMoving();
                }
            }

            if (this.State == NanoBotState.WaitingOrders)
            {
                if (this.Location == this.APoint)
                {
                    if (this.Stock == 0)
                    {
                        //Collect
                        CollectFrom(Location, this.ContainerCapacity / this.CollectTransfertSpeed);
                    }
                    else
                    {
                        //Go Hoshimi point
                        //MoveTo(this.HPoint);
                        MoveTo(_player.Pathfinder.FindPath(this.Location, this.HPoint));
                    }
                }
                if (this.Location == this.HPoint)
                {
                    foreach (NanoBot bot in _player.NanoBots)
                    {
                        if ((bot is Needle) && (bot.Stock == bot.ContainerCapacity) && (bot.Location == this.Location))
                        {
                            if (HPNumber >= 0)
                            {
                                _player.HoshimiPoints[HPNumber].Full = 1;
                                this.HPoint = _player.GetNearestUnfilledHP(this.Location, ref this.HPNumber);
                                //�������� ����������� "����������"!!!
                                if (Stock == 0)
                                {
                                    this.APoint = _player.GetNearestAZNPoint(this.Location, this.HPoint);
                                    //MoveTo(this.APoint);
                                    MoveTo(_player.Pathfinder.FindPath(this.Location, this.APoint));
                                }
                                else
                                {
                                    //this.MoveTo(this.HPoint);
                                    MoveTo(_player.Pathfinder.FindPath(this.Location, this.HPoint));
                                }
                            }
                        }
                    }
                    if (Stock == 0)
                    {
                        //return to azn
                        this.APoint = _player.GetNearestAZNPoint(this.Location, this.HPoint);
                        //MoveTo(this.APoint);
                        MoveTo(_player.Pathfinder.FindPath(this.Location, this.APoint));
                    }
                    else
                    {
                        //transfert
                        TransferTo(Location, this.Stock / this.CollectTransfertSpeed);
                    }
                }
                //�������� ����������� "����������"!!!
                if (Stock == 0)
                {
                    this.APoint = _player.GetNearestAZNPoint(this.Location, this.HPoint);
                    //this.MoveTo(this.APoint);
                    MoveTo(_player.Pathfinder.FindPath(this.Location, this.APoint));
                }
                else
                {
                    //this.HPoint = _player.GetNearestUnfilledHP(this.Location, ref this.HPNumber);
                    //this.MoveTo(this.HPoint);
                    MoveTo(_player.Pathfinder.FindPath(this.Location, this.HPoint));
                }
            }
        }
예제 #21
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)
                    {
                        //��������, ��� ������ ���������
                        _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;
                }
            }
        }
예제 #22
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;
                }
            }
        }