Beispiel #1
0
    public void Die()
    {
        isAlive = false;
        GameObject.FindGameObjectWithTag("PlayerHandler").GetComponent <Builder>().ReportDeadUnit(thisTransform, resourceWorth);

        if (aiBase.GetComponent <AgentBase>() != null)
        {
            aiBase.GetComponent <AgentBase>().agent.enabled = false;
        }
        if (deathParticleSystemSpawned != null)
        {
            deathParticleSystemSpawned.transform.position = middlePoint;
            deathParticleSystemSpawned.GetComponent <ParticleTimed>().StartParticleSystem();
        }
        if (deathAnimation != null)
        {
            animationObj.GetComponent <Animation>().Play(deathAnimation.name);
        }

        if (destroyOnDeath == true)
        {
            if (thisTransform.GetComponent <AIBase>() != null)
            {
                thisTransform.GetComponent <AIBase>().Dealloc();
            }
            Destroy(thisTransform.gameObject, delayedDeathTime);
        }
        else
        {
            StartCoroutine(DieDelayed());
        }
    }