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();
        }
    }
Esempio n. 2
0
    void Start()
    {
        //get the state script
        playerStateScript = GetComponent <player_state> ();

        //get the
        GameObject beaverSprite = transform.GetChild(1).gameObject;

        beaverMouth = transform.GetChild(1).gameObject;

        beaverPearlCollider = beaverSprite.transform.GetChild(0).gameObject;

        // get Player name form patent object
        Player_name = gameObject.transform.name;


        //gettign the scripts that will be disabled
        movingScript    = GetComponent <moving> ();
        dashScript      = GetComponent <dash> ();
        throwingScript  = GetComponent <throwing> ();
        colDetectScript = GetComponent <collision_detection> ();

        //get the scripts to animate the indicator

//		if (Player_name == "Beaver1") {
//			iconIndicator = GameObject.FindGameObjectWithTag ("iconP1").GetComponent<Animator>();
//
//		} else if (Player_name == "Beaver2") {
//			iconIndicator = GameObject.FindGameObjectWithTag ("iconP2").GetComponent<Animator>();
//		}

        //getting the particle system
        Bubbles = beaverMouth.GetComponentInChildren <ParticleSystem> ();

        //setting the emmision to 0
        Bubbles.emissionRate = 0;

        //initially not suffocating
        //isSuffocating = false;
        playerStateScript.SetIsSuffocating(false);

        // gettign the ridgit body of the Player
        rBody = GetComponent <Rigidbody2D> ();


        // getting the animator.
        animator = transform.GetChild(1).gameObject.GetComponent <Animator> ();

        soundPlayer = GameObject.FindGameObjectWithTag("Sound_Player").GetComponent <sound_player>();
    }
    void Start()
    {
        //get the state script
        playerStateScript = GetComponent<player_state> ();

        //get the
        GameObject beaverSprite = transform.GetChild (1).gameObject;
        beaverMouth = transform.GetChild (1).gameObject;

        beaverPearlCollider = beaverSprite.transform.GetChild (0).gameObject;

        // get Player name form patent object
        Player_name = gameObject.transform.name;

        //gettign the scripts that will be disabled
        movingScript = GetComponent<moving> ();
        dashScript = GetComponent<dash> ();
        throwingScript = GetComponent<throwing> ();
        colDetectScript = GetComponent<collision_detection> ();

        //get the scripts to animate the indicator

        //		if (Player_name == "Beaver1") {
        //			iconIndicator = GameObject.FindGameObjectWithTag ("iconP1").GetComponent<Animator>();
        //
        //		} else if (Player_name == "Beaver2") {
        //			iconIndicator = GameObject.FindGameObjectWithTag ("iconP2").GetComponent<Animator>();
        //		}

        //getting the particle system
        Bubbles = beaverMouth.GetComponentInChildren<ParticleSystem> ();

        //setting the emmision to 0
        Bubbles.emissionRate = 0;

        //initially not suffocating
        //isSuffocating = false;
        playerStateScript.SetIsSuffocating (false);

        // gettign the ridgit body of the Player
        rBody = GetComponent<Rigidbody2D> ();

        // getting the animator.
        animator = transform.GetChild (1).gameObject.GetComponent<Animator> ();

        soundPlayer = GameObject.FindGameObjectWithTag ("Sound_Player").GetComponent<sound_player>();
    }