public BattalionVisualizer CreateVisualsFor(BattalionType type, int totalRounds) { GameObject retObj = Instantiate(battalionVisualPrefab); BattalionVisualizer ret = retObj.GetComponent <BattalionVisualizer>(); ret.Initialize(totalRounds, bindingsDictionary[type].Sprite); return(ret); }
public BattalionBuilder(BattalionType type, int hitpoints, int moral) { id = new BattalionIdentifier(type); effectors = new List <BattalionEffector>(); modifiers = new List <BattalionStateModifier>(); modifiers.Add(new BattalionStateModifier(null, id, BattalionAttribute.MaxHitpoints, hitpoints)); modifiers.Add(new BattalionStateModifier(null, id, BattalionAttribute.RemainingHitpoints, hitpoints)); modifiers.Add(new BattalionStateModifier(null, id, BattalionAttribute.MaxMoral, moral)); modifiers.Add(new BattalionStateModifier(null, id, BattalionAttribute.RemainingMoral, moral)); }
private void DetermineBattalion(Army defendingArmy, Army attackingArmy, Army minimumTroopsNeededToWin, BattalionType type) { var defendingBattalion = new Battalion(); foreach (var troop in defendingArmy.Battalions) { if (troop.Type == type) { defendingBattalion = troop; break; } } var attackingBattalion = new Battalion(); foreach (var troop in attackingArmy.Battalions) { if (troop.Type == type) { attackingBattalion = troop; break; } } if (minimumTroopsNeededToWin.Elephants <= defendingArmy.Elephants) { defendingArmy.Elephants -= minimumTroopsNeededToWin.Elephants; armyToDeploy.Elephants = minimumTroopsNeededToWin.Elephants; } else { int numberOfElephantsShortBy = minimumTroopsNeededToWin.Elephants - defendingArmy.Elephants; armyToDeploy.Elephants = defendingArmy.Elephants; defendingArmy.Elephants = 0; if (defendingArmy.Horses > 0) { //use horses to replace elephants. if (defendingArmy.Horses / Lengaburu_To_Falicornia_Battalion_Strength_Ratio >= numberOfElephantsShortBy) //horses can cover for elephants { armyToDeploy.Horses += Lengaburu_To_Falicornia_Battalion_Strength_Ratio * numberOfElephantsShortBy; defendingArmy.Horses -= Lengaburu_To_Falicornia_Battalion_Strength_Ratio * numberOfElephantsShortBy; numberOfElephantsShortBy = 0; } else { //use remaining horse. numberOfElephantsShortBy -= defendingArmy.Horses / Lengaburu_To_Falicornia_Battalion_Strength_Ratio; armyToDeploy.Horses += (defendingArmy.Horses / Lengaburu_To_Falicornia_Battalion_Strength_Ratio) * Lengaburu_To_Falicornia_Battalion_Strength_Ratio; defendingArmy.Horses -= (defendingArmy.Horses / Lengaburu_To_Falicornia_Battalion_Strength_Ratio) * Lengaburu_To_Falicornia_Battalion_Strength_Ratio; } } minimumTroopsNeededToWin.Tanks += numberOfElephantsShortBy % Lengaburu_To_Falicornia_Battalion_Strength_Ratio == 0 ? numberOfElephantsShortBy / Lengaburu_To_Falicornia_Battalion_Strength_Ratio : numberOfElephantsShortBy / Lengaburu_To_Falicornia_Battalion_Strength_Ratio + 1; } }
public BattalionIdentifier(BattalionType type) { Type = type; }