Пример #1
0
    public void Die()
    {
        isAlive = false;
        head.GetComponent <Animator>().enabled = false;
        head.isKinematic = false;
        head.useGravity  = true;
        head.GetComponent <SphereCollider>().enabled = true;
        head.gameObject.transform.parent             = null;

        Vector3 position = head.transform.position;

        position[1]             = 13;
        head.transform.position = position;

        head.velocity = new Vector3(0, 26.0f, 3.0f);

        if (deathParticles)
        {
            deathParticles.transform.parent = null;
            position    = deathParticles.transform.position;
            position[1] = 13;
            deathParticles.transform.position = position;
            deathParticles.Activate();
        }

        OnDestroy.Invoke();
        OnDestroy.RemoveAllListeners();
        head.GetComponent <SelfDestruct>().Initiate();
        Destroy(gameObject);
    }
Пример #2
0
    public void Die()
    {
        // Remove the alien's head and give it a nice velocity boost.
        isAlive = false;
        head.GetComponent <Animator>().enabled = false;
        head.isKinematic = false;
        head.useGravity  = true;
        head.GetComponent <SphereCollider>().enabled = true;
        head.gameObject.transform.parent             = null;
        head.velocity = new Vector3(0, 26.0f, 3.0f);

        OnDestroy.Invoke();
        OnDestroy.RemoveAllListeners();
        SoundManager.Instance.PlayOneShot(SoundManager.Instance.alienDeath);

        head.GetComponent <SelfDestruct>().Initiate();

        if (deathParticles)
        {
            deathParticles.transform.parent = null;
            deathParticles.Activate();
        }

        Destroy(gameObject);
    }
Пример #3
0
    public void Die()
    {
        //kills alien and makes it fall apart
        isAlive = false;
        head.GetComponent <Animator>().enabled = false;
        head.isKinematic = false;
        head.useGravity  = true;
        head.GetComponent <SphereCollider>().enabled = true;
        head.gameObject.transform.parent             = null;
        head.velocity = new Vector3(0, 26.0f, 3.0f);

        //removes listeners and destroys object
        OnDestroy.Invoke();
        OnDestroy.RemoveAllListeners();
        SoundManager.Instance.PlayOneShot(SoundManager.Instance.alienDeath);
        head.GetComponent <SelfDestruct>().Initiate();

        if (deathParticles)
        {
            //makes blood splatter when alien dies
            deathParticles.transform.parent = null;
            deathParticles.Activate();
        }
        Destroy(gameObject);
    }
Пример #4
0
    //
    public void Die()
    {
        //You set IsMoving to false since the marine is dead
        bodyAnimator.SetBool("IsMoving", false);
        //We set the parent to null to remove the current GameObject from its parent.
        marineBody.transform.parent = null;
        //by enabling Use Gravity and disabling IsKinematic, the body will drop and roll, and we enable a collider to make this all work.
        marineBody.isKinematic = false;
        marineBody.useGravity  = true;
        marineBody.gameObject.GetComponent <CapsuleCollider>().enabled = true;
        // Disabling the gun prevents the player from firing after death.
        marineBody.gameObject.GetComponent <Gun>().enabled = false;

        //First, this destroys the joint to release the head from the body.
        //Then, like the body, we remove the parent and enable gravity.
        //Finally, we destroy the current GameObject while playing the death sound.
        Destroy(head.gameObject.GetComponent <HingeJoint>());
        head.transform.parent = null;
        head.useGravity       = true;
        SoundManager.Instance.PlayOneShot(SoundManager.Instance.marineDeath);

        deathParticles.Activate();



        Destroy(gameObject);
    }
Пример #5
0
    public void Die()
    {
        OnDisable.Invoke();
        OnDisable.RemoveAllListeners();

        if (deathParticles)
        {
            deathParticles.transform.parent = null;
            deathParticles.Activate();
        }

        gameObject.SetActive(false);
    }
 public void Die()
 {
     bodyAnimator.SetBool("IsMoving", false); marineBody.transform.parent = null;
     marineBody.isKinematic = false;
     marineBody.useGravity  = true;
     marineBody.gameObject.GetComponent <CapsuleCollider>().enabled = true;
     marineBody.gameObject.GetComponent <Gun>().enabled             = false;
     Destroy(head.gameObject.GetComponent <HingeJoint>());
     head.transform.parent = null;
     head.useGravity       = true;
     SoundManager.Instance.PlayOneShot(SoundManager.Instance.marineDeath);
     deathParticles.Activate();
     Destroy(gameObject);
 }
Пример #7
0
 public void Die()
 {
     bodyAnimator.SetBool("IsMoving", false);
     marineBody.transform.parent = null;
     marineBody.isKinematic      = false;                                    // player cant move the corpse
     marineBody.useGravity       = true;                                     // falls to the ground
     marineBody.gameObject.GetComponent <CapsuleCollider>().enabled = true;
     marineBody.gameObject.GetComponent <Gun>().enabled             = false; // prevents the player from firing after death.
     Destroy(head.gameObject.GetComponent <HingeJoint>());                   // destroys the joint to release the head from the body
     head.transform.parent = null;                                           // Now that head can roll!
     head.useGravity       = true;                                           //
     SoundManager.Instance.PlayOneShot(SoundManager.Instance.marineDeath);
     deathParticles.Activate();
     Destroy(gameObject);
 }
 public void Die()
 {
     bodyAnimator.SetBool("IsMoving", false); // set to false because space marine is dead to prevent a zombie from running around
     marineBody.transform.parent = null;      // removes current game object from the parent
     marineBody.isKinematic      = false;     // enables a collider to allow the marine's body to drop and roll
     marineBody.useGravity       = true;
     marineBody.gameObject.GetComponent <CapsuleCollider>().enabled = true;
     marineBody.gameObject.GetComponent <Gun>().enabled             = false; // disables the gun to prevent firing after death
     Destroy(head.gameObject.GetComponent <HingeJoint>());                   // destroys the joints to remove head from the body
     head.transform.parent = null;                                           //removes the gameobject from parent
     head.useGravity       = true;
     SoundManager.Instance.PlayOneShot(SoundManager.Instance.marineDeath);   // destroys current object while playing death sound
     deathParticles.Activate();
     Destroy(gameObject);
 }
Пример #9
0
    public void Die()
    {
        //make body fall to the floor
        bodyAnimator.SetBool("IsMoving", false);
        marineBody.transform.parent = null;
        marineBody.isKinematic      = false;
        marineBody.useGravity       = true;
        marineBody.gameObject.GetComponent <CapsuleCollider>().enabled = true;
        marineBody.gameObject.GetComponent <Gun>().CancelInvoke("fireBullet");
        marineBody.gameObject.GetComponent <Gun>().enabled = false;

        //make head fall to the floor and make blood splatter
        Destroy(head.gameObject.GetComponent <HingeJoint>());
        head.transform.parent = null;
        head.useGravity       = true;
        SoundManager.Instance.PlayOneShot(SoundManager.Instance.marineDeath);
        deathParticles.Activate();
        Destroy(gameObject);
    }
Пример #10
0
 public void Die()
 {
     isAlive = false;// all of this code does is launch the alien's head off the body then destroys the animator for the alien
     head.GetComponent <Animator>().enabled = false;
     head.isKinematic = false;
     head.useGravity  = true;
     head.GetComponent <SphereCollider>().enabled = true;
     head.gameObject.transform.parent             = null;
     head.velocity = new Vector3(0, 26.0f, 3.0f);
     OnDestroy.Invoke();
     OnDestroy.RemoveAllListeners();// this code notifies the listeners removes them then deletes game object
     SoundManager.Instance.PlayOneShot(SoundManager.Instance.alienDeath);
     head.GetComponent <SelfDestruct>().Initiate();
     if (deathParticles)
     {
         deathParticles.transform.parent = null;// makes blood splatter when aliens die
         deathParticles.Activate();
     }
     Destroy(gameObject);
 }
Пример #11
0
 //method to handle alien death
 public void die()
 {
     isAlive = false;
     head.GetComponent <Animator>().enabled = false;
     head.isKinematic = false;
     head.useGravity  = true;
     head.GetComponent <SphereCollider>().enabled = true;
     if (deathParticles)
     {
         //get the death particles and activate
         deathParticles.transform.parent = null;//disconnect the particle
         deathParticles.Activate();
     }
     //launch the head
     head.gameObject.transform.parent = null;
     head.velocity = new Vector3(0, 26, 3);
     head.GetComponent <SelfDestruct>().Initiate();
     onAlienDeath.Invoke();             //signal an alien has dies
     onAlienDeath.RemoveAllListeners(); //get rid of listeners
     Destroy(gameObject);
 }
    public void Die()
    {
        // Removes the marines body from its head, sets its physics settings properly and stops the marine from moving.
        bodyAnimator.SetBool("IsMoving", false);
        marineBody.transform.parent = null;
        marineBody.isKinematic      = false;
        marineBody.useGravity       = true;
        marineBody.gameObject.GetComponent <CapsuleCollider>().enabled = true;
        marineBody.gameObject.GetComponent <Gun>().enabled             = false;

        // Destroys the hinge connecting the head to the body and removes the parent from the head component.
        Destroy(head.gameObject.GetComponent <HingeJoint>());
        head.transform.parent = null;
        head.useGravity       = true;
        SoundManager.Instance.PlayOneShot(SoundManager.Instance.marineDeath);

        // Activate death particles
        deathParticles.Activate();

        Destroy(gameObject);
    }
 public void Die()
 {
     // You don’t want a zombie
     bodyAnimator.SetBool("IsMoving", false);
     // Remove the current GameObject from its parent
     marineBody.transform.parent = null;
     // The body will drop and roll
     marineBody.isKinematic = false;
     marineBody.useGravity  = true;
     // Use a collider to make it work
     marineBody.gameObject.GetComponent <CapsuleCollider>().enabled = true;
     // Prevent firing after death
     marineBody.gameObject.GetComponent <Gun>().enabled = false;
     // Behead the marine
     Destroy(head.gameObject.GetComponent <HingeJoint>());
     head.transform.parent = null;
     head.useGravity       = true;
     SoundManager.Instance.PlayOneShot(SoundManager.Instance.marineDeath);
     deathParticles.Activate();
     isDead = true;
 }
Пример #14
0
 //method to call on marine death
 public void die()
 {
     isDead = true;
     playerAnimator.SetBool("IsMoving", false);
     //disconect the body
     marineBody.transform.parent = null;
     marineBody.isKinematic      = false;//ragdoll
     marineBody.useGravity       = true;
     //enable the collider
     marineBody.gameObject.GetComponent <CapsuleCollider>().enabled = true;
     marineBody.gameObject.GetComponent <Gun>().enabled             = false;//no more shooting
     //remove head
     Destroy(head.gameObject.GetComponent <HingeJoint>());
     head.transform.parent = null;
     head.useGravity       = true;
     SoundManager.Instance.PlayOneShot(SoundManager.Instance.marineDeath);
     //spill blood
     marineParticles.Activate();
     Destroy(gameObject);
     //popup the game over panel
     gameUI.ShowGameOverPanel();
 }
Пример #15
0
    public void Die()
    {
        if (deathParticles)
        {
            deathParticles.transform.parent = null;
            deathParticles.Activate();
        }

        isAlive = false;
        head.GetComponent <Animator>().enabled = false;
        head.isKinematic = false;
        head.useGravity  = true;
        head.GetComponent <SphereCollider>().enabled = true;
        head.gameObject.transform.parent             = null;
        head.velocity = new Vector3(0, 26.0f, 3.0f);    //lanuches head off

        OnDestroy.Invoke();                             //generate the event, gameManager is listening for it and it notifies other listeners of the event
        OnDestroy.RemoveAllListeners();                 //prevent reference cycle memory leak
        SoundManager.Instance.PlayOneShot(SoundManager.Instance.alienDeath);
        head.GetComponent <SelfDestruct>().Inititate(); //gets the script/ component attached to the alien head and intiaites the public method which then
        // within the SelfDestrcut script invokes the private self destructing method that gets rids of the head after 3 seconds.
        Destroy(gameObject);
    }
Пример #16
0
    public void Die()
    {
        // stops player from moving once dead
        bodyAnimator.SetBool("IsMoving", false);
        // removes GameObject from its parent
        marineBody.transform.parent = null;
        // enabling body to drop and roll
        marineBody.isKinematic = false;
        marineBody.useGravity  = true;
        // enable the collider to allow it to drop and roll
        marineBody.gameObject.GetComponent <CapsuleCollider>().enabled = true;
        // prevents the player from firing when dead
        marineBody.gameObject.GetComponent <Gun>().enabled = false;

        // destroys the hinge joint from the head to the body
        Destroy(head.gameObject.GetComponent <HingeJoint>());
        // remove the parent and enable gravity
        head.transform.parent = null;
        head.useGravity       = true;
        // plays the death sound and destroys the game object
        SoundManager.Instance.PlayOneShot(SoundManager.Instance.marineDeath);
        deathParticles.Activate();
        Destroy(gameObject);
    }