//�������� �������. ��������� ����� ���������� ������ 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; } } }
//���������� ������� ��������� ������ 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.GetNextHPForConvoyWithBigContainer(this.Location, ref this.HPNumber); if (HPNumber == -10) { this.Delete(); this.State = ConvoyState.Deleted; return; } } if (this.HPNumber >= 0) { if (_player.NavigationPoints[HPNumber].Complete == true) { this.HPoint = _player.GetNextHPForConvoyWithBigContainer(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; } } }