Esempio n. 1
0
    void SetInfo(GameObject towerPrefab)
    {
        TowerMarketInfoBase marketInfo = towerPrefab.GetComponent <TowerMarketInfoBase>();

        towerName.text        = marketInfo.towerName;
        attackValue.text      = marketInfo.currentDamage.ToString();
        piercingValue.text    = marketInfo.armorPiercing.ToString();
        attackSpeedValue.text = marketInfo.currentAttackSpeed.ToString();
        attackRangeValue.text = marketInfo.currentAttackRange.ToString();

        if (currentType == TowerType.IceTower)
        {
            IceTowerMarketInfo iceTowerInfo = towerPrefab.GetComponent <IceTowerMarketInfo>();
            explosionRangeText.SetActive(true);
            freezingRateText.SetActive(true);
            freezingTimeText.SetActive(true);
            explosionRangeValue.text = iceTowerInfo.currentExplosionRange.ToString();
            freezingRateValue.text   = iceTowerInfo.currentFreezingRate.ToString();
            freezingTimeValue.text   = iceTowerInfo.currentFreezingTime.ToString();
        }
        else if (currentType == TowerType.FireTower)
        {
            MissileTowerMarketInfo missileInfo = towerPrefab.GetComponent <MissileTowerMarketInfo>();
            explosionRangeText.SetActive(true);
            freezingRateText.SetActive(false);
            freezingTimeText.SetActive(false);
            explosionRangeValue.text = missileInfo.currentExplosionRange.ToString();
        }
        else
        {
            explosionRangeText.SetActive(false);
            freezingRateText.SetActive(false);
            freezingTimeText.SetActive(false);
        }
    }
    IEnumerator BuyingInfoUpdate()
    {
        GameObject towerObject = Instantiate(marketScript.transform.parent.gameObject, new Vector3(100.0f, 0.0f, 0.0f), Quaternion.identity);

        towerObject.transform.SetParent(transform);
        marketScript = towerObject.GetComponentInChildren <TowerMarketInfoBase>();
        yield return(new WaitForSeconds(0.1f));

        UpdateInfo();
    }
 void Start()
 {
     for (int i = 0; i < prices.Length; i++)
     {
         TowerMarketInfoBase tower = Instantiate(prices[i].towerPrefab, new Vector3(-100.0f, 0.0f, 0.0f), Quaternion.identity).GetComponentInChildren <TowerMarketInfoBase>();
         prices[i].price          = tower.GetPrice();
         prices[i].priceText.text = prices[i].price.ToString();
         Destroy(tower.gameObject);
     }
     isHighlighted     = false;
     currentTowerPrice = 0;
 }
Esempio n. 4
0
    public void SetTowerLevel(int level)
    {
        GameObject          tower     = Instantiate(GetTowerObject(), new Vector3(-50.0f, 0.0f, 0.0f), Quaternion.identity) as GameObject;
        TowerMarketInfoBase towerInfo = tower.GetComponent <TowerMarketInfoBase>();

        towerInfo.RollBack();

        for (int i = 0; i < level; i++)
        {
            towerInfo.Upgrade();
        }
        if (level == 0)
        {
            string towerName = towerInfo.name;
            towerName             = towerName.Substring(0, towerName.IndexOf("(Clone)")); //Deletes "(Clone)" ending
            upgradeTowerName.text = towerName + " upgrades";
        }
        SetInfo(tower);
        Destroy(tower);
    }