/// <summary> /// Makes MapUnits from the Unitbook and otherwise laods the units onto the map. /// </summary> public void DeployUnits() { foreach (UnitRoster ur in UnitBook.GetAllUnits()) { foreach (UnitEntity ue in ur.GetAllUnits()) { SessionMap.AddUnit(ue, ue.InitalPosition); ue.HasActed = true; } } }
/// <summary> /// Starts the given team's turn, ending the current turn if needed /// </summary> /// <param name="team"></param> public void StartTurn(UnitTeam team) { if (teamTurn != team) { EndTurn(teamTurn); teamTurn = team; } foreach (UnitEntity ue in UnitBook.GetRoster(team).GetAllUnits()) { ue.HasActed = false; } }
/// <summary> /// Goes through all units for the active player and sets "HasActed" to true. This will end the turn for this team. /// </summary> /// <param name="team"></param> public void EndTurn(UnitTeam team) { if (teamTurn == UnitTeam.none) { return; } if (teamTurn != team) { throw new TurnOrderException("Not the player's turn"); } foreach (UnitEntity ue in UnitBook.GetRoster(team).GetAllUnits()) { ue.HasActed = true; } }
///// <summary> ///// Returns a list of actions available to the given unit, were it at the given position (presumably already ///// calculated to be a viable movement target) ///// </summary> ///// <param name="unit"></param> ///// <param name="newPosition"></param> ///// <returns></returns> //public List<MapActionCommand> GetMapActionsForUnit(UnitEntity unit, Position newPosition) //{ // List<MapActionCommand> retList = new List<MapActionCommand>(); // //retList.Add(MapActionCommand.Wait); //wait always available. // ////get attack range, and check team relationship in relevant tiles // //foreach (Position range in unit.AllAttackRanges()) // //{ // // Position targ = newPosition + range; // // UnitTeam targTeam = GetTile(targ.xPos, targ.yPos); // // if (targ.xPos == unit.xPos && targ.yPos == unit.yPos) continue; //can't attack yourself // // if (targTeam != UnitTeam.none && targTeam != UnitTeam.playerTeam) // // { // // retList.Add(MapActionCommand.Attack); // // break; // // } // //} // ////get utility range, and check team relationship in relevant tiles // //foreach (Position range in unit.AllUtilityRanges()) // //{ // // Position targ = newPosition + range; // // UnitTeam targTeam = GetTile(targ.xPos, targ.yPos); // // if (targ.xPos == unit.xPos && targ.yPos == unit.yPos) continue; //can't utility yourself // // if (targTeam != UnitTeam.none && targTeam == UnitTeam.playerTeam) // // { // // retList.Add(MapActionCommand.Heal); // // break; // // } // //} // return retList; //} /// <summary> /// Returns a UnitRoster of all Units in the Session for the given team /// </summary> /// <param name="team"></param> /// <returns></returns> public UnitRoster GetUnits(UnitTeam team) { return(UnitBook.GetRoster(team)); }
public void AddUnitBook(UnitBook book) { this.UnitBook = book; }