Exemple #1
0
    public override void OnUpdate()
    {
        foreach (BabyInShop baby in babies)
        {
            if (baby.GetMenuItem().IsJustPressed())
            {
                if (currentBaby == baby)
                {
                    //Buy
                    if (currentBaby.GetBaby().IsUnlocked() && !currentBaby.GetBaby().IsBought() && PlayerData.Instance.Coins >= currentBaby.Price)
                    {
                        PlayerData.Instance.BuyBaby((int)currentBaby.GetBaby().baby, currentBaby.Price);
                        currentBaby.ShowPrice(false);
                        currentBaby.SetShadowed(false);
                        currentBaby.GetBaby().Idle();

                        currentBaby.message.enabled = true;
                        HiddenMessageText.enabled   = false;
                        SetMessage(null);
                    }
                }
                else
                {
                    Select(baby);
                }
            }
        }

        if (backButton.IsJustPressed() || Input.GetKeyDown(KeyCode.Escape))
        {
            CoinsCounter.Instance.AnimateOut();
            MenuManager.Instance.SetPage(MenuManager.Instance.shopPage);
        }
    }
Exemple #2
0
    void Select(BabyInShop _baby)
    {
        //Unselect current baby
        if (currentBaby)
        {
            currentBaby.SetSelected(false);
            currentBaby.message.enabled = false;
            HiddenMessageText.enabled   = false;
        }

        currentBaby = _baby;

        //Select current baby
        if (currentBaby)
        {
            currentBaby.SetSelected(true);

            if (currentBaby.GetBaby().IsBought())
            {
                SetMessage(null);
                HiddenMessageText.enabled   = false;
                currentBaby.message.enabled = true;
            }
            else if (currentBaby.GetBaby().IsUnlocked())
            {
                HiddenMessageText.enabled = true;
                if (PlayerData.Instance.Coins >= currentBaby.Price)
                {
                    SetMessage(ClickToBuyText);
                }
                else
                {
                    SetMessage(NotEnoughCoinsText);
                }
            }
            else
            {
                HiddenMessageText.enabled = true;
                SetMessage(UnlockInGameText);
            }
        }
        else
        {
            SetMessage(DefaultText);
        }
    }
Exemple #3
0
    void Select(BabyInShop _baby)
    {
        //Unselect current baby
        if(currentBaby)
        {
            currentBaby.SetSelected(false);
            currentBaby.message.enabled = false;
            HiddenMessageText.enabled = false;
        }

        currentBaby = _baby;

        //Select current baby
        if(currentBaby)
        {
            currentBaby.SetSelected(true);

            if(currentBaby.GetBaby().IsBought())
            {
                SetMessage(null);
                HiddenMessageText.enabled = false;
                currentBaby.message.enabled = true;
            }
            else if(currentBaby.GetBaby().IsUnlocked())
            {
                HiddenMessageText.enabled = true;
                if(PlayerData.Instance.Coins >= currentBaby.Price)
                {
                    SetMessage(ClickToBuyText);
                }
                else
                {
                    SetMessage(NotEnoughCoinsText);
                }
            }
            else
            {
                HiddenMessageText.enabled = true;
                SetMessage(UnlockInGameText);
            }
        }
        else
        {
            SetMessage(DefaultText);
        }
    }