public void Save(ISave saveSystem, string keyPrefix) { saveSystem.SetInt(SaveUtils.GetKey(keyPrefix, SaveUtils.PLAYER_MAX_HEALTH_KEY), MaxHealth); saveSystem.SetInt(SaveUtils.GetKey(keyPrefix, SaveUtils.PLAYER_CURRENT_HEALTH_KEY), CurrentHealth); camController.Save(saveSystem, SaveUtils.CAMERA_PREFIX); }
private IEnumerator CastleInit() { Settings.Instance.Audio.ChangeMusic(AudioContainer.Music.CastleAmbience); if (ObjPoolMan == null) { ObjPoolMan = GetComponent <ObjectPoolManager>(); } /* * if (AIManager == null) * { * AIManager = GetComponent<AIManager>(); * } */ /* * if (PlayerManager == null) * { * PlayerManager = GetComponent<PlayerManager>(); * PlayerManager.Initialize(); * } */ CharController = FindObjectOfType <CharController>(); LevelUIManager = FindObjectOfType <LevelUIManager>(); LevelUIManager.InitializeLevelUIManager(PlayerManager); ObjPoolMan.InitializeCastleObjectPool(); PlayerT = CharController.gameObject.transform; // Wait for one frame before loading some of the values. yield return(null); // Load player pos/rot if (!CastleManager.UseStartPos) { Vector3 playerPos = PlayerT.position; float playerRot = PlayerT.rotation.eulerAngles.y; float posX = SaveSystem.GetFloat(SaveUtils.GetKey(SaveUtils.PLAYER_TRANS_PREFIX, SaveUtils.PLAYER_X_KEY), playerPos.x); float posY = SaveSystem.GetFloat(SaveUtils.GetKey(SaveUtils.PLAYER_TRANS_PREFIX, SaveUtils.PLAYER_Y_KEY), playerPos.y); float posZ = SaveSystem.GetFloat(SaveUtils.GetKey(SaveUtils.PLAYER_TRANS_PREFIX, SaveUtils.PLAYER_Z_KEY), playerPos.z); float rotY = SaveSystem.GetFloat(SaveUtils.GetKey(SaveUtils.PLAYER_TRANS_PREFIX, SaveUtils.PLAYER_ROT_KEY), playerRot); //print(new Vector3(posX, posY + 0.1f, posZ)); PlayerT.position = new Vector3(posX, posY + 0.1f, posZ); PlayerT.rotation = Quaternion.Euler(0f, rotY, 0f); } // Load player health and camera rotation CharController.Load(SaveSystem, SaveUtils.CHAR_CONTROLLER_PREFIX); LevelUIManager.StartFade(FadeType.FadeOut); //AudioSource audioSource = GetComponent<AudioSource>(); //Audio = new AudioManager(audioSource, mixer, audioData); }
public void LoadGame(string saveSlot) { SaveSystem.Load(saveSlot); string scene = SaveSystem.GetString(SaveUtils.GetKey(SaveUtils.GAME_MAN_PREFIX, SaveUtils.GAMEMAN_SCENE_NAME_KEY), GlobalVariables.GRAVEYARD); SceneManager.LoadScene(scene); }
public void AutoSave() { // Save scene SaveSystem.SetString(SaveUtils.GetKey(SaveUtils.GAME_MAN_PREFIX, SaveUtils.GAMEMAN_SCENE_NAME_KEY), SceneManager.GetActiveScene().name); //print("Scene saved"); // Save player pos/rot Vector3 playerPos = PlayerT.position; float playerRot = PlayerT.rotation.eulerAngles.y; SaveSystem.SetFloat(SaveUtils.GetKey(SaveUtils.PLAYER_TRANS_PREFIX, SaveUtils.PLAYER_X_KEY), playerPos.x); SaveSystem.SetFloat(SaveUtils.GetKey(SaveUtils.PLAYER_TRANS_PREFIX, SaveUtils.PLAYER_Y_KEY), playerPos.y); SaveSystem.SetFloat(SaveUtils.GetKey(SaveUtils.PLAYER_TRANS_PREFIX, SaveUtils.PLAYER_Z_KEY), playerPos.z); SaveSystem.SetFloat(SaveUtils.GetKey(SaveUtils.PLAYER_TRANS_PREFIX, SaveUtils.PLAYER_ROT_KEY), playerRot); //print("Player pos/rot saved"); // Save player health and camera rotation CharController.Save(SaveSystem, SaveUtils.CHAR_CONTROLLER_PREFIX); //print("Health and cam rot saved"); // Save player progress PlayerManager.Save(SaveSystem, SaveUtils.PLAYER_MAN_PREFIX); //print("Player progress saved"); // Save AI manager AIManager.Save(SaveSystem, SaveUtils.AI_MAN_PREFIX); //print("AI manager saved"); // TODO: better way to save levelmanagers. // Save GraveyardMan if (GraveyardManager != null) { //print("GraveyardMan not null, saving"); GraveyardManager.Save(SaveSystem, SaveUtils.GRAVEYARD_MAN_PREFIX); //print("GraveyardMan saved"); } // Save CastelMan if (CastleManager != null) { //print("CastleMan not null, saving"); CastleManager.Save(SaveSystem, SaveUtils.CASTLE_MAN_PREFIX); //print("CastleMan saved"); } //print("Calling savesystem to actually save shit"); SaveSystem.Save(SaveUtils.AUTOSAVE_SAVE_SLOT); //print("game saved"); }
public void Save(ISave saveSystem, string keyPrefix) { saveSystem.SetBool(SaveUtils.GetKey(keyPrefix, SaveUtils.GRAVEYARD_SPAWN_SKELETON_BOSS_1_KEY), spawnSkeletonBoss1); for (int i = 0; i < maxHealthIncreases.Length; i++) { saveSystem.SetBool(SaveUtils.GetKey(keyPrefix, string.Format(SaveUtils.GRAVEYARD_SPAWN_MAX_HEALTH_INCREASE_KEY, i)), spawnMaxHealtIncreases[i]); } for (int i = 0; i < gateLockedInfo.Count; i++) { bool isOpen = gateLockedInfo[(GateType)i]; saveSystem.SetBool(SaveUtils.GetKey(keyPrefix, string.Format(SaveUtils.GRAVEYARD_GATE_OPEN_KEY, i)), isOpen); } }
public void Load(ISave saveSystem, string keyPrefix) { Scene currentScene = SceneManager.GetActiveScene(); if (currentScene.name.Equals(GlobalVariables.CASTLE)) { if (GameMan.Instance.CastleManager.UseStartPos) { return; } } float rotY = saveSystem.GetFloat(SaveUtils.GetKey(keyPrefix, SaveUtils.CAMERA_ROT_Y_KEY), transform.rotation.eulerAngles.y); transform.rotation = Quaternion.Euler(0f, rotY, 0f); }
public void Load(ISave saveSystem, string keyPrefix) { spawnSkeletonBoss1 = saveSystem.GetBool(SaveUtils.GetKey(keyPrefix, SaveUtils.GRAVEYARD_SPAWN_SKELETON_BOSS_1_KEY), true); for (int i = 0; i < maxHealthIncreases.Length; i++) { spawnMaxHealtIncreases[i] = saveSystem.GetBool(SaveUtils.GetKey(keyPrefix, string.Format(SaveUtils.GRAVEYARD_SPAWN_MAX_HEALTH_INCREASE_KEY, i)), true); } gateLockedInfo.Clear(); for (int i = 0; i < Enum.GetNames(typeof(GateType)).Length; i++) { bool isOpen = saveSystem.GetBool(SaveUtils.GetKey(keyPrefix, string.Format(SaveUtils.GRAVEYARD_GATE_OPEN_KEY, i)), true); gateLockedInfo.Add((GateType)i, isOpen); } }
public void Load(ISave saveSystem, string keyPrefix) { MaxHealth = saveSystem.GetInt(SaveUtils.GetKey(keyPrefix, SaveUtils.PLAYER_MAX_HEALTH_KEY), startingMaxHealth); int loadedCurrentHealth = saveSystem.GetInt(SaveUtils.GetKey(keyPrefix, SaveUtils.PLAYER_CURRENT_HEALTH_KEY), startingHealth); if (loadedCurrentHealth < MaxHealth * 0.5f) { CurrentHealth = (int)(MaxHealth * 0.5f); } else { CurrentHealth = loadedCurrentHealth; } InvokeHealthChangedEvent(); camController.Load(saveSystem, SaveUtils.CAMERA_PREFIX); }
public void Save(ISave saveSystem, string keyPrefix) { saveSystem.SetBool(SaveUtils.GetKey(keyPrefix, SaveUtils.PLAYER_MELEE_UNLOCK_KEY), IsAttackUnlocked); saveSystem.SetBool(SaveUtils.GetKey(keyPrefix, SaveUtils.PLAYER_SPELLCAST_UNLOCK_KEY), IsSpellCastUnlocked); // TODO: extract method for these for (int i = 0; i < spellUnlockInfo.Count; i++) { bool hasSpell = spellUnlockInfo[(Spells)i]; saveSystem.SetBool(SaveUtils.GetKey(keyPrefix, string.Format(SaveUtils.PLAYER_SPELL_UNLOCK_KEY, i)), hasSpell); } for (int i = 0; i < keyCollectInfo.Count; i++) { bool hasCollectedKey = keyCollectInfo[(KeyType)i]; saveSystem.SetBool(SaveUtils.GetKey(keyPrefix, string.Format(SaveUtils.PLAYER_KEY_COLLECT_KEY, i)), hasCollectedKey); } }
public void Load(ISave saveSystem, string keyPrefix) { IsAttackUnlocked = saveSystem.GetBool(SaveUtils.GetKey(keyPrefix, SaveUtils.PLAYER_MELEE_UNLOCK_KEY), false); IsSpellCastUnlocked = saveSystem.GetBool(SaveUtils.GetKey(keyPrefix, SaveUtils.PLAYER_SPELLCAST_UNLOCK_KEY), false); spellUnlockInfo.Clear(); for (int i = 0; i < Enum.GetNames(typeof(Spells)).Length; i++) { bool hasSpell = saveSystem.GetBool(SaveUtils.GetKey(keyPrefix, string.Format(SaveUtils.PLAYER_SPELL_UNLOCK_KEY, i)), false); spellUnlockInfo.Add((Spells)i, hasSpell); } keyCollectInfo.Clear(); for (int i = 0; i < Enum.GetNames(typeof(KeyType)).Length; i++) { bool hasKey = saveSystem.GetBool(SaveUtils.GetKey(keyPrefix, string.Format(SaveUtils.PLAYER_KEY_COLLECT_KEY, i)), false); keyCollectInfo.Add((KeyType)i, hasKey); } }
public void Save(ISave saveSystem, string keyPrefix) { saveSystem.SetBool(SaveUtils.GetKey(keyPrefix, SaveUtils.CASTLE_USE_LEVEL_START_POS_KEY), UseStartPos); saveSystem.SetBool(SaveUtils.GetKey(keyPrefix, SaveUtils.CASTLE_FINAL_BOSS_DOOR_OPEN_KEY), FinalBossDoorOpen); }
public void Load(ISave saveSystem, string keyPrefix) { UseStartPos = saveSystem.GetBool(SaveUtils.GetKey(keyPrefix, SaveUtils.CASTLE_USE_LEVEL_START_POS_KEY), true); FinalBossDoorOpen = saveSystem.GetBool(SaveUtils.GetKey(keyPrefix, SaveUtils.CASTLE_FINAL_BOSS_DOOR_OPEN_KEY), false); }
public void Load(ISave saveSystem, string keyPrefix) { EnemiesKilledAmount = saveSystem.GetInt(SaveUtils.GetKey(keyPrefix, SaveUtils.AI_MAN_ENEMIES_KILLED_AMOUNT_KEY), 0); }
public void Save(ISave saveSystem, string keyPrefix) { saveSystem.SetInt(SaveUtils.GetKey(keyPrefix, SaveUtils.AI_MAN_ENEMIES_KILLED_AMOUNT_KEY), enemiesKilledAmount); }
public void Save(ISave saveSystem, string keyPrefix) { saveSystem.SetFloat(SaveUtils.GetKey(keyPrefix, SaveUtils.CAMERA_ROT_Y_KEY), transform.rotation.eulerAngles.y); }