private void AddUpgradeToList(DwellingUpgrade upgrade) { for (int i = 0; i < activeUnitUpgrades.Length; i++) { if (activeUnitUpgrades[i] == null) { activeUnitUpgrades[i] = upgrade; } } }
private bool CheckIfUpgradeExists(DwellingUpgrade upgrade, UpgradeType upgradeType, out int index) // Returns true if upgrade exists { for (int i = 0; i < activeUnitUpgrades.Length; i++) { if (activeUnitUpgrades[i] != null && activeUnitUpgrades[i].GetUpgradeType() == upgradeType) { index = i; return(true); } } index = 0; return(false); }
public void AddUpgrade(DwellingUpgrade upgrade) { if (upgrade.GetUpgradeType() == UpgradeType.Damage) { int index; if (CheckIfUpgradeExists(upgrade, UpgradeType.Damage, out index)) { activeUnitUpgrades[index].IncrementLevel(); return; } } else if (upgrade.GetUpgradeType() == UpgradeType.SpawnExtraUnits) { SetNumberOfUnitsToSpawnPerCountdown(GetNumberOfUnitsSpawnedPerCountdown() + Mathf.RoundToInt(upgrade.GetUpgradeVariables()[upgrade.GetCurrentLevel()])); } }