/// <summary> /// returns a "delta" list, containing lost troops when comparing the current and the "remaining" lists /// </summary> /// <param name="remainingTroops"></param> public TroopList GetLossesList(TroopList remainingTroops) { int troopIndexInAfter; int troopsOfCurTypeLost; TroopList resultingList = new TroopList(); for (int i = 0; i < Count; i++) { troopIndexInAfter = remainingTroops.IndexOfTroopInThisList(this[i].troopTypeID); if (troopIndexInAfter != -1) { troopsOfCurTypeLost = (remainingTroops[troopIndexInAfter].troopAmount - this[i].troopAmount) * -1; if (troopsOfCurTypeLost > 0) { resultingList.AddTroop(this[i].troopTypeID, troopsOfCurTypeLost); } } else { //all troops of that type have been lost, probably resultingList.AddTroop(this[i].troopTypeID, this[i].troopAmount); } } return(resultingList); }
/// <summary> /// returns a "delta" list, containing lost troops according to the percentage of remaining troops provided /// </summary> /// <param name="remainingTroops"></param> public TroopList GetLossesListByPercentage(float remainingPercent) { TroopList resultingList = new TroopList(); float lossPercent = 1.0f - remainingPercent; for (int i = 0; i < Count; i++) { resultingList.AddTroop(this[i].troopTypeID, Mathf.RoundToInt(this[i].troopAmount * lossPercent)); } return(resultingList); }