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(); }
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); }
bool CanBeLegallyAdded(UnitCreator unitCreator) { return(currentMoney >= unitCreator.GetCost() && Global.instance.armySavingManager.currentSave.GetQuantityOfUnit(unitCreator) < unitCreator.GetLimit()); }