//���������� ������� ��������� ������ 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; } } }
//�������� �������. ��������� ����� ���������� ������ 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) { 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.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; } } else { //��������, ��� ������ ��������� _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; } } }