Exemplo n.º 1
0
 public override void RefreshAchievements()
 {
     foreach (var item in SteamUserStats.Achievements)
     {
         if (Achievements.ContainsKey(item.Identifier))
         {
         }
         else
         {
             var tempData = GetAchieveData.Copy <TDBaseAchieveData>();
             {
                 tempData.State      = item.State;
                 tempData.UnlockTime = item.UnlockTime.Value;
                 tempData.SourceName = item.Name;
                 tempData.SourceDesc = item.Description;
             };
             if (tempData == null)
             {
                 CLog.Error("没有配置这个成就:{0}", item.Identifier);
                 continue;
             }
             Achievements.Add(item.Identifier, tempData);
         }
     }
 }
    public static void RegisterAchievement(GK_AchievementTemplate achievement)
    {
        bool isContains = false;

        int replaceIndex = 0;

        foreach (GK_AchievementTemplate tpl in Achievements)
        {
            if (tpl.Id.Equals(achievement.Id))
            {
                isContains   = true;
                replaceIndex = Achievements.IndexOf(tpl);
                break;
            }
        }

        if (isContains)
        {
            Achievements[replaceIndex] = achievement;
        }
        else
        {
            Achievements.Add(achievement);
        }
    }
Exemplo n.º 3
0
 public override void RefreshAchievements()
 {
     //Achievements.Clear();
     foreach (var item in Client.Instance.Achievements.All)
     {
         if (Achievements.ContainsKey(item.Id))
         {
         }
         else
         {
             var tempData = GetAchieveData.Copy();
             //var tempData = new PlatformAchievement()
             {
                 //tempData.Percent = item.Percentage;
                 tempData.State = item.State;
                 //if (!item.State)
                 //    tempData.Percent = 0;
                 tempData.UnlockTime = item.UnlockTime;
                 tempData.SourceName = item.Name;
                 tempData.SourceDesc = item.Description;
             };
             if (tempData == null)
             {
                 CLog.Error("没有配置这个成就:{0}", item.Id);
                 continue;
             }
             Achievements.Add(item.Id, tempData);
         }
     }
 }
Exemplo n.º 4
0
        public void AddAchievement(Achievement achievement)
        {
            if (Achievements.Any(p => p.Id == achievement.Id))
            {
                return;
            }

            Achievements.Add(achievement);
        }
Exemplo n.º 5
0
 public void AddAchievements(IEnumerable <AchievementLookup> newAchievements)
 {
     foreach (var achievementLookup in newAchievements)
     {
         Achievements.Add(new AchievementSetting {
             AchievementId = (int)achievementLookup.Id, DateAchieved = DateTime.Now
         });
     }
 }
Exemplo n.º 6
0
 private void ReadPlayerStatsValues()
 {
     Achievements.Clear();
     Achievements.Add(new KeyValuePair <AchievementType, object>(AchievementType.Jogger, PlayerStats.KmWalked));
     Achievements.Add(new KeyValuePair <AchievementType, object>(AchievementType.Kanto,
                                                                 PlayerStats.UniquePokedexEntries));
     Achievements.Add(new KeyValuePair <AchievementType, object>(AchievementType.Collector,
                                                                 PlayerStats.PokemonsCaptured));
     Achievements.Add(new KeyValuePair <AchievementType, object>(AchievementType.Scientist, PlayerStats.Evolutions));
     Achievements.Add(new KeyValuePair <AchievementType, object>(AchievementType.Breeder, PlayerStats.EggsHatched));
     Achievements.Add(new KeyValuePair <AchievementType, object>(AchievementType.Backpacker,
                                                                 PlayerStats.PokeStopVisits));
     if (PlayerStats.PokemonCaughtByType.Any())
     {
         Achievements.Add(new KeyValuePair <AchievementType, object>(AchievementType.SchoolKid,
                                                                     PlayerStats.PokemonCaughtByType[(int)PokemonType.Normal]));
         Achievements.Add(new KeyValuePair <AchievementType, object>(AchievementType.Swimmer,
                                                                     PlayerStats.PokemonCaughtByType[(int)PokemonType.Water]));
         Achievements.Add(new KeyValuePair <AchievementType, object>(AchievementType.BlackBelt,
                                                                     PlayerStats.PokemonCaughtByType[(int)PokemonType.Fighting]));
         Achievements.Add(new KeyValuePair <AchievementType, object>(AchievementType.BirdKeeper,
                                                                     PlayerStats.PokemonCaughtByType[(int)PokemonType.Flying]));
         Achievements.Add(new KeyValuePair <AchievementType, object>(AchievementType.PunkGirl,
                                                                     PlayerStats.PokemonCaughtByType[(int)PokemonType.Poison]));
         Achievements.Add(new KeyValuePair <AchievementType, object>(AchievementType.RuinManiac,
                                                                     PlayerStats.PokemonCaughtByType[(int)PokemonType.Ground]));
         Achievements.Add(new KeyValuePair <AchievementType, object>(AchievementType.Hiker,
                                                                     PlayerStats.PokemonCaughtByType[(int)PokemonType.Rock]));
         Achievements.Add(new KeyValuePair <AchievementType, object>(AchievementType.BugCatcher,
                                                                     PlayerStats.PokemonCaughtByType[(int)PokemonType.Bug]));
         Achievements.Add(new KeyValuePair <AchievementType, object>(AchievementType.HexManiac,
                                                                     PlayerStats.PokemonCaughtByType[(int)PokemonType.Ghost]));
         Achievements.Add(new KeyValuePair <AchievementType, object>(AchievementType.DepotAgent,
                                                                     PlayerStats.PokemonCaughtByType[(int)PokemonType.Steel]));
         Achievements.Add(new KeyValuePair <AchievementType, object>(AchievementType.Kindler,
                                                                     PlayerStats.PokemonCaughtByType[(int)PokemonType.Fire]));
         Achievements.Add(new KeyValuePair <AchievementType, object>(AchievementType.Gardener,
                                                                     PlayerStats.PokemonCaughtByType[(int)PokemonType.Grass]));
         Achievements.Add(new KeyValuePair <AchievementType, object>(AchievementType.Rocker,
                                                                     PlayerStats.PokemonCaughtByType[(int)PokemonType.Electric]));
         Achievements.Add(new KeyValuePair <AchievementType, object>(AchievementType.Psychic,
                                                                     PlayerStats.PokemonCaughtByType[(int)PokemonType.Psychic]));
         Achievements.Add(new KeyValuePair <AchievementType, object>(AchievementType.Skier,
                                                                     PlayerStats.PokemonCaughtByType[(int)PokemonType.Ice]));
         Achievements.Add(new KeyValuePair <AchievementType, object>(AchievementType.DragonTamer,
                                                                     PlayerStats.PokemonCaughtByType[(int)PokemonType.Dragon]));
         Achievements.Add(new KeyValuePair <AchievementType, object>(AchievementType.FairyTaleGirl,
                                                                     PlayerStats.PokemonCaughtByType[(int)PokemonType.Fairy]));
     }
     Achievements.Add(new KeyValuePair <AchievementType, object>(AchievementType.Youngster,
                                                                 PlayerStats.SmallRattataCaught));
     Achievements.Add(new KeyValuePair <AchievementType, object>(AchievementType.Fisherman,
                                                                 PlayerStats.BigMagikarpCaught));
     Achievements.Add(new KeyValuePair <AchievementType, object>(AchievementType.AceTrainer,
                                                                 PlayerStats.BattleTrainingWon));
 }
Exemplo n.º 7
0
 private void addAchievement_Click(object sender, EventArgs e)
 {
     using (AchievementWindow window = new AchievementWindow(AchievementWindow.Operation.Add))
     {
         var result = window.ShowDialog();
         if (result == DialogResult.OK)
         {
             string row = window.Value;
             Achievements.Add(row);
         }
     }
 }
        private async Task UpdateAchievements()
        {
            await BackupData.WaitForInitAsync();

            Achievements.Clear();
            if (IsLoggedIn) //current user is logged in to the server
            {
                try
                {
                    var newlyUnlocked = await IoCManager.Resolve <IAchievementFetcher>().UpdateAchievements();

                    AchievementNotification.QueueAchievementNotifications(newlyUnlocked);

                    var achievementCounter = 0;
                    var unlockedCounter    = 0;
                    foreach (var achievement in DbManager.DataAccess.Achievements().GetAchievements())
                    {
                        Achievements.Add(AchievementViewModel.CreateFrom(achievement));

                        if (achievement.IsUnlocked)
                        {
                            unlockedCounter++;
                        }

                        achievementCounter++;
                    }

                    Score            = $"{Strings.AchievementsScreenView_Score} {AppSharedData.CurrentAchievementsScore()}";
                    AchievementCount = $"{unlockedCounter + "/" + achievementCounter}{Strings.AchievementsScreenView_Achievement_Count}";
                }
                catch (Exception e)
                {
                    Debug.WriteLine(e);

                    if ((((WebException)e.InnerException).Response as HttpWebResponse)?.StatusCode == HttpStatusCode.InternalServerError)
                    {
                        await IoCManager.Resolve <INavigationService>()
                        .DisplayAlert(Strings.Alert_Server_Error_Title,
                                      Strings.Alert_Server_Error_Description,
                                      Strings.Alert_Confirm);
                    }
                    else
                    {
                        await IoCManager.Resolve <INavigationService>()
                        .DisplayAlert(Strings.Alert_Network_Error_Title,
                                      Strings.Alert_Network_Error_Description,
                                      Strings.Alert_Confirm);
                    }
                }
            }
        }
Exemplo n.º 9
0
        public void SetAchievment(AchievementData ad, bool finished)
        {
            var index = GetDataIndex(Achievements, ad);
            var value = finished ? 1 : 0;

            if (index != -1)
            {
                Achievements[index].Value = value;
            }
            else
            {
                var ds = new DataSlot(ad, value);
                Achievements.Add(ds);
            }
        }
    public static GK_AchievementTemplate GetAchievement(string achievementId)
    {
        foreach (GK_AchievementTemplate achievement in Achievements)
        {
            if (achievement.Id.Equals(achievementId))
            {
                return(achievement);
            }
        }

        GK_AchievementTemplate new_achievement = new GK_AchievementTemplate();

        new_achievement.Id = achievementId;
        Achievements.Add(new_achievement);

        return(new_achievement);
    }
Exemplo n.º 11
0
        private void EpicWinKeyPressedMethod(KeyEventArgs e)
        {
            if (e.Key != Key.Enter)
            {
                return;
            }
            var entry = new AchievementEntry
            {
                Nick = (e.Source as AutoCompleteBox)?.Text,
                TypeOfAchievements = AchievementsType.EpicWin
            };

            Achievements.Add(entry);
            EpicWin.Add(entry);
            ((AutoCompleteBox)e.Source).Text = string.Empty;
            CountScale();
        }
Exemplo n.º 12
0
        private void ComboWfKeyPressedMethod([CanBeNull] KeyEventArgs e)
        {
            if (e?.Key != Key.Enter)
            {
                return;
            }
            var entry = new AchievementEntry
            {
                Nick = (e.Source as AutoCompleteBox)?.Text,
                TypeOfAchievements = AchievementsType.ComboFw
            };

            Achievements.Add(entry);
            ComboWf.Add(entry);
            ((AutoCompleteBox)e.Source).Text = string.Empty;
            CountScale();
        }
Exemplo n.º 13
0
        private void EpicWfKeyPressedMethod(KeyEventArgs e)
        {
            if (e.Key != Key.Enter)
            {
                return;
            }
            var nick  = (e.Source as AutoCompleteBox)?.Text;
            var entry = new AchievementEntry
            {
                Nick = nick,
                TypeOfAchievements = AchievementsType.EpicFw,
                WinSeries          = Context.SeasonRatingDbSet.FirstOrDefault(t => t.Nick == nick)?.WinRow ?? 0
            };

            Achievements.Add(entry);
            EpicWf.Add(entry);
            ((AutoCompleteBox)e.Source).Text = string.Empty;
            CountScale();
        }
Exemplo n.º 14
0
    private void OnRequestAchievementsCompleted(AGSRequestAchievementsResponse response)
    {
        if (response.IsError())
        {
            AMN_RequestAchievementsResult result = new AMN_RequestAchievementsResult(response.error);

            OnRequestAchievementsReceived(result);
        }
        else
        {
            Achievements.Clear();
            foreach (AGSAchievement achieve in response.achievements)
            {
                Achievements.Add(new GC_Achievement(achieve));
            }

            AMN_RequestAchievementsResult result = new AMN_RequestAchievementsResult(Achievements);

            OnRequestAchievementsReceived(result);
        }
    }
Exemplo n.º 15
0
    private void OnAchievementsLoaded(string data)
    {
        string[] storeData;
        storeData = data.Split(AndroidNative.DATA_SPLITTER [0]);

        GooglePlayResult result = new GooglePlayResult(storeData [0]);

        if (result.IsSucceeded)
        {
            Achievements.Clear();

            for (int i = 1; i < storeData.Length; i += 7)
            {
                if (storeData[i] == AndroidNative.DATA_EOF)
                {
                    break;
                }

                GPAchievement ach = new GPAchievement(storeData[i],
                                                      storeData[i + 1],
                                                      storeData[i + 2],
                                                      storeData[i + 3],
                                                      storeData[i + 4],
                                                      storeData[i + 5],
                                                      storeData[i + 6]
                                                      );

                Debug.Log(ach.Name);
                Debug.Log(ach.Type);


                Achievements.Add(ach);
            }

            Debug.Log("Loaded: " + Achievements.Count + " Achievements");
        }

        ActionAchievementsLoaded(result);
    }
Exemplo n.º 16
0
 public void Load(GuildAchievementsJson guildAchievementsJson)
 {
     if (CheckJson(guildAchievementsJson))
     {
         AchievementCount  = guildAchievementsJson.TotalQuantity;
         AchievementPoints = guildAchievementsJson.TotalPoints;
         if (Achievements.Any())
         {
             Achievements.Clear();
         }
         foreach (AchievementCompletionJson achievmentCompletionJson in guildAchievementsJson.Achievements)
         {
             Achievements.Add(new AchievementCompletion(achievmentCompletionJson));
         }
         if (AchievementCategoryCompletion.Any())
         {
             AchievementCategoryCompletion.Clear();
         }
         foreach (AchievementCategoryCompletionJson achievementCategoryCompletionJson in guildAchievementsJson.CategoriesProgress)
         {
             AchievementCategoryCompletion.Add(new AchievementCategoryCompletion(achievementCategoryCompletionJson));
         }
     }
 }
Exemplo n.º 17
0
        public ResultSvc <Achievement> CreateAchievement(string name, string description, string lang, int reward, int?count)
        {
            var achievement = new Achievement();
            var result      = new ResultSvc <Achievement>(achievement);

            try
            {
                if (!string.IsNullOrEmpty(name))
                {
                    achievement.UserCreatedId = Context.HttpContext.User.GetUserId();
                    achievement.AchievementLangs.Add(new AchievementLang
                    {
                        Name          = name?.Trim(),
                        Description   = description?.Trim(),
                        Lang          = lang,
                        UserCreatedId = Context.HttpContext.User.GetUserId()
                    });
                    achievement.AchievementLevels.Add(new AchievementLevel
                    {
                        Reward        = reward,
                        Count         = count,
                        UserCreatedId = Context.HttpContext.User.GetUserId()
                    });
                    Achievements.Add(achievement);
                }
                else
                {
                    result.Errors.Add("Název musí být vyplněn!");
                }
            }
            catch
            {
                result.Errors.Add("Něco se pokazilo!");
            }
            return(result);
        }
Exemplo n.º 18
0
        public void LoadFromJSON(string jsonString)
        {
            var jsonObject = JObject.Parse(jsonString);

            m_vId            = jsonObject["avatar_id"].ToObject <long>();
            m_vToken         = jsonObject["token"].ToObject <string>();
            m_vCurrentHomeId = jsonObject["current_home_id"].ToObject <long>();
            m_vAllianceId    = jsonObject["alliance_id"].ToObject <long>();
            SetAllianceCastleLevel(jsonObject["alliance_castle_level"].ToObject <int>());
            SetAllianceCastleTotalCapacity(jsonObject["alliance_castle_total_capacity"].ToObject <int>());
            SetAllianceCastleUsedCapacity(jsonObject["alliance_castle_used_capacity"].ToObject <int>());
            SetTownHallLevel(jsonObject["townhall_level"].ToObject <int>());
            m_vAvatarName  = jsonObject["avatar_name"].ToObject <string>();
            m_vAvatarLevel = jsonObject["avatar_level"].ToObject <int>();
            m_vExperience  = jsonObject["experience"].ToObject <int>();
            m_vCurrentGems = jsonObject["current_gems"].ToObject <int>();
            SetScore(jsonObject["score"].ToObject <int>());
            m_vNameChangingLeft = jsonObject["nameChangesLeft"].ToObject <byte>();
            m_vnameChosenByUser = jsonObject["nameChosenByUser"].ToObject <byte>();

            /*JArray jsonMaxResources = (JArray)jsonObject["max_resources"];
             * foreach (JObject resource in jsonMaxResources)
             * {
             *  var ds = new DataSlot(null, 0);
             *  ds.Load(resource);
             *  m_vResourceCaps.Add(ds);
             * }*/

            var jsonResources = (JArray)jsonObject["resources"];

            foreach (JObject resource in jsonResources)
            {
                var ds = new DataSlot(null, 0);
                ds.Load(resource);
                GetResources().Add(ds);
            }

            var jsonUnits = (JArray)jsonObject["units"];

            foreach (JObject unit in jsonUnits)
            {
                var ds = new DataSlot(null, 0);
                ds.Load(unit);
                m_vUnitCount.Add(ds);
            }

            var jsonSpells = (JArray)jsonObject["spells"];

            foreach (JObject spell in jsonSpells)
            {
                var ds = new DataSlot(null, 0);
                ds.Load(spell);
                m_vSpellCount.Add(ds);
            }

            var jsonUnitLevels = (JArray)jsonObject["unit_upgrade_levels"];

            foreach (JObject unitLevel in jsonUnitLevels)
            {
                var ds = new DataSlot(null, 0);
                ds.Load(unitLevel);
                m_vUnitUpgradeLevel.Add(ds);
            }

            var jsonSpellLevels = (JArray)jsonObject["spell_upgrade_levels"];

            foreach (JObject data in jsonSpellLevels)
            {
                var ds = new DataSlot(null, 0);
                ds.Load(data);
                m_vSpellUpgradeLevel.Add(ds);
            }

            var jsonHeroLevels = (JArray)jsonObject["hero_upgrade_levels"];

            foreach (JObject data in jsonHeroLevels)
            {
                var ds = new DataSlot(null, 0);
                ds.Load(data);
                m_vHeroUpgradeLevel.Add(ds);
            }

            var jsonHeroHealth = (JArray)jsonObject["hero_health"];

            foreach (JObject data in jsonHeroHealth)
            {
                var ds = new DataSlot(null, 0);
                ds.Load(data);
                m_vHeroHealth.Add(ds);
            }

            var jsonHeroState = (JArray)jsonObject["hero_state"];

            foreach (JObject data in jsonHeroState)
            {
                var ds = new DataSlot(null, 0);
                ds.Load(data);
                m_vHeroState.Add(ds);
            }

            var jsonAllianceUnits = (JArray)jsonObject["alliance_units"];

            foreach (JObject data in jsonAllianceUnits)
            {
                var ds = new DataSlot(null, 0);
                ds.Load(data);
                AllianceUnits.Add(ds);
            }
            TutorialStepsCount = jsonObject["tutorial_step"].ToObject <uint>();

            /*
             * JArray jsonUnlockedAchievements = (JArray)jsonObject["unlocked_achievements"];
             * foreach (JObject data in jsonUnlockedAchievements)
             * {
             *  var ds = new DataSlot(null, 0);
             *  ds.Load(data);
             *  AchievementsUnlocked.Add(ds);
             * }
             */

            var jsonAchievementsProgress = (JArray)jsonObject["achievements_progress"];

            foreach (JObject data in jsonAchievementsProgress)
            {
                var ds = new DataSlot(null, 0);
                ds.Load(data);
                Achievements.Add(ds);
            }

            var jsonNpcStars = (JArray)jsonObject["npc_stars"];

            foreach (JObject data in jsonNpcStars)
            {
                var ds = new DataSlot(null, 0);
                ds.Load(data);
                NpcStars.Add(ds);
            }

            var jsonNpcLootedGold = (JArray)jsonObject["npc_looted_gold"];

            foreach (JObject data in jsonNpcLootedGold)
            {
                var ds = new DataSlot(null, 0);
                ds.Load(data);
                NpcLootedGold.Add(ds);
            }

            var jsonNpcLootedElixir = (JArray)jsonObject["npc_looted_elixir"];

            foreach (JObject data in jsonNpcLootedElixir)
            {
                var ds = new DataSlot(null, 0);
                ds.Load(data);
                NpcLootedElixir.Add(ds);
            }
        }
Exemplo n.º 19
0
        private void GetUserData()
        {
            Task.Run(async() =>
            {
                User = await ServiceBus.UserService.GetUserByServerId(UserId);

                var userCvs  = await ServiceBus.UserService.GetUserCvsByServerId(UserId);
                var userInfo = await ServiceBus.UserService.GetUserInfoById(User.UserId);

                Position = userInfo?.Department ?? "?";

                InvokeOnMainThread(() => { UserTechnologyCategoryViewModels.Clear(); });

                var technologyCategoryIds = new Dictionary <string, UserTechnologyCategoryViewModel>();
                foreach (var technologyCvs in userCvs.UserCv.Technologies)
                {
                    if (!technologyCategoryIds.ContainsKey(technologyCvs.Category.Id))
                    {
                        var userTechnologyCategoryViewModel = new UserTechnologyCategoryViewModel
                        {
                            Name = technologyCvs.Category.Name
                        };
                        technologyCategoryIds.Add(technologyCvs.Category.Id, userTechnologyCategoryViewModel);

                        // TODO: Currently replaced with awful approach below
                        InvokeOnMainThread(
                            () => { CategoryViewModels.Add(userTechnologyCategoryViewModel); });
                    }

                    InvokeOnMainThread(() =>
                    {
                        technologyCategoryIds[technologyCvs.Category.Id].UserTechnologyViewModels.Add(
                            new UserTechnologyViewModel(technologyCvs.Name, technologyCvs.Stars));
                    });
                }

                // TODO: Awful approach suggested due to Nested ListViews are poorly supported.
                // TODO: Anyway, UserTechnologyCategoryViewModel has propriate collection of user technologies to create nested binding in future.
                foreach (var userTechnologyCategoryViewModel in technologyCategoryIds.OrderBy(t => t.Value.Name))
                {
                    InvokeOnMainThread(
                        () =>
                    {
                        UserTechnologyCategoryViewModels.Add(userTechnologyCategoryViewModel.Value);
                        foreach (
                            var userTechnologyViewModel in userTechnologyCategoryViewModel
                            .Value
                            .UserTechnologyViewModels
                            .OrderByDescending(i => i.Stars))
                        {
                            UserTechnologyCategoryViewModels.Add(userTechnologyViewModel);
                        }
                    });
                }

                RaisePropertyChanged(() => TechnologiesVisibility);

                foreach (var achievementId in _user.Pdp.AchievementsIds)
                {
                    var achievement       = await ServiceBus.UserService.GetAchievementsById(achievementId);
                    var userAchievementVm = new UserAchievementViewModel
                    {
                        Name     = achievement.Name,
                        Category = achievement.Category.Name,
                        ImageUri = Constants.BaseUrl + achievement.ImageUri
                    };
                    InvokeOnMainThread(() => { Achievements.Add(userAchievementVm); });
                }

                RaisePropertyChanged(() => AchievementsVisibility);

                foreach (var certificationId in _user.Pdp.CertificationsIds)
                {
                    var certification       = await ServiceBus.UserService.GetCertificateByIdAsync(certificationId);
                    var userCertificationVm = new UserCertificationViewModel
                    {
                        Name     = certification.Name,
                        Category = certification.Category.Name,
                        ImageUri = Constants.BaseUrl + certification.ImageUri
                    };
                    InvokeOnMainThread(() => { Certifications.Add(userCertificationVm); });
                }

                RaisePropertyChanged(() => CertificationsVisibility);
            });
        }
Exemplo n.º 20
0
        public void LoadFromJson(string jsonString)
        {
            var jsonObject = JObject.Parse(jsonString);

            m_vId                  = jsonObject["avatar_id"].ToObject <long>();
            m_vHighInt             = jsonObject["id_high_int"].ToObject <int>();
            m_vLowInt              = jsonObject["id_low_int"].ToObject <int>();
            m_vToken               = jsonObject["token"].ToObject <string>();
            m_vRegion              = jsonObject["region"].ToObject <string>();
            m_vAccountCreationDate = jsonObject["avatar_creation_date"].ToObject <DateTime>();
            m_vActiveLayout        = jsonObject["active_layout"].ToObject <int>();
            m_vAndroid             = jsonObject["android"].ToObject <bool>();
            m_vCurrentHomeId       = jsonObject["current_home_id"].ToObject <long>();
            m_vAllianceId          = jsonObject["alliance_id"].ToObject <long>();
            SetAllianceCastleLevel(jsonObject["alliance_castle_level"].ToObject <int>());
            SetAllianceCastleTotalCapacity(jsonObject["alliance_castle_total_capacity"].ToObject <int>());
            SetAllianceCastleUsedCapacity(jsonObject["alliance_castle_used_capacity"].ToObject <int>());
            SetTownHallLevel(jsonObject["townhall_level"].ToObject <int>());
            m_vAvatarName  = jsonObject["avatar_name"].ToObject <string>();
            m_vAvatarLevel = jsonObject["avatar_level"].ToObject <int>();
            m_vExperience  = jsonObject["experience"].ToObject <int>();
            m_vCurrentGems = jsonObject["current_gems"].ToObject <int>();
            SetScore(jsonObject["score"].ToObject <int>());
            m_vNameChangingLeft = jsonObject["nameChangesLeft"].ToObject <byte>();
            m_vnameChosenByUser = jsonObject["nameChosenByUser"].ToObject <byte>();

            var jsonBookmarkedClan = (JArray)jsonObject["bookmark"];

            foreach (JObject jobject in jsonBookmarkedClan)
            {
                var data = (JObject)jobject;
                var ds   = new BookmarkSlot(0);
                ds.Load(data);
                BookmarkedClan.Add(ds);
            }

            var jsonResources = (JArray)jsonObject["resources"];

            foreach (JObject resource in jsonResources)
            {
                var ds = new DataSlot(null, 0);
                ds.Load(resource);
                GetResources().Add(ds);
            }

            var jsonUnits = (JArray)jsonObject["units"];

            foreach (JObject unit in jsonUnits)
            {
                var ds = new DataSlot(null, 0);
                ds.Load(unit);
                m_vUnitCount.Add(ds);
            }

            var jsonSpells = (JArray)jsonObject["spells"];

            foreach (JObject spell in jsonSpells)
            {
                var ds = new DataSlot(null, 0);
                ds.Load(spell);
                m_vSpellCount.Add(ds);
            }

            var jsonUnitLevels = (JArray)jsonObject["unit_upgrade_levels"];

            foreach (JObject unitLevel in jsonUnitLevels)
            {
                var ds = new DataSlot(null, 0);
                ds.Load(unitLevel);
                m_vUnitUpgradeLevel.Add(ds);
            }

            var jsonSpellLevels = (JArray)jsonObject["spell_upgrade_levels"];

            foreach (JObject data in jsonSpellLevels)
            {
                var ds = new DataSlot(null, 0);
                ds.Load(data);
                m_vSpellUpgradeLevel.Add(ds);
            }

            var jsonHeroLevels = (JArray)jsonObject["hero_upgrade_levels"];

            foreach (JObject data in jsonHeroLevels)
            {
                var ds = new DataSlot(null, 0);
                ds.Load(data);
                m_vHeroUpgradeLevel.Add(ds);
            }

            var jsonHeroHealth = (JArray)jsonObject["hero_health"];

            foreach (JObject data in jsonHeroHealth)
            {
                var ds = new DataSlot(null, 0);
                ds.Load(data);
                m_vHeroHealth.Add(ds);
            }

            var jsonHeroState = (JArray)jsonObject["hero_state"];

            foreach (JObject data in jsonHeroState)
            {
                var ds = new DataSlot(null, 0);
                ds.Load(data);
                m_vHeroState.Add(ds);
            }

            var jsonAllianceUnits = (JArray)jsonObject["alliance_units"];

            foreach (JObject data in jsonAllianceUnits)
            {
                var ds = new TroopDataSlot(null, 0, 0);
                ds.Load(data);
                AllianceUnits.Add(ds);
            }
            TutorialStepsCount = jsonObject["tutorial_step"].ToObject <uint>();

            var jsonAchievementsProgress = (JArray)jsonObject["achievements_progress"];

            foreach (JObject data in jsonAchievementsProgress)
            {
                var ds = new DataSlot(null, 0);
                ds.Load(data);
                Achievements.Add(ds);
            }

            var jsonNpcStars = (JArray)jsonObject["npc_stars"];

            foreach (JObject data in jsonNpcStars)
            {
                var ds = new DataSlot(null, 0);
                ds.Load(data);
                NpcStars.Add(ds);
            }

            var jsonNpcLootedGold = (JArray)jsonObject["npc_looted_gold"];

            foreach (JObject data in jsonNpcLootedGold)
            {
                var ds = new DataSlot(null, 0);
                ds.Load(data);
                NpcLootedGold.Add(ds);
            }

            var jsonNpcLootedElixir = (JArray)jsonObject["npc_looted_elixir"];

            foreach (JObject data in jsonNpcLootedElixir)
            {
                var ds = new DataSlot(null, 0);
                ds.Load(data);
                NpcLootedElixir.Add(ds);
            }
            var jsonQuickTrain1 = (JArray)jsonObject["quick_train_1"];

            foreach (JObject data in jsonQuickTrain1)
            {
                var ds = new DataSlot(null, 0);
                ds.Load(data);
                QuickTrain1.Add(ds);
            }
            var jsonQuickTrain2 = (JArray)jsonObject["quick_train_2"];

            foreach (JObject data in jsonQuickTrain2)
            {
                var ds = new DataSlot(null, 0);
                ds.Load(data);
                QuickTrain2.Add(ds);
            }
            var jsonQuickTrain3 = (JArray)jsonObject["quick_train_3"];

            foreach (JObject data in jsonQuickTrain3)
            {
                var ds = new DataSlot(null, 0);
                ds.Load(data);
                QuickTrain3.Add(ds);
            }
            m_vPremium = jsonObject["Premium"].ToObject <bool>();
        }
 public void Add(Achievement achievement)
 {
     Achievements.Add(achievement);
 }
Exemplo n.º 22
0
        public void LoadFromJSON(string jsonString)
        {
            var jsonObject = JObject.Parse(jsonString);

            this.UserId    = jsonObject["avatar_id"].ToObject <long>();
            this.HighID    = jsonObject["id_high_int"].ToObject <int>();
            this.LowID     = jsonObject["id_low_int"].ToObject <int>();
            this.UserToken = jsonObject["token"].ToObject <string>();
            this.Region    = jsonObject["region"].ToObject <string>();
            this.IPAddress = jsonObject["IPAddress"].ToObject <string>();
            this.m_vAccountCreationDate = jsonObject["avatar_creation_date"].ToObject <DateTime>();
            this.AccountPrivileges      = jsonObject["avatar_privilages"].ToObject <byte>();
            this.AccountBanned          = jsonObject["avatar_banned"].ToObject <bool>();
            this.m_vActiveLayout        = jsonObject["active_layout"].ToObject <int>();
            this.LastTickSaved          = jsonObject["last_tick_save"].ToObject <DateTime>();
            this.m_vAndroid             = jsonObject["android"].ToObject <bool>();
            this.CurrentHomeId          = jsonObject["current_home_id"].ToObject <long>();
            this.AllianceId             = jsonObject["alliance_id"].ToObject <long>();
            SetAllianceCastleLevel(jsonObject["alliance_castle_level"].ToObject <int>());
            SetAllianceCastleTotalCapacity(jsonObject["alliance_castle_total_capacity"].ToObject <int>());
            SetAllianceCastleUsedCapacity(jsonObject["alliance_castle_used_capacity"].ToObject <int>());
            SetTownHallLevel(jsonObject["townhall_level"].ToObject <int>());
            this.AvatarName     = jsonObject["avatar_name"].ToObject <string>();
            this.m_vAvatarLevel = jsonObject["avatar_level"].ToObject <int>();
            this.m_vExperience  = jsonObject["experience"].ToObject <int>();
            this.m_vCurrentGems = jsonObject["current_gems"].ToObject <int>();
            SetScore(jsonObject["score"].ToObject <int>());
            this.m_vNameChangingLeft = jsonObject["nameChangesLeft"].ToObject <byte>();
            this.m_vnameChosenByUser = jsonObject["nameChosenByUser"].ToObject <byte>();
            this.m_vShieldTime       = jsonObject["shield_time"].ToObject <int>();
            this.m_vProtectionTime   = jsonObject["protection_time"].ToObject <int>();
            this.FacebookId          = jsonObject["fb_id"].ToObject <string>();
            this.FacebookToken       = jsonObject["fb_token"].ToObject <string>();
            this.GoogleId            = jsonObject["gg_id"].ToObject <string>();
            this.m_vReceived         = jsonObject["troops_received"].ToObject <int>();
            this.m_vDonated          = jsonObject["troops_donated"].ToObject <int>();
            this.GoogleToken         = jsonObject["gg_token"].ToObject <string>();
            this.TroopRequestMessage = jsonObject["rq_message"].ToObject <string>();
            JArray jsonBookmarkedClan = (JArray)jsonObject["bookmark"];

            foreach (JObject jobject in jsonBookmarkedClan)
            {
                JObject      data = (JObject)jobject;
                BookmarkSlot ds   = new BookmarkSlot(0);
                ds.Load(data);
                BookmarkedClan.Add(ds);
            }

            JArray jsonResources = (JArray)jsonObject["resources"];

            foreach (JObject resource in jsonResources)
            {
                DataSlot ds = new DataSlot(null, 0);
                ds.Load(resource);
                GetResources().Add(ds);
            }

            JArray jsonUnits = (JArray)jsonObject["units"];

            foreach (JObject unit in jsonUnits)
            {
                DataSlot ds = new DataSlot(null, 0);
                ds.Load(unit);
                m_vUnitCount.Add(ds);
            }

            JArray jsonSpells = (JArray)jsonObject["spells"];

            foreach (JObject spell in jsonSpells)
            {
                DataSlot ds = new DataSlot(null, 0);
                ds.Load(spell);
                m_vSpellCount.Add(ds);
            }

            JArray jsonUnitLevels = (JArray)jsonObject["unit_upgrade_levels"];

            foreach (JObject unitLevel in jsonUnitLevels)
            {
                DataSlot ds = new DataSlot(null, 0);
                ds.Load(unitLevel);
                m_vUnitUpgradeLevel.Add(ds);
            }

            JArray jsonSpellLevels = (JArray)jsonObject["spell_upgrade_levels"];

            foreach (JObject data in jsonSpellLevels)
            {
                DataSlot ds = new DataSlot(null, 0);
                ds.Load(data);
                m_vSpellUpgradeLevel.Add(ds);
            }

            JArray jsonHeroLevels = (JArray)jsonObject["hero_upgrade_levels"];

            foreach (JObject data in jsonHeroLevels)
            {
                DataSlot ds = new DataSlot(null, 0);
                ds.Load(data);
                m_vHeroUpgradeLevel.Add(ds);
            }

            JArray jsonHeroHealth = (JArray)jsonObject["hero_health"];

            foreach (JObject data in jsonHeroHealth)
            {
                DataSlot ds = new DataSlot(null, 0);
                ds.Load(data);
                m_vHeroHealth.Add(ds);
            }

            JArray jsonHeroState = (JArray)jsonObject["hero_state"];

            foreach (JObject data in jsonHeroState)
            {
                DataSlot ds = new DataSlot(null, 0);
                ds.Load(data);
                m_vHeroState.Add(ds);
            }

            JArray jsonAllianceUnits = (JArray)jsonObject["alliance_units"];

            foreach (JObject data in jsonAllianceUnits)
            {
                DonationSlot ds = new DonationSlot(0, 0, 0, 0);
                ds.Load(data);
                AllianceUnits.Add(ds);
            }
            TutorialStepsCount = jsonObject["tutorial_step"].ToObject <uint>();

            JArray jsonAchievementsProgress = (JArray)jsonObject["achievements_progress"];

            foreach (JObject data in jsonAchievementsProgress)
            {
                DataSlot ds = new DataSlot(null, 0);
                ds.Load(data);
                Achievements.Add(ds);
            }

            JArray jsonNpcStars = (JArray)jsonObject["npc_stars"];

            foreach (JObject data in jsonNpcStars)
            {
                DataSlot ds = new DataSlot(null, 0);
                ds.Load(data);
                NpcStars.Add(ds);
            }

            JArray jsonNpcLootedGold = (JArray)jsonObject["npc_looted_gold"];

            foreach (JObject data in jsonNpcLootedGold)
            {
                DataSlot ds = new DataSlot(null, 0);
                ds.Load(data);
                NpcLootedGold.Add(ds);
            }

            JArray jsonNpcLootedElixir = (JArray)jsonObject["npc_looted_elixir"];

            foreach (JObject data in jsonNpcLootedElixir)
            {
                DataSlot ds = new DataSlot(null, 0);
                ds.Load(data);
                NpcLootedElixir.Add(ds);
            }
            JArray jsonQuickTrain1 = (JArray)jsonObject["quick_train_1"];

            foreach (JObject data in jsonQuickTrain1)
            {
                DataSlot ds = new DataSlot(null, 0);
                ds.Load(data);
                QuickTrain1.Add(ds);
            }
            JArray jsonQuickTrain2 = (JArray)jsonObject["quick_train_2"];

            foreach (JObject data in jsonQuickTrain2)
            {
                DataSlot ds = new DataSlot(null, 0);
                ds.Load(data);
                QuickTrain2.Add(ds);
            }
            JArray jsonQuickTrain3 = (JArray)jsonObject["quick_train_3"];

            foreach (JObject data in jsonQuickTrain3)
            {
                DataSlot ds = new DataSlot(null, 0);
                ds.Load(data);
                QuickTrain3.Add(ds);
            }
            m_vPremium = jsonObject["Premium"].ToObject <bool>();
        }