void Awake() { NotificationCentre.AddObserver(this, "OnBGMFadeIn"); NotificationCentre.AddObserver(this, "OnBGMFadeOut"); NotificationCentre.AddObserver(this, "DisplayHowToPlay"); NotificationCentre.AddObserver(this, "OnHoldingGunHigh"); NotificationCentre.AddObserver(this, "OnBattleBGM"); NotificationCentre.AddObserver(this, "OnSFXSwift"); NotificationCentre.AddObserver(this, "OnSFXVFX1"); NotificationCentre.AddObserver(this, "OnSFXVFX2"); NotificationCentre.AddObserver(this, "OnMonsterCry"); NotificationCentre.AddObserver(this, "OnExclamation"); NotificationCentre.AddObserver(this, "OnQuestion"); NotificationCentre.AddObserver(this, "OnPauseEnter"); NotificationCentre.AddObserver(this, "OnPauseExit"); NotificationCentre.AddObserver(this, "OnCrosshairAppear"); NotificationCentre.AddObserver(this, "OnCannonFire"); NotificationCentre.AddObserver(this, "OnGooey1"); NotificationCentre.AddObserver(this, "OnGooey2"); NotificationCentre.AddObserver(this, "OnZombunnyLaugh"); NotificationCentre.AddObserver(this, "OnMissionClear"); NotificationCentre.AddObserver(this, "OnIgniteCannon"); NotificationCentre.AddObserver(this, "OnPlayerDeath"); src = GetComponent <AudioSource> (); one = gameObject.AddComponent <AudioSource> () as AudioSource; pause = gameObject.AddComponent <AudioSource> () as AudioSource; InitializeAudioSource(one); InitializeAudioSource(pause); pause.ignoreListenerVolume = true; }
void Awake() { /** * Won't throw error even if it doesn't exist. */ player = GameObject.FindWithTag("Player").transform; /** * Will throw error if they don't exist. */ nav = GetComponent <NavMeshAgent> (); animator = GetComponent <Animator> (); rigidBody = GetComponent <Rigidbody> (); hitBox = GetComponentInChildren <EnemyHitBox> (); myHealth = GetComponent <EnemyHealth> (); timer = 0f; attackEnd = false; isDead = false; isGameOver = false; audioSrc = gameObject.AddComponent <AudioSource> (); audioSrc.playOnAwake = false; audioSrc.loop = false; // Stay idle when player die. NotificationCentre.AddObserver(this, "OnPlayerDeath"); // Reassign player object when new one is created. NotificationCentre.AddObserver(this, "OnUpdatePlayer"); }
void Awake() { // Set max number of enemies allowed. SSGlobals.MAX_NUM_ENEMY = 30; spawnPoints = GetComponentsInChildren <EnemySpawn> (); NotificationCentre.AddObserver(this, "OnEnemyAppear"); NotificationCentre.AddObserver(this, "OnZombearAppear"); NotificationCentre.AddObserver(this, "OnPanOut"); NotificationCentre.AddObserver(this, "OnBattleBegin"); NotificationCentre.AddObserver(this, "ReportEnemyDeath"); NotificationCentre.AddObserver(this, "OnPlayerDeath"); NotificationCentre.AddObserver(this, "OnNaturalSpawn"); NotificationCentre.AddObserver(this, "OnResumeFromCheckpoint"); if (zombunny) { zombunny.gameObject.SetActive(false); } if (zombear) { zombear.gameObject.SetActive(false); } }
void Awake() { NotificationCentre.AddObserver(this, "OnEnemyAppear"); NotificationCentre.AddObserver(this, "OnZombunnyAppear"); if (vfxcam) { vfxcam.SetActive(false); } if (splashEffect) { splashEffect.SetActive(false); } if (splashEffect2) { splashEffect2.SetActive(false); } if (splashEffect3) { splashEffect3.SetActive(false); } if (textZombunny) { textZombunny.SetActive(false); } if (textZombear) { textZombear.SetActive(false); } }
void Awake() { NotificationCentre.AddObserver(this, "OnNewGame"); NotificationCentre.AddObserver(this, "OnQuit"); cg = GetComponent <CanvasGroup> (); }
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."); }
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."); } }
void Awake() { icon = GetComponent <Image> (); NotificationCentre.AddObserver(this, "OnLoading"); NotificationCentre.AddObserver(this, "OnFinishLoading"); }
void Awake() { NotificationCentre.AddObserver(this, "OnIntroEvent"); NotificationCentre.AddObserver(this, "OnIntroEventExit"); NotificationCentre.AddObserver(this, "OnPickUpGun"); NotificationCentre.AddObserver(this, "OnHoldingGunHigh"); NotificationCentre.AddObserver(this, "OnPlayerActivate"); NotificationCentre.AddObserver(this, "OnEnemyAppear"); NotificationCentre.AddObserver(this, "OnBattleBegin"); NotificationCentre.AddObserver(this, "OnZoomInCannon"); NotificationCentre.AddObserver(this, "OnCameraNormalize"); NotificationCentre.AddObserver(this, "OnUpdatePlayer"); player = GameObject.FindWithTag("Player"); pe = GameObject.FindWithTag("PlayerEvent"); cam = GameObject.FindWithTag("MainCamera").GetComponent <CameraMovement> (); if (cam) { cam.gameObject.SetActive(true); cam.SetCameraOffset(new Vector3(0, 5, -7)); cam.SetCameraTarget(player); cam.SetCameraFollow(true); SetCamPosRot(new Vector3(0, 6, -7), new Vector3(40, 0, 0)); } }
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"); } }
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 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; } }
void Awake() { Initialize(); NotificationCentre.AddObserver(this, "OnBlockInitialize"); NotificationCentre.AddObserver(this, "OnBlockDestructible"); NotificationCentre.AddObserver(this, "OnBlockIndestructible"); }
void Awake() { NotificationCentre.AddObserver(this, "ActivateCannon"); NotificationCentre.AddObserver(this, "DeactivateCannon"); NotificationCentre.AddObserver(this, "OnEventEnter"); NotificationCentre.AddObserver(this, "OnIgniteCannon"); OnPutOutCannon(); }
public void StartShrinking() { GetComponent <NavMeshAgent> ().enabled = false; GetComponent <Rigidbody> ().isKinematic = true; isShrinking = true; NotificationCentre.PostNotification(this, "ReportEnemyDeath"); Destroy(gameObject, 2f); }
void Awake() { // // Force developers to fix bugs. // ExceptionHandler.SetupExceptionHandling(); NotificationCentre.AddObserver(this, "OnGameOver"); }
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); }
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"); } }
void Awake() { floorMask = LayerMask.GetMask("Floor"); animator = GetComponent <Animator>(); rigidBody = GetComponent <Rigidbody>(); NotificationCentre.AddObserver(this, "OnEventEnter"); NotificationCentre.AddObserver(this, "OnEventExit"); NotificationCentre.AddObserver(this, "OnPlayerDeath"); }
void Awake() { img = GetComponent <Image> (); lastCoroutine = null; // Register on Awake so you won't miss any early notification. NotificationCentre.AddObserver(this, "OnNewGame"); NotificationCentre.AddObserver(this, "OnIntroEvent"); NotificationCentre.AddObserver(this, "OnFadeIn"); NotificationCentre.AddObserver(this, "OnFadeOut"); }
void Awake() { cg = GetComponent <CanvasGroup> (); cg.alpha = 0; coroutine = null; NotificationCentre.AddObserver(this, "DisplayHowToPlay"); NotificationCentre.AddObserver(this, "HideHowToPlay"); NotificationCentre.AddObserver(this, "Continue"); }
void Awake() { NotificationCentre.AddObserver(this, "PauseAllow"); NotificationCentre.AddObserver(this, "PauseDisallow"); NotificationCentre.AddObserver(this, "Pause"); NotificationCentre.AddObserver(this, "PressEnterToContinue"); pauseAllowed = false; paused = false; pressEnterToContinue = false; }
IEnumerator OnZombunnyAppear() { NotificationCentre.PostNotification(this, "OnZombunnyAppear"); yield return(new WaitForSeconds(0.3f)); if (zombunny) { zombunny.Pause(); } }
void Awake() { NotificationCentre.AddObserver(this, "OnIntroEvent"); NotificationCentre.AddObserver(this, "OnEnemyRushOver"); NotificationCentre.AddObserver(this, "OnActivateFlammableBlock"); NotificationCentre.AddObserver(this, "OnResumeFromCheckpoint"); if (flammableBlock) { flammableBlock.SetActive(false); } }
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 Awake() { c = GetComponent <SphereCollider> (); eventTriggered = false; NotificationCentre.AddObserver(this, "OnIntroEvent"); NotificationCentre.AddObserver(this, "OnHoldingGunHigh"); NotificationCentre.AddObserver(this, "Continue"); // Activate only in new game. SetActiveGun(false); }
void Awake() { //NotificationCentre.AddObserver (this, "OnEventEnter"); //NotificationCentre.AddObserver (this, "OnEventExit"); NotificationCentre.AddObserver(this, "OnIntroEvent"); NotificationCentre.AddObserver(this, "OnPlayerActivate"); NotificationCentre.AddObserver(this, "OnBattleBegin"); NotificationCentre.AddObserver(this, "OnEnemyRushOver"); NotificationCentre.AddObserver(this, "OnEnemyRushOverExit"); NotificationCentre.AddObserver(this, "OnResumeFromCheckpoint"); GetPlayer(); }
public void OnApplicationQuit() { instance = null; }