public void DmgDrop() { float dirVel = 30; for (int i = 0; i < 4; i++) { GiftCount--; if (GiftCount < 0) { DoGiftCheck(); return; } float y = this.transform.position.y; int r = GetRandom(_previus, GiftPrefabs.Length); _previus = r; GameObject go = Instantiate(GiftPrefabs[r], _dropPoint.transform.position, Quaternion.identity, DroppObjectHolder); DropObject_script drop = go.GetComponent <DropObject_script>(); Rigidbody2D rb = go.GetComponent <Rigidbody2D>(); drop.Config(GameManger, y); Vector3 dir = new Vector3(Random.Range(-dirVel, dirVel), Random.Range(dirVel / 2, dirVel), 0); rb.velocity = dir; if (GiftCount < 0) { GiftCount = 0; } DoGiftCheck(); } }
void DoDrop() { _activeGift.Config(GameManger, this.transform.position.y); GiftCount--; DoGiftCheck(); _activeGift.transform.SetParent(DroppObjectHolder); _activeGift = null; StartCoroutine("CreateGift"); }
IEnumerator CreateGift() { yield return(new WaitForSeconds(SpawnTimer)); if (GiftCount > 0) { int r = GetRandom(_previus, GiftPrefabs.Length); _previus = r; GameObject go = Instantiate(GiftPrefabs[r], _dropPoint.transform.position, Quaternion.identity, _dropPoint); _activeGift = go.GetComponent <DropObject_script>(); _drops.Add(go); } }