public void _SelectNextUnitInFaction() { if (selectedFactionID < 0) { selectedFactionID = 0; } if (TurnControl.GetMoveOrder() == _MoveOrder.Free) { bool unitAvailable = factionList[selectedFactionID].SelectFirstAvailableUnit(); if (!unitAvailable) { _SelectNextFaction(); } } else { //pass true to SelectNextUnitInQueue() so when the all unit in the faction has been selected before, the function will return true bool allUnitCycled = factionList[selectedFactionID].SelectNextUnitInQueue(true); //original line //bool allUnitCycled=factionList[selectedFactionID].SelectNextUnitInQueue(true); if (allUnitCycled) { _SelectNextFaction(); } } }
public void _OnTile(Tile tile) { //if (!FactionManager.IsPlayerTurn()) return; if (tile.unit != null) { //select the unit if the unit belong's to current player in turn if (FactionManager.GetSelectedFactionID() == tile.unit.factionID) { if (TurnControl.GetMoveOrder() != _MoveOrder.Free) { return; } // if (TurnControl.GetTurnMode() == _TurnMode.UnitPerTurn) return; if (!BattleControl.AllowUnitSelect()) { return; } if (BattleControl.selectedUnit != null && BattleControl.selectedUnit.tile == tile) { return; } BattleControl.SelectUnit(tile.unit); } //if the unit in the tile can be attack by current selected unit, attack it else if (attackableTileList.Contains(tile)) { BattleControl.selectedUnit.Attack(tile.unit); } } //if the tile is within the move range of current selected unit, move to it else { if (walkableTileList.Contains(tile)) { if (onExitWalkableTileE != null) { onExitWalkableTileE(); } BattleControl.selectedUnit.Move(tile); ClearAllTile(); } else { BattleControl.ClearSelectedUnit(); } } ClearHoveredTile(); //clear the hovered tile so all the UI overlay will be cleared }
public void _SelectNextFaction() { BattleControl.ClearSelectedUnit(); selectedFactionID += 1; if (selectedFactionID >= factionList.Count) { selectedFactionID = 0; } factionList[selectedFactionID].ResetFactionTurnData(); if (true) //if it's a player's faction { if (TurnControl.GetMoveOrder() == _MoveOrder.Free) { factionList[selectedFactionID].SelectFirstAvailableUnit(); } else { factionList[selectedFactionID].SelectNextUnitInQueue(true); } } //else //{//if it's a AI's faction, execute AI move // Debug.Log("AIManager.MoveFaction ------------------------"); // BattleControl.DisplayMessage("AI's Turn"); // if (TurnControl.GetMoveOrder() == _MoveOrder.Free) // { // AIManager.MoveFaction(factionList[selectedFactionID]); // } // else // { // SelectNextUnitInFaction(); //when an AI unit pass to BattleControl.Select(), AI routine will be called // } //} }