public CouchbaseSettings(LogicJSONObject jsonObject) { LogicJSONArray serverArray = jsonObject.GetJSONArray("servers"); LogicJSONArray bucketArray = jsonObject.GetJSONArray("buckets"); this.Servers = new LogicArrayList <CouchbaseServerEntry>(serverArray.Size()); this.Buckets = new LogicArrayList <CouchbaseBucketEntry>(bucketArray.Size()); for (int i = 0; i < serverArray.Size(); i++) { this.Servers.Add(new CouchbaseServerEntry(serverArray.GetJSONObject(i))); } for (int i = 0; i < bucketArray.Size(); i++) { CouchbaseBucketEntry entry = new CouchbaseBucketEntry(bucketArray.GetJSONString(i)); if (this.GetBucketIdx(entry.Name) != -1) { Logging.Warning("EnvironmentSettings::CouchbaseSettings.ctr: bucket with the same name already exists."); continue; } if ((uint)entry.ServerIndex >= this.Servers.Size()) { Logging.Warning(string.Format("EnvironmentSettings::CouchbaseSettings.ctr: server index is out of bounds (bucket name: {0})", entry.ServerIndex)); continue; } this.Buckets.Add(entry); } }
protected sealed override void Load(LogicJSONObject jsonObject) { LogicJSONArray allianceRankingListArray = jsonObject.GetJSONArray(SeasonDocument.JSON_ATTRIBUTE_ALLIANCE_RANKINGS); LogicJSONArray avatarRankingArray = jsonObject.GetJSONArray(SeasonDocument.JSON_ATTRIBUTE_AVATAR_RANKINGS); LogicJSONArray avatarDuelRankingArray = jsonObject.GetJSONArray(SeasonDocument.JSON_ATTRIBUTE_AVATAR_DUEL_RANKINGS); for (int i = 0; i < 2; i++) { LogicJSONArray allianceRankingArray = allianceRankingListArray.GetJSONArray(i); LogicArrayList <AllianceRankingEntry> allianceRankingList = this.AllianceRankingList[i]; for (int j = 0; j < allianceRankingArray.Size(); j++) { AllianceRankingEntry allianceRankingEntry = new AllianceRankingEntry(); allianceRankingEntry.Load(allianceRankingArray.GetJSONObject(j)); allianceRankingList.Add(allianceRankingEntry); } } for (int i = 0; i < avatarRankingArray.Size(); i++) { AvatarRankingEntry avatarRankingEntry = new AvatarRankingEntry(); avatarRankingEntry.Load(avatarRankingArray.GetJSONObject(i)); this.AvatarRankingList.Add(avatarRankingEntry); } for (int i = 0; i < avatarDuelRankingArray.Size(); i++) { AvatarDuelRankingEntry avatarDuelRankingEntry = new AvatarDuelRankingEntry(); avatarDuelRankingEntry.Load(avatarDuelRankingArray.GetJSONObject(i)); this.AvatarDuelRankingList.Add(avatarDuelRankingEntry); } this.NextCheckTime = DateTime.Parse(jsonObject.GetJSONString(SeasonDocument.JSON_ATTRIBUTE_NEXT_CHECK_TIME).GetStringValue()); }
/// <summary> /// Loads resources file. /// </summary> private static void LoadResources() { ResourceManager.ContentUrlList = new LogicArrayList <string>(); ResourceManager.ChronosContentUrlList = new LogicArrayList <string>(); ResourceManager.AppStoreUrlList = new LogicArrayList <string>(); string resourceFile = WebManager.DownloadConfigString("/res/resources.json"); if (resourceFile != null) { LogicJSONObject jsonObject = (LogicJSONObject)LogicJSONParser.Parse(resourceFile); LogicJSONArray contentArray = jsonObject.GetJSONArray("content"); LogicJSONArray chronosContentArray = jsonObject.GetJSONArray("chronosContent"); LogicJSONArray appStoreArray = jsonObject.GetJSONArray("appstore"); for (int i = 0; i < contentArray.Size(); i++) { ResourceManager.ContentUrlList.Add(contentArray.GetJSONString(i).GetStringValue()); } for (int i = 0; i < chronosContentArray.Size(); i++) { ResourceManager.ChronosContentUrlList.Add(chronosContentArray.GetJSONString(i).GetStringValue()); } for (int i = 0; i < appStoreArray.Size(); i++) { ResourceManager.AppStoreUrlList.Add(appStoreArray.GetJSONString(i).GetStringValue()); } } else { Debugger.Error("ResourceManager::loadResources resources.json not exist"); } }
public override void Load(LogicJSONObject jsonObject) { LogicJSONObject baseObject = jsonObject.GetJSONObject("base"); if (baseObject == null) { Debugger.Error("ChatStreamEntry::load base is NULL"); } base.Load(baseObject); this.m_castleLevel = LogicJSONHelper.GetInt(jsonObject, "castle_level"); this.m_castleUsedCapacity = LogicJSONHelper.GetInt(jsonObject, "castle_used"); this.m_castleUsedSpellCapacity = LogicJSONHelper.GetInt(jsonObject, "castle_sp_used"); this.m_castleTotalCapacity = LogicJSONHelper.GetInt(jsonObject, "castle_total"); this.m_castleTotalSpellCapacity = LogicJSONHelper.GetInt(jsonObject, "castle_sp_total"); LogicJSONString messageObject = jsonObject.GetJSONString("message"); if (messageObject != null) { this.m_message = messageObject.GetStringValue(); } LogicJSONArray donationArray = jsonObject.GetJSONArray("donators"); if (donationArray != null) { for (int i = 0; i < donationArray.Size(); i++) { DonationContainer donationContainer = new DonationContainer(); donationContainer.Load(donationArray.GetJSONObject(i)); this.m_donationContainerList.Add(donationContainer); } } LogicJSONArray unitArray = jsonObject.GetJSONArray("units"); if (unitArray != null) { this.m_unitCount = new LogicArrayList <LogicUnitSlot>(); for (int i = 0; i < unitArray.Size(); i++) { LogicUnitSlot unitSlot = new LogicUnitSlot(null, -1, 0); unitSlot.ReadFromJSON(unitArray.GetJSONObject(i)); this.m_unitCount.Add(unitSlot); } } }
public static void LoadDebugJSON(LogicLevel level, string json) { LogicJSONObject jsonObject = LogicJSONParser.ParseObject(json); if (jsonObject != null) { LogicArrayList <LogicComponent> unitStorageComponents = level.GetComponentManager().GetComponents(LogicComponentType.UNIT_STORAGE); for (int i = 0; i < unitStorageComponents.Size(); i++) { ((LogicUnitStorageComponent)unitStorageComponents[i]).RemoveAllUnits(); } level.SetLoadingVillageType(0); LogicDebugUtil.LoadDebugJSONArray(level, jsonObject.GetJSONArray("buildings"), LogicGameObjectType.BUILDING, 0); LogicDebugUtil.LoadDebugJSONArray(level, jsonObject.GetJSONArray("obstacles"), LogicGameObjectType.OBSTACLE, 0); LogicDebugUtil.LoadDebugJSONArray(level, jsonObject.GetJSONArray("traps"), LogicGameObjectType.TRAP, 0); LogicDebugUtil.LoadDebugJSONArray(level, jsonObject.GetJSONArray("decos"), LogicGameObjectType.DECO, 0); level.SetLoadingVillageType(1); LogicDebugUtil.LoadDebugJSONArray(level, jsonObject.GetJSONArray("buildings2"), LogicGameObjectType.BUILDING, 1); LogicDebugUtil.LoadDebugJSONArray(level, jsonObject.GetJSONArray("obstacles2"), LogicGameObjectType.OBSTACLE, 1); LogicDebugUtil.LoadDebugJSONArray(level, jsonObject.GetJSONArray("traps2"), LogicGameObjectType.TRAP, 1); LogicDebugUtil.LoadDebugJSONArray(level, jsonObject.GetJSONArray("decos2"), LogicGameObjectType.DECO, 1); level.SetLoadingVillageType(-1); } }
protected override void Load(LogicJSONObject jsonObject) { this.LogicClientAvatar.Load(jsonObject); this.LogicClientHome.Load(jsonObject.GetJSONObject(GameDocument.JSON_ATTRIBUTE_HOME)); this.SaveTime = jsonObject.GetJSONNumber(GameDocument.JSON_ATTRIBUTE_SAVE_TIME).GetIntValue(); this.MaintenanceTime = jsonObject.GetJSONNumber(GameDocument.JSON_ATTRIBUTE_MAINTENANCE_TIME).GetIntValue(); LogicJSONArray recentlyMatchedEnemyArray = jsonObject.GetJSONArray(GameDocument.JSON_ATTRIBUTE_RECENTLY_MATCHED_ENEMIES); if (recentlyMatchedEnemyArray != null) { for (int i = 0; i < recentlyMatchedEnemyArray.Size(); i++) { LogicJSONArray value = recentlyMatchedEnemyArray.GetJSONArray(i); this.RecentlyMatchedEnemies.Add(new RecentlyEnemy(new LogicLong(value.GetJSONNumber(0).GetIntValue(), value.GetJSONNumber(1).GetIntValue()), value.GetJSONNumber(2).GetIntValue())); } } LogicJSONArray allianceBookmarksArray = jsonObject.GetJSONArray(GameDocument.JSON_ATTRIBUTE_ALLIANCE_BOOKMARKS_LIST); if (allianceBookmarksArray != null) { this.AllianceBookmarksList.EnsureCapacity(allianceBookmarksArray.Size()); for (int i = 0; i < allianceBookmarksArray.Size(); i++) { LogicJSONArray value = allianceBookmarksArray.GetJSONArray(i); this.AllianceBookmarksList.Add(new LogicLong(value.GetJSONNumber(0).GetIntValue(), value.GetJSONNumber(1).GetIntValue())); } } LogicJSONArray avatarStreamArray = jsonObject.GetJSONArray(GameDocument.JSON_ATTRIBUTE_AVATAR_STREAM_LIST); if (avatarStreamArray != null) { this.AvatarStreamList.EnsureCapacity(avatarStreamArray.Size()); for (int i = 0; i < avatarStreamArray.Size(); i++) { LogicJSONArray value = avatarStreamArray.GetJSONArray(i); this.AvatarStreamList.Add(new LogicLong(value.GetJSONNumber(0).GetIntValue(), value.GetJSONNumber(1).GetIntValue())); } } this.SetLogicId(this.Id); }
public override void Load(LogicJSONObject jsonObject) { LogicJSONObject baseObject = jsonObject.GetJSONObject("base"); if (baseObject == null) { Debugger.Error("AllianceGiftStreamEntry::load base is NULL"); } base.Load(baseObject); this.m_diamondReward = jsonObject.GetJSONNumber("diamond_reward").GetIntValue(); this.m_giftCount = jsonObject.GetJSONNumber("gift_count").GetIntValue(); LogicJSONArray collectedPlayersArray = jsonObject.GetJSONArray("collected_players"); for (int i = 0; i < collectedPlayersArray.Size(); i++) { LogicJSONArray idArray = collectedPlayersArray.GetJSONArray(i); LogicLong id = new LogicLong(idArray.GetJSONNumber(0).GetIntValue(), idArray.GetJSONNumber(1).GetIntValue()); if (this.m_collectedPlayers.IndexOf(id) == -1) { this.m_collectedPlayers.Add(id); } } }
public override void Load(LogicJSONObject jsonObject) { LogicJSONBoolean initialSpawnDoneBoolean = jsonObject.GetJSONBoolean("initial_spawn_done"); if (initialSpawnDoneBoolean != null) { this.m_initialSpawnDone = initialSpawnDoneBoolean.IsTrue(); } if (this.m_timer != null) { this.m_timer.Destruct(); this.m_timer = null; } this.m_timer = LogicTimer.GetLogicTimer(jsonObject, this.m_parent.GetLevel().GetLogicTime(), "spawn_timer", this.m_intervalSeconds); LogicJSONNumber lifetimeSpawnsNumber = jsonObject.GetJSONNumber("lifetime_spawns"); if (lifetimeSpawnsNumber != null) { this.m_lifeTimeSpawns = lifetimeSpawnsNumber.GetIntValue(); } LogicJSONArray spawnedArray = jsonObject.GetJSONArray("spawned"); if (spawnedArray != null) { for (int i = 0; i < spawnedArray.Size(); i++) { this.m_spawned.Add(spawnedArray.GetJSONNumber(i).GetIntValue()); } } }
public void Load(LogicJSONObject jsonObject) { Debugger.DoAssert(this.m_errorHandler != null, "LogicCalendarErrorHandler must not be NULL!"); if (jsonObject == null) { this.m_errorHandler.ErrorFunction(this.m_calendarEvent, this, "Event function malformed."); return; } string name = LogicJSONHelper.GetString(jsonObject, "name"); this.m_functionData = LogicDataTables.GetCalendarEventFunctionByName(name, null); if (this.m_functionData == null) { this.m_errorHandler.ErrorFunction(this.m_calendarEvent, this, string.Format("event function '{0}' not found.", name)); return; } LogicJSONArray parameterArray = jsonObject.GetJSONArray("parameters"); if (parameterArray != null) { for (int i = 0; i < parameterArray.Size(); i++) { this.m_parameters.Add(parameterArray.GetJSONString(i).GetStringValue()); } } this.LoadingFinished(); }
public void Load(LogicJSONObject jsonObject) { LogicJSONNumber avatarIdHighObject = jsonObject.GetJSONNumber("avatar_id_high"); LogicJSONNumber avatarIdLowObject = jsonObject.GetJSONNumber("avatar_id_low"); if (avatarIdHighObject != null && avatarIdLowObject != null) { this.m_avatarId = new LogicLong(avatarIdHighObject.GetIntValue(), avatarIdLowObject.GetIntValue()); } LogicJSONArray donationArray = jsonObject.GetJSONArray("donations"); if (donationArray != null) { for (int i = 0; i < donationArray.Size(); i++) { LogicJSONArray array = donationArray.GetJSONArray(i); if (array != null && array.Size() == 2) { LogicData data = LogicDataTables.GetDataById(array.GetJSONNumber(0).GetIntValue()); if (data != null) { this.m_donationData.Add((LogicCombatItemData)data); this.m_donationLevel.Add(array.GetJSONNumber(1).GetIntValue()); } } } } }
/// <summary> /// Laods the calendar. /// </summary> public void Load(string json, int activeTimestamp) { Debugger.DoAssert(json != null, "Event json NULL"); if (json.Length > 0) { LogicJSONObject jsonObject = (LogicJSONObject)LogicJSONParser.Parse(json); if (jsonObject != null) { LogicJSONArray eventArray = jsonObject.GetJSONArray("events"); if (eventArray != null) { for (int i = 0; i < eventArray.Size(); i++) { LogicJSONObject calendarObject = eventArray.GetJSONObject(i); if (calendarObject != null) { } else { Debugger.Error("Events json malformed!"); } } } } else { Debugger.Error("Events json malformed!"); } } }
/// <summary> /// Loads this instance from json. /// </summary> internal void Load(string json) { LogicJSONObject jsonObject = (LogicJSONObject)LogicJSONParser.Parse(json); this.Id = new LogicLong(LogicJSONHelper.GetJSONNumber(jsonObject, "id_hi"), LogicJSONHelper.GetJSONNumber(jsonObject, "id_lo")); this.PassToken = LogicJSONHelper.GetJSONString(jsonObject, "pass_t"); this.PlayTimeSecs = LogicJSONHelper.GetJSONNumber(jsonObject, "pt_secs"); this.AccountCreatedDate = LogicJSONHelper.GetJSONString(jsonObject, "acc_cr"); this.TotalBan = LogicJSONHelper.GetJSONNumber(jsonObject, "t_ban"); LogicJSONArray sessionArray = jsonObject.GetJSONArray("sessions"); if (sessionArray != null) { int size = LogicMath.Min(sessionArray.Size(), 20); for (int i = 0; i < size; i++) { LogicJSONObject obj = sessionArray.GetJSONObject(i); AccountSession session = new AccountSession(); session.Load(obj); this.LastSessions.Add(session); } } LogicJSONObject banObject = jsonObject.GetJSONObject("ban"); if (banObject != null) { this.CurrentBan = new AccountBan(); this.CurrentBan.Load(banObject); } }
public void Load(LogicJSONObject jsonObject) { this.m_streamData = Convert.FromBase64String(jsonObject.GetJSONString(ReplayStreamEntry.JSON_ATTRIBUTE_STREAM_DATA).GetStringValue()); LogicJSONArray versionArray = jsonObject.GetJSONArray(ReplayStreamEntry.JSON_ATTRIBUTE_STREAM_VERSION); this.m_majorVersion = versionArray.GetJSONNumber(0).GetIntValue(); this.m_buildVersion = versionArray.GetJSONNumber(1).GetIntValue(); this.m_contentVersion = versionArray.GetJSONNumber(2).GetIntValue(); }
public virtual void Load(LogicJSONObject jsonObject) { LogicJSONArray idArray = jsonObject.GetJSONArray(RankingEntry.JSON_ATTRIBUTE_ID); this.m_id = new LogicLong(idArray.GetJSONNumber(0).GetIntValue(), idArray.GetJSONNumber(1).GetIntValue()); this.m_name = jsonObject.GetJSONString(RankingEntry.JSON_ATTRIBUTE_NAME).GetStringValue(); this.m_order = jsonObject.GetJSONNumber(RankingEntry.JSON_ATTRIBUTE_ORDER).GetIntValue(); this.m_previousOrder = jsonObject.GetJSONNumber(RankingEntry.JSON_ATTRIBUTE_PREVIOUS_ORDER).GetIntValue(); this.m_score = jsonObject.GetJSONNumber(RankingEntry.JSON_ATTRIBUTE_SCORE).GetIntValue(); }
public RedisSettings(LogicJSONObject jsonObject) { LogicJSONArray databases = jsonObject.GetJSONArray("databases"); this.Databases = new LogicArrayList <RedisDatabaseEntry>(databases.Size()); for (int i = 0; i < databases.Size(); i++) { this.Databases.Add(new RedisDatabaseEntry(databases.GetJSONObject(i))); } }
public CouchbaseServerEntry(LogicJSONObject jsonObject) { LogicJSONArray hostArray = jsonObject.GetJSONArray("hosts"); this.Hosts = new Uri[hostArray.Size()]; for (int i = 0; i < hostArray.Size(); i++) { this.Hosts[i] = new Uri("http://" + hostArray.GetJSONString(i).GetStringValue()); } this.Username = jsonObject.GetJSONString("username").GetStringValue(); this.Password = jsonObject.GetJSONString("password").GetStringValue(); }
public override int Execute(LogicLevel level) { LogicClientAvatar playerAvatar = level.GetPlayerAvatar(); if (playerAvatar != null) { LogicGameObjectManager gameObjectManager = level.GetGameObjectManagerAt(1); if (gameObjectManager.GetTownHall() == null) { LogicJSONObject jsonObject = level.GetGameListener().ParseCompressedHomeJSON(this.m_compressedHomeJSON, this.m_compressedHomeJSON.Length); level.SetLoadingVillageType(1); this.LoadGameObjectsJsonArray(level, jsonObject.GetJSONArray("buildings2"), 1); this.LoadGameObjectsJsonArray(level, jsonObject.GetJSONArray("obstacles2"), 1); this.LoadGameObjectsJsonArray(level, jsonObject.GetJSONArray("traps2"), 1); this.LoadGameObjectsJsonArray(level, jsonObject.GetJSONArray("decos2"), 1); level.SetLoadingVillageType(-1); if (playerAvatar.GetResourceCount(LogicDataTables.GetGold2Data()) == 0) { playerAvatar.CommodityCountChangeHelper(0, LogicDataTables.GetGold2Data(), LogicDataTables.GetGlobals().GetStartingGold2()); } if (playerAvatar.GetResourceCount(LogicDataTables.GetElixir2Data()) == 0) { playerAvatar.CommodityCountChangeHelper(0, LogicDataTables.GetElixir2Data(), LogicDataTables.GetGlobals().GetStartingElixir2()); } } return(0); } return(-1); }
protected sealed override void Load(LogicJSONObject jsonObject) { this.Header.Load(jsonObject); this.Header.SetAllianceId(this.Id); this.Description = jsonObject.GetJSONString(AllianceDocument.JSON_ATTRIBUTE_DESCRIPTION).GetStringValue(); LogicJSONArray memberArray = jsonObject.GetJSONArray(AllianceDocument.JSON_ATTRIBUTE_MEMBERS); for (int i = 0; i < memberArray.Size(); i++) { AllianceMemberEntry allianceMemberEntry = new AllianceMemberEntry(); allianceMemberEntry.Load(memberArray.GetJSONObject(i)); this.Members.Add(allianceMemberEntry.GetAvatarId(), allianceMemberEntry); } LogicJSONArray kickedMemberTimeArray = jsonObject.GetJSONArray(AllianceDocument.JSON_ATTRIBUTE_KICKED_MEMBER_TIMES); for (int i = 0; i < kickedMemberTimeArray.Size(); i++) { LogicJSONObject obj = kickedMemberTimeArray.GetJSONObject(i); LogicJSONArray avatarIdArray = obj.GetJSONArray(AllianceDocument.JSON_ATTRIBUTE_KICKED_MEMBER_TIMES_ID); LogicLong avatarId = new LogicLong(avatarIdArray.GetJSONNumber(0).GetIntValue(), avatarIdArray.GetJSONNumber(1).GetIntValue()); DateTime kickTime = DateTime.Parse(obj.GetJSONString(AllianceDocument.JSON_ATTRIBUTE_KICKED_MEMBER_TIMES_TIME).GetStringValue()); this.KickedMembersTimes.Add(avatarId, kickTime); } LogicJSONArray streamArray = jsonObject.GetJSONArray(AllianceDocument.JSON_ATTRIBUTE_STREAM_ENTRY_LIST); for (int i = 0; i < streamArray.Size(); i++) { LogicJSONArray avatarIdArray = streamArray.GetJSONArray(i); LogicLong id = new LogicLong(avatarIdArray.GetJSONNumber(0).GetIntValue(), avatarIdArray.GetJSONNumber(1).GetIntValue()); this.StreamEntryList.Add(id); } }
/// <summary> /// Loads this instance from json. /// </summary> public override void Load(LogicJSONObject jsonObject) { LogicJSONObject unitProductionObject = jsonObject.GetJSONObject("up2"); if (unitProductionObject != null) { LogicJSONNumber timerObject = jsonObject.GetJSONNumber("t"); if (timerObject != null) { int time = timerObject.GetIntValue(); if (this._trainingTimer != null) { this._trainingTimer.Destruct(); this._trainingTimer = null; } this._trainingTimer = new LogicTimer(); this._trainingTimer.StartTimer(time, this._parent.GetLevel().GetLogicTime(), false, -1); } LogicJSONArray unitArray = jsonObject.GetJSONArray("unit"); if (unitArray != null) { LogicJSONNumber dataObject = unitArray.GetJSONNumber(0); LogicJSONNumber cntObject = unitArray.GetJSONNumber(0); if (dataObject != null) { if (cntObject != null) { LogicData data = LogicDataTables.GetDataById(dataObject.GetIntValue(), this._productionType != 0 ? 25 : 3); if (data != null) { this._unit = new LogicDataSlot(data, cntObject.GetIntValue()); } else { Debugger.Error("LogicVillage2UnitComponent::load - Character data is NULL!"); } } } } } }
/// <summary> /// Loads this instance from json. /// </summary> public void Load(LogicJSONObject jsonObject) { LogicJSONArray cooldownArray = jsonObject.GetJSONArray("cooldowns"); if (cooldownArray != null) { int size = cooldownArray.Size(); for (int i = 0; i < size; i++) { LogicCooldown cooldown = new LogicCooldown(); cooldown.Load(cooldownArray.GetJSONObject(i)); this._cooldowns.Add(cooldown); } } }
public AdminSettings(LogicJSONObject jsonObject) { LogicJSONArray presetLevelFileArray = jsonObject.GetJSONArray("presetLevelFiles"); if (presetLevelFileArray != null) { this.PresetLevelFiles = new LogicArrayList <string>(presetLevelFileArray.Size()); for (int i = 0; i < presetLevelFileArray.Size(); i++) { this.PresetLevelFiles.Add(presetLevelFileArray.GetJSONString(i).GetStringValue()); } } else { this.PresetLevelFiles = null; } }
public void LoadProgress(LogicJSONObject jsonObject) { LogicJSONArray eventArray = jsonObject.GetJSONArray("events"); if (eventArray != null) { for (int i = 0; i < eventArray.Size(); i++) { this.m_startedEvents.Add(eventArray.GetJSONNumber(i).GetIntValue()); } } LogicJSONNumber endSessionNumber = jsonObject.GetJSONNumber("es"); if (endSessionNumber != null) { this.m_eventSeenTime = endSessionNumber.GetIntValue(); } }
public override void ReadFromJSON(LogicJSONObject jsonObject) { base.ReadFromJSON(jsonObject); LogicJSONArray jsonArray = jsonObject.GetJSONArray("dels"); if (jsonArray != null) { for (int i = 0; i < jsonArray.Size(); i++) { LogicJSONObject obj = jsonArray.GetJSONObject(i); if (obj != null) { this.m_deliverables.Add(LogicJSONHelper.GetLogicDeliverable(obj)); } } } }
/// <summary> /// Loads this instance. /// </summary> public override void Load(LogicJSONObject jsonObject) { LogicJSONArray unitArray = jsonObject.GetJSONArray("units"); if (unitArray != null) { if (this._slots.Count > 0) { Debugger.Error("LogicUnitStorageComponent::load - Unit array size > 0!"); } for (int i = 0, size = unitArray.Size(); i < size; i++) { LogicJSONArray unitObject = unitArray.GetJSONArray(i); if (unitObject != null) { LogicJSONNumber dataObject = unitObject.GetJSONNumber(0); LogicJSONNumber countObject = unitObject.GetJSONNumber(1); if (dataObject != null) { if (countObject != null) { LogicData data = LogicDataTables.GetDataById(dataObject.GetIntValue(), this._storageType != 0 ? 25 : 3); if (data != null) { this._slots.Add(new LogicUnitSlot(data, -1, countObject.GetIntValue())); } else { Debugger.Error("LogicUnitStorageComponent::load - Character data is NULL!"); } } } } } } }
protected sealed override void Load(LogicJSONObject jsonObject) { LogicJSONArray ownerIdArray = jsonObject.GetJSONArray(StreamDocument.JSON_ATTRIBUTE_OWNER_ID); this.OwnerId = new LogicLong(ownerIdArray.GetJSONNumber(0).GetIntValue(), ownerIdArray.GetJSONNumber(1).GetIntValue()); this.CreateTime = DateTime.Parse(jsonObject.GetJSONString(StreamDocument.JSON_ATTRIBUTE_CREATE_TIME).GetStringValue()); this.Type = (StreamType)jsonObject.GetJSONNumber(StreamDocument.JSON_ATTRIBUTE_TYPE).GetIntValue(); switch (this.Type) { case StreamType.ALLIANCE: { StreamEntry entry = StreamEntryFactory.CreateStreamEntryByType((StreamEntryType)jsonObject.GetJSONNumber(StreamDocument.JSON_ATTRIBUTE_ENTRY_TYPE).GetIntValue()); entry.Load(jsonObject.GetJSONObject(StreamDocument.JSON_ATTRIBUTE_ENTRY)); entry.SetId(this.Id); this.Entry = entry; break; } case StreamType.AVATAR: { AvatarStreamEntry entry = AvatarStreamEntryFactory.CreateStreamEntryByType((AvatarStreamEntryType)jsonObject.GetJSONNumber(StreamDocument.JSON_ATTRIBUTE_ENTRY_TYPE).GetIntValue()); entry.Load(jsonObject.GetJSONObject(StreamDocument.JSON_ATTRIBUTE_ENTRY)); entry.SetId(this.Id); this.Entry = entry; break; } case StreamType.REPLAY: { ReplayStreamEntry entry = new ReplayStreamEntry(); entry.Load(jsonObject.GetJSONObject(StreamDocument.JSON_ATTRIBUTE_ENTRY)); this.Entry = entry; break; } } }
public void Load(string json, int activeTimestamp) { Debugger.DoAssert(json != null, "Event json NULL"); if (json.Length > 0) { LogicJSONObject jsonObject = (LogicJSONObject)LogicJSONParser.Parse(json); if (jsonObject != null) { LogicArrayList <LogicCalendarEvent> events = new LogicArrayList <LogicCalendarEvent>(); LogicJSONArray eventArray = jsonObject.GetJSONArray("events"); if (eventArray != null) { for (int i = 0; i < eventArray.Size(); i++) { LogicJSONObject calendarObject = eventArray.GetJSONObject(i); if (calendarObject == null) { Debugger.Error("Events json malformed!"); } events.Add(LogicCalendarEventFactory.LoadFromJSON(calendarObject, null)); } } this.LoadingFinished(events, activeTimestamp); } else { Debugger.Error("Events json malformed!"); } } }
public override void Load(LogicJSONObject jsonObject) { base.Load(jsonObject); this.m_expLevel = jsonObject.GetJSONNumber(AvatarRankingEntry.JSON_ATTRIBUTE_EXP_LEVEL).GetIntValue(); this.m_attackWinCount = jsonObject.GetJSONNumber(AvatarRankingEntry.JSON_ATTRIBUTE_ATTACK_WIN_COUNT).GetIntValue(); this.m_attackLoseCount = jsonObject.GetJSONNumber(AvatarRankingEntry.JSON_ATTRIBUTE_ATTACK_LOSE_COUNT).GetIntValue(); this.m_defenseWinCount = jsonObject.GetJSONNumber(AvatarRankingEntry.JSON_ATTRIBUTE_DEFENSE_WIN_COUNT).GetIntValue(); this.m_defenseLoseCount = jsonObject.GetJSONNumber(AvatarRankingEntry.JSON_ATTRIBUTE_DEFENSE_LOSE_COUNT).GetIntValue(); this.m_leagueType = jsonObject.GetJSONNumber(AvatarRankingEntry.JSON_ATTRIBUTE_LEAGUE_TYPE).GetIntValue(); LogicJSONObject allianceObject = jsonObject.GetJSONObject(AvatarRankingEntry.JSON_ATTRIBUTE_ALLIANCE); if (allianceObject != null) { LogicJSONArray allianceIdArray = allianceObject.GetJSONArray(AvatarRankingEntry.JSON_ATTRIBUTE_ALLIANCE_ID); this.m_allianceId = new LogicLong(allianceIdArray.GetJSONNumber(0).GetIntValue(), allianceIdArray.GetJSONNumber(1).GetIntValue()); this.m_allianceName = allianceObject.GetJSONString(AvatarRankingEntry.JSON_ATTRIBUTE_ALLIANCE_NAME).GetStringValue(); this.m_allianceBadgeId = allianceObject.GetJSONNumber(AvatarRankingEntry.JSON_ATTRIBUTE_ALLIANCE_BADGE_ID).GetIntValue(); } this.m_homeId = this.GetId().Clone(); }
public override void Load(LogicJSONObject root) { if (this.m_timer != null) { this.m_timer.Destruct(); this.m_timer = null; } for (int i = this.m_slots.Size() - 1; i >= 0; i--) { this.m_slots[i].Destruct(); this.m_slots.Remove(i); } LogicJSONObject jsonObject = root.GetJSONObject("unit_prod"); if (jsonObject != null) { LogicJSONNumber modeObject = jsonObject.GetJSONNumber("m"); if (modeObject != null) { this.m_mode = true; } LogicJSONNumber unitTypeObject = jsonObject.GetJSONNumber("unit_type"); if (unitTypeObject != null) { this.m_productionType = unitTypeObject.GetIntValue(); } LogicJSONArray slotArray = jsonObject.GetJSONArray("slots"); if (slotArray != null) { for (int i = 0; i < slotArray.Size(); i++) { LogicJSONObject slotObject = slotArray.GetJSONObject(i); if (slotObject != null) { LogicJSONNumber idObject = slotObject.GetJSONNumber("id"); if (idObject != null) { LogicData data = LogicDataTables.GetDataById(idObject.GetIntValue(), this.m_productionType == 0 ? LogicDataType.CHARACTER : LogicDataType.SPELL); if (data != null) { LogicJSONNumber countObject = slotObject.GetJSONNumber("cnt"); if (countObject != null) { if (countObject.GetIntValue() > 0) { this.m_slots.Add(new LogicDataSlot(data, countObject.GetIntValue())); } } } } } } } if (this.m_slots.Size() > 0) { LogicJSONNumber timeObject = jsonObject.GetJSONNumber("t"); if (timeObject != null) { this.m_timer = new LogicTimer(); this.m_timer.StartTimer(timeObject.GetIntValue(), this.m_parent.GetLevel().GetLogicTime(), false, -1); } else { LogicCombatItemData data = (LogicCombatItemData)this.m_slots[0].GetData(); LogicAvatar homeOwnerAvatar = this.m_parent.GetLevel().GetHomeOwnerAvatar(); int upgLevel = homeOwnerAvatar != null?homeOwnerAvatar.GetUnitUpgradeLevel(data) : 0; this.m_timer = new LogicTimer(); this.m_timer.StartTimer(data.GetTrainingTime(upgLevel, this.m_parent.GetLevel(), 0), this.m_parent.GetLevel().GetLogicTime(), false, -1); } } } else { this.m_productionType = 0; if (this.m_parent.GetVillageType() == 0) { Debugger.Warning("LogicUnitProductionComponent::load - Component wasn't found from the JSON"); } } }
public void Load(LogicJSONObject root) { if (this.m_timer != null) { this.m_timer.Destruct(); this.m_timer = null; } if (this.m_boostTimer != null) { this.m_boostTimer.Destruct(); this.m_boostTimer = null; } for (int i = this.m_slots.Size() - 1; i >= 0; i--) { this.m_slots[i].Destruct(); this.m_slots.Remove(i); } LogicJSONObject jsonObject = root.GetJSONObject("unit_prod"); if (jsonObject != null) { LogicJSONArray slotArray = jsonObject.GetJSONArray("slots"); if (slotArray != null) { for (int i = 0; i < slotArray.Size(); i++) { LogicJSONObject slotObject = slotArray.GetJSONObject(i); if (slotObject != null) { LogicJSONNumber dataObject = slotObject.GetJSONNumber("id"); if (dataObject != null) { LogicData data = LogicDataTables.GetDataById(dataObject.GetIntValue()); if (data != null) { LogicJSONNumber countObject = slotObject.GetJSONNumber("cnt"); LogicJSONBoolean termineObject = slotObject.GetJSONBoolean("t"); if (countObject != null) { if (countObject.GetIntValue() > 0) { LogicUnitProductionSlot slot = new LogicUnitProductionSlot(data, countObject.GetIntValue(), false); if (termineObject != null) { slot.SetTerminate(termineObject.IsTrue()); } this.m_slots.Add(slot); } } } } } } } if (this.m_slots.Size() > 0) { LogicUnitProductionSlot slot = this.GetCurrentlyTrainedSlot(); if (slot != null) { LogicJSONNumber timeObject = jsonObject.GetJSONNumber("t"); if (timeObject != null) { this.m_timer = new LogicTimer(); this.m_timer.StartTimer(timeObject.GetIntValue(), this.m_level.GetLogicTime(), false, -1); } else { LogicCombatItemData combatItemData = (LogicCombatItemData)slot.GetData(); LogicAvatar avatar = this.m_level.GetHomeOwnerAvatar(); int upgradeLevel = 0; if (avatar != null) { upgradeLevel = avatar.GetUnitUpgradeLevel(combatItemData); } this.m_timer = new LogicTimer(); this.m_timer.StartTimer(combatItemData.GetTrainingTime(upgradeLevel, this.m_level, 0), this.m_level.GetLogicTime(), false, -1); Debugger.Print("LogicUnitProduction::load null timer, restart: " + this.m_timer.GetRemainingSeconds(this.m_level.GetLogicTime())); } } } LogicJSONNumber boostTimeObject = jsonObject.GetJSONNumber("boost_t"); if (boostTimeObject != null) { this.m_boostTimer = new LogicTimer(); this.m_boostTimer.StartTimer(boostTimeObject.GetIntValue(), this.m_level.GetLogicTime(), false, -1); } LogicJSONBoolean boostPauseObject = jsonObject.GetJSONBoolean("boost_pause"); if (boostPauseObject != null) { this.m_boostPause = boostPauseObject.IsTrue(); } } else { Debugger.Warning("LogicUnitProduction::load - Component wasn't found from the JSON"); } }
/// <summary> /// Downloads assets from config server. /// </summary> private static void DownloadAssets(LogicJSONObject currentFingerprint, string fingerprint) { LogicJSONArray currentFileArray = currentFingerprint?.GetJSONArray("files"); LogicJSONObject jsonObject = (LogicJSONObject)LogicJSONParser.Parse(fingerprint); LogicJSONArray fileArray = jsonObject.GetJSONArray("files"); if (currentFileArray != null) { if (fileArray.Size() != currentFileArray.Size()) { currentFileArray = null; } } string shaFingerprint = LogicJSONHelper.GetJSONString(jsonObject, "sha"); Logging.Print("Download " + shaFingerprint + " assets..."); Parallel.For(0, fileArray.Size(), new ParallelOptions { MaxDegreeOfParallelism = 4 }, i => { LogicJSONObject fileObject = fileArray.GetJSONObject(i); if (fileObject != null) { string fileName = LogicJSONHelper.GetJSONString(fileObject, "file"); string sha = LogicJSONHelper.GetJSONString(fileObject, "sha"); if (currentFileArray != null) { for (int j = 0; j < currentFileArray.Size(); j++) { LogicJSONObject currentFileObject = currentFileArray.GetJSONObject(j); LogicJSONString currentFileNameObject = currentFileObject.GetJSONString("file"); if (fileName == currentFileNameObject.GetStringValue()) { LogicJSONString currentShaObject = currentFileObject.GetJSONString("sha"); if (sha == currentShaObject.GetStringValue()) { return; } } } } WebClient client = new WebClient(); byte[] data = client.DownloadData(ServiceCore.ConfigurationServer + "/assets/" + shaFingerprint + "/" + fileName); client.Dispose(); if (data != null) { Logging.Print("file " + fileName + " downloaded"); switch (Path.GetExtension(fileName)) { case ".csv": using (MemoryStream inputStream = new MemoryStream(data)) { using (MemoryStream outputStream = new MemoryStream()) { Decoder decompresser = new Decoder(); byte[] properties = new byte[5]; byte[] fileLengthBytes = new byte[4]; inputStream.Read(properties, 0, 5); inputStream.Read(fileLengthBytes, 0, 4); int fileLength = fileLengthBytes[0] | fileLengthBytes[1] << 8 | fileLengthBytes[2] << 16 | fileLengthBytes[3] << 24; decompresser.SetDecoderProperties(properties); decompresser.Code(inputStream, outputStream, inputStream.Length, fileLength, null); data = outputStream.ToArray(); } } break; } Directory.CreateDirectory("Assets/" + fileName.Replace(Path.GetFileName(fileName), string.Empty)); File.WriteAllBytes("Assets/" + fileName, data); } else { Logging.Warning("file " + fileName + " not exist"); } } }); File.WriteAllText("Assets/fingerprint.json", fingerprint); Logging.Print("Download completed"); }