EnemyBase.DestroyThis C# (CSharp) Method

DestroyThis() public method

Called when this objects time has come to an end. Spawns a death int with the money the user get, returns enemy to pool, and cleans up references.
public DestroyThis ( ) : IEnumerator
return IEnumerator
    public virtual IEnumerator DestroyThis()
    {
        // Call callback
        if (this.Killed != null)
        {
            this.Killed();
        }

        TextMesh deathInt = this.objectManager.Map.enemyDeathInt.GetObjectFromPool<TextMesh>(this.objectManager.Map.enemyDeathInt.name, new Vector3(this.transform.position.x, 40, this.transform.position.z), Quaternion.Euler(new Vector3(90, 0, 0)));
        deathInt.gameObject.name = this.objectManager.Map.enemyDeathInt.name;

        if (this.onNode.enemie == this)
        {
            this.onNode.enemie = null;
        }

        this.objectManager.DeReference(this);

        if (this.onNode == this.objectManager.WaveManager.destinationNode)
        {
            this.objectManager.gameState.PlayerHealth -= this.damageValue;
            deathInt.text = "-" + this.damageValue;
        }
        else if (!this.objectManager.gameState.gameOver)
        {
            this.objectManager.gameState.playerMoney += this.moneyValue;
            this.objectManager.gameState.score += this.moneyValue;
            deathInt.text = "+" + this.moneyValue;
        }

        animator.SetTrigger("Dead");
        yield return new WaitForSeconds(1.5f);

        // remove debuffs
        foreach (var debuff in debuffs)
        {
            debuff.EndEffect();
        }
        debuffs.Clear();

        this.gameObject.ReturnToPool(this.gameObject.name);
    }