// Update is called once per frame void Update() { if (pictureHasStartedDisplaying) { if (!picturehasDisplayed) { currentPictureFadingTime -= Time.deltaTime; backgroundPictureSprite.color = new Color(1, 1, 1, 1 - currentPictureFadingTime / INITIALPICTUREFADINGINTIME); memoryPicture.color = new Color(1, 1, 1, 1 - currentPictureFadingTime / INITIALPICTUREFADINGINTIME); if (currentPictureFadingTime < 0) { GameObject.Find("PlayerAndCamera/UI/CompassBase").SetActive(false); picturehasDisplayed = true; } } else { if (Input.GetButtonDown("Pickup") && !pictureIsSkipped) { pictureIsSkipped = true; DayNightManager.SetDay(false); currentPictureFadingOutTime = INITIALPICTUREFADINGOUTTIME; } } if (pictureIsSkipped && !pictureHasFadedOut) { currentPictureFadingOutTime -= Time.deltaTime; backgroundPictureSprite.color = new Color(1, 1, 1, currentPictureFadingOutTime / INITIALPICTUREFADINGOUTTIME); memoryPicture.color = new Color(1, 1, 1, currentPictureFadingOutTime / INITIALPICTUREFADINGOUTTIME); if (currentPictureFadingOutTime < 0) { pictureHasFadedOut = true; player.GetComponent <Rigidbody2D>().constraints = RigidbodyConstraints2D.FreezeRotation; GetComponent <Storm>().StartStorm(); } } } }
// Update is called once per frame void Update() { if (hasWon) { Debug.Log(winTransition); winTransition -= Time.deltaTime; backgroundImage.color = new Color(1, 1, 1, 1 - winTransition / WINTRANSITIONTIME); if (winTransition < 0) { switch (SceneManager.GetActiveScene().name) { case "01_Level_TUTO": PlayerPrefs.SetFloat("Photo0", 1); SceneManager.LoadScene("MainMenu"); break; case "02_Level_Cliff": PlayerPrefs.SetFloat("Photo1", 1); SceneManager.LoadScene("MainMenu"); break; case "03_Level_Hole": PlayerPrefs.SetFloat("Photo2", 1); SceneManager.LoadScene("MainMenu"); break; case "04_Level_Final": PlayerPrefs.SetFloat("Photo3", 1); SceneManager.LoadScene("MainMenu"); break; default: SceneManager.LoadScene("MainMenu"); break; } } } // TODO : Remove if (Input.GetKeyDown("n")) { Debug.Log("Cheat code activated"); DayNightManager.SetDay(!DayNightManager.GetDay()); } if (Input.GetKeyDown("r")) { Debug.Log("Reloading level"); SceneManager.LoadScene(SceneManager.GetActiveScene().name); } GetComponentInChildren <InteractionCollider>().canInteract(DayNightManager.GetDay()); if (Input.GetButtonDown("Pickup") && !GetComponent <CharacterMovement>().IsJumping() && !storm.IsFalling()) { Queue <GameObject> items = new Queue <GameObject>(interactibles); if (items.Count > 0) { GameObject item = items.Dequeue(); if (item.CompareTag("Neon") && DayNightManager.GetDay()) { RemoveNeon(item); } if (item.CompareTag("Door") && DayNightManager.GetDay()) { item.GetComponentInParent <DoorManager>().Open(); interactibles.Remove(item); GameObject.Find("Frame").gameObject.SetActive(false); } if (item.CompareTag("Rift")) { Destroy(item); GameObject.FindGameObjectWithTag("Storm").GetComponent <PictureBehaviour>().StartAnimation(); } } } if (Input.GetButtonDown("PlaceObject") && !GetComponent <CharacterMovement>().IsJumping() && !storm.IsFalling() && DayNightManager.GetDay()) { if (currentNeonCount > 0) { PlaceNeon(); } } }