//===================================================== void OnFadeOutCompleteEvent() { m_ScreenIndex++; switch (m_ScreenIndex) { case 1: m_Screen1.SetActive(false); m_Screen2.SetActive(true); m_Screen3.SetActive(false); m_bFadingOut = false; m_Timer = 0.0f; ScreenManager.FadeIn(); m_bFadeInComplete = false; break; case 2: m_Screen1.SetActive(false); m_Screen2.SetActive(false); m_Screen3.SetActive(true); m_bFadingOut = false; m_Timer = 0.0f; ScreenManager.FadeIn(); m_bFadeInComplete = false; break; case 3: ScreenManager.FadeInCompleteEvent -= OnFadeInCompleteEvent; ScreenManager.FadeOutCompleteEvent -= OnFadeOutCompleteEvent; // If not registered then load the registration scene if (ServerManager.Registered == false) { Application.LoadLevel("RefectoryRoom"); } else { // Load the tutorial or main hall scene if (PlayerPrefsWrapper.HasKey("IsTutorialCompleted") && PlayerPrefsWrapper.GetInt("IsTutorialCompleted") != 0) { Application.LoadLevel("MainHall"); } else { Application.LoadLevel("Tutorial"); } } break; } }
//===================================================== void OnFadeOutCompleteEvent() { ScreenManager.FadeInCompleteEvent -= OnFadeInCompleteEvent; ScreenManager.FadeOutCompleteEvent -= OnFadeOutCompleteEvent; // Load the tutorial or main hall scene if (PlayerPrefsWrapper.HasKey("IsTutorialCompleted") && PlayerPrefsWrapper.GetInt("IsTutorialCompleted") != 0) { Application.LoadLevel("MainHall"); } else { Application.LoadLevel("Tutorial"); } }
//===================================================== public void OnBossDeadEvent() { _isPlayerDead = false; if (BossManager.Instance == null || BossManager.Instance.CutsceneBossLoses == null) { return; } _isLeavingBossRoom = true; SetNextLocation(eLocation.MAIN_HALL); // Play cutscene if (BossLosesEvent != null) { BossLosesEvent(BossManager.Instance.CutsceneBossLoses); } // Apply wild magic bonus if (PlayerPrefsWrapper.HasKey("FirstBossKill") == false || PlayerPrefsWrapper.GetInt("FirstBossKill") != 1) { PlayerPrefsWrapper.SetInt("FirstBossKill", 1); GameDataManager.Instance.AddWildMagicAndPopulation( WildMagicItemsManager.GetWildMagicItem("WM_RATE_BOSS_FIGHT_WIN_FIRST")); } else { GameDataManager.Instance.AddWildMagicAndPopulation( WildMagicItemsManager.GetWildMagicItem("WM_RATE_BOSS_FIGHT_WIN_DEFAULT")); } // Increment boss level if (GameDataManager.Instance.PlayerBossLevel < GameDataManager.Instance.PlayerMaxFairyLevel) { GameDataManager.Instance.PlayerBossLevel += 1; } // If boss is at level 3 then start timer intervals between boss appearances // Note: time-interval-start checked by boss door on entering MainHall scene if (GameDataManager.Instance.PlayerBossLevel >= GameDataManager.Instance.PlayerMaxFairyLevel) { PlayerPrefsWrapper.SetDouble("BossRoomTimedIntervalStarted", PreHelpers.UnixUtcNow()); } }
//===================================================== #region State Controllers private void EnterState(eBossState bossStateEntered) { switch (bossStateEntered) { case eBossState.INIT: // Delay then IDLE StartCoroutine(Initialising()); break; case eBossState.IDLE: // ToDo: DEBUG - REMOVE THIS //_debugStateRenderer.material.color = Color.cyan; // Assign jobs and update jobs list _currentJobs.Add(new Job(Idling())); // Note: Exiting from state ( -> TELEPORT ) is managed in Update() break; case eBossState.TELEPORT: // ToDo: DEBUG - REMOVE THIS //_debugStateRenderer.material.color = Color.black; // Assign jobs var teleporting = new Job(Teleporting(() => { Debug.Log("Teleported into scene!"); CurrentState = eBossState.SUMMON_GEMS; }), true); // Update jobs list _currentJobs.Add(teleporting); break; case eBossState.SUMMON_GEMS: // ToDo: DEBUG - REMOVE THIS //_debugStateRenderer.material.color = Color.magenta; // Assign jobs var summonGems = new Job(SummoningGems(() => { Debug.Log("Summoned Gems!"); CurrentState = eBossState.SUMMON_ENEMIES; }), true); // Update jobs list _currentJobs.Add(summonGems); break; case eBossState.SUMMON_ENEMIES: // ToDo: DEBUG - REMOVE THIS //_debugStateRenderer.material.color = Color.magenta; // Assign jobs var summonEnemies = new Job(SummoningEnemies(() => { Debug.Log("Summoned Enemies!"); CurrentState = eBossState.ATTACK; }), true); // Update jobs list _currentJobs.Add(summonEnemies); break; case eBossState.ATTACK: // ToDo: DEBUG - REMOVE THIS //_debugStateRenderer.material.color = Color.red; // Assign jobs var attacking = new Job(Attacking(() => { Debug.Log("Attacked complete!"); CurrentState = eBossState.IDLE; _timer = _attackInterval; Debug.Log("_attackInterval: timer: " + _timer); }), true); // Update jobs list _currentJobs.Add(attacking); break; case eBossState.DISABLED: // ToDo: DEBUG - REMOVE THIS //_debugStateRenderer.material.color = Color.white; // Exiting from state (-> RECOVER ) is managed in Update() if (_previousState != eBossState.DISABLED_DAMAGED) { _timer = _disabledInterval; Debug.Log("***_disabledInterval: timer: " + _timer); // Show health bar _healthBar.SetHealthBar(_health / _maxHealth); _healthBar.ShowBubble(); } break; case eBossState.DISABLED_DAMAGED: // ToDo: DEBUG - REMOVE THIS //_debugStateRenderer.material.color = Color.red; Debug.Log("DISABLED_DAMAGED"); // Damaged -> DISABLED StartCoroutine(Interval(0, 0.5f, () => { if (_timer > 0.0f) { CurrentState = eBossState.DISABLED; } })); break; case eBossState.RECOVER: // ToDo: DEBUG - REMOVE THIS //_debugStateRenderer.material.color = Color.white; // Assign jobs var recovering = new Job(Recovering(() => { Debug.Log("Recovered!"); // Hide health bar _healthBar.HideBubble(); CurrentState = eBossState.TELEPORT; }), true); // Update jobs list _currentJobs.Add(recovering); break; case eBossState.DEAD: // ToDo: DEBUG - REMOVE THIS //_debugStateRenderer.material.color = Color.black; _animator.SetTrigger(HashIDs.Dead); // Add penalties to wild magic rate and population (first time awards then default awards thereafter) if (PlayerPrefsWrapper.HasKey("PlayerWinsFirstBossFight") && PlayerPrefsWrapper.GetInt("PlayerWinsFirstBossFight") == 1) { GameDataManager.Instance.AddWildMagicAndPopulation(WildMagicItemsManager.GetWildMagicItem("WM_RATE_BOSS_FIGHT_WIN_DEFAULT")); } else { GameDataManager.Instance.AddWildMagicAndPopulation(WildMagicItemsManager.GetWildMagicItem("WM_RATE_BOSS_FIGHT_WIN_FIRST")); PlayerPrefsWrapper.SetInt("PlayerWinsFirstBossFight", 1); } // Update managers _gridManager.OnBossDeadEvent(); _enemyManager.OnClearEnemiesEvent(true); GameManager.Instance.OnBossDeadEvent(); break; } }
/// <summary> /// Get int value from PlayerPrefs /// </summary> /// <returns>The int.</returns> /// <param name="key">Key.</param> public static int GetInt(string key) { return(PlayerPrefsWrapper.GetInt(key)); }