Beispiel #1
0
 public void Pause()
 {
     //Set time.timescale to 0, this will cause animations and physics to stop updating
     Time.timeScale = 0;
     // disable jump on touch
     PlayerContainer.GetComponent <JumpLeftRight>().enabled = false;
     //Show pause menu
     ShowPauseMenu();
     soundControls.StopClimbingSound();
 }
Beispiel #2
0
 void Die()
 {
     soundControls.StopClimbingSound();
     isAlive = false;
     SpecialEffectsHelper.Instance.Explosion(transform.position);
     score.SaveScore();
     gameplayControls.ShowGameover();
     gameplayControls.HidePlayer();
     Destroy(GameObject.FindGameObjectWithTag("RunEffect").gameObject);
 }
Beispiel #3
0
    // Update is called once per frame
    void Update()
    {
        float currentPositionX = transform.position.x;

        // jump to the left
        if ((Input.GetKeyDown("space") || TouchedScreen()) && !movingLeft && !movingRight && currentPositionX > leftLimitX)
        {
            soundControls.PlayJump();

            //RunEffectRight.SetActive(false);
            Destroy(GameObject.FindGameObjectWithTag("RunEffect").gameObject);

            // start to move left
            gameObject.GetComponent <Rigidbody2D>().velocity = new Vector2((-1f) * moveForce, 0);
            movingLeft = true;

            // change to jumping left sprite
            SpyAnimator.SetTrigger("Jumping");
            SpyAnimator.ResetTrigger("Climbing");
            transform.eulerAngles = new Vector3(0, 0, 0);

            // stop cracks on left side
            cracksRightGenerator.StopCracks();
        }

        // Climb left
        if (transform.position.x <= leftLimitX && movingLeft == true)
        {
            //RunEffectLeft.SetActive(true);
            StartRunEffectLeft();

            // ajusta posicao do Player
            gameObject.GetComponent <Rigidbody2D>().velocity = Vector2.zero;
            gameObject.transform.position = new Vector2(leftLimitX, gameObject.transform.position.y);

            // sinaliza final de pulo
            movingLeft = false;

            // change to climbing left sprite
            SpyAnimator.SetTrigger("Climbing");
            SpyAnimator.ResetTrigger("Jumping");

            // inicia som de subida
            soundControls.PlayClimbingSound();

            // starts cracks on the left side
            cracksLeftGenerator.StartCracks();
        }

        // jump to right
        if ((Input.GetKeyDown("space") || TouchedScreen()) && !movingRight && !movingLeft && currentPositionX < rightLimitX)
        {
            //RunEffectLeft.SetActive(false);
            Destroy(GameObject.FindGameObjectWithTag("RunEffect").gameObject);

            soundControls.PlayJump();

            // change to jumping left sprite
            SpyAnimator.SetTrigger("Jumping");
            SpyAnimator.ResetTrigger("Climbing");
            transform.eulerAngles = new Vector3(0, 180, 0);

            // para som de subida
            soundControls.StopClimbingSound();

            gameObject.GetComponent <Rigidbody2D>().velocity = new Vector2(moveForce, 0);
            movingRight = true;

            soundControls.StopClimbingSound();

            cracksLeftGenerator.StopCracks();
        }

        // Climb right
        if (transform.position.x >= rightLimitX && movingRight == true)
        {
            //RunEffectRight.SetActive(true);
            Instantiate(RunEffectRight);

            // change to climbing right sprite
            SpyAnimator.SetTrigger("Climbing");
            SpyAnimator.ResetTrigger("Jumping");

            gameObject.GetComponent <Rigidbody2D>().velocity = Vector2.zero;
            gameObject.transform.position = new Vector2(rightLimitX, gameObject.transform.position.y);
            movingRight = false;

            // invert x position of RunEffectContainer animation
            RunEffectLeft.transform.position = new Vector2(8.62f, RunEffectLeft.transform.position.y);

            // inicia som de subida
            soundControls.PlayClimbingSound();

            cracksRightGenerator.StartCracks();
        }
    }