IEnumerator Spawn() { int count = Mathf.Clamp((int)(coinAmount / 10), 1, 30); spawnCount = count; dividedAmount = System.Math.Floor(coinAmount / spawnCount); for (int i = 0; i < spawnCount; i++) { TaxObjectGold objectGold = CreatTaxObjectGold(); objectGold.gameObject.SetActive(true); } int enableCount = objectGoldPool.Count; while (enableCount > 0) { enableCount = 0; for (int i = 0; i < objectGoldPool.Count; i++) { if (objectGoldPool[i].gameObject.activeSelf) { enableCount++; } } yield return(null); } User.Tax(coinAmount); //MoneyManager.GetMoney(MoneyType.gold).value += coinAmount; //실제 서버 통신하는 부분 //Todo: 일단 막아둠.. //MoneyManager.SendMoneyToServer("gold", coinAmount.ToString()); Destroy(slot); money = null; spawnCoroutine = null; }
TaxObjectGold CreatTaxObjectGold() { TaxObjectGold taxObject = null; for (int i = 0; i < objectGoldPool.Count; i++) { if (objectGoldPool[i].gameObject.activeSelf == false) { taxObject = objectGoldPool[i]; break; } } if (taxObject == null) { GameObject go = Instantiate(taxObjectPrefab); go.transform.SetParent(taxObjectGoldParent, false); taxObject = go.GetComponent <TaxObjectGold>(); objectGoldPool.Add(taxObject); } return(taxObject); }