Exemple #1
0
 public void AddUnit(UnitCreator unit)
 {
     if (ownedUnits.ContainsKey(unit) == false)
     {
         GameObject button = AddButton(unit);
         ownedUnits.Add(unit, button.GetComponent <UnitButtonScript>());
     }
     ownedUnits[unit].amount++;
     currentMoney -= unit.GetCost();
 }
Exemple #2
0
 void RemoveUnit(UnitCreator unit)
 {
     if (ownedUnits[unit].amount > 1)
     {
         ownedUnits[unit].amount--;
     }
     else
     {
         if (Application.isEditor)
         {
             Object.DestroyImmediate(ownedUnits[unit].gameObject);
         }
         else
         {
             Object.Destroy(ownedUnits[unit].gameObject);
         }
         ownedUnits.Remove(unit);
     }
     currentMoney += unit.GetCost();
     Global.instance.armySavingManager.currentSave.RemoveUnit(unit);
 }
Exemple #3
0
 bool CanBeLegallyAdded(UnitCreator unitCreator)
 {
     return(currentMoney >= unitCreator.GetCost() && Global.instance.armySavingManager.currentSave.GetQuantityOfUnit(unitCreator) < unitCreator.GetLimit());
 }