Exemple #1
0
    public void OnItemSelected(string itemKey)
    {
        GameController.StopItem item = GameController.instance.allShopItems[itemKey];

        if (item.equiped)
        {
            buttonText.text           = "EQUIPPED";
            bottomButton.interactable = false;
        }
        else if (item.currentLevel >= item.costs.Length)
        {
            if (item.weapon)
            {
                buttonText.text           = "Equip";
                bottomButton.interactable = true;
            }
            else
            {
                buttonText.text           = "MAX LEVEL";
                bottomButton.interactable = false;
            }
        }
        else
        {
            buttonText.text           = "Buy for " + item.costs[item.currentLevel];
            bottomButton.interactable = (item.costs[item.currentLevel] <= GameController.instance.totalMoney);
        }

        descriptionText.text = item.description;
    }
Exemple #2
0
    public void Refresh()
    {
        GameController.StopItem data = GameController.instance.allShopItems[key];

        for (int i = 0; i < bars.Count; i++)
        {
            bars[i].color = (data.currentLevel > i) ? orangeColor : grayColor;
        }

        if (data.equiped)
        {
            Equip();
        }

        Shop.instance.OnItemSelected(key);
    }
Exemple #3
0
    public void Init(string itemKey, bool equiped = false)
    {
        key = itemKey;

        GameController.StopItem data = GameController.instance.allShopItems[key];

        subTitleText.text = data.upgradeString;
        if (!data.weapon)
        {
            UpdateMainText();
            weaponIcon.enabled = false;
        }
        else
        {
            mainText.enabled  = false;
            weaponIcon.sprite = WeaponManager.instance.GetIconFromName(key);
        }

        int numLevels = data.costs.Length;

        for (int i = 0; i < numLevels; i++)
        {
            if (i > 0)
            {
                GameObject newBarObj = Instantiate(bars[0].gameObject, bars[0].transform.parent);
                bars.Add(newBarObj.GetComponent <Image>());
            }

            bars[i].color = (data.currentLevel > i) ? orangeColor : grayColor;
        }

        borders = borderParent.GetComponentsInChildren <Image>();

        if (equiped)
        {
            SetAllBorders(orangeColor);
            equippedItem = this;
        }
        else
        {
            borderParent.SetActive(false);
        }
    }
Exemple #4
0
 public void UpdateMainText()        // for items only (not weapons)
 {
     GameController.StopItem data = GameController.instance.allShopItems[key];
     if (data.dynamicText)
     {
         string displayString = "";
         if (data.upgradeString == "tank")
         {
             float diplayValue = 0f;
             diplayValue   = PlayerController.instance.tankMultiplier;
             diplayValue   = 1f / diplayValue;
             diplayValue   = Mathf.Round(diplayValue * 10f) / 10f;
             displayString = (diplayValue * 100f) + "%";
         }
         else if (data.upgradeString == "reach")
         {
             displayString = PlayerController.instance.reachMultiplier.ToString();
         }
         else if (data.upgradeString == "patches")
         {
             displayString = PlayerController.instance.patches.ToString();
         }
         else if (data.upgradeString == "recovery")
         {
             float diplayValue = 0f;
             diplayValue   = PlayerController.instance.recovery;
             diplayValue   = Mathf.Round(diplayValue * 100f) / 100f;
             displayString = (diplayValue * 100f) + "%";
         }
         mainText.text = "" + displayString + data.topText;
     }
     else
     {
         mainText.text = data.topText;
     }
 }