public static void SaveCharacterProgress(CharacterProgressData progress) { FileStream file = File.Create(Application.persistentDataPath + m_CharacterPath); m_Formatter.Serialize(file, progress); file.Close(); }
private static void SaveCharacterProgress(ushort slotId) { var data = new CharacterProgressData(ClientCurrentCharacterHelper.Character, slotId); ClientStoredCharacterData.Save(data); Logger.Important("Saved character progress: slotId=" + slotId); }
private bool ServerRemote_RestoreCharacterData(CharacterProgressData data) { var character = ServerRemoteContext.Character; if (!Server.Core.IsLocalServer || !Server.Core.IsLocalServerHoster(character)) { throw new Exception("The player is not the local server hoster: " + character); } Logger.Important("New Game +: Restoring old character progress"); // restore style CharacterStyleSystem.ServerSetStyle(character, data.FaceStyle, data.IsMale); CharacterCreationSystem.ServerSetOrigin(character, data.ProtoCharacterOrigin); // ensure character spawned CharacterCreationSystem.ServerSpawnIfReady(character); // restore finished quests var quests = character.SharedGetQuests(); quests.ServerReset(); foreach (var quest in data.FinishedQuests) { QuestsSystem.ServerCompleteQuest(quests, quest, ignoreRequirements: true, provideReward: false); } // restore technologies var technologies = character.SharedGetTechnologies(); technologies.ServerSetLearningPoints(data.LearningPoints); foreach (var techGroup in data.TechGroups) { technologies.ServerAddGroup(techGroup); } foreach (var techNode in data.TechNodes) { technologies.ServerAddNode(techNode); } // restore skills var skills = character.SharedGetSkills(); skills.ServerReset(); foreach (var(skill, experience) in data.Skills) { skills.ServerDebugSetSkill(skill, experience); } Logger.Important("New Game +: Finished restoring old character data"); return(true); }
private void LoadCharacterProgress() { m_CharacterData = SaveLoad.LoadCharacterProgress(); if (m_CharacterData == null) { m_CharacterData = new CharacterProgressData(); m_CharacterData.Init(); SaveCharacterProgress(); } else { Debug.LogFormat("> Successfully Loaded Character Progress"); } }
public static CharacterProgressData LoadCharacterProgress() { if (File.Exists(Application.persistentDataPath + m_CharacterPath)) { FileStream file = File.Open(Application.persistentDataPath + m_CharacterPath, FileMode.Open); CharacterProgressData progress = (CharacterProgressData)m_Formatter.Deserialize(file); file.Close(); return(progress); } else { Debug.LogErrorFormat("No File exists at {0}", Application.persistentDataPath + m_CharacterPath); return(null); } }