Exemplo n.º 1
0
    void updateVersion()
    {
        if (userInfo.version <= 4)
        {
            PlayerMap[] tempMaps    = maps.Load <PlayerMap>();
            int         tempDiamond = userInfo.Load <UserInfo>().diamond + 10;

            PlayerPrefs.DeleteAll();

            //map
            maps.DeleteAll();
            int len = tempMaps.Length;
            for (int i = 0; i < len; i++)
            {
                maps.Add(new PlayerMap(tempMaps[i].id, tempMaps[i].starSuccess, tempMaps[i].starTotal));
            }

            //enemy
            enemies.DeleteAll();
            foreach (System.Collections.Generic.KeyValuePair <string, EnemyData> iterator in ReadDatabase.Instance.EnemyInfo)
            {
                enemies.Add(new PlayerEnemy(iterator.Key, false));
            }

            dailyQuests.DeleteAll();
            len = ReadDatabase.Instance.QuestInfo.Count;
            for (int i = 1; i <= len; i++)
            {
                dailyQuests.Add(new PlayerDailyQuest(i, 0));
            }

            achievements.DeleteAll();
            len = ReadDatabase.Instance.AchievementInfo.Count;
            for (int i = 0; i < len; i++)
            {
                int result = -1;
                if (int.TryParse(ReadDatabase.Instance.AchievementInfo[i].Value, out result))
                {
                    achievements.Add(new PlayerAchievement(i, 0));
                }
                else
                {
                    achievements.Add(new PlayerAchievement(i, ""));
                }
            }

            //user
            userInfo.diamond     = tempDiamond; //Diamond trong game
            userInfo.new_player  = 1;
            userInfo.volumeSound = 100;
            userInfo.volumeMusic = 100;
            userInfo.instruction = 1; // huong dan choi game: 1 la co hien ra, 0 la khong co
            userInfo.check       = 1; //Kiem tra lan dau khi choi, 0 la choi lan dau , 1 la da choi roi
            userInfo.version     = 5; //Version hien tai cua game
            userInfo.dateTime    = DateTime.Now.ToShortDateString();

            Save();
        }
        if (userInfo.version > 4 && userInfo.version < 7) //version add dragon
        {
            if (dragonInfo.id.Equals(""))
            {
                dragonInfo.id         = EBranchGame.FIRE.ToString().ToUpper();
                dragonInfo.rank       = 1;
                dragonInfo.itemAmulet = dragonInfo.itemBody = dragonInfo.itemHead = dragonInfo.itemRing = dragonInfo.itemRune = dragonInfo.itemWing = "";
                dragonInfo.Save();
            }

            // version hien tai
            userInfo.version = 7;
            userInfo.Save();
        }
        if (userInfo.version == 7)
        {
        }
    }