예제 #1
0
    private void Purchase()
    {
        GlobalStats.coins -= cost;


        int randomIndex;

        //Get a random unlockable.
        if (isSnake)
        {
            randomIndex = UnlockRandomSnakeIndex();
        }
        else
        {
            randomIndex = UnlockRandomLevelThemeIndex();
        }

        if (isSnake)
        {
            Skins.unlockedSnakeSkins[randomIndex] = true;
        }
        else
        {
            Skins.unlockedLevelThemes[randomIndex] = true;
        }

        //Update both pools
        skinObj.CreateRandomSkinPoolList();


        //Show feedback for what you just bought


        if (isSnake)
        {
            //text.text = "New Snake!\n";
            text.text = ((Skins.SnakeSkins)randomIndex).ToString();
        }
        else
        {
            //text.text = "New Theme!\n";
            text.text = ((Skins.Themes)randomIndex).ToString();
        }

        //Update coin count on HUD
        GlobalStats.hud.UpdateHUD();

        //Recolour buttons
        UpdateButtons();

        //-------------------------------------------------------------------------------------
        //Open up the skin get screen here.
        //Makes some of the above visual stuff kind of irrelevant but keep it just in case.

        SkinGet skinGetScript = skinGetMenu.GetComponent <SkinGet>();

        if (isSnake)
        {
            skinGetScript.SetSnakeIcon(text.text, (Skins.SnakeSkins)randomIndex);
        }
        else
        {
            skinGetScript.SetThemeIcon(text.text, (Skins.Themes)randomIndex);
        }

        skinGetMenu.SetActive(true);
        //-------------------------------------------------------------------------------------
    }