Exemple #1
0
    public void ClickedBuy(int itemID)
    {
        GameParams.SetCoins(GameParams.GetCoins() - GetItem(itemID).Price);
        for (int i = 0; i < transform.childCount; i++)
        {
            if (GetItem(i).State == "ACTUAL")
            {
                GetItem(i).State = "OPEN";
            }
        }
        GetItem(itemID).State = "ACTUAL";

        // init location
        if (GetItem(itemID).KeyItem)
        {
            for (int i = 0; i < locationContent.transform.childCount; i++)
            {
                if (i == transform.GetChild(itemID).GetComponent <KeyItem>().locationID)
                {
                    Data.locations[i] = "UNLOCKED";
                }
            }
        }

        if (GetItem(itemID).KeyItem)
        {
            transform.GetChild(itemID).GetComponent <KeyItem>().OnLockItem();
        }
        for (int i = 0; i < transform.childCount; i++)
        {
            InitState(i);
        }

        am.PlayClickPicupcoin();
    }
 private void UpdateGUI()
 {
     GUI.score.text     = GameParams.GetScore().ToString();
     GUI.lastScore.text = GameParams.GetLastScore().ToString();
     GUI.topScore.text  = GameParams.GetTopScore().ToString();
     GUI.coins.text     = GameParams.GetCoins().ToString();
 }
Exemple #3
0
 private void InitState(int indexItem)
 {
     if ((GetItem(indexItem).State != "OPEN" && GameParams.GetCoins() < GetItem(indexItem).Price) && GetItem(indexItem).State != "ACTUAL")
     {
         GetItem(indexItem).State = "CLOSED";
         if (GetItem(indexItem).KeyItem)
         {
             GetItem(indexItem).State = "CAN_BUY";
             GetItem(indexItem).transform.GetChild(3).GetComponent <Button>().interactable = false;
         }
     }
     else if ((GetItem(indexItem).State != "OPEN" && !GetItem(indexItem).Locked&& GameParams.GetCoins() >= GetItem(indexItem).Price) && GetItem(indexItem).State != "ACTUAL")
     {
         GetItem(indexItem).State = "CAN_BUY";
         GetItem(indexItem).transform.GetChild(3).GetComponent <Button>().interactable = true;
     }
 }