コード例 #1
0
    private IEnumerator OnTriggerEnter(Collider other)
    {
        if (other.gameObject.tag == monster_tag)
        {
            //  yield return new WaitForSeconds(5f);


            playerLife--;
            sound.playDamageSound(false);
            damage_feedback.SetActive(true);
            yield return(new WaitForSeconds(1f));

            damage_feedback.SetActive(false);
            // Debug.Log("Getting Damage");
            // Debug.Log(playerLife);
            if (playerLife < 0)
            {
                is_dead = true;
                gameOver.SetActive(true);
                damage_feedback.SetActive(true);
                leap_rig.useGravity = true;
                yield return(new WaitForSeconds(5f));

                gameOver.SetActive(false);
                damage_feedback.SetActive(false);
                is_dead             = false;
                leap_rig.useGravity = false;
                SceneManager.LoadScene("Menu");
            }
        }
        yield return(new WaitForSeconds(.2f));
    }
コード例 #2
0
    IEnumerator OnTriggerEnter(Collider col)
    {
        if (col.gameObject.tag == power_tag)
        {
            life--;
            if (life == 0)
            {
                GetComponent <Rigidbody>().velocity    = new Vector3(0, 0, 0);
                GetComponent <GolenMoviment>().enabled = false;
                sound.playDieSound(false);
                anim.SetTrigger("Die");
                yield return(new WaitForSeconds(10f));

                Destroy(gameObject);
            }

            bool is_atack = golen_atack.is_atack;
            if (is_atack)
            {
                sound.playDamageSound(false);
                anim.SetTrigger("Damage");
                yield return(new WaitForSeconds(1f));

                anim.SetTrigger("Atack");
                sound.playAtackSound(false);
            }
            else
            {
                GetComponent <Rigidbody>().velocity = new Vector3(0, 0, 0);
                sound.playDamageSound(false);
                anim.SetTrigger("Damage");
                GetComponent <GolenMoviment>().enabled = false;
                yield return(new WaitForSeconds(1f));

                anim.SetTrigger("Walk");
                GetComponent <GolenMoviment>().enabled = true;
                sound.playWalkSound(true);
            }
        }
        else
        {
            if (col.gameObject.tag == "firestorm")
            {
                if (is_alive)
                {
                    life--;

                    // Debug.Log(life);
                    if (life == 0)
                    {
                        GetComponent <Rigidbody>().velocity    = new Vector3(0, 0, 0);
                        GetComponent <GolenMoviment>().enabled = false;
                        golen_atack.is_atack = false;
                        //yield return new WaitForSeconds(.5f);
                        GetComponent <Rigidbody>().AddForce(new Vector3(0, 0, 250));
                        yield return(new WaitForSeconds(.5f));

                        GetComponent <Rigidbody>().velocity = new Vector3(0, 0, 0);
                        sound.playDieSound(false);
                        anim.SetTrigger("Die");
                        GetComponent <SphereCollider>().enabled = false;
                        yield return(new WaitForSeconds(10f));

                        Destroy(gameObject);
                    }


                    else
                    {
                        if (life > 0)
                        {
                            GetComponent <GolenMoviment>().enabled = false;
                            golen_atack.is_atack = false;
                            sound.playDamageSound(false);
                            anim.SetTrigger("Damage");
                            GetComponent <Rigidbody>().AddForce(new Vector3(0, 0, 250));
                            yield return(new WaitForSeconds(1f));

                            anim.SetTrigger("Walk");
                            GetComponent <Rigidbody>().velocity    = (new Vector3(0, 0, 0));
                            GetComponent <GolenMoviment>().enabled = true;
                        }
                    }
                }
            }
        }
    }