コード例 #1
0
    private void updateCurrentSkinText()
    {
        //updates the text on the "Current Skin" button
        currentSkinText.GetComponent <Text>().text = "CURRENT SKIN:\n" + StaticVariables.skin.skinName.ToUpper();
        GameObject parentBox = expandSkinButton.transform.parent.gameObject;

        for (int i = 1; i < parentBox.transform.childCount; i++)
        {
            bool isActive = (InterfaceFunctions.getSkinFromName(parentBox.transform.GetChild(i).name) == StaticVariables.skin);
            parentBox.transform.GetChild(i).Find("Button").Find("On").gameObject.SetActive(isActive);
            parentBox.transform.GetChild(i).Find("Button").Find("Off").gameObject.SetActive(!isActive);
        }
    }
コード例 #2
0
    public void unlockSkin(GameObject parent)
    {
        Skin skin = InterfaceFunctions.getSkinFromName(parent.name);

        if (canPurchase(StaticVariables.unlockedSkins.Contains(skin), getSkinPrice(skin)))
        {
            StaticVariables.unlockedSkins.Add(skin);
            StaticVariables.skin = skin;
            background.GetComponent <SpriteRenderer>().sprite = StaticVariables.skin.shopBackground;
            InterfaceFunctions.colorMenuButton(menuButton);
            doPurchase(getSkinPrice(skin));
        }
    }
コード例 #3
0
    private void expandSkinButtons()
    {
        //expands the skin details button beneath the "Choose Skin" button
        GameObject parentBox = expandSkinButton.transform.parent.gameObject;

        parentBox.transform.Find("Basic").gameObject.SetActive(true);
        for (int i = 2; i < parentBox.transform.childCount; i++)
        {
            bool switchTo = StaticVariables.unlockedSkins.Contains(InterfaceFunctions.getSkinFromName(parentBox.transform.GetChild(i).name));
            parentBox.transform.GetChild(i).gameObject.SetActive(switchTo);
            parentBox.transform.GetChild(i).Find("Button").Find("Text").GetComponent <Text>().text = parentBox.transform.GetChild(i).name.ToUpper() + " SKIN";
        }
        resizeToFitChildren(parentBox, false);
        setScrollViewHeight();
    }
コード例 #4
0
ファイル: SaveData.cs プロジェクト: chilscher/Cityscapes
    private List <Skin> getUnlockedSkins()
    {
        //parses the string containing the player's unlocked skins, specifically for loading
        List <Skin> skins = new List <Skin>();

        if (unlockedSkinNames != "")
        {
            string[] strings = unlockedSkinNames.Split(' ');
            foreach (string str in strings)
            {
                skins.Add(InterfaceFunctions.getSkinFromName(str));
            }
        }
        return(skins);
    }
コード例 #5
0
ファイル: SaveData.cs プロジェクト: chilscher/Cityscapes
    // ---------------------------------------------------
    //ALL OF THE FUNCTIONS THAT ARE USED TO LOAD PLAYER DATA
    // ---------------------------------------------------

    public void LoadData()
    {
        //takes all of the variables stored in the SaveData object and stores them into StaticVariables
        StaticVariables.coins = coins;
        StaticVariables.includeNotes1Button = includeNotes1;
        StaticVariables.includeNotes2Button = includeNotes2;
        StaticVariables.changeResidentColorOnCorrectRows = changeResidentColorOnCorrectRows;
        StaticVariables.highestUnlockedSize       = highestUnlockedSize;
        StaticVariables.includeUndoRedo           = includeUndoRedo;
        StaticVariables.includeRemoveAllOfNumber  = includeRemoveAllOfNumber;
        StaticVariables.includeClearPuzzle        = includeClearPuzzle;
        StaticVariables.includeHighlightBuildings = includeHighlightBuildings;

        StaticVariables.showMed   = showMed;
        StaticVariables.showLarge = showLarge;
        StaticVariables.showHuge  = showHuge;

        StaticVariables.unlockedMedium = unlockedMed;
        StaticVariables.unlockedLarge  = unlockedLarge;
        StaticVariables.unlockedHuge   = unlockedHuge;
        StaticVariables.unlockedNotes1 = unlockedNotes1;
        StaticVariables.unlockedNotes2 = unlockedNotes2;
        StaticVariables.unlockedResidentsChangeColor = unlockedResidentsChangeColor;
        StaticVariables.unlockedUndoRedo             = unlockedUndoRedo;
        StaticVariables.unlockedRemoveAllOfNumber    = unlockedRemoveAllOfNumber;
        StaticVariables.unlockedClearPuzzle          = unlockedClearPuzzle;
        StaticVariables.unlockedHighlightBuildings   = unlockedHighlightBuildings;

        StaticVariables.skin                  = InterfaceFunctions.getSkinFromName(skinName);
        StaticVariables.unlockedSkins         = getUnlockedSkins();
        StaticVariables.hidePurchasedUpgrades = hidePurchasedUpgrades;

        StaticVariables.hasBeatenTutorial = hasBeatenTutorial;

        //loads the player's puzzle states
        StaticVariables.hasSavedPuzzleState = hasSavedPuzzleState;
        if (hasSavedPuzzleState)
        {
            StaticVariables.previousPuzzleStates = getPuzzleStateListFromString(previousPuzzleStates, savedPuzzleSize);
            StaticVariables.currentPuzzleState   = new PuzzleState(currentPuzzleState, savedPuzzleSize);
            StaticVariables.nextPuzzleStates     = getPuzzleStateListFromString(nextPuzzleStates, savedPuzzleSize);
            StaticVariables.puzzleSolution       = puzzleSolution;
            StaticVariables.savedPuzzleSize      = savedPuzzleSize;
            StaticVariables.savedBuildNumber     = savedBuildNumber;
            StaticVariables.savedBuildType       = savedBuildType;
        }
    }
コード例 #6
0
    private void Start()
    {
        //set some private variables based on elements edited by the inspector
        ColorUtility.TryParseHtmlString(affordableCoinColor, out affordableColor);
        ColorUtility.TryParseHtmlString(unaffordableCoinColor, out unaffordableColor);
        ColorUtility.TryParseHtmlString(purchaseButtonExterior, out purchaseButtonExteriorColor);
        ColorUtility.TryParseHtmlString(purchaseButtonInterior, out purchaseButtonInteriorColor);
        ColorUtility.TryParseHtmlString(noPurchaseButtonExterior, out noPurchaseButtonExteriorColor);
        ColorUtility.TryParseHtmlString(noPurchaseButtonInterior, out noPurchaseButtonInteriorColor);
        sprite1s     = coinsBox1s.GetComponent <SpriteRenderer>();
        sprite10s    = coinsBox10s.GetComponent <SpriteRenderer>();
        sprite100s   = coinsBox100s.GetComponent <SpriteRenderer>();
        sprite1000s  = coinsBox1000s.GetComponent <SpriteRenderer>();
        sprite10000s = coinsBox10000s.GetComponent <SpriteRenderer>();
        blackSprite  = blackForeground.GetComponent <SpriteRenderer>();

        //show the amount of coins the player has, and also the cost of various upgrades
        displayCoinsAmount();
        displayCoinsOnButton(expandMedButton, medCityPrice);
        displayCoinsOnButton(expandLargeButton, largeCityPrice);
        displayCoinsOnButton(expandHugeButton, hugeCityPrice);
        displayCoinsOnButton(expandNotes1Button, notes1Price);
        displayCoinsOnButton(expandNotes2Button, notes2Price);
        displayCoinsOnButton(expandResidentColorButton, residentColorPrice);
        displayCoinsOnButton(expandUndoRedoButton, undoRedoPrice);
        displayCoinsOnButton(expandRemoveAllButton, removeAllPrice);
        displayCoinsOnButton(expandClearButton, clearPrice);
        displayCoinsOnButton(expandHighlightBuildingsButton, highlightBuildingsPrice);

        //show the cost of the various skins
        findSkinButtons();
        foreach (GameObject parent in skinButtons)
        {
            displayCoinsOnButton(parent.transform.Find("Expand Button").gameObject, getSkinPrice((InterfaceFunctions.getSkinFromName(parent.name))));
        }

        //update the buttons for the various upgrades to denote if they can be purchased right now
        updateButtons();

        //apply the cosmetics from the current skin
        background.GetComponent <SpriteRenderer>().sprite = StaticVariables.skin.shopBackground;
        InterfaceFunctions.colorMenuButton(menuButton);

        //starts the fade-in process, which is carried out in the Update function
        if (StaticVariables.isFading && StaticVariables.fadingTo == "shop")
        {
            fadeTimer = fadeInTime;
        }

        //determine the full scope of the scroll view, determined by what elements are expanded within the scrollview
        setScrollViewHeight();
    }
コード例 #7
0
    private void updateButtons()
    {
        //updates every button's color to denote if the player can purchase it
        //each button has a price that must be met, and also some have a prerequisite purchase that must be made
        Color grey = Color.grey;

        updateButton(expandMedButton, StaticVariables.unlockedMedium, medCityPrice);
        updateButton(expandLargeButton, StaticVariables.unlockedLarge, largeCityPrice, StaticVariables.unlockedMedium);
        updateButton(expandHugeButton, StaticVariables.unlockedHuge, hugeCityPrice, StaticVariables.unlockedLarge);
        updateButton(expandNotes1Button, StaticVariables.unlockedNotes1, notes1Price);
        updateButton(expandNotes2Button, StaticVariables.unlockedNotes2, notes2Price, StaticVariables.unlockedNotes1);
        updateButton(expandResidentColorButton, StaticVariables.unlockedResidentsChangeColor, residentColorPrice);
        updateButton(expandUndoRedoButton, StaticVariables.unlockedUndoRedo, undoRedoPrice);
        updateButton(expandRemoveAllButton, StaticVariables.unlockedRemoveAllOfNumber, removeAllPrice, StaticVariables.unlockedUndoRedo);
        updateButton(expandClearButton, StaticVariables.unlockedClearPuzzle, clearPrice, StaticVariables.unlockedUndoRedo);
        updateButton(expandHighlightBuildingsButton, StaticVariables.unlockedHighlightBuildings, highlightBuildingsPrice);

        foreach (GameObject parent in skinButtons)
        {
            updateButton(parent.transform.Find("Expand Button").gameObject, StaticVariables.unlockedSkins.Contains(InterfaceFunctions.getSkinFromName(parent.name)), getSkinPrice((InterfaceFunctions.getSkinFromName(parent.name))));
        }

        //also update text shown when all upgrades of a single type have been purchased.
        //these texts should only appear if the player chooses to hide purchased upgrades
        bool allCities   = StaticVariables.unlockedMedium && StaticVariables.unlockedLarge && StaticVariables.unlockedHuge;
        bool allFeatures = StaticVariables.unlockedNotes1 && StaticVariables.unlockedNotes2 && StaticVariables.unlockedResidentsChangeColor && StaticVariables.unlockedUndoRedo && StaticVariables.unlockedRemoveAllOfNumber && StaticVariables.unlockedClearPuzzle && StaticVariables.unlockedHighlightBuildings;
        bool allSkins    = StaticVariables.unlockedSkins.Count + 1 == StaticVariables.allSkins.Length;
        bool allContent  = allCities && allFeatures && allSkins;

        unlockedAllFeaturesText.SetActive(allFeatures && allCities && StaticVariables.hidePurchasedUpgrades);
        unlockedAllSkinsText.SetActive(allSkins && StaticVariables.hidePurchasedUpgrades);
        unlockedEverythingText.SetActive(allContent);
        newFeaturesText.SetActive(true);
        cosmeticsText.SetActive(true);
        if (allContent && StaticVariables.hidePurchasedUpgrades)
        {
            unlockedAllFeaturesText.SetActive(false);
            unlockedAllSkinsText.SetActive(false);
            newFeaturesText.SetActive(false);
            cosmeticsText.SetActive(false);
        }

        //after all of that, resize the scroll view
        setScrollViewHeight();
    }
コード例 #8
0
 public void clickedSkinButton(GameObject button)
 {
     //equips a particular skin
     chooseSkin(InterfaceFunctions.getSkinFromName(button.transform.parent.gameObject.name));
     updateCurrentSkinText();
 }