// Update is called once per frame void Update() { if (Input.GetKey("w")) { stateMachine.Victory(); } if (displayScore == false && stateMachine.getGameState() == CentralStateScript.GameState.Victory) { LevelCleared(); displayScore = true; } }
// Update is called once per frame void Update() { if (Input.GetKey("g")) { GameOver(); } if (Input.GetKey("r")) { Restart(); } if (!isGameOver) { if (stateMachine.getGameState() == CentralStateScript.GameState.GameOver) { GameOver(); isGameOver = true; } } }
// Update is called once per frame void Update() { if (stateMachine.getGameState() != CentralStateScript.GameState.Victory) { timeLeft -= Time.deltaTime; if (timeLeft <= 0) { timeLeft = 0; stateMachine.GameOver(); } if (timeLeft < 10) { time.text = "00" + ((int)timeLeft).ToString(); } else { time.text = "0" + ((int)timeLeft).ToString(); } } }
void DetectInput() { //Detect Input if (stateMachine.getGameState() != CentralStateScript.GameState.Victory) { if (Input.GetKey("up") || (Input.touchCount > 0 && Input.GetTouch(0).phase == TouchPhase.Stationary)) { tapTime += Time.deltaTime; } else if (Input.GetKeyUp("up") || (Input.touchCount > 0 && Input.GetTouch(0).phase == TouchPhase.Ended)) { Debug.Log(tapTime); if (tapTime <= 0.15) { if (touchButton) { touchButton = false; } if (UFOEnableTouch) { //Take flight CurrentPlanet.enabled = false; rg2d.velocity = BurstDirecton * 200; rg2d.angularVelocity = 30.0f; if (bouncingSound != null) { bouncingSound.Play(); } if (stateMachine) { stateMachine.enterFlight(); } else { Debug.Log("State Machine does not exist"); Application.Quit(); } UFOEnableTouch = false; } } tapTime = 0; } } if (tapTime > 0.05 && UFOEnableTouch) { if (rg2d.velocity.magnitude > 1.5) { rg2d.velocity = rg2d.velocity.normalized * 1.5f; } if (rg2d.velocity.magnitude < 1.2) { rg2d.velocity = rg2d.velocity.normalized * 1.2f; } } else { if (rg2d.velocity.magnitude > 4) { rg2d.velocity = rg2d.velocity.normalized * 4; } if (rg2d.velocity.magnitude < 3) { rg2d.velocity = rg2d.velocity.normalized * 3; } } }