Esempio n. 1
0
    void Update()
    {
        //Check if the Bsave is at surface. Thsi is a temporary solution the OnTriggerEnter method is a little bit more elegant
        // but will only work right when the mouth peace flips with the beaver sprite whoch it hopefully will.
        if (playerStateScript.GetIsSuffocating() && transform.position.y > 2.4f)
        {
            rBody.gravityScale = constants.waterGravity;
        }
        // beaver is suffocating and out of water
        if (playerStateScript.GetCanBreathe() && playerStateScript.GetIsSuffocating())
        {
            //set gravity back
            rBody.gravityScale = constants.airGravity;

            //isSuffocating = false;
            playerStateScript.SetIsSuffocating(false);
            //print("isSuffocating set false");

            // reset the beaver to be in the normal layer where they can interact with obstacles
            transform.FindChild("Beaver").gameObject.layer = LayerMask.NameToLayer("Non_Interactable");
            beaverMouth.transform.FindChild("beaver_mouth").gameObject.layer = LayerMask.NameToLayer("Non_Interactable");

            //animator.SetBool ("at_surface", true); // sets animator so that it transitions form foating to idle
            animator.SetTrigger("surface");

            // sets the icon animator to normal
//			iconIndicator.SetTrigger ("out_of_water");
//			iconIndicator.SetBool("isDead", false);

            //movingScript.enabled = true; // enable movement again (same for dashing and throwing)
            movingScript.SetMoveForce(constants.moveForceNormal);
            dashScript.enabled      = true;
            throwingScript.enabled  = true;
            colDetectScript.enabled = true;

            beaverPearlCollider.GetComponent <Collider2D> ().enabled = true;
        }
        // beaver is fine and under water
        else if (!playerStateScript.GetIsSuffocating() && !playerStateScript.GetCanBreathe())
        {
            animator.SetBool("at_surface", false);
            check_breathing();
        }
    }