IEnumerator OnResumeFromCheckpoint() { if (player) { // Destroy the old player and instantiate the new. Destroy(player); player = Instantiate(playerPrefab, Vector3.zero, Quaternion.identity) as GameObject; gun = player.GetComponentInChildren <PlayerShooting> (); switch (PlayerPrefs.GetString(PlayerPrefsKeys.CHECKPOINT)) { case "FirstBattle": player.SetActive(true); gun.enabled = true; SetPlayerPosRot(new Vector3(21.5f, 0, -1), new Vector3(0, 180, 0)); break; default: player.SetActive(true); gun.enabled = true; SetPlayerPosRot(Vector3.zero, Vector3.zero); break; } // Need to wait 1 frame for gameobject tag search to work. yield return(null); NotificationCentre.PostNotification(this, "OnUpdatePlayer"); } }
IEnumerator OnPanOut() { NotificationCentre.PostNotification(this, "OnPanOut"); if (vfxcam) { //CustomUtilities.SetPosRot (vfxcam, new Vector3(5,1,5), new Vector3(0,-35,0)); yield return(StartCoroutine(CustomUtilities.MovLocRot(vfxcam, Vector3.zero, new Vector3(1, -45, 0), 0.5f))); StartCoroutine(CustomUtilities.MovLocRot(vfxcam, new Vector3(15, 0, -8), Vector3.zero, 2)); //CustomUtilities.SetPosRot (vfxcam, new Vector3(18,1,-3), new Vector3(0,-35,0)); } NotificationCentre.PostNotification(this, "OnBattleBGM"); yield return(new WaitForSeconds(3)); NotificationCentre.PostNotification(this, "OnFadeOut"); yield return(new WaitForSeconds(1.5f)); if (vfxcam) { vfxcam.SetActive(false); } NotificationCentre.PostNotification(this, "OnFadeIn"); NotificationCentre.PostNotification(this, "OnEventExit"); NotificationCentre.PostNotification(this, "OnBattleBegin"); MissionManager.UpdateMission("Survive the horde."); }
void Start() { PlayerPrefs.SetString(PlayerPrefsKeys.PREV_SCENE, "None"); // Deactivate intro event for debug. NotificationCentre.PostNotification(this, "ActivateCannon"); // Debug the cannon. NotificationCentre.PostNotification(this, "OnActivateFlammableBlock"); // Debug the block. NotificationCentre.PostNotification(this, "OnBlockDestructible"); // Debug the block. //PlayerPrefs.SetString (PlayerPrefsKeys.PREV_SCENE, "Title Scene"); // Simulate New Game. //PlayerPrefs.SetString (PlayerPrefsKeys.CHECKPOINT, "FirstBattle"); PlayerPrefs.SetString(PlayerPrefsKeys.CHECKPOINT, "PuzzleSolving"); // // Avoid notifying on Awake () because observers might register on Start (). // NotificationCentre.PostNotification(this, "PauseAllow"); MissionManager.UpdateMission("None"); switch (PlayerPrefs.GetString(PlayerPrefsKeys.PREV_SCENE)) { case "Title Scene": NotificationCentre.PostNotification(this, "OnEventEnter"); NotificationCentre.PostNotification(this, "OnBGMFadeIn"); NotificationCentre.PostNotification(this, "OnIntroEvent"); break; default: NotificationCentre.PostNotification(this, "OnFadeIn"); NotificationCentre.PostNotification(this, "OnBGMFadeIn"); break; } }
IEnumerator ResumeFromCheckpoint() { NotificationCentre.PostNotification(this, "PauseAllow"); switch (PlayerPrefs.GetString(PlayerPrefsKeys.CHECKPOINT)) { case "FirstBattle": NotificationCentre.PostNotification(this, "OnFadeIn"); NotificationCentre.PostNotification(this, "OnBattleBGM"); NotificationCentre.PostNotification(this, "OnEventExit"); NotificationCentre.PostNotification(this, "OnResumeFromCheckpoint"); break; case "PuzzleSolving": NotificationCentre.PostNotification(this, "OnFadeIn"); NotificationCentre.PostNotification(this, "OnBGMFadeIn"); NotificationCentre.PostNotification(this, "OnEventExit"); NotificationCentre.PostNotification(this, "OnResumeFromCheckpoint"); yield return(new WaitForSeconds(3)); NotificationCentre.PostNotification(this, "ActivateCannon"); break; default: NotificationCentre.PostNotification(this, "OnFadeIn"); NotificationCentre.PostNotification(this, "OnBGMFadeIn"); NotificationCentre.PostNotification(this, "OnEventExit"); NotificationCentre.PostNotification(this, "OnResumeFromCheckpoint"); break; } }
IEnumerator OnHoldingGunHigh() { StartCoroutine(RotateGun()); Vector3 locA = transform.position; Vector3 locB = locA + new Vector3(-0.5f, 1.5f, 0); float timer = 0; while (true) { transform.position = Vector3.Lerp(locA, locB, timer / 0.4f); if (timer >= 0.4f) { break; } timer += Time.deltaTime; yield return(null); } Hashtable table = new Hashtable(); table.Add("Text", "You found a gun!"); table.Add("TextAnchor", "UpperCenter"); table.Add("Sender", "PlayRoomGunCollider"); NotificationCentre.PostNotification(this, "DisplayText", table); NotificationCentre.PostNotification(this, "PressEnterToContinue", table); }
IEnumerator OnIntroEventExit() { if (pe && cam) { cam.SetCameraOffset(new Vector3(0, 5, -7)); cam.SetCameraTarget(pe); cam.SetCameraFollow(true); float timer = 0; Quaternion a = cam.transform.rotation; while (true) { cam.transform.rotation = Quaternion.Lerp(a, Quaternion.Euler(new Vector3(40, 0, 0)), timer / 2); if (timer > 2) { break; } timer += Time.deltaTime; yield return(null); } NotificationCentre.PostNotification(this, "DisplayHowToPlay"); MissionManager.UpdateMission("Search the room for something useful."); } }
IEnumerator OnEnemyRushOver() { // Wait until all enemies are dead. while (enemyNumber > 0) { yield return(null); } NotificationCentre.PostNotification(this, "OnBGMFadeOut"); yield return(new WaitForSeconds(1)); NotificationCentre.PostNotification(this, "OnMissionClear"); MissionManager.UpdateMission("None."); yield return(new WaitForSeconds(1)); NotificationCentre.PostNotification(this, "OnEventEnter"); NotificationCentre.PostNotification(this, "OnEnemyRushOver"); NotificationCentre.PostNotification(this, "OnFadeOut"); PlayerPrefs.SetString(PlayerPrefsKeys.CHECKPOINT, "PuzzleSolving"); yield return(new WaitForSeconds(1)); // Move ZombunnyEvent next to the cannon. if (zombunny) { CustomUtilities.SetPosRot(zombunny.gameObject, new Vector3(4.3f, 13.7f, 28), new Vector3(0, 180, 0)); zombunny.gameObject.SetActive(true); zombunny.followTarget = false; } }
public void StartShrinking() { GetComponent <NavMeshAgent> ().enabled = false; GetComponent <Rigidbody> ().isKinematic = true; isShrinking = true; NotificationCentre.PostNotification(this, "ReportEnemyDeath"); Destroy(gameObject, 2f); }
void Continue(Notification value) { if (value.data.ContainsKey("HowToPlay")) { // This code gives "list changed" error. //NotificationCentre.RemoveObserver (this, "Continue"); StartCoroutine(HideHowToPlay()); NotificationCentre.PostNotification(this, "OnEventExit"); } }
IEnumerator OnGunFound() { NotificationCentre.PostNotification(this, "OnEventEnter"); NotificationCentre.PostNotification(this, "OnFadeOut"); yield return(new WaitForSeconds(1)); NotificationCentre.PostNotification(this, "OnPickUpGun"); NotificationCentre.PostNotification(this, "OnFadeIn"); //yield return new WaitForSeconds(1); }
IEnumerator OnZombunnyAppear() { NotificationCentre.PostNotification(this, "OnZombunnyAppear"); yield return(new WaitForSeconds(0.3f)); if (zombunny) { zombunny.Pause(); } }
IEnumerator OnZoomInCannon() { if (cam) { cam.SetCameraFollow(false); CustomUtilities.SetPosRot(cam.gameObject, new Vector3(0, 1, -3), Vector3.zero); } NotificationCentre.PostNotification(this, "OnFadeIn"); NotificationCentre.PostNotification(this, "OnBGMFadeIn"); yield return(new WaitForSeconds(3)); // Final Pos (3,16,24) Rot (25,30,0) if (cam) { yield return(StartCoroutine(CustomUtilities.MovLocRot(cam.gameObject, new Vector3(3, 15, 27), new Vector3(25, 30, 0), 2))); } yield return(new WaitForSeconds(1)); NotificationCentre.PostNotification(this, "OnZombunnyLaugh"); yield return(new WaitForSeconds(0.5f)); NotificationCentre.PostNotification(this, "OnIgniteCannon"); yield return(new WaitForSeconds(0.5f)); if (cam) { // Final Pos (3,16,24) Rot (35,45,0) yield return(StartCoroutine(CustomUtilities.MovLocRot(cam.gameObject, Vector3.zero, new Vector3(10, 15, 0), 0.7f))); // Final Pos (4.2,16.8,22) Rot (35,5,0) yield return(StartCoroutine(CustomUtilities.MovLocRot(cam.gameObject, new Vector3(1.2f, 0.8f, -2), new Vector3(0, -40, 0), 0.8f))); } NotificationCentre.PostNotification(this, "OnFadeOut"); yield return(new WaitForSeconds(1)); OnCameraNormalize(); NotificationCentre.PostNotification(this, "OnEventExit"); NotificationCentre.PostNotification(this, "OnEnemyRushOverExit"); NotificationCentre.PostNotification(this, "OnNaturalSpawn"); NotificationCentre.PostNotification(this, "OnFadeIn"); MissionManager.UpdateMission("This room is a nightmare! Find the way out."); yield return(new WaitForSeconds(3)); NotificationCentre.PostNotification(this, "ActivateCannon"); }
void Update() { if (pressEnterToContinue && (Input.GetKeyDown(KeyCode.Return) || Input.GetKeyDown(KeyCode.Escape))) { PressEnterToContinue(false); NotificationCentre.PostNotification(this, "Continue", continueNotification.data); } else if (pauseAllowed && Input.GetKeyDown(KeyCode.Escape)) { Pause(); } }
void Fire() { // fire repeatedly. GameObject player = GameObject.FindWithTag("Player"); GameObject cannon = GameObject.FindWithTag("Cannon"); if (player && cannon) { BallisticProjectile cannonball = cannon.GetComponent <BallisticProjectile> (); cannonball.Fire(barrelEnd.position, player.transform.position, 2f); NotificationCentre.PostNotification(this, "OnCannonFire"); } }
IEnumerator ClickToShoot() { Hashtable table = new Hashtable { { "TextAnchor", "UpperCenter" }, { "Text", "Click to shoot enemies!!" } }; NotificationCentre.PostNotification(this, "DisplayText", table); yield return(new WaitForSeconds(3)); NotificationCentre.PostNotification(this, "HideText"); }
// Send "NewGame" Message to TitleController to call this. IEnumerator NewGame() { NotificationCentre.PostNotification(this, "OnNewGame"); yield return(new WaitForSeconds(7)); asrc.Stop(); yield return(new WaitForSeconds(2)); PlayerPrefs.SetString("Previous Scene", "Title Scene"); async.allowSceneActivation = true; }
void ResumeFromCheckpoint() { NotificationCentre.PostNotification(this, "PauseAllow"); switch (PlayerPrefs.GetString(PlayerPrefsKeys.CHECKPOINT)) { default: NotificationCentre.PostNotification(this, "OnFadeIn"); NotificationCentre.PostNotification(this, "OnBGMFadeIn"); NotificationCentre.PostNotification(this, "OnEventExit"); NotificationCentre.PostNotification(this, "OnResumeFromCheckpoint"); break; } }
void GameOver() { // // Hide all visual and sound effects. // playerSFX.PlayHeartBeat(false); VFX.ToggleHeartBeatFlash(false); cGroup.alpha = 0; gameover = true; NotificationCentre.PostNotification(this, "OnGameOver"); NotificationCentre.PostNotification(this, "OnPlayerDeath"); }
IEnumerator OnGameOver() { // Game Over is an event. NotificationCentre.PostNotification(this, "OnEventEnter"); // Wait for animations and effects to finish. yield return(new WaitForSeconds(2)); NotificationCentre.PostNotification(this, "OnFadeOut"); NotificationCentre.PostNotification(this, "OnBGMFadeOut"); yield return(new WaitForSeconds(2)); StartCoroutine(ResumeFromCheckpoint()); }
IEnumerator OnEnemyRushOver() { if (gun) { gun.EnableGun(false); } yield return(new WaitForSeconds(1)); if (player) { CustomUtilities.SetPosRot(player, Vector3.zero, new Vector3(0, 180, 0)); } NotificationCentre.PostNotification(this, "OnZoomInCannon"); }
IEnumerator DisplayHowToPlay() { if (coroutine != null) { StopCoroutine(coroutine); } coroutine = AlphaLerp(0, 1, 0.25f); yield return(StartCoroutine(coroutine)); Hashtable data = new Hashtable(); data.Add("HowToPlay", null); NotificationCentre.PostNotification(this, "PressEnterToContinue", data); }
IEnumerator OnEnemyAppear() { if (vfxcam) { splashEffect.SetActive(false);; vfxcam.SetActive(true); CustomUtilities.SetPosRot(vfxcam, new Vector3(22, 2, -2), new Vector3(20, -70, 0)); NotificationCentre.PostNotification(this, "OnSFXSwift"); yield return(new WaitForSeconds(0.5f)); yield return(StartCoroutine(CustomUtilities.MovLocRot(vfxcam, new Vector3(-18.5f, 0, 0), Vector3.zero, 0.7f))); } }
// Descend from sky. IEnumerator OnIntroEvent() { if (pe && cam) { cam.SetCameraFollow(false); SetCamPosRot(new Vector3(-8, 34, -4), new Vector3(40, 0, 0)); yield return(StartCoroutine(DescendFromSky())); SetCamPosRot(pe.transform.position + new Vector3(0, 3, -4), new Vector3(30, 0, 0)); yield return(new WaitForSeconds(1)); NotificationCentre.PostNotification(this, "OnIntroEventCameraDone"); } }
public void Pause() { paused = !paused; Time.timeScale = paused ? 0 : 1; if (paused) { NotificationCentre.PostNotification(this, "OnPauseEnter"); } else { NotificationCentre.PostNotification(this, "OnPauseExit"); } // Dim all sounds. Set AudioSource.ignoreListenerVolume to ignore this. DimAudio(); }
void OnResumeFromCheckpoint() { OnActivateFlammableBlock(); NotificationCentre.PostNotification(this, "OnBlockInitialize"); switch (PlayerPrefs.GetString(PlayerPrefsKeys.CHECKPOINT)) { case "PuzzleSolving": NotificationCentre.PostNotification(this, "OnBlockDestructible"); break; case "FirstBattle": NotificationCentre.PostNotification(this, "OnBlockIndestructible"); break; default: break; } }
void OnResumeFromCheckpoint() { NotificationCentre.PostNotification(this, "OnDestroyAllEnemies"); enemyNumber = 0; // unnecessary, but to be safe. switch (PlayerPrefs.GetString(PlayerPrefsKeys.CHECKPOINT)) { case "FirstBattle": OnBattleBegin(); break; case "PuzzleSolving": OnNaturalSpawn(); break; default: break; } }
// Send "Quit" Message to TC to quit application. IEnumerator Quit() { NotificationCentre.PostNotification(this, "OnQuit"); yield return(new WaitForSeconds(1)); // Fade out screen. NotificationCentre.PostNotification(this, "OnFadeOut"); // Lower BGM volume. StartCoroutine(FadeBGM()); yield return(new WaitForSeconds(1.1f)); #if UNITY_EDITOR EditorApplication.isPlaying = false; #else Application.Quit(); #endif }
IEnumerator OnPlayerActivate() { if (player) { player.SetActive(true); gun.EnableGun(false); SetPlayerPosRot(new Vector3(21.5f, 0, -1), new Vector3(0, 180, 0)); yield return(new WaitForSeconds(1)); ParticleController.Exclamation(player.transform.position, 2); yield return(new WaitForSeconds(0.5f)); yield return(StartCoroutine(CustomUtilities.MovLocRot(player, Vector3.zero, new Vector3(0, 90, 0), 0.5f))); yield return(new WaitForSeconds(0.3f)); NotificationCentre.PostNotification(this, "OnEnemyAppear"); } }
IEnumerator Start() { // Play BGM. asrc.PlayDelayed(1); // Load the Play Room scene asyncronously. NotificationCentre.PostNotification(this, "OnLoading"); async = Application.LoadLevelAsync("Play Room"); async.allowSceneActivation = false; // // Weird LoadLevelAsync behavior: progress will stop at 0.9 // until allowSceneActivation is set to true, which in turn // activates the new scene and loads the remaining 0.1. // while (async.progress < 0.89f) { yield return(null); } NotificationCentre.PostNotification(this, "OnFinishLoading"); }
IEnumerator OnIntroEventCameraDone() { Animator a = pe.GetComponent <Animator> (); if (a) { a.SetTrigger("Wake"); yield return(new WaitForSeconds(6)); Vector3 question = pe.transform.position; question.y += 1; ParticleController.Question(question, 1); yield return(new WaitForSeconds(1)); NotificationCentre.PostNotification(this, "OnIntroEventExit"); //a.SetTrigger ("Standby"); // Wake automatically transitions to Idle } }