private void ShootBullet() { GameObject bullet = bulletPool.Rent(false); BulletController bulletComponent = bullet.GetComponent <BulletController>(); bulletComponent.SetBulletType(); if (GameObject.Find("BulletPool")) { if (GameObject.Find("FreezeBullet") && bulletComponent.bulletType == Scriptable.BulletTypes.Freeze) { bullet.transform.parent = GameObject.Find("BulletPool/FreezeBullet").transform; } if (GameObject.Find("FreezeBullet") && bulletComponent.bulletType == Scriptable.BulletTypes.AreaDamage) { bullet.transform.parent = GameObject.Find("BulletPool/NormalBullet").transform; } } bullet.transform.position = Vector3.zero; bullet.transform.position = bulletSpawnPoint.transform.position; bullet.SetActive(true); Tools.EmitOnDisable emitOnDisable = bullet.GetComponent <Tools.EmitOnDisable>(); emitOnDisable.OnDisableGameObject += BulletDisable; bulletComponent.ResetBullet(MapCreation.MapCreator.BlockSize, activeTargets[0].transform.position); }
private void Expand(uint amount) { for (int i = 0; i < amount; i++) { GameObject instance = Object.Instantiate(m_Prefab, m_Parent); EmitOnDisable emitOnDisable = instance.AddComponent <EmitOnDisable>(); emitOnDisable.OnDisableGameObject += UnRent; m_Objects.Push(instance); } }
private GameObject CreateNew() { GameObject instance = Object.Instantiate(m_Prefab, m_Parent); EmitOnDisable emitOnDisable = instance.AddComponent <EmitOnDisable>(); emitOnDisable.OnDisableGameObject += UnRent; //Listener, subscribe the event m_Created.Add(instance); return(instance); }
private void Expand(uint amount) { for (int i = 0; i < amount; i++) { GameObject tempObj = Object.Instantiate(poolPrefab, poolParent); EmitOnDisable emitOnDisable = tempObj.AddComponent <EmitOnDisable>(); emitOnDisable.OnDisableGameObject += UnRent; objStack.Push(tempObj); } }