コード例 #1
0
    void Die()
    {
        Debug.Log("enemy die!");
        InjuredSmoke.Stop();
        Explode.SetActive(true);
        Explode.transform.parent = null;
        AliveObj.SetActive(false);
        DeadObj.SetActive(true);
        EnemyCollider.enabled = false;
        Destroy(Explode, 1f);
        HealthBarObj.SetActive(false);
        if (TurretShootingScript)
        {
            TurretShootingScript.DisableShooting();
        }

        //--if the go we're replacing this with has an rb, pass the vector
        if (DeadObj.GetComponent <Rigidbody2D>())
        {
            Vector2 vel = rb.velocity;
            // Debug.Log("killed enemy has rb. Give it a velocity of "+vel);
            DeadObj.GetComponent <Rigidbody2D>().velocity = vel;
        }

        //--EnemyDamageController
        if (EnemyRagdoll)
        {
            Debug.Log("kill chicken on " + transform.name);
            EnemyRagdoll.Die();
        }
    }
コード例 #2
0
    public void Die()
    {
        Debug.Log("chicken die!");
        Explode.SetActive(true);
        Explode.transform.parent = null;
        health           = 0;
        Collider.enabled = false;
        ShootingScript.DisableShooting();
        Debug.Log("shootingscript = " + ShootingScript.isActive);
        Bounds.SetActive(false);

        if (health == 0)
        {
            //--check if this isn't being killed by ramming
            SwitchToRigidbodyScript.SwitchAndPush(new Vector2(1, 0.2f));
        }

        if (ShootingScript)
        {
            ShootingScript.DisableShooting();
        }
    }