Example #1
0
    public void LoadDataromServer(string json_data)
    {
        var Json = SimpleJSON.JSON.Parse(json_data);
        string arrayName = "achievements";
        achievements = new List<Achievement>(Json[arrayName].Count);
        for (int a = 0; a < Json[arrayName].Count; a++)
        {
            string type = Json[arrayName][a]["type"];

            switch (type)
            {
                case "MISSION":
                    AchievementMission achievement_mission = new AchievementMission();
                    achievement_mission.title = Json[arrayName][a]["title"];
                    achievement_mission.id = a;
                    achievement_mission.progress = int.Parse(Json[arrayName][a]["progress"]);
                    achievement_mission.image = Json[arrayName][a]["image"];
                    achievement_mission.mission = int.Parse(Json[arrayName][a]["mission"]);
                    achievement_mission.Init();
                    achievements.Add(achievement_mission);
                    break;
                case "DISTANCE":
                    AchievementDistance achievement_distance = new AchievementDistance();
                    achievement_distance.title = Json[arrayName][a]["title"];
                    achievement_distance.id = a;
                    achievement_distance.progress = int.Parse(Json[arrayName][a]["progress"]);
                    achievement_distance.image = Json[arrayName][a]["image"];
                    achievement_distance.pointsToBeReady = int.Parse(Json[arrayName][a]["distance"]);
                    achievement_distance.Init();
                    achievements.Add(achievement_distance);
                    break;
            }
        }
    }
Example #2
0
    public void LoadDataromServer(string json_data)
    {
        var    Json      = SimpleJSON.JSON.Parse(json_data);
        string arrayName = "achievements";

        achievements = new List <Achievement>(Json[arrayName].Count);
        for (int a = 0; a < Json[arrayName].Count; a++)
        {
            string type = Json[arrayName][a]["type"];

            switch (type)
            {
            case "MISSION":
                AchievementMission achievement_mission = new AchievementMission();
                achievement_mission.title    = Json[arrayName][a]["title"];
                achievement_mission.id       = a;
                achievement_mission.progress = int.Parse(Json[arrayName][a]["progress"]);
                achievement_mission.image    = Json[arrayName][a]["image"];
                achievement_mission.mission  = int.Parse(Json[arrayName][a]["mission"]);
                achievement_mission.Init();
                achievements.Add(achievement_mission);
                break;

            case "DISTANCE":
                AchievementDistance achievement_distance = new AchievementDistance();
                achievement_distance.title           = Json[arrayName][a]["title"];
                achievement_distance.id              = a;
                achievement_distance.progress        = int.Parse(Json[arrayName][a]["progress"]);
                achievement_distance.image           = Json[arrayName][a]["image"];
                achievement_distance.pointsToBeReady = int.Parse(Json[arrayName][a]["distance"]);
                achievement_distance.Init();
                achievements.Add(achievement_distance);
                break;
            }
        }
    }