public override void Save(LogicJSONObject root, int villageType)
        {
            LogicJSONObject jsonObject = new LogicJSONObject();

            jsonObject.Put("m", new LogicJSONNumber(1));
            jsonObject.Put("unit_type", new LogicJSONNumber(this.m_productionType));

            if (this.m_timer != null)
            {
                jsonObject.Put("t", new LogicJSONNumber(this.m_timer.GetRemainingSeconds(this.m_parent.GetLevel().GetLogicTime())));
            }

            if (this.m_slots.Size() > 0)
            {
                LogicJSONArray slotArray = new LogicJSONArray();

                for (int i = 0; i < this.m_slots.Size(); i++)
                {
                    LogicDataSlot   slot       = this.m_slots[i];
                    LogicJSONObject slotObject = new LogicJSONObject();

                    slotObject.Put("id", new LogicJSONNumber(slot.GetData().GetGlobalID()));
                    slotObject.Put("cnt", new LogicJSONNumber(slot.GetCount()));

                    slotArray.Add(slotObject);
                }

                jsonObject.Put("slots", slotArray);
            }

            root.Put("unit_prod", jsonObject);
        }
        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);
                }
            }
        }
Пример #3
0
        /// <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");
            }
        }
Пример #4
0
        /// <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);
            }
        }
        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());
        }
Пример #6
0
        public override LogicJSONObject Save()
        {
            LogicJSONObject jsonObject = base.Save();

            jsonObject.Put(AvatarRankingEntry.JSON_ATTRIBUTE_EXP_LEVEL, new LogicJSONNumber(this.m_expLevel));
            jsonObject.Put(AvatarRankingEntry.JSON_ATTRIBUTE_ATTACK_WIN_COUNT, new LogicJSONNumber(this.m_attackWinCount));
            jsonObject.Put(AvatarRankingEntry.JSON_ATTRIBUTE_ATTACK_LOSE_COUNT, new LogicJSONNumber(this.m_attackLoseCount));
            jsonObject.Put(AvatarRankingEntry.JSON_ATTRIBUTE_DEFENSE_WIN_COUNT, new LogicJSONNumber(this.m_defenseWinCount));
            jsonObject.Put(AvatarRankingEntry.JSON_ATTRIBUTE_DEFENSE_LOSE_COUNT, new LogicJSONNumber(this.m_defenseLoseCount));
            jsonObject.Put(AvatarRankingEntry.JSON_ATTRIBUTE_LEAGUE_TYPE, new LogicJSONNumber(this.m_leagueType));

            if (this.m_allianceId != null)
            {
                LogicJSONObject allianceObject  = new LogicJSONObject();
                LogicJSONArray  allianceIdArray = new LogicJSONArray(2);

                allianceIdArray.Add(new LogicJSONNumber(this.m_allianceId.GetHigherInt()));
                allianceIdArray.Add(new LogicJSONNumber(this.m_allianceId.GetLowerInt()));

                allianceObject.Put(AvatarRankingEntry.JSON_ATTRIBUTE_ALLIANCE_ID, allianceIdArray);
                allianceObject.Put(AvatarRankingEntry.JSON_ATTRIBUTE_ALLIANCE_NAME, new LogicJSONString(this.m_allianceName));
                allianceObject.Put(AvatarRankingEntry.JSON_ATTRIBUTE_ALLIANCE_BADGE_ID, new LogicJSONNumber(this.m_allianceBadgeId));

                jsonObject.Put(AvatarRankingEntry.JSON_ATTRIBUTE_ALLIANCE, allianceObject);
            }

            return(jsonObject);
        }
        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());
                }
            }
        }
        protected sealed override void Save(LogicJSONObject jsonObject)
        {
            LogicJSONArray allianceRankingListArray = new LogicJSONArray(2);
            LogicJSONArray avatarRankingArray       = new LogicJSONArray(SeasonDocument.RANKING_LIST_SIZE);
            LogicJSONArray avatarDuelRankingArray   = new LogicJSONArray(SeasonDocument.RANKING_LIST_SIZE);

            for (int i = 0; i < 2; i++)
            {
                LogicJSONArray allianceRankingArray = new LogicJSONArray(SeasonDocument.RANKING_LIST_SIZE);
                LogicArrayList <AllianceRankingEntry> allianceRankingList = this.AllianceRankingList[i];

                for (int j = 0; j < allianceRankingList.Size(); j++)
                {
                    allianceRankingArray.Add(allianceRankingList[j].Save());
                }

                allianceRankingListArray.Add(allianceRankingArray);
            }

            for (int i = 0; i < this.AvatarRankingList.Size(); i++)
            {
                avatarRankingArray.Add(this.AvatarRankingList[i].Save());
            }

            for (int i = 0; i < this.AvatarDuelRankingList.Size(); i++)
            {
                avatarDuelRankingArray.Add(this.AvatarDuelRankingList[i].Save());
            }

            jsonObject.Put(SeasonDocument.JSON_ATTRIBUTE_ALLIANCE_RANKINGS, allianceRankingListArray);
            jsonObject.Put(SeasonDocument.JSON_ATTRIBUTE_AVATAR_RANKINGS, avatarRankingArray);
            jsonObject.Put(SeasonDocument.JSON_ATTRIBUTE_AVATAR_DUEL_RANKINGS, avatarDuelRankingArray);
            jsonObject.Put(SeasonDocument.JSON_ATTRIBUTE_NEXT_CHECK_TIME, new LogicJSONString(this.NextCheckTime.ToString("O")));
        }
        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();
        }
Пример #10
0
        /// <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!");
                }
            }
        }
        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());
                        }
                    }
                }
            }
        }
            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);
                }
            }
Пример #13
0
        /// <summary>
        ///     Saves this instance to json.
        /// </summary>
        internal LogicJSONObject Save()
        {
            LogicJSONObject jsonObject = new LogicJSONObject();

            jsonObject.Put("id_hi", new LogicJSONNumber(this.Id.GetHigherInt()));
            jsonObject.Put("id_lo", new LogicJSONNumber(this.Id.GetLowerInt()));
            jsonObject.Put("pass_t", new LogicJSONString(this.PassToken));
            jsonObject.Put("pt_secs", new LogicJSONNumber(this.PlayTimeSecs));
            jsonObject.Put("acc_cr", new LogicJSONString(this.AccountCreatedDate));
            jsonObject.Put("t_ban", new LogicJSONNumber(this.TotalBan));

            LogicJSONArray sessionArray = new LogicJSONArray();

            for (int i = 0; i < this.LastSessions.Count; i++)
            {
                LogicJSONObject obj = new LogicJSONObject();
                this.LastSessions[i].Save(obj);
                sessionArray.Add(obj);
            }

            jsonObject.Put("sessions", sessionArray);

            if (this.CurrentBan != null)
            {
                LogicJSONObject banObject = new LogicJSONObject();
                this.CurrentBan.Save(banObject);
                jsonObject.Put("ban", banObject);
            }

            return(jsonObject);
        }
Пример #14
0
        /// <summary>
        ///     Records the command.
        /// </summary>
        public void RecordCommand(LogicCommand command)
        {
            LogicJSONArray  commandArray  = this._replayObject.GetJSONArray("cmd");
            LogicJSONObject commandObject = new LogicJSONObject();

            LogicCommandManager.SaveCommandToJSON(commandObject, command);

            commandArray.Add(commandObject);
        }
Пример #15
0
        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 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();
        }
Пример #17
0
        private static LogicJSONArray SaveStringArray(LogicArrayList <string> arrayList)
        {
            LogicJSONArray jsonArray = new LogicJSONArray();

            for (int i = 0; i < arrayList.Size(); i++)
            {
                jsonArray.Add(new LogicJSONString(arrayList[i]));
            }

            return(jsonArray);
        }
        protected override void Save(LogicJSONObject jsonObject)
        {
            this.LogicClientAvatar.Save(jsonObject);

            jsonObject.Put(GameDocument.JSON_ATTRIBUTE_HOME, this.LogicClientHome.Save());
            jsonObject.Put(GameDocument.JSON_ATTRIBUTE_SAVE_TIME, new LogicJSONNumber(this.SaveTime));
            jsonObject.Put(GameDocument.JSON_ATTRIBUTE_MAINTENANCE_TIME, new LogicJSONNumber(this.MaintenanceTime));

            LogicJSONArray recentlyMatchedEnemyArray = new LogicJSONArray(this.RecentlyMatchedEnemies.Size());

            for (int i = 0; i < this.RecentlyMatchedEnemies.Size(); i++)
            {
                RecentlyEnemy  entry = this.RecentlyMatchedEnemies[i];
                LogicJSONArray value = new LogicJSONArray(3);

                value.Add(new LogicJSONNumber(entry.AvatarId.GetHigherInt()));
                value.Add(new LogicJSONNumber(entry.AvatarId.GetLowerInt()));
                value.Add(new LogicJSONNumber(entry.Timestamp));

                recentlyMatchedEnemyArray.Add(value);
            }

            jsonObject.Put(GameDocument.JSON_ATTRIBUTE_RECENTLY_MATCHED_ENEMIES, recentlyMatchedEnemyArray);

            LogicJSONArray allianceBookmarksArray = new LogicJSONArray(this.AllianceBookmarksList.Size());

            for (int i = 0; i < this.AllianceBookmarksList.Size(); i++)
            {
                LogicLong      id  = this.AllianceBookmarksList[i];
                LogicJSONArray ids = new LogicJSONArray(2);

                ids.Add(new LogicJSONNumber(id.GetHigherInt()));
                ids.Add(new LogicJSONNumber(id.GetLowerInt()));

                allianceBookmarksArray.Add(ids);
            }

            jsonObject.Put(GameDocument.JSON_ATTRIBUTE_ALLIANCE_BOOKMARKS_LIST, allianceBookmarksArray);

            LogicJSONArray avatarStreamsArray = new LogicJSONArray(this.AvatarStreamList.Size());

            for (int i = 0; i < this.AvatarStreamList.Size(); i++)
            {
                LogicLong      id  = this.AvatarStreamList[i];
                LogicJSONArray ids = new LogicJSONArray(2);

                ids.Add(new LogicJSONNumber(id.GetHigherInt()));
                ids.Add(new LogicJSONNumber(id.GetLowerInt()));

                avatarStreamsArray.Add(ids);
            }

            jsonObject.Put(GameDocument.JSON_ATTRIBUTE_AVATAR_STREAM_LIST, avatarStreamsArray);
        }
            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 void Save(LogicJSONObject jsonObject)
        {
            jsonObject.Put(ReplayStreamEntry.JSON_ATTRIBUTE_STREAM_DATA, new LogicJSONString(Convert.ToBase64String(this.m_streamData)));

            LogicJSONArray versionArray = new LogicJSONArray(3);

            versionArray.Add(new LogicJSONNumber(this.m_majorVersion));
            versionArray.Add(new LogicJSONNumber(this.m_buildVersion));
            versionArray.Add(new LogicJSONNumber(this.m_contentVersion));

            jsonObject.Put(ReplayStreamEntry.JSON_ATTRIBUTE_STREAM_VERSION, versionArray);
        }
        public static void LoadDebugJSONArray(LogicLevel level, LogicJSONArray jsonArray, LogicGameObjectType gameObjectType, int villageType)
        {
            if (jsonArray != null)
            {
                LogicGameObjectManager           gameObjectManager = level.GetGameObjectManagerAt(villageType);
                LogicArrayList <LogicGameObject> prevGameObjects   = new LogicArrayList <LogicGameObject>();

                prevGameObjects.AddAll(gameObjectManager.GetGameObjects(gameObjectType));

                for (int i = 0; i < prevGameObjects.Size(); i++)
                {
                    gameObjectManager.RemoveGameObject(prevGameObjects[i]);
                }

                for (int i = 0; i < jsonArray.Size(); i++)
                {
                    LogicJSONObject  jsonObject    = jsonArray.GetJSONObject(i);
                    LogicJSONNumber  dataNumber    = jsonObject.GetJSONNumber("data");
                    LogicJSONNumber  lvlNumber     = jsonObject.GetJSONNumber("lvl");
                    LogicJSONBoolean lockedBoolean = jsonObject.GetJSONBoolean("locked");
                    LogicJSONNumber  xNumber       = jsonObject.GetJSONNumber("x");
                    LogicJSONNumber  yNumber       = jsonObject.GetJSONNumber("y");

                    if (dataNumber != null && xNumber != null && yNumber != null)
                    {
                        LogicGameObjectData data = (LogicGameObjectData)LogicDataTables.GetDataById(dataNumber.GetIntValue());

                        if (data != null)
                        {
                            LogicGameObject gameObject = LogicGameObjectFactory.CreateGameObject(data, level, villageType);

                            if (gameObjectType == LogicGameObjectType.BUILDING)
                            {
                                ((LogicBuilding)gameObject).StartConstructing(true);
                            }

                            if (lockedBoolean != null && lockedBoolean.IsTrue())
                            {
                                ((LogicBuilding)gameObject).Lock();
                            }

                            gameObject.Load(jsonObject);
                            gameObjectManager.AddGameObject(gameObject, -1);

                            if (lvlNumber != null)
                            {
                                LogicDebugUtil.SetBuildingUpgradeLevel(level, gameObject.GetGlobalID(), lvlNumber.GetIntValue(), villageType);
                            }
                        }
                    }
                }
            }
        }
Пример #22
0
        /// <summary>
        ///     Saves this instance to json.
        /// </summary>
        public void Save(LogicJSONObject jsonObject)
        {
            LogicJSONArray cooldownArray = new LogicJSONArray();

            for (int i = 0; i < this._cooldowns.Count; i++)
            {
                LogicJSONObject cooldownObject = new LogicJSONObject();
                this._cooldowns[i].Save(cooldownObject);
                cooldownArray.Add(cooldownObject);
            }

            jsonObject.Put("cooldowns", cooldownArray);
        }
        protected sealed override void Save(LogicJSONObject jsonObject)
        {
            LogicJSONArray ownerIdArray = new LogicJSONArray(2);

            ownerIdArray.Add(new LogicJSONNumber(this.OwnerId.GetHigherInt()));
            ownerIdArray.Add(new LogicJSONNumber(this.OwnerId.GetLowerInt()));

            jsonObject.Put(StreamDocument.JSON_ATTRIBUTE_OWNER_ID, ownerIdArray);
            jsonObject.Put(StreamDocument.JSON_ATTRIBUTE_CREATE_TIME, new LogicJSONString(this.CreateTime.ToString("O")));
            jsonObject.Put(StreamDocument.JSON_ATTRIBUTE_TYPE, new LogicJSONNumber((int)this.Type));

            switch (this.Type)
            {
            case StreamType.ALLIANCE:
            {
                LogicJSONObject entryObject = new LogicJSONObject();
                StreamEntry     entry       = (StreamEntry)this.Entry;

                jsonObject.Put(StreamDocument.JSON_ATTRIBUTE_ENTRY_TYPE, new LogicJSONNumber((int)entry.GetStreamEntryType()));
                jsonObject.Put(StreamDocument.JSON_ATTRIBUTE_ENTRY, entryObject);

                entry.Save(entryObject);
                break;
            }

            case StreamType.AVATAR:
            {
                LogicJSONObject   entryObject = new LogicJSONObject();
                AvatarStreamEntry entry       = (AvatarStreamEntry)this.Entry;

                jsonObject.Put(StreamDocument.JSON_ATTRIBUTE_ENTRY_TYPE, new LogicJSONNumber((int)entry.GetAvatarStreamEntryType()));
                jsonObject.Put(StreamDocument.JSON_ATTRIBUTE_ENTRY, entryObject);

                entry.Save(entryObject);
                break;
            }

            case StreamType.REPLAY:
            {
                LogicJSONObject   entryObject = new LogicJSONObject();
                ReplayStreamEntry entry       = (ReplayStreamEntry)this.Entry;

                jsonObject.Put(StreamDocument.JSON_ATTRIBUTE_ENTRY, entryObject);

                entry.Save(entryObject);

                break;
            }
            }
        }
            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();
            }
        private static LogicJSONArray SaveStringArray(string[] stringArray)
        {
            LogicJSONArray jsonArray = new LogicJSONArray();

            if (stringArray != null)
            {
                for (int i = 0; i < stringArray.Length; i++)
                {
                    jsonArray.Add(new LogicJSONString(stringArray[i]));
                }
            }

            return(jsonArray);
        }
            public LogicJSONObject Save()
            {
                LogicJSONObject jsonObject    = new LogicJSONObject();
                LogicJSONArray  databaseArray = new LogicJSONArray();

                for (int i = 0; i < this.Databases.Size(); i++)
                {
                    databaseArray.Add(this.Databases[i].Save());
                }

                jsonObject.Put("databases", databaseArray);

                return(jsonObject);
            }
        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);
                }
            }
        }
Пример #28
0
        private static LogicArrayList <string> LoadStringArray(LogicJSONArray jsonArray)
        {
            LogicArrayList <string> arrayList = new LogicArrayList <string>();

            if (jsonArray != null)
            {
                for (int i = 0; i < jsonArray.Size(); i++)
                {
                    arrayList.Add(jsonArray.GetJSONString(i).GetStringValue());
                }
            }

            return(arrayList);
        }
Пример #29
0
        public static void AddJSONDataSlotsToArray(LogicJSONArray jsonArray, LogicArrayList <LogicDataSlot> slot)
        {
            for (int i = 0; i < jsonArray.Size(); i++)
            {
                LogicJSONArray objectArray = jsonArray.GetJSONArray(i);

                if (objectArray != null && objectArray.Size() == 2)
                {
                    LogicData data  = LogicDataTables.GetDataById(jsonArray.GetJSONNumber(0).GetIntValue());
                    int       count = objectArray.GetJSONNumber(1).GetIntValue();

                    slot.Add(new LogicDataSlot(data, count));
                }
            }
        }
        public override void WriteToJSON(LogicJSONObject jsonObject)
        {
            base.WriteToJSON(jsonObject);

            LogicJSONArray jsonArray = new LogicJSONArray(this.m_deliverables.Size());

            for (int i = 0; i < this.m_deliverables.Size(); i++)
            {
                LogicJSONObject obj = new LogicJSONObject();
                this.m_deliverables[i].WriteToJSON(obj);
                jsonArray.Add(obj);
            }

            jsonObject.Put("dels", jsonArray);
        }