public void Resume() { HidePauseMenu(); Time.timeScale = 1; PlayerContainer.GetComponent <JumpLeftRight>().enabled = true; soundControls.PlayClimbingSound(); }
//private Vector3 temp; // Use this for initialization void Start() { soundControls = GameObject.FindGameObjectWithTag("SoundsController").GetComponent <SoundControls>(); Spy = GameObject.FindGameObjectWithTag("Player"); SpyAnimator = Spy.GetComponent <Animator> (); cracksLeftGenerator = LeftCrackSet.GetComponent <GenerateCracks>(); cracksRightGenerator = RightCrackSet.GetComponent <GenerateCracks>(); soundControls.PlayClimbingSound(); cracksLeftGenerator.StartCracks(); //RunEffectLeft.SetActive(true); //RunEffectRight.SetActive(false); StartRunEffectLeft(); }
//private Vector3 temp; // Use this for initialization void Start() { soundControls = GameObject.FindGameObjectWithTag("SoundsController").GetComponent<SoundControls>(); Spy = GameObject.FindGameObjectWithTag("Player"); SpyAnimator = Spy.GetComponent <Animator> (); cracksLeftGenerator = LeftCrackSet.GetComponent<GenerateCracks>(); cracksRightGenerator = RightCrackSet.GetComponent<GenerateCracks>(); soundControls.PlayClimbingSound(); cracksLeftGenerator.StartCracks(); //RunEffectLeft.SetActive(true); //RunEffectRight.SetActive(false); StartRunEffectLeft(); }
// 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(); } }