コード例 #1
0
    public static void SaveCharacterProgress(CharacterProgressData progress)
    {
        FileStream file = File.Create(Application.persistentDataPath + m_CharacterPath);

        m_Formatter.Serialize(file, progress);
        file.Close();
    }
コード例 #2
0
        private static void SaveCharacterProgress(ushort slotId)
        {
            var data = new CharacterProgressData(ClientCurrentCharacterHelper.Character, slotId);

            ClientStoredCharacterData.Save(data);
            Logger.Important("Saved character progress: slotId=" + slotId);
        }
コード例 #3
0
        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);
        }
コード例 #4
0
    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");
        }
    }
コード例 #5
0
    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);
        }
    }