public int getCurrentUpgradeCost() { GameObject tower = GameManager.activeNodeManager.currentTower; if (tower == null) { return(-1); } TowerDetails towerDetailsComponent = tower.GetComponent <TowerDetails>(); if (towerDetailsComponent == null) { return(-1); } if (towerDetailsComponent.level >= TowerManager.instance.getMaxLevelFromType(towerDetailsComponent.type)) { return(-1); } int towerBaseCost = TowerManager.instance.getBaseCostFromType(towerDetailsComponent.type); int currentLevel = towerDetailsComponent.level; return(getUpgradeCost(towerBaseCost, currentLevel)); }
public void setTower(GameObject tower) { currentTower = tower; TowerDetails towerDetailsComponent = currentTower.GetComponent <TowerDetails>(); if (towerDetailsComponent != null) { towerDetailsComponent.node = this; } GameManager.emptyNodes.Remove(this); }
public override void triggerDeath() { GameObject towerDeathEffectParticleSystem = (GameObject)Instantiate(towerDeathEffect, transform.position, transform.rotation); Destroy(towerDeathEffectParticleSystem, 1.0f); TowerDetails towerDetailsComponent = gameObject.GetComponent <TowerDetails>(); if (towerDetailsComponent != null) { towerDetailsComponent.node.removeTower(); } Destroy(gameObject); }
public void upgradeTower() { if (GameManager.activeNodeManager == null) { return; } GameObject tower = GameManager.activeNodeManager.currentTower; if (tower == null) { return; } TowerDetails towerDetailsComponent = tower.GetComponent <TowerDetails>(); if (towerDetailsComponent == null) { return; } int towerBaseCost = TowerManager.instance.getBaseCostFromType(towerDetailsComponent.type); int currentLevel = towerDetailsComponent.level; int upgradeCost = getUpgradeCost(towerBaseCost, currentLevel); if (CurrencyManager.instance.currentCurrency < upgradeCost) { return; } if (towerDetailsComponent.level >= TowerManager.instance.getMaxLevelFromType(towerDetailsComponent.type)) { return; } CurrencyManager.instance.currentCurrency -= upgradeCost; towerDetailsComponent.level++; handleUpgrade(tower); }