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(); }