예제 #1
0
 public Convoy()
 {
     State            = ConvoyState.UnderConstruction;
     DefendersNumber  = 0;
     ContainersNumber = 0;
     Location         = new Point(-1, -1);
     APoint           = new Point(-1, -1);
     HPoint           = new Point(-1, -1);
     HPNumber         = -1;
     Path             = null;
     MyContainer      = new ConvoyContainer[2];
     MyContainer[0]   = null;
     MyContainer[1]   = null;
     MyDefender       = null;
 }
예제 #2
0
 public Convoy()
 {
     State = ConvoyState.UnderConstruction;
     DefendersNumber = 0;
     ContainersNumber = 0;
     Location = new Point(-1, -1);
     APoint = new Point(-1, -1);
     HPoint = new Point(-1, -1);
     HPNumber = -1;
     Path = null;
     MyContainer = new ConvoyContainer[2];
     MyContainer[0] = null;
     MyContainer[1] = null;
     MyDefender = null;
 }
예제 #3
0
 //Останавливает конвой
 private void Stop()
 {
     if (MyDefender != null)
     {
         MyDefender.StopMoving();
     }
     if (MyContainer[0] != null)
     {
         MyContainer[0].StopMoving();
     }
     if (MyContainer[1] != null)
     {
         MyContainer[1].StopMoving();
     }
     this.State = ConvoyState.Waiting;
 }
예제 #4
0
 public Convoy(bool NM)
 {
     State = ConvoyState.UnderConstruction;
     DefendersNumber = 0;
     ContainersNumber = 0;
     Location = new Point(-1, -1);
     APoint = new Point(-1, -1);
     HPoint = new Point(-1, -1);
     HPNumber = -1;
     Path = null;
     MyContainer = new ConvoyContainer[2];
     MyContainer[0] = null;
     MyContainer[1] = null;
     MyDefender = null;
     NavMission = NM;
     AZNChosen = false;
 }
예제 #5
0
 //Уничтожение конвоя
 public void Delete()
 {
     if (MyDefender != null)
     {
         MyDefender.ForceAutoDestruction();
     }
     if (MyContainer[0] != null)
     {
         MyContainer[0].ForceAutoDestruction();
     }
     if (MyContainer[1] != null)
     {
         MyContainer[1].ForceAutoDestruction();
     }
     ContainersNumber = 0;
     DefendersNumber  = 0;
     State            = ConvoyState.UnderConstruction;
     MyDefender       = null;
     MyContainer[0]   = null;
     MyContainer[1]   = null;
     HPNumber         = -1;
 }
예제 #6
0
        //�������� �������. ��������� ����� ���������� ������
        public void Action(MyAI _player)
        {
            double Distance;
            double MinDistance;
            Point ShootAt = new Point();

            //���� ������ ��� ���, �� � ������ ������
            if (State == ConvoyState.UnderConstruction)
                return;

            //������������� ��� ��������: State, Location, Stock, etc
            SetState(_player);

            //���� ���� ���, ��������� ������� �����������
            if (MyDefender != null)
            {
                //���� � �������� ������������ ���-�� ����, ������������� ������
                if (_player.OtherNanoBotsInfo != null)
                    foreach (NanoBotInfo botEnemy in _player.OtherNanoBotsInfo)
                    {
                        if (botEnemy.PlayerID == 0)
                        {
                            Distance = _player.GeomDist(botEnemy.Location, MyDefender.Location);
                            if (Distance < MyDefender.DefenseDistance)
                            {
                                this.Stop();
                            }
                        }
                    }
                //���� ������ �����
                if (this.State == ConvoyState.Waiting)
                {
                    //���� ��������� ����
                    MinDistance = 1000;
                    if (_player.OtherNanoBotsInfo != null)
                        foreach (NanoBotInfo botEnemy in _player.OtherNanoBotsInfo)
                        {
                            if (botEnemy.PlayerID == 0)
                            {
                                Distance = _player.GeomDist(botEnemy.Location, MyDefender.Location);
                                if ((botEnemy.NanoBotType == NanoBotType.NanoAI) && (Distance < MyDefender.DefenseDistance))
                                {
                                    MinDistance = -1;
                                    ShootAt = botEnemy.Location;
                                }
                                if (Distance < MinDistance)
                                {
                                    MinDistance = Distance;
                                    ShootAt = botEnemy.Location;
                                }
                            }
                        }
                    //���� ��� ���������� ������, �������� � ��������� ��������
                    if (MinDistance < MyDefender.DefenseDistance)
                    {
                        MyDefender.DefendTo(ShootAt, 3);
                        return;
                    }
                }
            }

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

                //���� �� �� AZNPoint
                if (this.Location == this.APoint)
                {
                    //���� ���������� ������, �� ��������� ��
                    if (this.Stock == 0)
                    {
                        this.FillContainers();
                        return;
                    }
                    //���� �� ������, �� ��� � HoshimiPoint
                    else
                    {
                        if (this.Location == this.HPoint)
                            return;
                        this.Path = _player.Pathfinder.FindPath(this.Location, this.HPoint);
                        this.Move();
                        return;
                    }
                }

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

                //���� �� ����� ���
                //���� ������, �� �� AZN
                if (this.Stock == 0)
                {
                    this.APoint = _player.GetNearestAZNPoint(this.Location, this.HPoint);
                    this.Path = _player.Pathfinder.FindPath(this.Location, this.APoint);
                    this.Move();
                    return;
                }
                //����� �� HP
                else
                {
                    if (this.Location == this.HPoint)
                        return;
                    this.Path = _player.Pathfinder.FindPath(this.Location, this.HPoint);
                    this.Move();
                    return;
                }
            }
        }
예제 #7
0
 //������������� ������
 private void Stop()
 {
     if (MyDefender != null)
     {
         MyDefender.StopMoving();
     }
     if (MyContainer[0] != null)
     {
         MyContainer[0].StopMoving();
     }
     if (MyContainer[1] != null)
     {
         MyContainer[1].StopMoving();
     }
     this.State = ConvoyState.Waiting;
 }
예제 #8
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 && !IsNavigating)
            {
                if ((_player.HoshimiPoints[HPNumber].Needle == 2) || (_player.HoshimiPoints[HPNumber].Full == 1) || (_player.HoshimiPoints[HPNumber].InPast == 1 && _player.HoshimiPoints[HPNumber].Needle != 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;
                }
            }
        }
예제 #9
0
 //����������� ������
 public void Delete()
 {
     if (MyDefender != null)
         MyDefender.ForceAutoDestruction();
     if (MyContainer[0] != null)
         MyContainer[0].ForceAutoDestruction();
     if (MyContainer[1] != null)
         MyContainer[1].ForceAutoDestruction();
     ContainersNumber = 0;
     DefendersNumber = 0;
     State = ConvoyState.UnderConstruction;
     MyDefender = null;
     MyContainer[0] = null;
     MyContainer[1] = null;
     HPNumber = -1;
 }
예제 #10
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;
                }
            }
        }
예제 #11
0
 public ConvoyWithCollector()
 {
     State = ConvoyState.UnderConstruction;
     DefendersNumber = 0;
     ContainersNumber = 0;
     Location = new Point(-1, -1);
     APoint = new Point(-1, -1);
     HPoint = new Point(-1, -1);
     HPNumber = -1;
     Path = null;
     MyContainer = null;
     MyDefender = null;
 }
예제 #12
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;
                }
            }
        }
예제 #13
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);
            }

            //Если 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);
                    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;
                }
            }
        }