//===================================================== public void OnButtonPressedClose() { if (InputManager.Instance != null) { InputManager.Instance.OnBlockInput(false); } // Start Brafilius' cutscene switch (_currentTutorial) { case eTutorial.TUTORIAL01: if (PopupStartTutorial != null) { PopupStartTutorial(); } break; case eTutorial.NULL: case eTutorial.TUTORIAL04: // Tutorial is completed PlayerPrefsWrapper.SetInt("IsTutorialCompleted", 1); // Go to Main Hall scene via cutscene GameManager.Instance.SetNextLocation(eLocation.MAIN_HALL); CutsceneManager.Instance.OnRestartEvent(); break; } _camera.SetActive(false); }
/// <summary> /// Save option value to player prefs. /// </summary> public override void SaveOption() { switch (optionSaveType) { case OptionSaveType.Float: PlayerPrefsWrapper.SetFloat(key, slider.value); break; case OptionSaveType.Int: PlayerPrefsWrapper.SetInt(key, (int)slider.value); break; } }
//============================================================================= private void OnDownloadPlayerDataSuccessEvent() { ServerManager.DownloadPlayerDataSuccessEvent -= OnDownloadPlayerDataSuccessEvent; ServerManager.DownloadPlayerDataFailEvent -= OnDownloadPlayerDataFailEvent; // Reload playerData into manager class if (GameDataManager.Instance != null) { GameDataManager.Instance.LoadPlayer(); PlayerPrefsWrapper.SetInt("IsTutorialCompleted", 1); } m_CurrentStage = eRegistrationStage.RestoringPreviousFairySuccess; }
//===================================================== 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> /// Save int value to PlayerPrefs /// </summary> /// <param name="key">Key.</param> /// <param name="value">Value to save.</param> public static void SetInt(string key, int value) { PlayerPrefsWrapper.SetInt(key, value); }