public void Death() { GameMaster.CountKill(); transform.localScale = Vector3.one; ObjectsPool.Spawn(GameMaster.enemyFX, GameMaster.idPool_enemyDeathFX, transform.position, transform.rotation).GetComponent <AudioSource>().Play(); ObjectsPool.Despawn(GameMaster.idPool_enemies, gameObject); }
/// <summary> /// Destroys the projectile immediatly. /// </summary> protected virtual void DestroyProjectile() { // Stop all active coroutines. StopAllCoroutines(); // Object pool despawn ObjectsPool.Despawn(this.gameObject); }
void OnCollisionEnter2D(Collision2D coll) { //If the weight hits the player, despawn it and remove one life if (coll.gameObject.tag == "Player") { ObjectsPool.Despawn(this.gameObject); GameController.Damage(1); } }
IEnumerator Play() { if (fx != null) { fx.Play(); } yield return(new WaitForSeconds(timeLife)); ObjectsPool.Despawn(idPool, gameObject); yield return(null); }
/// <summary> /// Destroys the projectile immediatly. /// </summary> protected virtual void DestroyProjectile() { // Stop all active coroutines. StopAllCoroutines(); // Set back the original size, so there are no scaling problems after respawning this.transform.localScale = originalSize; // Object pool despawn ObjectsPool.Despawn(this.gameObject); }
private void OnTriggerEnter2D(Collider2D other) { //Kill and deactivate the player if (other.tag == "Player") { GameController.Damage(5); other.gameObject.SetActive(false); } //Despawn the weight if (other.tag == "Weight") { ObjectsPool.Despawn(other.gameObject); } }
void OnTriggerEnter2D(Collider2D col) { //If the col has the tag 'Line' despawn and put it back in the pool if (col.tag == "Line") { ObjectsPool.Despawn(col.gameObject); } //If the col has the tag 'Platform', destroy it if (col.tag == "Platform") { Destroy(col.gameObject); } //If the col has the tag 'Player', remove all lives if (col.tag == "Player") { GameController.Damage(5); } }
void Deactivate() { BoxCollider box = GetComponent <BoxCollider>(); if (box != null) { Destroy(box); } SkinnedMeshRenderer renderer = GetComponent <SkinnedMeshRenderer>(); if (renderer != null) { Destroy(renderer); attachedRenderer = gameObject.AddComponent <MeshRenderer>(); attachedFilter = gameObject.AddComponent <MeshFilter>(); } MeshFilter filter = GetComponent <MeshFilter>(); if (filter == null) { attachedFilter = gameObject.AddComponent <MeshFilter>(); } if (attachedRigid != null) { attachedRigid.angularDrag = 0.0f; attachedRigid.drag = 0.0f; attachedRigid.useGravity = true; } if (gameObject != null) { ObjectsPool.Despawn(gameObject); } }
void Update() { //Enable if this weight is spawned after the spawner reaches a position past x if (thisTransform.position.x > 49) { this.gameObject.SetActive(true); } else { this.gameObject.SetActive(false); } //Get all the objects in a radius tagged Line Collider2D[] colliders = Physics2D.OverlapCircleAll(thisTransform.position, 0.7f); //Dispawn the lines hit foreach (Collider2D col in colliders) { if (col.tag == "Line") { ObjectsPool.Despawn(col.gameObject); } } }
private IEnumerator Destroy() { yield return(new WaitForSeconds(time)); ObjectsPool.Despawn(gameObject); }
public static void Despawn(this GameObject objToDespawn) { ObjectsPool.Despawn(objToDespawn); }
void DisableObj() { ObjectsPool.Despawn(GameMaster.idPool_bullet, gameObject); }