示例#1
0
    /// <summary>
    /// 添加任务
    /// </summary>
    public void AddMission()
    {
        int val = Random.Range(0, (int)MissionBase.MissionType.MAX);

        MissionBase newMission = MissionBase.GetNewMissionFromType((MissionBase.MissionType)val);

        newMission.Created();

        missions.Add(newMission);
    }
示例#2
0
    /// <summary>
    /// 从文件中读数据(读写顺序要一致!)
    /// </summary>
    public void Read()
    {
        BinaryReader br = new BinaryReader(new FileStream((saveFile), FileMode.Open));
        //读取版本号
        int verson = br.ReadInt32();

        if (verson < 6)
        {
            br.Close();

            NewSave();
            br     = new BinaryReader(new FileStream(saveFile, FileMode.Open));
            verson = br.ReadInt32();
        }
        //读取金币
        coins = br.ReadInt32();
        //读取消耗品
        consumables.Clear();
        int consumableCount = br.ReadInt32();

        for (int i = 0; i < consumableCount; ++i)
        {
            consumables.Add((Consumable.ConsumableType)br.ReadInt32(), br.ReadInt32());
        }
        //读取角色
        characters.Clear();
        int charCount = br.ReadInt32();

        for (int i = 0; i < charCount; ++i)
        {
            string charName = br.ReadString();

            if (charName.Contains("Raccooon") && verson < 11)
            {
                charName = charName.Replace("Racoon", "Raccoon");
            }

            characters.Add(charName);
        }
        usedCharater = br.ReadInt32();

        //读取角色装扮数据
        characterAccessories.Clear();
        int accCount = br.ReadInt32();

        for (int i = 0; i < accCount; ++i)
        {
            characterAccessories.Add(br.ReadString());
        }
        //读取主题数据
        themes.Clear();
        int themeCount = br.ReadInt32();

        for (int i = 0; i < themeCount; ++i)
        {
            themes.Add(br.ReadString());
        }

        usedTheme = br.ReadInt32();

        if (verson >= 2)
        {
            diamonds = br.ReadInt32();
        }

        //读取排名记录
        if (verson >= 3)
        {
            highscores.Clear();
            int count = br.ReadInt32();
            for (int i = 0; i < count; ++i)
            {
                HighscoreEntry entry = new HighscoreEntry();
                entry.name  = br.ReadString();
                entry.score = br.ReadInt32();

                highscores.Add(entry);
            }
        }

        // 读取任务记录.
        if (verson >= 4)
        {
            missions.Clear();

            int count = br.ReadInt32();
            for (int i = 0; i < count; ++i)
            {
                MissionBase.MissionType type        = (MissionBase.MissionType)br.ReadInt32();
                MissionBase             tempMission = MissionBase.GetNewMissionFromType(type);

                tempMission.Deserialize(br);

                if (tempMission != null)
                {
                    missions.Add(tempMission);
                }
            }
        }

        //读取排名列表中用过的名字的记录
        if (verson >= 7)
        {
            previousName = br.ReadString();
        }

        if (verson >= 8)
        {
            licenceAccepted = br.ReadBoolean();
        }
        //读取音量设置的数据
        if (verson >= 9)
        {
            masterVolume    = br.ReadSingle();
            musicVolume     = br.ReadSingle();
            masterSFXVolume = br.ReadSingle();
        }

        if (verson >= 10)
        {
            ftueLevel = br.ReadInt32();
            rank      = br.ReadInt32();
        }

        br.Close();
    }
示例#3
0
    public void Read()
    {
        BinaryReader r = new BinaryReader(new FileStream(saveFile, FileMode.Open));

        int ver = r.ReadInt32();

        if (ver < 6)
        {
            r.Close();

            NewSave();
            r   = new BinaryReader(new FileStream(saveFile, FileMode.Open));
            ver = r.ReadInt32();
        }

        coins = r.ReadInt32();


        consumables.Clear();
        int consumableCount = r.ReadInt32();

        for (int i = 0; i < consumableCount; ++i)
        {
            consumables.Add((Consumable.ConsumableType)r.ReadInt32(), r.ReadInt32());
        }

        // Read character.
        characters.Clear();
        int charCount = r.ReadInt32();

        for (int i = 0; i < charCount; ++i)
        {
            string charName = r.ReadString();

            if (charName.Contains("Raccoon") && ver < 11)
            {//in 11 version, we renamed Raccoon (fixing spelling) so we need to patch the save to give the character if player had it already
                charName = charName.Replace("Racoon", "Raccoon");
            }

            characters.Add(charName);
        }

        usedCharacter = r.ReadInt32();

        // Read character accesories.
        characterAccessories.Clear();
        int accCount = r.ReadInt32();

        for (int i = 0; i < accCount; ++i)
        {
            characterAccessories.Add(r.ReadString());
        }

        // Read Themes.
        themes.Clear();
        int themeCount = r.ReadInt32();

        for (int i = 0; i < themeCount; ++i)
        {
            themes.Add(r.ReadString());
        }

        usedTheme = r.ReadInt32();

        // Save contains the version they were written with. If data are added bump the version & test for that version before loading that data.
        if (ver >= 2)
        {
            premium = r.ReadInt32();
        }

        // Added highscores.
        if (ver >= 3)
        {
            highscores.Clear();
            int count = r.ReadInt32();
            for (int i = 0; i < count; ++i)
            {
                HighscoreEntry entry = new HighscoreEntry();
                entry.name  = r.ReadString();
                entry.score = r.ReadInt32();

                highscores.Add(entry);
            }
        }

        // Added missions.
        if (ver >= 4)
        {
            missions.Clear();

            int count = r.ReadInt32();
            for (int i = 0; i < count; ++i)
            {
                MissionBase.MissionType type        = (MissionBase.MissionType)r.ReadInt32();
                MissionBase             tempMission = MissionBase.GetNewMissionFromType(type);

                tempMission.Deserialize(r);

                if (tempMission != null)
                {
                    missions.Add(tempMission);
                }
            }
        }

        // Added highscore previous name used.
        if (ver >= 7)
        {
            previousName = r.ReadString();
        }

        if (ver >= 8)
        {
            licenceAccepted = r.ReadBoolean();
        }

        if (ver >= 9)
        {
            masterVolume    = r.ReadSingle();
            musicVolume     = r.ReadSingle();
            masterSFXVolume = r.ReadSingle();
        }

        if (ver >= 10)
        {
            ftueLevel = r.ReadInt32();
            rank      = r.ReadInt32();
        }

        r.Close();
    }
    public void Read()
    {
        BinaryReader r = new BinaryReader(new FileStream(saveFile, FileMode.Open));

        int ver = r.ReadInt32();

        if (ver < 6)
        {
            r.Close();

            NewSave();
            r   = new BinaryReader(new FileStream(saveFile, FileMode.Open));
            ver = r.ReadInt32();
        }

        stars = r.ReadInt32();

        /*
         * consumables.Clear();
         * int consumableCount = r.ReadInt32();
         * for (int i = 0; i < consumableCount; ++i)
         * {
         *  consumables.Add((Consumable.ConsumableType)r.ReadInt32(), r.ReadInt32());
         * }
         */

        // Read character.
        characters.Clear();
        int charCount = r.ReadInt32();

        for (int i = 0; i < charCount; ++i)
        {
            string charName = r.ReadString();

            /*
             * if (charName.Contains("Raccoon") && ver < 11)
             * {//in 11 version, we renamed Raccoon (fixing spelling) so we need to patch the save to give the character if player had it already
             *  charName = charName.Replace("Racoon", "Raccoon");
             * }
             */
            characters.Add(charName);
        }

        // Read skin.
        skins.Clear();
        int skinCount = r.ReadInt32();

        for (int i = 0; i < skinCount; ++i)
        {
            string skinName = r.ReadString();

            /*
             * if (charName.Contains("Raccoon") && ver < 11)
             * {//in 11 version, we renamed Raccoon (fixing spelling) so we need to patch the save to give the character if player had it already
             *  charName = charName.Replace("Racoon", "Raccoon");
             * }
             */
            skins.Add(skinName);
        }

        tutorialCompletion = r.ReadBoolean();
        tutorialCheck      = r.ReadBoolean();
        koreanCheck        = r.ReadBoolean();

        usedCharacter = r.ReadInt32();
        usedSkin      = r.ReadInt32();

        /*
         * // Read character accesories.
         * characterAccessories.Clear();
         * int accCount = r.ReadInt32();
         * for (int i = 0; i < accCount; ++i)
         * {
         *  characterAccessories.Add(r.ReadString());
         * }
         *
         * // Read Themes.
         * themes.Clear();
         * int themeCount = r.ReadInt32();
         * for (int i = 0; i < themeCount; ++i)
         * {
         *  themes.Add(r.ReadString());
         * }
         *
         * usedTheme = r.ReadInt32();
         */
        // Save contains the version they were written with. If data are added bump the version & test for that version before loading that data.
        if (ver >= 2)
        {
            coins = r.ReadInt32();
        }


        // Added highscores.
        if (ver >= 3)
        {
            highscores.Clear();
            int count = r.ReadInt32();
            for (int i = 0; i < count; ++i)
            {
                HighscoreEntry entry = new HighscoreEntry();
                entry.name  = r.ReadString();
                entry.score = r.ReadInt32();

                highscores.Add(entry);
            }
        }

        // Added missions.
        if (ver >= 4)
        {
            missions.Clear();

            int count = r.ReadInt32();
            for (int i = 0; i < count; ++i)
            {
                MissionBase.MissionType type        = (MissionBase.MissionType)r.ReadInt32();
                MissionBase             tempMission = MissionBase.GetNewMissionFromType(type);

                tempMission.Deserialize(r);

                if (tempMission != null)
                {
                    missions.Add(tempMission);
                }
            }

            achievementMissions.Clear();

            int aCount = r.ReadInt32();
            for (int i = 0; i < aCount; ++i)
            {
                AchievementMissionBase.MissionType type = (AchievementMissionBase.MissionType)r.ReadInt32();
                AchievementMissionBase             achievementTempMission = AchievementMissionBase.GetNewMissionFromType(type);

                achievementTempMission.Deserialize(r);

                if (achievementTempMission != null)
                {
                    achievementMissions.Add(achievementTempMission);
                }
            }
        }

        // Added highscore previous name used.
        if (ver >= 7)
        {
            previousName = r.ReadString();
        }

        /*
         * if (ver >= 8)
         * {
         *  licenceAccepted = r.ReadBoolean();
         * }
         */
        if (ver >= 9)
        {
            masterVolume    = r.ReadSingle();
            musicVolume     = r.ReadSingle();
            masterSFXVolume = r.ReadSingle();
        }

        if (ver >= 10)
        {
            ftueLevel         = r.ReadInt32();
            rank              = r.ReadInt32();
            adsActivatingTime = r.ReadInt64();
        }

        r.Close();
    }