public void DoRespawn() { if (darknessCollider != null) { if (!darknessCollider.bounds.Contains(respawnPos)) { GameMenu_Handler UIHandler = GameObject.FindGameObjectWithTag("UIManager").GetComponent <GameMenu_Handler>(); UIHandler.FadeToBlack(true, 0.5f); shouldRespawn = true; //transform.position = respawnPos; } else if (!GameManager.Consuming) { GameManager gm = GameObject.FindGameObjectWithTag("GameManager").GetComponent <GameManager>(); gm.QuickDarknessConsume(); if (voiceLinePlayer != null) { voiceLinePlayer.PlayVoiceLine(2); } } } else { GameMenu_Handler UIHandler = GameObject.FindGameObjectWithTag("UIManager").GetComponent <GameMenu_Handler>(); UIHandler.FadeToBlack(true, 0.5f); shouldRespawn = true; // myPlayer.GetRigidBody().velocity = new Vector3(0, 0, 0); //transform.position = respawnPos; } }
// Update is called once per frame void Update() { if (iAmPlaying) { if (!myAudioSource.isPlaying) { isPlaying = false; iAmPlaying = false; if (endTutorial) { GameMenu_Handler.StartRealLevel(); } } } }
void OnTriggerEnter(Collider other) { if (!isPlaying || !shouldWait) { if (other.tag == "Player") { if (singleUse) { if (!used) { myAudioSource.Play(); if (shouldWait) { isPlaying = true; iAmPlaying = true; } if (endTutorial) { iAmPlaying = true; GameMenu_Handler UIHandler = GameObject.FindGameObjectWithTag("UIManager").GetComponent <GameMenu_Handler>(); UIHandler.FadeToBlack(true, 3); } used = true; } } else { myAudioSource.Play(); if (shouldWait) { isPlaying = true; iAmPlaying = true; } if (endTutorial) { iAmPlaying = true; GameMenu_Handler UIHandler = GameObject.FindGameObjectWithTag("UIManager").GetComponent <GameMenu_Handler>(); UIHandler.FadeToBlack(true, 3); } } } } }
// Update is called once per frame void Update() { if (!GameManager.GameOver && !GameMenu_Handler.isFading) { if (Input.GetKeyDown(KeyCode.R)) { DoRespawn(); } } if (shouldRespawn) { if (!GameMenu_Handler.isFading) { shouldRespawn = false; myPlayer.GetRigidBody().velocity = new Vector3(0, 0, 0); transform.position = respawnPos; GameMenu_Handler UIHandler = GameObject.FindGameObjectWithTag("UIManager").GetComponent <GameMenu_Handler>(); UIHandler.FadeToBlack(false, 0.5f); } } }