Exemplo n.º 1
0
    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));
    }
Exemplo n.º 2
0
    public void setTower(GameObject tower)
    {
        currentTower = tower;
        TowerDetails towerDetailsComponent = currentTower.GetComponent <TowerDetails>();

        if (towerDetailsComponent != null)
        {
            towerDetailsComponent.node = this;
        }
        GameManager.emptyNodes.Remove(this);
    }
Exemplo n.º 3
0
    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);
    }
Exemplo n.º 4
0
    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);
    }