IEnumerator UnlockRandomCoKnife() { unlockingRandom = true; List <TestShopKnifeItem> lockedItems = shopItems.FindAll((obj) => { return(!obj.KnifeUnlock); }); TestShopKnifeItem randomSelect = null; for (int i = 0; i < lockedItems.Count * 2; i++) { randomSelect = lockedItems[Random.Range(0, lockedItems.Count)]; if (!randomSelect.selected) { randomSelect.selected = true; #if UNITY_ANDROID && !UNITY_EDITOR SoundManager.instance.RandomUnlockSFX(); #else SoundManager.instance.PlaySingle(RandomUnlockSfx); #endif } yield return(new WaitForSeconds(.2f)); } GameManager.Apple -= UnlockRandomPrice; randomSelect.KnifeUnlock = true; randomSelect.UpdateUIColor(); GameManager.SelectedKnifeIndex = randomSelect.index; UpdateUI(); unlockingRandom = false; #if UNITY_ANDROID && !UNITY_EDITOR SoundManager.instance.OnUnlockSFX(); #else SoundManager.instance.PlaySingle(onUnlocksfx); #endif }
void SetupShop() { unlockBtnApple.GetComponentInChildren <Text>().text = UnlockPrice + ""; unlockBtnWatchAds.GetComponentInChildren <Text>().text = UnlockAdsAmount + ""; //unlockRandomBtn.GetComponentInChildren<Text>().text = UnlockRandomPrice + ""; shopItems = new List <TestShopKnifeItem>(); //edited list name //for (int i = 0; i < shopKnifeAppleList.Count; i++) for (int i = 0; i < 10; i++) { //edited name TestShopKnifeItem temp = Instantiate <TestShopKnifeItem>(shopKnifePrefab, shopPageAppleContent); temp.setup(i, this); temp.name = i + ""; temp.itemType = "apple"; shopItems.Add(temp); } //for (int i = 0; i < shopKnifeWatchList.Count; i++) for (int i = 10; i < 20; i++) { //edited name TestShopKnifeItem temp = Instantiate <TestShopKnifeItem>(shopKnifePrefab, shopPageWatchContent); temp.setup(i, this); temp.name = i + ""; temp.itemType = "ads"; //temp.adsAmount = UnlockAdsAmount; temp.adsLeft = UnlockAdsAmount; shopItems.Add(temp); } //for (int i = 0; i < shopKnifeBuyList.Count; i++) /*for (int i = 20; i < 25; i++) * { * //edited name * TestShopKnifeItem temp = Instantiate<TestShopKnifeItem>(shopKnifePrefab, shopPageBuyContent); * temp.setupBuy(i, this); * temp.name = i + ""; * shopItems.Add(temp); * } */ shopItems[GameManager.SelectedKnifeIndex].OnClick(); }