void UpdateTimer() { timeText.text = ConvertSecsToString(timeInSec); if (countDown) { timeInSec--; } else { timeInSec++; } if (countDown && timeInSec == 9) { watch.color = Color.red; timeText.color = Color.red; ChangeToColor(red); } if (countDown && timeInSec < 0) { timerActive = false; GPlayclass.UnlockAchievement("CgkI-Meyi84DEAIQCA"); StartCoroutine(DeathScript.Reset(false)); } if (timeInSec > 3599) { StartCoroutine(DeathScript.Reset(false)); } if (timeInSec == 180) { GPlayclass.UpdateEvent("CgkI-Meyi84DEAIQCQ", 1); } else if (timeInSec == 360) { GPlayclass.UpdateEvent("CgkI-Meyi84DEAIQCQ", 2); } }
/// <summary> /// El Update se encarga del movimiento del personaje y de comprobar si ha llegado a la meta /// </summary> void Update() { if (Input.GetKeyDown(KeyCode.E)) { GameEnded(); } if (isMovActive && infoNotActive) { timeMoving = 0; PosUpdate(); AnimationPlay(false); if (Input.GetKeyDown(KeyCode.D)) { playerDir = Direction.rightMov; setMov(false); } else if (Input.GetKeyDown(KeyCode.W)) { playerDir = Direction.upMov; setMov(false); } else if (Input.GetKeyDown(KeyCode.S)) { playerDir = Direction.downMov; setMov(false); } else if (Input.GetKeyDown(KeyCode.A)) { playerDir = Direction.leftMov; setMov(false); } } else { AnimationPlay(true); GetObstacle(); count += Time.deltaTime; timeMoving += Time.deltaTime; if (count > timeToGo) { if (playerDir == Direction.rightMov) { //rb.velocity = new Vector2(speed, 0); tr.position = new Vector3(tr.position.x + space, tr.position.y); } else if (playerDir == Direction.upMov) { //rb.velocity = new Vector2(0, speed); tr.position = new Vector3(tr.position.x, tr.position.y + space); } else if (playerDir == Direction.downMov) { //rb.velocity = new Vector2(0, -speed); tr.position = new Vector3(tr.position.x, tr.position.y - space); } else if (playerDir == Direction.leftMov) { //rb.velocity = new Vector2(-speed, 0); tr.position = new Vector3(tr.position.x - space, tr.position.y); GPlayclass.UpdateEvent("CgkI-Meyi84DEAIQCg", 1); } count = 0; } } }