Example #1
0
    private void ReplaceChips()
    {
        if (myUpgradeCategoryIndex == 0)
        {
            Upgrade[] upgrades = myPlayerUpgrades.GetTypeAUpgrades();
            for (int i = 0; i < upgrades.Length; i++)
            {
                if (upgrades[i] == myCurrentUpgradeSelected)
                {
                    myPlayerUpgrades.SetUpgradeTypeA(myCurrentUpgradeReplaceSelected, i);
                    for (int j = 0; j < myUpgradesInventory.Count; j++)
                    {
                        if (myUpgradesInventory[j] == myCurrentUpgradeReplaceSelected)
                        {
                            myUpgradesInventory[j] = myCurrentUpgradeSelected;
                        }
                    }
                    break;
                }
            }
        }
        else if (myUpgradeCategoryIndex == 1)
        {
            Upgrade[] upgrades = myPlayerUpgrades.GetTypeBUpgrades();
            for (int i = 0; i < upgrades.Length; i++)
            {
                if (upgrades[i] == myCurrentUpgradeSelected)
                {
                    myPlayerUpgrades.SetUpgradeTypeB(myCurrentUpgradeReplaceSelected, i);
                    break;
                }
            }
            for (int j = 0; j < myUpgradesInventory.Count; j++)
            {
                if (myUpgradesInventory[j] == myCurrentUpgradeReplaceSelected)
                {
                    myUpgradesInventory[j] = myCurrentUpgradeSelected;
                }
            }
        }
        else if (myUpgradeCategoryIndex == 2)
        {
            Upgrade[] upgrades = myPlayerUpgrades.GetTypeCUpgrades();
            for (int i = 0; i < upgrades.Length; i++)
            {
                if (upgrades[i] == myCurrentUpgradeSelected)
                {
                    myPlayerUpgrades.SetUpgradeTypeC(myCurrentUpgradeReplaceSelected, i);
                    for (int j = 0; j < myUpgradesInventory.Count; j++)
                    {
                        if (myUpgradesInventory[j] == myCurrentUpgradeReplaceSelected)
                        {
                            myUpgradesInventory[j] = myCurrentUpgradeSelected;
                        }
                    }
                    break;
                }
            }
        }
        else if (myUpgradeCategoryIndex == 3)
        {
            Upgrade[] upgrades = myPlayerUpgrades.GetTypeDUpgrades();
            for (int i = 0; i < upgrades.Length; i++)
            {
                if (upgrades[i] == myCurrentUpgradeSelected)
                {
                    myPlayerUpgrades.SetUpgradeTypeD(myCurrentUpgradeReplaceSelected, i);
                    for (int j = 0; j < myUpgradesInventory.Count; j++)
                    {
                        if (myUpgradesInventory[j] == myCurrentUpgradeReplaceSelected)
                        {
                            myUpgradesInventory[j] = myCurrentUpgradeSelected;
                        }
                    }
                    break;
                }
            }
        }

        if (myCurrentUpgradeSelected != null)
        {
            myPlayerStats.AddCurrentWatt(-myCurrentUpgradeSelected.GetWatt());
        }
        myPlayerStats.AddCurrentWatt(myCurrentUpgradeReplaceSelected.GetWatt());

        Upgrade temp = myCurrentUpgradeSelected;

        if (myCurrentUpgradeSelected != null)
        {
            myCurrentUpgradeSelected.RemoveUpgrade(myPlayer);
        }

        myCurrentUpgradeSelected = myCurrentUpgradeReplaceSelected;

        if (myCurrentUpgradeSelected != null)
        {
            myCurrentUpgradeSelected.AddUpgrade(myPlayer);
        }

        myCurrentUpgradeReplaceSelected = temp;

        HideInventoryChip();
        SetUpgradeSelected(myCurrentUpgradeTransformSelected, myCurrentUpgradeSelected, myUpgradeIndex, myUpgradeCategoryIndex);

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