Beispiel #1
0
    void Update()
    {
        if (Input.GetKeyDown(KeyCode.Space) && isGrounded && !isShooting || Input.GetKeyDown(KeyCode.W) && isGrounded && !isShooting)
        {
            rb.velocity = new Vector2(rb.velocity.x, jump);
        }

        playerVelXatual = rb.velocity.x;
        playerVelYatual = rb.velocity.y;

        direction = Input.GetAxisRaw("Horizontal");

        isGrounded = Physics2D.OverlapCircle(localPes.position, 0.5f, layerChao);

        if (playerHealth <= 0f)
        {
            var morteAtual = Instantiate(playerDeathAnim);
            morteAtual.transform.position = this.transform.position;
            this.gameObject.SetActive(false);
        }

        if (playerbalas > 6f)
        {
            playerbalas = 6f;
            scriptPontuacao.UpdateUI();
        }
        if (playerHealth > 7f)
        {
            playerHealth = 7f;
            scriptPontuacao.UpdateUI();
        }
    }
    void OnTriggerEnter2D(Collider2D target)
    {
        if (target.gameObject.tag == "EnemyBullet")
        {
            scriptPlayer.playerHealth--;
            Destroy(target.gameObject);
            scriptPontuacao.UpdateUI();
            animPlayer.SetInteger("animPlayer", 4);
            scriptPlayer.isHooked   = false;
            scriptPlayer.isShooting = false;
            scriptGerenciaSons.playTheSoundPlayer(0);
        }

        if (target.gameObject.tag == "EnemyBackside")
        {
            scriptEnemyBehavior = target.gameObject.GetComponentInParent <scrEnemyBehavior>();
            if (scriptEnemyBehavior.enemyState != 4)
            {
                canBackstab = true;
            }
            stealthInstance = Instantiate(stealthIndicator, new Vector3(this.transform.position.x, this.transform.position.y + 5f, this.transform.position.z), transform.rotation);
        }

        if (target.gameObject.tag == "pegaveis")
        {
            Destroy(target.gameObject);
            scriptPontuacao.pontos += 200f;
            scriptPontuacao.UpdateUI();
            Debug.Log("Pontos: " + scriptPontuacao.pontos);
            scriptGerenciaSons.playTheSoundMisc(7);
        }

        if (target.gameObject.tag == "HealthUp")
        {
            Destroy(target.gameObject);
            scriptPlayer.playerHealth++;
            scriptPontuacao.UpdateUI();
            Debug.Log("Health: " + scriptPlayer.playerHealth);
            scriptGerenciaSons.playTheSoundMisc(6);
        }

        if (target.gameObject.tag == "AmmoUp")
        {
            Destroy(target.gameObject);
            scriptPlayer.playerbalas += 6;
            scriptPontuacao.UpdateUI();
            Debug.Log("Ammo: " + scriptPlayer.playerbalas);
            scriptGerenciaSons.playTheSoundMisc(8);
        }
    }