//execute move/attack for a single unit IEnumerator _MoveUnit(UnitTB unit) { //make sure no event is taking place while(GameControlTB.IsActionInProgress()) yield return null; if(!unit.IsStunned()){ /* DateTime timeS; DateTime timeE; TimeSpan timeSpan; timeS=System.DateTime.Now; */ Tile destinationTile=null; if(aIStance==_AIStance.Trigger){ if(unit.triggered) destinationTile=Analyse(unit); } else{ destinationTile=Analyse(unit); } //if there's target in current tile, just attack it if(destinationTile==unit.occupiedTile){ if(destinationTile.AIHostileList.Count!=0){ //unit.Attack(destinationTile.AIHostileList[UnityEngine.Random.Range(0, destinationTile.AIHostileList.Count)]); //unit will simply attack instead of move if(!unit.MoveAttack(unit.occupiedTile)) NoActionForUnit(unit); } else{ unitInAction=false; } yield break; } if(destinationTile!=null){ if(GameControlTB.EnableFogOfWar()){ bool visibleToPlayer=CheckEncounterOnPath(unit.occupiedTile, destinationTile); if(visibleToPlayer){ if(!unit.MoveAttack(destinationTile)) NoActionForUnit(unit); } else{ if(destinationTile.AIHostileList.Count==0){ MoveUnitToTileInstant(unit, destinationTile); unit.CompleteAllAction(); } else{ if(!unit.MoveAttack(destinationTile)) NoActionForUnit(unit); } } } else{ if(!unit.MoveAttack(destinationTile)) NoActionForUnit(unit); } } else{ //no action is available for the unit, simply registred it as moved NoActionForUnit(unit); } /* timeE=System.DateTime.Now; timeSpan=timeE-timeS; Debug.Log( "Time:"+timeSpan.TotalMilliseconds); */ } else{ NoActionForUnit(unit); } }
void NoActionForUnit(UnitTB unit) { UnitControl.MoveUnit(unit); unit.CompleteAllAction(); unitInAction = false; }
void NoActionForUnit(UnitTB unit) { UnitControl.MoveUnit(unit); unit.CompleteAllAction(); unitInAction=false; }
//execute move/attack for a single unit IEnumerator _MoveUnit(UnitTB unit) { //make sure no event is taking place while (GameControlTB.IsActionInProgress()) { yield return(null); } if (!unit.IsStunned()) { /* * DateTime timeS; * DateTime timeE; * TimeSpan timeSpan; * timeS=System.DateTime.Now; */ Tile destinationTile = null; if (aIStance == _AIStance.Trigger) { if (unit.triggered) { destinationTile = Analyse(unit); } } else { destinationTile = Analyse(unit); } //if there's target in current tile, just attack it if (destinationTile == unit.occupiedTile) { if (destinationTile.AIHostileList.Count != 0) { //unit.Attack(destinationTile.AIHostileList[UnityEngine.Random.Range(0, destinationTile.AIHostileList.Count)]); //unit will simply attack instead of move if (!unit.MoveAttack(unit.occupiedTile)) { NoActionForUnit(unit); } } else { unitInAction = false; } yield break; } if (destinationTile != null) { if (GameControlTB.EnableFogOfWar()) { bool visibleToPlayer = CheckEncounterOnPath(unit.occupiedTile, destinationTile); if (visibleToPlayer) { if (!unit.MoveAttack(destinationTile)) { NoActionForUnit(unit); } } else { if (destinationTile.AIHostileList.Count == 0) { MoveUnitToTileInstant(unit, destinationTile); unit.CompleteAllAction(); } else { if (!unit.MoveAttack(destinationTile)) { NoActionForUnit(unit); } } } } else { if (!unit.MoveAttack(destinationTile)) { NoActionForUnit(unit); } } } else { //no action is available for the unit, simply registred it as moved NoActionForUnit(unit); } /* * timeE=System.DateTime.Now; * timeSpan=timeE-timeS; * Debug.Log( "Time:"+timeSpan.TotalMilliseconds); */ } else { NoActionForUnit(unit); } }