private string GetSquadDetails(BattleSquad squad) { string report = "\n" + squad.Name + "\n" + squad.Soldiers.Count.ToString() + " soldiers standing\n\n"; foreach (BattleSoldier soldier in squad.Soldiers) { report += GetSoldierDetails(soldier); } return(report); }
private void RemoveSoldier(BattleSoldier soldier, BattleSquad squad) { squad.RemoveSoldier(soldier); _grid.RemoveSoldier(soldier.Soldier.Id); BattleView.RemoveSoldier(soldier.Soldier.Id); _soldierBattleSquadMap.Remove(soldier.Soldier.Id); if (squad.Soldiers.Count == 0) { RemoveSquad(squad); } }
private void UpdateSquadMeleeStatus(BattleSquad squad) { bool atLeastOneSoldierInMelee = false; foreach (BattleSoldier soldier in squad.Soldiers) { soldier.IsInMelee = _grid.IsAdjacentToEnemy(soldier.Soldier.Id); if (soldier.IsInMelee) { atLeastOneSoldierInMelee = true; } } squad.IsInMelee = atLeastOneSoldierInMelee; }
private Vector2 PlaceBottomSquad(BattleSquad squad, ref int left, ref int bottom, ref int right, ref int top) { Tuple <int, int> squadSize = squad.GetSquadBoxSize(); // determine if there's more space to the left or right of the current limits int spaceRight = _grid.GridWidth - right; int placeLeft, placeBottom; if (squadSize.Item1 > spaceRight && squadSize.Item1 > left) { // there's not enough room; move "up" bottom = top + 2; top += squadSize.Item2 + 2; left = (_grid.GridWidth / 2) - 2; right = left + squadSize.Item1 + 2; placeLeft = left; placeBottom = bottom; } else if (spaceRight > left) { // place to the right of the current box placeLeft = right + 2; placeBottom = bottom; right += squadSize.Item1 + 2; if (top < bottom + squadSize.Item2 + 2) { top = bottom + squadSize.Item2 + 2; } } else { // place to the left of the current box left -= squadSize.Item1 + 2; placeLeft = left; placeBottom = bottom; if (top < bottom + squadSize.Item2 + 2) { top = bottom + squadSize.Item2 + 2; } } _grid.PlaceBattleSquad(squad, new Tuple <int, int>(placeLeft, placeBottom), true); return(new Vector2(placeLeft, placeBottom)); }
private void RemoveSquad(BattleSquad squad) { Log(false, "<b>" + squad.Name + " wiped out</b>"); if (squad.IsPlayerSquad) { _playerBattleSquads.Remove(squad.Id); } else { _opposingBattleSquads.Remove(squad.Id); } if (_selectedBattleSquad == squad) { _selectedBattleSquad = null; } }
public void BattleView_OnSoldierPointerClick(int soldierId) { IEnumerable <int> soldierIds; if (_selectedBattleSquad != null) { soldierIds = _selectedBattleSquad.Soldiers.Select(s => s.Soldier.Id); BattleView.HighlightSoldiers(soldierIds, false, Color.clear); } _selectedBattleSquad = _soldierBattleSquadMap[soldierId]; soldierIds = _selectedBattleSquad.Soldiers.Select(s => s.Soldier.Id); BattleView.HighlightSoldiers(soldierIds, true, Color.yellow); if (_selectedBattleSquad.IsPlayerSquad) { BattleView.OverwritePlayerWoundTrack(GetSquadDetails(_selectedBattleSquad)); } else { BattleView.OverwritePlayerWoundTrack(GetSquadSummary(_selectedBattleSquad)); } }
public void BattleView_OnSoldierPointerEnter(int soldierId) { BattleSquad battleSquad = _soldierBattleSquadMap[soldierId]; if (_hoveredBattleSquad != null && _hoveredBattleSquad.Id != battleSquad.Id && battleSquad.Id != _selectedBattleSquad?.Id) { BattleView.HighlightSoldiers(_hoveredBattleSquad.Soldiers .Select(s => s.Soldier.Id), false, Color.clear); } if (battleSquad.Id != _selectedBattleSquad?.Id) { BattleView.HighlightSoldiers(battleSquad.Soldiers.Select(s => s.Soldier.Id), true, Color.cyan); _hoveredBattleSquad = battleSquad; } BattleSoldier soldier = battleSquad.Soldiers.First(s => s.Soldier.Id == soldierId); Tooltip.ShowTooltip(GetSoldierDetails(soldier)); }
private string GetSquadSummary(BattleSquad squad) { return("\n" + squad.Name + "\n" + squad.Soldiers.Count.ToString() + " soldiers standing\n\n"); }