Ejemplo n.º 1
0
    public static Story Deserialize(DataStream reader)
    {
        Story newStory = new Story();

        newStory.StoryName = reader.ReadString8();
        int chapterCount = reader.ReadSInt32();

        newStory.Chapters = new SortedDictionary <int, Chapter>();
        for (int i = 0; i < chapterCount; i++)
        {
            Chapter chapter = Chapter.Deserialize(reader);
            if (newStory.Chapters.ContainsKey(chapter.ChapterID))
            {
                Utils.DebugLog("Duplicate! chapter.ChapterID: " + chapter.ChapterID);
            }
            else
            {
                newStory.Chapters.Add(chapter.ChapterID, chapter);
            }
        }

        int cldCount = reader.ReadSInt32();

        newStory.Base_CardLimitDict = new SortedDictionary <int, int>();
        for (int i = 0; i < cldCount; i++)
        {
            int key   = reader.ReadSInt32();
            int value = reader.ReadSInt32();
            if (newStory.Base_CardLimitDict.ContainsKey(key))
            {
                Utils.DebugLog("Duplicate! Base_CardLimitDict.key: " + key);
            }
            else
            {
                newStory.Base_CardLimitDict.Add(key, value);
            }
        }

        int cardUnlockInfoCount = reader.ReadSInt32();
        SortedDictionary <int, bool> cardUnlockInfos = new SortedDictionary <int, bool>();

        for (int i = 0; i < cardUnlockInfoCount; i++)
        {
            int  cardID = reader.ReadSInt32();
            bool unlock = reader.ReadByte() == 0x01;
            cardUnlockInfos.Add(cardID, unlock);
        }

        newStory.CardUnlockInfos = cardUnlockInfos;

        int buildCount = reader.ReadSInt32();

        newStory.PlayerBuildInfos = new SortedDictionary <int, BuildInfo>();
        for (int i = 0; i < buildCount; i++)
        {
            BuildInfo bi = BuildInfo.Deserialize(reader);
            if (newStory.PlayerBuildInfos.ContainsKey(bi.BuildID))
            {
                Utils.DebugLog("Duplicate! bi.BuildID: " + bi.BuildID);
            }
            else
            {
                newStory.PlayerBuildInfos.Add(bi.BuildID, bi);
            }
        }

        newStory.StoryGamePlaySettings    = GamePlaySettings.Deserialize(reader);
        newStory.CurrentFightingChapterID = reader.ReadSInt32();
        newStory.Crystal = reader.ReadSInt32();
        return(newStory);
    }