コード例 #1
0
ファイル: PlayerInventory.cs プロジェクト: antoinusitos/Aloi
    private void UpdateInventory()
    {
        Upgrade[] aType = myPlayerUpgrades.GetTypeAUpgrades();
        for (int i = 0; i < aType.Length; i++)
        {
            Transform t = Instantiate(myInventoryChipsItemPrefab, mySlotAChipsPanel);
            if (myCurrentUpgradeTransformSelected == null)
            {
                SetUpgradeSelected(t, aType[i], i, 0);
            }
            if (aType[i] != null)
            {
                t.GetComponent <Image>().sprite = myTypeASprite;
            }
        }

        Upgrade[] bType = myPlayerUpgrades.GetTypeBUpgrades();
        for (int i = 0; i < bType.Length; i++)
        {
            Transform t = Instantiate(myInventoryChipsItemPrefab, mySlotBChipsPanel);
            if (bType[i] != null)
            {
                t.GetComponent <Image>().sprite = myTypeBSprite;
                if (myCurrentUpgradeTransformSelected == null)
                {
                    SetUpgradeSelected(t, bType[i], i, 1);
                }
            }
        }

        Upgrade[] cType = myPlayerUpgrades.GetTypeCUpgrades();
        for (int i = 0; i < cType.Length; i++)
        {
            Transform t = Instantiate(myInventoryChipsItemPrefab, mySlotCChipsPanel);
            if (cType[i] != null)
            {
                if (myCurrentUpgradeTransformSelected == null)
                {
                    SetUpgradeSelected(t, cType[i], i, 2);
                }
            }
        }

        Upgrade[] dType = myPlayerUpgrades.GetTypeDUpgrades();
        for (int i = 0; i < dType.Length; i++)
        {
            Transform t = Instantiate(myInventoryChipsItemPrefab, mySlotDChipsPanel);
            if (dType[i] != null)
            {
                if (myCurrentUpgradeTransformSelected == null)
                {
                    SetUpgradeSelected(t, dType[i], i, 3);
                }
            }
        }

        if (myCurrentUpgradeTransformSelected == null)
        {
            return;
        }

        myCurrentUpgradeTransformSelected.GetChild(0).gameObject.SetActive(true);

        myExperienceText.text = myPlayerStats.GetExperience().ToString();

        myCurrentWattText.text = "<b>" + myPlayerStats.GetCurrentWatt().ToString() + "</b> / " + myPlayerStats.GetMaxWatt().ToString();
        myWattSlider.value     = (float)myPlayerStats.GetCurrentWatt() / myPlayerStats.GetMaxWatt();
    }