Example #1
0
    /// <summary>
    /// Update UI elements of purchaseable button after being pressed.
    /// </summary>
    public void PurchaseableButtonPressed(int sectionIndex, int purchaseableIndex)
    {
        currentSection = (ShopSection)sectionIndex;
        switch (currentSection)
        {
        case ShopSection.HATS:
            for (int i = 0; i < hatSelectButtons.Length; i++)
            {
                hatSelectButtons[i].SetColor(Color.white);
            }
            hatSelectButtons[purchaseableIndex].SetColor(buttonPressedColor);
            break;

        case ShopSection.COLORSCHEME:
            for (int i = 0; i < colorSelectButtons.Length; i++)
            {
                colorSelectButtons[i].SetColor(Color.white);
            }
            colorSelectButtons[purchaseableIndex].SetColor(buttonPressedColor);
            break;

        case ShopSection.POWERUPS:
            for (int i = 0; i < powerupSelectButtons.Length; i++)
            {
                powerupSelectButtons[i].SetColor(Color.white);
            }
            powerupSelectButtons[purchaseableIndex].SetColor(buttonPressedColor);
            break;
        }
    }
Example #2
0
 /// <summary>
 /// Update UI elements of purchaseable button after buying.
 /// </summary>
 public void UpdatePurchaseableSelectButton(SavedData savedData, int sectionIndex, int purchaseableIndex)
 {
     currentSection = (ShopSection)sectionIndex;
     if (currentSection == ShopSection.POWERUPS)
     {
         powerupSelectButtons[purchaseableIndex].SetProgressBar(savedData);
     }
 }
Example #3
0
    private void ResetTabs(ShopSection section)
    {
        foreach (var panel in instantiatedPanelList)
        {
            panel.SetActive(false);
        }

        section.panel.SetActive(true);
    }
Example #4
0
    public void TabClicked(ShopSection section)
    {
        if (selectedSection != null)
        {
            Deselect(selectedSection);
        }

        selectedSection = section;
        Select(section);
        ResetTabs(section);
    }
Example #5
0
    /// <summary>
    /// Change the currently selected purchaseable by the players request.
    /// </summary>
    public void SelectPurchaseable(int sectionIndex, int purchaseableIndex)
    {
        currentShopSection = (ShopSection)sectionIndex;
        switch (currentShopSection)
        {
        case ShopSection.HATS:
            currentHat = (PlayerHatTypes)purchaseableIndex;
            break;

        case ShopSection.COLORSCHEME:
            currentColor = (PlayerColorTypes)purchaseableIndex;
            break;
        }
    }
Example #6
0
    /// <summary>
    /// Update UI elements of purchaseable button after selecting.
    /// </summary>
    public void PurchaseableSelected(int sectionIndex, int purchaseableIndex)
    {
        currentSection = (ShopSection)sectionIndex;
        switch (currentSection)
        {
        case ShopSection.HATS:
            hatSelectButtons[purchaseableIndex].SetSelected(checkMark);
            break;

        case ShopSection.COLORSCHEME:
            colorSelectButtons[purchaseableIndex].SetSelected(checkMark);
            break;
        }
    }
Example #7
0
    public int GetPurchaseablePrice(int sectionIndex, int purchaseableIndex)
    {
        currentShopSection = (ShopSection)sectionIndex;
        switch (currentShopSection)
        {
        case ShopSection.HATS:
            return(hatObjectList[purchaseableIndex].GetPrice());

        case ShopSection.COLORSCHEME:
            return(colorObjectList[purchaseableIndex].GetPrice());

        case ShopSection.POWERUPS:
            return(powerupObjectList[purchaseableIndex].GetPrice());

        default:
            return(0);
        }
    }
Example #8
0
    public bool IsPurchaseableUnlocked(int sectionIndex, int purchaseableIndex)
    {
        currentShopSection = (ShopSection)sectionIndex;
        switch (currentShopSection)
        {
        case ShopSection.HATS:
            return(hatObjectList[purchaseableIndex].IsUnlocked());

        case ShopSection.COLORSCHEME:
            return(colorObjectList[purchaseableIndex].IsUnlocked());

        case ShopSection.POWERUPS:
            return(powerupObjectList[purchaseableIndex].IsUnlocked());

        default:
            return(false);
        }
    }
Example #9
0
    /// <summary>
    /// Show the selected section with its purchaseables.
    /// </summary>
    public void ShowSection(int index)
    {
        if (selectedSectionIndex == index)
        {
            return;
        }

        selectedSectionIndex = index;
        selectedShopSection  = (ShopSection)index;
        DisableAllSections();
        powerupPreview.DisableAllPreviews();

        switch (selectedShopSection)
        {
        case ShopSection.HATS:
            hatSection.SetActive(true);
            hatButtonImage.color = savedData.GetColorByPurchaseableColorType(PurchaseableColorType.BASE);
            hatButtonIcon.color  = Color.white;
            shopSectionManager.PurchaseableSelected(selectedSectionIndex, (int)savedData.GetSelectedHatType());
            PurchaseableObjectSelected((int)savedData.GetSelectedHatType());
            break;

        case ShopSection.COLORSCHEME:
            colorSection.SetActive(true);
            colorButtonImage.color = savedData.GetColorByPurchaseableColorType(PurchaseableColorType.BASE);
            colorButtonIcon.color  = Color.white;
            shopSectionManager.PurchaseableSelected(selectedSectionIndex, (int)savedData.GetSelectedColorType());
            PurchaseableObjectSelected((int)savedData.GetSelectedColorType());
            break;

        case ShopSection.POWERUPS:
            powerupSection.SetActive(true);
            powerupButtonImage.color = savedData.GetColorByPurchaseableColorType(PurchaseableColorType.BASE);
            powerupButtonIcon.color  = Color.white;
            PurchaseableObjectSelected(0);
            powerupPreview.Show(PlayerPowerupTypes.INVINCIBILTY);
            break;
        }

        shopSectionManager.UpdateSectionText(index);
        HideAllHatPreviewModels();
        hatPreviewModels[(int)savedData.GetSelectedHatType()].SetActive(true);
        styleManager.Init(savedData);
    }
Example #10
0
    /// <summary>
    /// Unlock a certain purchaseable by the players request.
    /// </summary>
    public void UnlockPurchaseable(int sectionIndex, int purchaseableIndex)
    {
        currentShopSection = (ShopSection)sectionIndex;
        switch (currentShopSection)
        {
        case ShopSection.HATS:
            totalScore -= hatObjectList[purchaseableIndex].GetPrice();
            hatObjectList[purchaseableIndex].Unlock();
            break;

        case ShopSection.COLORSCHEME:
            totalScore -= colorObjectList[purchaseableIndex].GetPrice();
            colorObjectList[purchaseableIndex].Unlock();
            break;

        case ShopSection.POWERUPS:
            totalScore -= powerupObjectList[purchaseableIndex].GetPrice();
            powerupObjectList[purchaseableIndex].Unlock();
            break;
        }
    }
Example #11
0
    /// <summary>
    /// Purchaseable object has been clicked on by player.
    /// </summary>
    public void PurchaseableObjectSelected(int index)
    {
        selectedPurchaseableIndex = index;
        shopSectionManager.PurchaseableButtonPressed(selectedSectionIndex, selectedPurchaseableIndex);
        selectedShopSection = (ShopSection)selectedSectionIndex;

        // Pretend like this terrible section doesn't exist...
        if (selectedShopSection == ShopSection.POWERUPS)
        {
            if (savedData.IsPurchaseableUnlocked(selectedSectionIndex, selectedPurchaseableIndex))
            {
                buySelectButton.interactable = false;
                buyText.gameObject.SetActive(true);
                priceText.gameObject.SetActive(false);
                selectText.gameObject.SetActive(false);
            }
            else if (savedData.totalScore >= savedData.GetPurchaseablePrice(selectedSectionIndex, selectedPurchaseableIndex))
            {
                buySelectButton.interactable = true;
                priceText.text = savedData.GetPurchaseablePrice(selectedSectionIndex, selectedPurchaseableIndex).ToString();
                buyText.gameObject.SetActive(true);
                priceText.gameObject.SetActive(true);
                selectText.gameObject.SetActive(false);
            }
            else
            {
                buySelectButton.interactable = false;
                priceText.text = savedData.GetPurchaseablePrice(selectedSectionIndex, selectedPurchaseableIndex).ToString();
                buyText.gameObject.SetActive(true);
                priceText.gameObject.SetActive(true);
                selectText.gameObject.SetActive(false);
            }
            buyMode = true;
        }
        else
        {
            if (savedData.IsPurchaseableUnlocked(selectedSectionIndex, selectedPurchaseableIndex))
            {
                buySelectButton.interactable = true;
                priceText.text = savedData.GetPurchaseablePrice(selectedSectionIndex, selectedPurchaseableIndex).ToString();
                buyMode        = false;
                buyText.gameObject.SetActive(false);
                priceText.gameObject.SetActive(false);
                selectText.gameObject.SetActive(true);
            }
            else if (savedData.totalScore >= savedData.GetPurchaseablePrice(selectedSectionIndex, selectedPurchaseableIndex))
            {
                buySelectButton.interactable = true;
                priceText.text = savedData.GetPurchaseablePrice(selectedSectionIndex, selectedPurchaseableIndex).ToString();
                buyMode        = true;
                buyText.gameObject.SetActive(true);
                priceText.gameObject.SetActive(true);
                selectText.gameObject.SetActive(false);
            }
            else
            {
                buySelectButton.interactable = false;
                priceText.text = savedData.GetPurchaseablePrice(selectedSectionIndex, selectedPurchaseableIndex).ToString();
                buyMode        = true;
                buyText.gameObject.SetActive(true);
                priceText.gameObject.SetActive(true);
                selectText.gameObject.SetActive(false);
            }
        }

        switch (selectedShopSection)
        {
        case ShopSection.HATS:
            HideAllHatPreviewModels();
            hatPreviewModels[selectedPurchaseableIndex].SetActive(true);
            break;

        case ShopSection.COLORSCHEME:
            styleManager.InitByIndex(savedData, selectedPurchaseableIndex);
            break;
        }
    }
Example #12
0
 public void Deselect(ShopSection section)
 {
     OnTabDeselected?.Invoke(section);
 }
Example #13
0
 public void Select(ShopSection section)
 {
     OnTabSelected?.Invoke(section);
 }