void Update() { if (!alreadyPaused && Input.GetKeyDown(KeyCode.Escape)) { alreadyPaused = true; GameObject.Find("GameFlow").GetComponent <ControlGameFlow>().PauseGame(); SceneManager.LoadScene("InPlayExit", LoadSceneMode.Additive); } if (textController == null) { textController = GameObject.Find("HelperText").GetComponent <HelperTextController>(); } if (gameObject.GetComponent <Rigidbody2D>().velocity.normalized != Vector2.zero) { lastPlayerDirection = gameObject.GetComponent <Rigidbody2D>().velocity.normalized; } if (gotCross && Input.GetKeyDown(KeyCode.Space) && canShoot) { Fire(); gunCooldown = Time.time + 0.3f; canShoot = false; } if (!canShoot && Time.time > gunCooldown) { canShoot = true; } if (nearCross && Input.GetKeyDown(KeyCode.E)) { gotCross = true; textController.CrossImage(); textController.CrossText(false); HighScore.score += 10; highScore = HighScore.score; } if (nearHearths && Input.GetKeyDown(KeyCode.E)) { gotHearts = true; currentHealth = maxHealth; textController.HeartsText(false); HighScore.score += 10; highScore = HighScore.score; } if (nearNextPortal && Input.GetKeyDown(KeyCode.E)) { if (gotCross && gotHearts && GameObject.FindGameObjectsWithTag("Enemy").Length == 0) { GameObject.Find("SceneChanger").GetComponent <LevelChanger>().next = true; gameObject.transform.position = new Vector2(-40, -130); nearNextPortal = false; } } if (nearPreviousPortal && Input.GetKeyDown(KeyCode.E)) { GameObject.Find("SceneChanger").GetComponent <LevelChanger>().previous = true; gameObject.transform.position = new Vector2(-40, -130); nearPreviousPortal = false; } if (currentHealth <= 0) { currentHealth = 0; Die(); } if (BuffManager.playerHealthDebuff) { BuffManager.playerHealthDebuff = false; BuffManager.debuffCounter += 1; AudioSource.PlayClipAtPoint(exorcistDamagedAudio, transform.position); currentHealth -= 1; } if (BuffManager.healthBuff) { BuffManager.healthBuff = false; BuffManager.buffCounter += 1; currentHealth += 1; } if (BuffManager.fireRateBuff) { BuffManager.fireRateBuff = false; BuffManager.buffCounter += 1; projectileVelocity = 20; } }
private void Start() { currentHealth = maxHealth; textController = GameObject.Find("HelperText").GetComponent <HelperTextController>(); }