Пример #1
0
    public void Load()
    {
        int length;

        //PlayerPrefs.DeleteAll();
        //userInfo = new UserInfo();

        userInfo   = userInfo.Load <UserInfo>();
        dragonInfo = dragonInfo.Load <PlayerDragon>();
        tutorialInfo.resetValue();

        // reset lai tutorial trong game, chi xuat hien mot lan duy nhat trong 1 lan choi game cua nguoi choi
        userInfo.checkTutorialLevel = 0;
        userInfo.checkTutorialPlay  = 0;

        userInfo.Save();

        if (userInfo.check == 0)
        {
            reset();
            //openAllMap();
        }
        else
        {
            updateVersion();
        }

        maps.DeleteAll();
        enemies.DeleteAll();
        dailyQuests.DeleteAll();
        achievements.DeleteAll();

        PlayerMap[] tempMap = this.maps.Load <PlayerMap>();
        length = tempMap.Length;
        for (int i = 0; i < length; i++)
        {
            maps.Add(tempMap[i]);
            listMap.Add(tempMap[i].id, new PlayerMap(tempMap[i].id, tempMap[i].starSuccess, tempMap[i].starTotal));
        }

        PlayerEnemy[] tempEnemy = this.enemies.Load <PlayerEnemy>();
        length = tempEnemy.Length;
        for (int i = 0; i < length; i++)
        {
            enemies.Add(tempEnemy[i]);
            listEnemy.Add(tempEnemy[i].id, tempEnemy[i].visible);
        }

        PlayerDailyQuest[] tempDailyQuest = this.dailyQuests.Load <PlayerDailyQuest>();
        length = tempDailyQuest.Length;
        for (int i = 0; i < length; i++)
        {
            dailyQuests.Add(tempDailyQuest[i]);
            listDailyQuest.Add(tempDailyQuest[i].id, tempDailyQuest[i].Amount);
        }

        PlayerAchievement[] tempAchievement = this.achievements.Load <PlayerAchievement> ();
        length = tempAchievement.Length;

        for (int i = 0; i < length; i++)
        {
            achievements.Add(tempAchievement[i]);
            listAchievement.Add(tempAchievement[i].id, tempAchievement[i].value);
        }
    }