/// <summary> /// Returns a String Array from a key & char seperator /// </summary> public static string[] GetStringArray(string key, char separator) { if (PlayerPrefsWrapper.HasKey(key)) { return(PlayerPrefsWrapper.GetString(key).Split(separator)); } return(new string[0]); }
/// <summary> /// Returns a Bool Array from a key /// </summary> public static string[] GetStringArray(string key) { if (PlayerPrefsWrapper.HasKey(key)) { return(PlayerPrefsWrapper.GetString(key).Split("\n"[0])); } return(new string[0]); }
/// <summary> /// Returns a Bool Array from a Key /// Note: Uses default values to initialize if no key was found /// </summary> public static bool[] GetBoolArray(string key, bool defaultValue, int defaultSize) { if (PlayerPrefsWrapper.HasKey(key)) { return(GetBoolArray(key)); } bool[] boolArray = new bool[defaultSize]; for (int i = 0; i < defaultSize; i++) { boolArray[i] = defaultValue; } return(boolArray); }
/// <summary> /// Returns a String Array from a key & char seperator /// Note: Uses default values to initialize if no key was found /// </summary> public static string[] GetStringArray(string key, char separator, string defaultValue, int defaultSize) { if (PlayerPrefsWrapper.HasKey(key)) { return(PlayerPrefsWrapper.GetString(key).Split(separator)); } string[] stringArray = new string[defaultSize]; for (int i = 0; i < defaultSize; i++) { stringArray[i] = defaultValue; } return(stringArray); }
/// <summary> /// Returns a String Array from a Key /// Note: Uses default values to initialize if no key was found /// </summary> public static float[] GetFloatArray(string key, float defaultValue, int defaultSize) { if (PlayerPrefsWrapper.HasKey(key)) { return(GetFloatArray(key)); } float[] floatArray = new float[defaultSize]; for (int i = 0; i < defaultSize; i++) { floatArray[i] = defaultValue; } return(floatArray); }
/// <summary> /// Returns a Int Array from a Key /// Note: Uses default values to initialize if no key was found /// </summary> public static int[] GetIntArray(string key, int defaultValue, int defaultSize) { if (PlayerPrefsWrapper.HasKey(key)) { return(GetIntArray(key)); } int[] intArray = new int[defaultSize]; for (int i = 0; i < defaultSize; i++) { intArray[i] = defaultValue; } return(intArray); }
/// <summary> /// Returns a Bool Array from a Key /// </summary> public static bool[] GetBoolArray(string key) { if (PlayerPrefsWrapper.HasKey(key)) { string[] stringArray = PlayerPrefsWrapper.GetString(key).Split("|"[0]); bool[] boolArray = new bool[stringArray.Length]; for (int i = 0; i < stringArray.Length; i++) { boolArray[i] = Convert.ToBoolean(stringArray[i]); } return(boolArray); } return(new bool[0]); }
/// <summary> /// Returns a Float Array from a Key /// </summary> public static float[] GetFloatArray(string key) { if (PlayerPrefsWrapper.HasKey(key)) { string[] stringArray = PlayerPrefsWrapper.GetString(key).Split("|"[0]); float[] floatArray = new float[stringArray.Length]; for (int i = 0; i < stringArray.Length; i++) { floatArray[i] = Convert.ToSingle(stringArray[i]); } return(floatArray); } return(new float[0]); }
/// <summary> /// Returns a Int Array from a Key /// </summary> public static int[] GetIntArray(string key) { if (PlayerPrefsWrapper.HasKey(key)) { string[] stringArray = PlayerPrefsWrapper.GetString(key).Split("|"[0]); int[] intArray = new int[stringArray.Length]; for (int i = 0; i < stringArray.Length; i++) { intArray[i] = Convert.ToInt32(stringArray[i]); } return(intArray); } return(new int[0]); }
//===================================================== 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; } }
//===================================================== void Start() { if (Application.isPlaying == false) { return; } // Boss Doors - enable boss torches - all torches enabled unlocks boss door if (_type != eDoorType.BOSS || _targetScene != eLocation.BOSS_ROOM || _bossTorches == null) { return; } // Max level for fairies and boss var maxLevel = GameDataManager.Instance.PlayerMaxFairyLevel; // Get current boss level var bossLevel = GameDataManager.Instance.PlayerBossLevel; // Get current min fairy level for boss fight var minFairyLevel = GameDataManager.Instance.PlayerFairyMinLevel(); // Are we at the max-level boss? If so, check time interval else check current fairy levels // Note: time-interval-start set after killing level 3 boss: GameManager->OnBossDeadEvent() if (bossLevel >= maxLevel && minFairyLevel >= maxLevel) { // Get time in seconds since last boss appearance var timeNow = PreHelpers.UnixUtcNow(); double timePassed = 0; if (PlayerPrefsWrapper.HasKey("BossRoomTimedIntervalStarted")) { timePassed = timeNow - PlayerPrefsWrapper.GetDouble("BossRoomTimedIntervalStarted"); } var intervalInDays = Convert.ToSingle(SettingsManager.GetSettingsItem("BOSS_RESPAWN_TIME", -1)); var intervalInSeconds = intervalInDays * 24 * 60 * 60; // ToDo: check time since boss last appeared if (timePassed > intervalInSeconds) { // Enable torches foreach (var torch in _bossTorches) { torch.EnableTorch(); } return; } } // Check current fairy levels var fairyLevels = GameDataManager.Instance.PlayerFairyLevels(); if (fairyLevels.Length > _bossTorches.Length) { return; } // Enable torches for fairies at high enough level for (var i = 0; i < fairyLevels.Length; i++) { if (fairyLevels[i] >= bossLevel) { _bossTorches[i].EnableTorch(); } } }
/// <summary> /// Determines if has key the specified key. /// </summary> /// <returns><c>true</c> if has key the specified key; otherwise, <c>false</c>.</returns> /// <param name="key">Key.</param> public static bool HasKey(string key) { return(PlayerPrefsWrapper.HasKey(key)); }