Esempio n. 1
0
    // Button onClick to buy aura, if player has enough gold, unlock aura and update gold
    public void BuyAura(int index)
    {
        int gold = SaveLoadManager.LoadGold();

        if (gold >= auraPrice[index])
        {
            int indexOfSelection = auraIndex[index];

            saveData.UpdateGold(gold - auraPrice[index]);
            savedGold.UpdateGold();

            saveData.UnlockAura(indexOfSelection);      // Unlock the aura index from overall auras list, not from this shop's aura list
            UpdateShop();
            shopChat.SetChat(auraBought[index]);        // Show chat response to the aura bought

            // Move to next item
            shopNav.NavShop(shopNav.Selected + 1);

            SoundManager.SoundInstance.PlaySound("ShopBuySuccess");
        }
        else
        {
            shopChat.SetChat(auraFail);     // Show chat response if can't afford aura

            SoundManager.SoundInstance.PlaySound("ShopBuyFail");
        }
    }
Esempio n. 2
0
    // Button onClick to enhance aura
    public void BuyEnhance(int index)
    {
        // Return if selection has been disabled
        if (!auraSelection[index].interactable)
        {
            return;
        }

        int gold = SaveLoadManager.LoadGold();

        if (gold >= auras[index].enhancePrice[saveData.ExtraDmg[index]])
        {
            saveData.UpdateGold(gold - auras[index].enhancePrice[saveData.ExtraDmg[index]]);
            savedGold.UpdateGold();

            saveData.UpdateExtraDmg(index);      // Increase extra dmg
            UpdateShop();
            shopChat.SetChat(enhanceBuy);        // Show chat response to the purchase

            EnhanceAuraDisplay display = auraSelection[index].gameObject.GetComponent <EnhanceAuraDisplay>();
            display.UpdateDmg();
            display.UpdatePrice();

            SoundManager.SoundInstance.PlaySound("ShopBuySuccess");
        }
        else
        {
            shopChat.SetChat(buyFail);     // Show chat response if can't afford

            SoundManager.SoundInstance.PlaySound("ShopBuyFail");
        }
    }