示例#1
0
 private void Update()
 {
     //Con un nivel de yuyu mayor de 1--> no puedes saltar
     if (_yuyuController.GetYuyuLevel() > 1)
     {
         return;
     }
     if (Input.GetButtonDown("Jump") && (!isJumping))
     {
         Jump();
     }
 }
    void Update()
    {
        if (_yuyuController.GetYuyuLevel() < 3)
        {
            if (Input.GetKeyDown(KeyCode.Mouse0) && clinesAmmo > 0)
            {
                isFacingRight = GetComponent <ScrollController>().facingRight;
                CheckSpeed();

                GameObject bulletClone;
                myRotation = transform.rotation;

                //SE INSTANCIA LA BALA
                bulletClone = (GameObject)Instantiate(bullet, spawnPoint.transform.position, myRotation);
                bulletClone.GetComponent <Rigidbody2D>().velocity = new Vector2(localBulletSpeed, bulletClone.GetComponent <Rigidbody2D>().velocity.y);
                clinesAmmo--;

                StartCoroutine("playAudio", clinesSound);
            }

            if (Input.GetKeyDown(KeyCode.Mouse1) && flusAmmo > 0)
            {
                isFacingRight = GetComponent <ScrollController>().facingRight;
                CheckSpeed();

                GameObject flusBulletClone;
                myRotation = transform.rotation;

                //SE INSTANCIA LA BALA
                flusBulletClone = (GameObject)Instantiate(flusBullet, spawnPoint.transform.position, myRotation);
                flusBulletClone.GetComponent <Rigidbody2D>().velocity = new Vector2(localFlusSpeed, flusBulletClone.GetComponent <Rigidbody2D>().velocity.y);
                flusAmmo -= 10;

                StartCoroutine("playAudio", flusSound);
            }

            if (rb.velocity.x == 0f && rb.velocity.y == 0)
            {
                if (Input.GetKeyDown(KeyCode.R) && flusAmmo < maxFlusAmmo)
                {
                    StartCoroutine("playAudio", reloadSound);
                    flusAmmo += 10;
                }
            }
        }
        else
        {
            if (Input.GetKeyDown(KeyCode.R) && clinesAmmo > 0)
            {
                isFacingRight = GetComponent <ScrollController>().facingRight;
                CheckSpeed();

                GameObject bulletClone;
                myRotation = transform.rotation;

                //SE INSTANCIA LA BALA
                bulletClone = (GameObject)Instantiate(bullet, spawnPoint.transform.position, myRotation);
                bulletClone.GetComponent <Rigidbody2D>().velocity = new Vector2(localBulletSpeed, bulletClone.GetComponent <Rigidbody2D>().velocity.y);
                clinesAmmo--;

                StartCoroutine("playAudio", clinesSound);
            }

            if (Input.GetKeyDown(KeyCode.Mouse0) && flusAmmo > 0)
            {
                isFacingRight = GetComponent <ScrollController>().facingRight;
                CheckSpeed();

                GameObject flusBulletClone;
                myRotation = transform.rotation;

                //SE INSTANCIA LA BALA
                flusBulletClone = (GameObject)Instantiate(flusBullet, spawnPoint.transform.position, myRotation);
                flusBulletClone.GetComponent <Rigidbody2D>().velocity = new Vector2(localFlusSpeed, flusBulletClone.GetComponent <Rigidbody2D>().velocity.y);
                flusAmmo -= 10;

                StartCoroutine("playAudio", flusSound);
            }

            if (rb.velocity.x == 0f && rb.velocity.y == 0)
            {
                if (Input.GetKeyDown(KeyCode.Mouse1) && flusAmmo < maxFlusAmmo)
                {
                    StartCoroutine("playAudio", reloadSound);
                    flusAmmo += 10;
                }
            }
        }
    }