public void DespawnMoney(GameObject obj, bool isChest) { if (isChest) { managerPool.Despawn(PoolType.Entities, obj); if (score.isEnlargeSpeedMoney()) { speed += (speed * enlargeSpeed) / 100f; } } else { managerPool.Despawn(PoolType.Entities, obj); } }
private IEnumerator MoveCoin(Transform coinTransform, Transform moveTo) { while (Vector2.Distance(coinTransform.position, moveTo.position) > 0.04f) { coinTransform.position = Vector3.Slerp(coinTransform.position, moveTo.position, _flySpeed); yield return(null); } _audioSource.PlayOneShot(_coinSound); _animator.Play(_zoom.name); _pool.Despawn(PoolType.Entities, coinTransform.gameObject); }
private void ClearArena() { if (enemyInWave.Count > 0) { for (int enemy = 0; enemy < enemyInWave.Count; enemy++) { managerPool.Despawn(enemyInWave[enemy].PoolType, enemyInWave[enemy].gameObject); } enemyInWave.Clear(); } var Bullets = GameObject.FindGameObjectsWithTag("Bullet"); if (Bullets != null) { for (int i = 0; i < Bullets.Length; i++) { managerPool.Despawn(PoolType.Bullet, Bullets[i]); } } }
IEnumerator SecondSpawn() { yield return(new WaitForSeconds(3f)); for (int i = 0; i < countWaters; i++) { managerPool.Despawn(PoolType.Entities, objs[i]); } for (int i = 0; i < countWaters; i++) { objs.Add(managerPool.Spawn(PoolType.Entities, water, crane.transform.position)); float rand = Random.Range(150, 250) / 1000f; objs[objs.Count - 1].transform.localScale = new Vector3(rand, rand, rand); objs[objs.Count - 1].GetComponent <Rigidbody2D>().velocity = new Vector2(Random.Range(-1, 2), Random.Range(-1, 2)); objs[objs.Count - 1].transform.position = new Vector3(objs[objs.Count - 1].transform.position.x, objs[objs.Count - 1].transform.position.y, -10f); yield return(new WaitForSeconds(0.2f)); } }
void Update() { if (Input.GetKeyDown(KeyCode.A)) { for (var i = 0; i < 1; i++) { objs.Add(managerPool.Spawn(PoolType.Entities, prefab)); } } if (Input.GetKeyDown(KeyCode.W)) { for (var i = 0; i < objs.Count; i++) { managerPool.Despawn(PoolType.Entities, objs[i]); } objs.Clear(); } }