public virtual void Load(LogicJSONObject jsonObject)
        {
            LogicJSONObject senderObject = jsonObject.GetJSONObject("sender");

            if (senderObject != null)
            {
                LogicJSONNumber avatarIdHighNumber = senderObject.GetJSONNumber("avatar_id_hi");

                if (avatarIdHighNumber != null)
                {
                    this.m_senderAvatarId = new LogicLong(avatarIdHighNumber.GetIntValue(), senderObject.GetJSONNumber("avatar_id_lo").GetIntValue());
                }

                this.m_senderName       = senderObject.GetJSONString("name").GetStringValue();
                this.m_senderExpLevel   = senderObject.GetJSONNumber("exp_lvl").GetIntValue();
                this.m_senderLeagueType = senderObject.GetJSONNumber("league_type").GetIntValue();

                LogicJSONBoolean isDismissedObject = senderObject.GetJSONBoolean("is_dismissed");

                if (isDismissedObject != null)
                {
                    this.m_dismiss = isDismissedObject.IsTrue();
                }

                LogicJSONBoolean isNewObject = senderObject.GetJSONBoolean("is_new");

                if (isNewObject != null)
                {
                    this.m_new = isNewObject.IsTrue();
                }
            }
        }
Exemplo n.º 2
0
        /// <summary>
        ///     Loads this instance.
        /// </summary>
        public virtual void Load(LogicJSONObject jsonObject)
        {
            LogicJSONNumber idHigh = jsonObject.GetJSONNumber("id_hi");
            LogicJSONNumber idLow  = jsonObject.GetJSONNumber("id_lo");

            if (idHigh != null)
            {
                if (idLow != null)
                {
                    this._id = new LogicLong(idHigh.GetIntValue(), idLow.GetIntValue());
                }
            }

            LogicJSONObject senderObject = jsonObject.GetJSONObject("sender");

            if (senderObject != null)
            {
                LogicJSONString nameObject = senderObject.GetJSONString("name");

                if (nameObject != null)
                {
                    this._senderName = nameObject.GetStringValue();
                }

                LogicJSONNumber expLevelObject = senderObject.GetJSONNumber("exp_lvl");

                if (expLevelObject != null)
                {
                    this._senderExpLevel = expLevelObject.GetIntValue();
                }

                LogicJSONNumber leagueTypeObject = senderObject.GetJSONNumber("league_type");

                if (leagueTypeObject != null)
                {
                    this._senderLeagueType = leagueTypeObject.GetIntValue();
                }

                LogicJSONNumber ageSecsObject = senderObject.GetJSONNumber("age_secs");

                if (ageSecsObject != null)
                {
                    this._ageSeconds = ageSecsObject.GetIntValue();
                }

                LogicJSONBoolean isDismissedObject = senderObject.GetJSONBoolean("is_dismissed");

                if (isDismissedObject != null)
                {
                    this._dismiss = isDismissedObject.IsTrue();
                }

                LogicJSONBoolean isNewObject = senderObject.GetJSONBoolean("is_new");

                if (isNewObject != null)
                {
                    this._new = isNewObject.IsTrue();
                }
            }
        }
Exemplo n.º 3
0
        public void Load(LogicJSONObject jsonObject)
        {
            this.m_allianceName           = jsonObject.GetJSONString("alliance_name").GetStringValue();
            this.m_allianceBadgeId        = jsonObject.GetJSONNumber("badge_id").GetIntValue();
            this.m_allianceType           = (AllianceType)jsonObject.GetJSONNumber("type").GetIntValue();
            this.m_memberCount            = jsonObject.GetJSONNumber("member_count").GetIntValue();
            this.m_score                  = jsonObject.GetJSONNumber("score").GetIntValue();
            this.m_duelScore              = jsonObject.GetJSONNumber("duel_score").GetIntValue();
            this.m_requiredScore          = jsonObject.GetJSONNumber("required_score").GetIntValue();
            this.m_requiredDuelScore      = jsonObject.GetJSONNumber("required_duel_score").GetIntValue();
            this.m_winWarCount            = jsonObject.GetJSONNumber("win_war_count").GetIntValue();
            this.m_lostWarCount           = jsonObject.GetJSONNumber("lost_war_count").GetIntValue();
            this.m_drawWarCount           = jsonObject.GetJSONNumber("draw_war_count").GetIntValue();
            this.m_warFrequency           = jsonObject.GetJSONNumber("war_freq").GetIntValue();
            this.m_expLevel               = jsonObject.GetJSONNumber("xp_level").GetIntValue();
            this.m_expPoints              = jsonObject.GetJSONNumber("xp_points").GetIntValue();
            this.m_consecutiveWinWarCount = jsonObject.GetJSONNumber("cons_win_war_count").GetIntValue();
            this.m_publicWarLog           = jsonObject.GetJSONBoolean("public_war_log").IsTrue();
            this.m_amicalWarEnabled       = jsonObject.GetJSONBoolean("amical_war_enabled").IsTrue();

            LogicJSONNumber localeObject = jsonObject.GetJSONNumber("locale");

            if (localeObject != null)
            {
                this.m_localeData = LogicDataTables.GetDataById(localeObject.GetIntValue());
            }

            LogicJSONNumber originObject = jsonObject.GetJSONNumber("origin");

            if (originObject != null)
            {
                this.m_originData = LogicDataTables.GetDataById(originObject.GetIntValue());
            }
        }
Exemplo n.º 4
0
        public override void Load(LogicJSONObject jsonObject)
        {
            LogicJSONObject baseObject = jsonObject.GetJSONObject("base");

            if (baseObject == null)
            {
                Debugger.Error("AllianceInvitationAvatarStreamEntry::load base is NULL");
            }

            base.Load(baseObject);

            this.m_titleTID       = jsonObject.GetJSONString("title").GetStringValue();
            this.m_descriptionTID = jsonObject.GetJSONString("description").GetStringValue();

            LogicJSONString buttonString = jsonObject.GetJSONString("button");

            if (buttonString != null)
            {
                this.m_buttonTID = buttonString.GetStringValue();
            }

            LogicJSONString helpshiftUrlString = jsonObject.GetJSONString("helpshift_url");

            if (helpshiftUrlString != null)
            {
                this.m_helpshiftLink = helpshiftUrlString.GetStringValue();
            }

            LogicJSONString urlString = jsonObject.GetJSONString("url");

            if (urlString != null)
            {
                this.m_urlLink = urlString.GetStringValue();
            }

            LogicJSONNumber diamondsNumber = jsonObject.GetJSONNumber("diamonds");

            if (diamondsNumber != null)
            {
                this.m_diamondCount = diamondsNumber.GetIntValue();
            }

            LogicJSONBoolean supportMessageBoolean = jsonObject.GetJSONBoolean("support_msg");

            if (supportMessageBoolean != null)
            {
                this.m_supportMessage = supportMessageBoolean.IsTrue();
            }

            LogicJSONBoolean claimedBoolean = jsonObject.GetJSONBoolean("claimed");

            if (claimedBoolean != null)
            {
                this.m_claimed = claimedBoolean.IsTrue();
            }
        }
Exemplo n.º 5
0
        /// <summary>
        ///     Loads this instance from json.
        /// </summary>
        public override void Load(LogicJSONObject jsonObject)
        {
            LogicJSONNumber  hpNumber     = jsonObject.GetJSONNumber("hp");
            LogicJSONBoolean regenBoolean = jsonObject.GetJSONBoolean("reg");

            if (hpNumber != null)
            {
                if (this._parent.GetLevel().GetState() != 2)
                {
                    this._hp = LogicMath.Clamp(hpNumber.GetIntValue(), 0, this._maxHp);
                }
                else
                {
                    this._hp = this._maxHp;
                }
            }
            else
            {
                this._hp = this._maxHp;
            }

            if (regenBoolean != null)
            {
                this._regenerationEnabled = regenBoolean.IsTrue();
            }
            else
            {
                this._regenerationEnabled = false;
            }
        }
        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 override void Load(LogicJSONObject jsonObject)
        {
            LogicJSONObject baseObject = jsonObject.GetJSONObject("base");

            if (baseObject == null)
            {
                Debugger.Error("ReplayStreamEntry::load base is NULL");
            }

            base.Load(baseObject);

            this.m_battleLogJSON  = jsonObject.GetJSONString("battleLog").GetStringValue();
            this.m_message        = jsonObject.GetJSONString("message").GetStringValue();
            this.m_opponentName   = jsonObject.GetJSONString("opponent_name").GetStringValue();
            this.m_attack         = jsonObject.GetJSONBoolean("attack").IsTrue();
            this.m_majorVersion   = jsonObject.GetJSONNumber("replay_major_v").GetIntValue();
            this.m_buildVersion   = jsonObject.GetJSONNumber("replay_build_v").GetIntValue();
            this.m_contentVersion = jsonObject.GetJSONNumber("replay_content_v").GetIntValue();

            LogicJSONNumber replayShardId = jsonObject.GetJSONNumber("replay_shard_id");

            if (replayShardId != null)
            {
                this.m_replayShardId = replayShardId.GetIntValue();
                this.m_replayId      = new LogicLong(jsonObject.GetJSONNumber("replay_id_hi").GetIntValue(), jsonObject.GetJSONNumber("replay_id_lo").GetIntValue());
            }
        }
Exemplo n.º 8
0
        public override void Load(LogicJSONObject jsonObject)
        {
            LogicJSONObject baseObject = jsonObject.GetJSONObject("base");

            if (baseObject == null)
            {
                Debugger.Error("BattleReportStreamEntry::load base is NULL");
            }

            base.Load(baseObject);

            this.m_battleLogJSON  = jsonObject.GetJSONString("battle_log").GetStringValue();
            this.m_majorVersion   = jsonObject.GetJSONNumber("major_v").GetIntValue();
            this.m_buildVersion   = jsonObject.GetJSONNumber("build_v").GetIntValue();
            this.m_contentVersion = jsonObject.GetJSONNumber("content_v").GetIntValue();
            this.m_replayShardId  = jsonObject.GetJSONNumber("replay_shard_id").GetIntValue();
            this.m_revengeUsed    = jsonObject.GetJSONBoolean("revenge_used").IsTrue();

            LogicJSONNumber replayIdHigh = jsonObject.GetJSONNumber("replay_id_hi");

            if (replayIdHigh != null)
            {
                this.m_replayId = new LogicLong(replayIdHigh.GetIntValue(), jsonObject.GetJSONNumber("replay_id_lo").GetIntValue());
            }
        }
Exemplo n.º 9
0
        /// <summary>
        ///     Gets the specified json boolean.
        /// </summary>
        public static bool GetJSONBoolean(LogicJSONObject jsonObject, string key)
        {
            LogicJSONBoolean jsonBoolean = jsonObject.GetJSONBoolean(key);

            if (jsonBoolean != null)
            {
                return(jsonBoolean.IsTrue());
            }

            return(false);
        }
        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);
                            }
                        }
                    }
                }
            }
        }
        public void LoadHitpoint(LogicJSONObject jsonObject)
        {
            LogicJSONNumber  hpNumber     = jsonObject.GetJSONNumber("hp");
            LogicJSONBoolean regenBoolean = jsonObject.GetJSONBoolean("reg");

            if (hpNumber != null)
            {
                this.m_hp = this.m_parent.GetLevel().GetState() != 2 ? LogicMath.Clamp(hpNumber.GetIntValue(), 0, this.m_maxHp) : this.m_maxHp;
            }
            else
            {
                this.m_hp = this.m_maxHp;
            }

            this.m_regenerationEnabled = regenBoolean != null && regenBoolean.IsTrue();
        }
Exemplo n.º 12
0
        public void LoadUpgradeLevel(LogicJSONObject jsonObject)
        {
            LogicJSONNumber lvlObject = jsonObject.GetJSONNumber("lvl");

            if (lvlObject != null)
            {
                this.m_upgLevel = lvlObject.GetIntValue();
                int maxLvl = this.GetVillageObjectData().GetUpgradeLevelCount();

                if (this.m_upgLevel >= maxLvl)
                {
                    Debugger.Warning(string.Format("LogicVillageObject::load() - Loaded upgrade level {0} is over max! (max = {1}) id {2} data id {3}",
                                                   lvlObject.GetIntValue(),
                                                   maxLvl,
                                                   this.m_globalId,
                                                   this.m_data.GetGlobalID()));
                    this.m_upgLevel = maxLvl - 1;
                }
                else
                {
                    if (this.m_upgLevel < -1)
                    {
                        Debugger.Error("LogicVillageObject::load() - Loaded an illegal upgrade level!");
                    }
                }
            }
            else
            {
                Debugger.Error("LogicVillageObject::load - Upgrade level was not found!");
            }

            if (this.GetVillageObjectData().IsRequiresBuilder())
            {
                this.m_level.GetWorkerManagerAt(this.m_villageType).DeallocateWorker(this);
            }

            LogicJSONBoolean lockedObject = jsonObject.GetJSONBoolean("locked");

            if (lockedObject != null)
            {
                this.m_locked = lockedObject.IsTrue();
            }
        }
Exemplo n.º 13
0
        public override void Load(LogicJSONObject jsonObject)
        {
            LogicJSONObject baseObject = jsonObject.GetJSONObject("base");

            if (baseObject == null)
            {
                Debugger.Error("ReplayVersusBattleStreamEntry::load base is NULL");
            }

            base.Load(baseObject);

            this.m_message          = jsonObject.GetJSONString("message").GetStringValue();
            this.m_snapshotHomeJSON = Convert.FromBase64String(jsonObject.GetJSONString("snapshot_home").GetStringValue());
            this.m_warLayout        = jsonObject.GetJSONBoolean("war_layout").IsTrue();

            LogicJSONString battleLogString = jsonObject.GetJSONString("battleLog");

            if (battleLogString != null)
            {
                this.m_battleLogJSON = battleLogString.GetStringValue();
            }
        }
Exemplo n.º 14
0
        public override void Load(LogicJSONObject jsonObject)
        {
            base.Load(jsonObject.GetJSONObject("base"));

            this.m_resultType    = jsonObject.GetJSONNumber("battle_result").GetIntValue();
            this.m_attackerStars = jsonObject.GetJSONNumber("attacker_stars").GetIntValue();
            this.m_attackerDestructionPercentage = jsonObject.GetJSONNumber("attacker_destruction_percentage").GetIntValue();
            this.m_opponentStars = jsonObject.GetJSONNumber("opponent_stars").GetIntValue();
            this.m_opponentDestructionPercentage = jsonObject.GetJSONNumber("opponent_destruction_percentage").GetIntValue();
            this.m_goldCount   = jsonObject.GetJSONNumber("golds").GetIntValue();
            this.m_elixirCount = jsonObject.GetJSONNumber("elixirs").GetIntValue();
            this.m_scoreCount  = jsonObject.GetJSONNumber("scores").GetIntValue();
            this.m_battleEnded = jsonObject.GetJSONBoolean("battle_ended").IsTrue();

            LogicJSONNumber attackerReplayIdHighNumber = jsonObject.GetJSONNumber("attacker_replay_id_hi");

            if (attackerReplayIdHighNumber != null)
            {
                this.m_attackerReplayId             = new LogicLong(attackerReplayIdHighNumber.GetIntValue(), jsonObject.GetJSONNumber("attacker_replay_id_lo").GetIntValue());
                this.m_attackerReplayShardId        = jsonObject.GetJSONNumber("attacker_replay_shard_id").GetIntValue();
                this.m_attackerReplayMajorVersion   = jsonObject.GetJSONNumber("attacker_replay_major_v").GetIntValue();
                this.m_attackerReplayBuildVersion   = jsonObject.GetJSONNumber("attacker_replay_build_v").GetIntValue();
                this.m_attackerReplayContentVersion = jsonObject.GetJSONNumber("attacker_replay_content_v").GetIntValue();
            }

            LogicJSONNumber opponentReplayIdHighNumber = jsonObject.GetJSONNumber("opponent_replay_id_hi");

            if (opponentReplayIdHighNumber != null)
            {
                this.m_attackerReplayId             = new LogicLong(opponentReplayIdHighNumber.GetIntValue(), jsonObject.GetJSONNumber("opponent_replay_id_lo").GetIntValue());
                this.m_attackerReplayShardId        = jsonObject.GetJSONNumber("opponent_replay_shard_id").GetIntValue();
                this.m_attackerReplayMajorVersion   = jsonObject.GetJSONNumber("opponent_replay_major_v").GetIntValue();
                this.m_attackerReplayBuildVersion   = jsonObject.GetJSONNumber("opponent_replay_build_v").GetIntValue();
                this.m_attackerReplayContentVersion = jsonObject.GetJSONNumber("opponent_replay_content_v").GetIntValue();
            }

            this.m_attackerBattleLog = jsonObject.GetJSONString("attacker_battleLog").GetStringValue();
            this.m_opponentBattleLog = jsonObject.GetJSONString("opponent_battleLog").GetStringValue();
        }
Exemplo n.º 15
0
        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");
            }
        }
Exemplo n.º 16
0
        public override void Load(LogicJSONObject jsonObject)
        {
            this.LoadUpgradeLevel(jsonObject);

            LogicTrapData data = this.GetTrapData();

            if (data.HasAlternativeMode() || data.GetSpawnedCharAir() != null && data.GetSpawnedCharGround() != null)
            {
                LogicLayoutComponent layoutComponent = (LogicLayoutComponent)this.GetComponent(LogicComponentType.LAYOUT);

                if (layoutComponent != null)
                {
                    for (int i = 0; i < 8; i++)
                    {
                        LogicJSONBoolean airModeObject = jsonObject.GetJSONBoolean(layoutComponent.GetLayoutVariableNameAirMode(i, false));

                        if (airModeObject != null)
                        {
                            this.m_useAirMode[i] = airModeObject.IsTrue();
                        }

                        LogicJSONBoolean draftAirModeObject = jsonObject.GetJSONBoolean(layoutComponent.GetLayoutVariableNameAirMode(i, true));

                        if (draftAirModeObject != null)
                        {
                            this.m_draftUseAirMode[i] = draftAirModeObject.IsTrue();
                        }
                    }
                }

                LogicTriggerComponent triggerComponent = this.GetTriggerComponent();

                int  layoutId = this.m_level.GetCurrentLayout();
                bool airMode  = this.m_useAirMode[layoutId];

                triggerComponent.SetAirTrigger(airMode);
                triggerComponent.SetGroundTrigger(!airMode);
            }

            if (data.GetDirectionCount() > 0)
            {
                LogicLayoutComponent layoutComponent = (LogicLayoutComponent)this.GetComponent(LogicComponentType.LAYOUT);

                if (layoutComponent != null)
                {
                    for (int i = 0; i < 8; i++)
                    {
                        LogicJSONNumber trapDistanceObject = jsonObject.GetJSONNumber(layoutComponent.GetLayoutVariableNameTrapDirection(i, false));

                        if (trapDistanceObject != null)
                        {
                            this.m_direction[i] = trapDistanceObject.GetIntValue();
                        }

                        LogicJSONNumber draftTrapDistanceObject = jsonObject.GetJSONNumber(layoutComponent.GetLayoutVariableNameTrapDirection(i, true));

                        if (draftTrapDistanceObject != null)
                        {
                            this.m_draftDirection[i] = draftTrapDistanceObject.GetIntValue();
                        }
                    }
                }
            }

            this.m_level.GetWorkerManagerAt(this.m_villageType).DeallocateWorker(this);

            if (this.m_constructionTimer != null)
            {
                this.m_constructionTimer.Destruct();
                this.m_constructionTimer = null;
            }

            LogicJSONNumber constTimeObject = jsonObject.GetJSONNumber("const_t");

            if (constTimeObject != null)
            {
                int constTime = constTimeObject.GetIntValue();

                if (!LogicDataTables.GetGlobals().ClampBuildingTimes())
                {
                    if (this.m_upgLevel < data.GetUpgradeLevelCount() - 1)
                    {
                        constTime = LogicMath.Min(constTime, data.GetBuildTime(this.m_upgLevel + 1));
                    }
                }

                this.m_constructionTimer = new LogicTimer();
                this.m_constructionTimer.StartTimer(constTime, this.m_level.GetLogicTime(), false, -1);

                LogicJSONNumber constTimeEndObject = jsonObject.GetJSONNumber("const_t_end");

                if (constTimeEndObject != null)
                {
                    this.m_constructionTimer.SetEndTimestamp(constTimeEndObject.GetIntValue());
                }

                LogicJSONNumber conffObject = jsonObject.GetJSONNumber("con_ff");

                if (conffObject != null)
                {
                    this.m_constructionTimer.SetFastForward(conffObject.GetIntValue());
                }

                this.m_level.GetWorkerManagerAt(this.m_villageType).AllocateWorker(this);
                this.m_upgrading = this.m_upgLevel != -1;
            }

            LogicJSONBoolean disarmed = jsonObject.GetJSONBoolean("needs_repair");

            if (disarmed != null)
            {
                this.m_disarmed = disarmed.IsTrue();
            }

            this.SetUpgradeLevel(this.m_upgLevel);
            base.Load(jsonObject);
        }
Exemplo n.º 17
0
        public override void LoadFromSnapshot(LogicJSONObject jsonObject)
        {
            if (this.m_data.GetVillageType() == 1)
            {
                this.Load(jsonObject);
                return;
            }

            LogicTrapData data = this.GetTrapData();

            this.LoadUpgradeLevel(jsonObject);
            this.m_level.GetWorkerManagerAt(this.m_villageType).DeallocateWorker(this);

            if (this.m_constructionTimer != null)
            {
                this.m_constructionTimer.Destruct();
                this.m_constructionTimer = null;
            }

            if (data.HasAlternativeMode() || data.GetSpawnedCharAir() != null && data.GetSpawnedCharGround() != null)
            {
                LogicLayoutComponent layoutComponent = (LogicLayoutComponent)this.GetComponent(LogicComponentType.LAYOUT);

                if (layoutComponent != null)
                {
                    for (int i = 0; i < 8; i++)
                    {
                        LogicJSONBoolean airModeObject = jsonObject.GetJSONBoolean(layoutComponent.GetLayoutVariableNameAirMode(i, false));

                        if (airModeObject != null)
                        {
                            this.m_useAirMode[i] = airModeObject.IsTrue();
                        }
                    }
                }

                LogicTriggerComponent triggerComponent = this.GetTriggerComponent();

                bool airMode = this.m_useAirMode[this.m_level.GetWarLayout()];

                triggerComponent.SetAirTrigger(airMode);
                triggerComponent.SetGroundTrigger(!airMode);
            }

            if (data.GetDirectionCount() > 0)
            {
                LogicLayoutComponent layoutComponent = (LogicLayoutComponent)this.GetComponent(LogicComponentType.LAYOUT);

                if (layoutComponent != null)
                {
                    for (int i = 0; i < 8; i++)
                    {
                        LogicJSONNumber trapDistanceObject = jsonObject.GetJSONNumber(layoutComponent.GetLayoutVariableNameTrapDirection(i, false));

                        if (trapDistanceObject != null)
                        {
                            this.m_direction[i] = trapDistanceObject.GetIntValue();
                        }
                    }
                }
            }

            this.m_level.GetWorkerManagerAt(this.m_data.GetVillageType()).DeallocateWorker(this);

            if (this.m_constructionTimer != null)
            {
                this.m_constructionTimer.Destruct();
                this.m_constructionTimer = null;
            }

            this.SetUpgradeLevel(this.m_upgLevel);
            base.LoadFromSnapshot(jsonObject);
        }
Exemplo n.º 18
0
        public LogicJSONObject LoadBattleLogFromJSON(LogicJSONObject root)
        {
            LogicJSONNumber villageTypeNumber = root.GetJSONNumber("villageType");

            if (villageTypeNumber != null)
            {
                this.m_villageType = villageTypeNumber.GetIntValue();
            }

            LogicJSONNode lootNode = root.Get("loot");

            if (lootNode != null && lootNode.GetJSONNodeType() == LogicJSONNodeType.ARRAY)
            {
                LogicBattleLog.AddJSONDataSlotsToArray((LogicJSONArray)lootNode, this.m_lootCount);
            }
            else if (this.m_villageType != 1)
            {
                Debugger.Warning("LogicBattleLog has no loot.");
            }

            LogicJSONNode unitNode = root.Get("units");

            if (unitNode != null && unitNode.GetJSONNodeType() == LogicJSONNodeType.ARRAY)
            {
                LogicBattleLog.AddJSONDataSlotsToArray((LogicJSONArray)unitNode, this.m_castedUnitCount);
            }
            else
            {
                Debugger.Warning("LogicBattleLog has no loot.");
            }

            LogicJSONNode allianceUnitNode = root.Get("cc_units");

            if (allianceUnitNode != null && allianceUnitNode.GetJSONNodeType() == LogicJSONNodeType.ARRAY)
            {
                LogicBattleLog.AddJSONUnitSlotsToArray((LogicJSONArray)allianceUnitNode, this.m_castedAllianceUnitCount);
            }

            LogicJSONNode costNode = root.Get("costs");

            if (costNode != null && costNode.GetJSONNodeType() == LogicJSONNodeType.ARRAY)
            {
                LogicBattleLog.AddJSONDataSlotsToArray((LogicJSONArray)costNode, this.m_costCount);
            }

            LogicJSONNode spellNode = root.Get("spells");

            if (spellNode != null && spellNode.GetJSONNodeType() == LogicJSONNodeType.ARRAY)
            {
                LogicBattleLog.AddJSONDataSlotsToArray((LogicJSONArray)spellNode, this.m_costCount);
            }
            else if (this.m_villageType != 1)
            {
                Debugger.Warning("LogicBattleLog has no spells.");
            }

            LogicJSONNode levelNode = root.Get("levels");

            if (levelNode != null && levelNode.GetJSONNodeType() == LogicJSONNodeType.ARRAY)
            {
                LogicBattleLog.AddJSONDataSlotsToArray((LogicJSONArray)levelNode, this.m_unitLevelCount);
            }
            else
            {
                Debugger.Warning("LogicBattleLog has no levels.");
            }

            LogicJSONNode statsNode = root.Get("stats");

            if (statsNode != null && statsNode.GetJSONNodeType() == LogicJSONNodeType.OBJECT)
            {
                LogicJSONObject  statsObject = (LogicJSONObject)statsNode;
                LogicJSONBoolean townhallDestroyedBoolean = statsObject.GetJSONBoolean("townhallDestroyed");

                if (townhallDestroyedBoolean != null)
                {
                    this.m_townhallDestroyed = townhallDestroyedBoolean.IsTrue();
                }

                LogicJSONBoolean battleEndedBoolean = statsObject.GetJSONBoolean("battleEnded");

                if (battleEndedBoolean != null)
                {
                    this.m_battleEnded = battleEndedBoolean.IsTrue();
                }

                LogicJSONBoolean allianceUsedBoolean = statsObject.GetJSONBoolean("allianceUsed");

                if (allianceUsedBoolean != null)
                {
                    this.m_allianceUsed = allianceUsedBoolean.IsTrue();
                }

                LogicJSONNumber destructionPercentageNumber = statsObject.GetJSONNumber("destructionPercentage");

                if (destructionPercentageNumber != null)
                {
                    this.m_destructionPercentage = destructionPercentageNumber.GetIntValue();
                }

                LogicJSONNumber battleTimeNumber = statsObject.GetJSONNumber("battleTime");

                if (battleTimeNumber != null)
                {
                    this.m_battleTime = battleTimeNumber.GetIntValue();
                }

                LogicJSONNumber attackerScoreNumber = statsObject.GetJSONNumber("attackerScore");

                if (attackerScoreNumber != null)
                {
                    this.m_attackerScore = attackerScoreNumber.GetIntValue();
                }

                LogicJSONNumber defenderScoreNumber = statsObject.GetJSONNumber("defenderScore");

                if (defenderScoreNumber != null)
                {
                    this.m_defenderScore = defenderScoreNumber.GetIntValue();
                }

                LogicJSONNumber originalAttackerScoreNumber = statsObject.GetJSONNumber("originalAttackerScore");

                if (originalAttackerScoreNumber != null)
                {
                    this.m_originalAttackerScore = originalAttackerScoreNumber.GetIntValue();
                }
                else
                {
                    this.m_attackerScore = -1;
                }

                LogicJSONNumber originalDefenderScoreNumber = statsObject.GetJSONNumber("originalDefenderScore");

                if (originalDefenderScoreNumber != null)
                {
                    this.m_originalDefenderScore = originalDefenderScoreNumber.GetIntValue();
                }
                else
                {
                    this.m_originalDefenderScore = -1;
                }

                this.LoadAttackerNameFromJson(statsObject);
                this.LoadDefenderNameFromJson(statsObject);

                LogicJSONNumber lootMultiplierByTownHallDiffNumber = statsObject.GetJSONNumber("lootMultiplierByTownHallDiff");

                if (lootMultiplierByTownHallDiffNumber != null)
                {
                    this.m_lootMultiplierByTownHallDiff = lootMultiplierByTownHallDiffNumber.GetIntValue();
                }
                else
                {
                    this.m_lootMultiplierByTownHallDiff = -1;
                }

                LogicJSONNumber deployedHousingSpaceNumber = statsObject.GetJSONNumber("deployedHousingSpace");

                if (deployedHousingSpaceNumber != null)
                {
                    this.m_deployedHousingSpace = deployedHousingSpaceNumber.GetIntValue();
                }

                LogicJSONNumber armyDeploymentPercentageNumber = statsObject.GetJSONNumber("armyDeploymentPercentage");

                if (armyDeploymentPercentageNumber != null)
                {
                    this.m_armyDeploymentPercentage = armyDeploymentPercentageNumber.GetIntValue();
                }

                LogicJSONNumber attackerStarsNumber = statsObject.GetJSONNumber("attackerStars");

                if (attackerStarsNumber != null)
                {
                    this.m_attackerStars = attackerStarsNumber.GetIntValue();
                }

                return(statsObject);
            }

            Debugger.Warning("LogicBattleLog has no stats.");

            return(null);
        }
 public ServerSettings(LogicJSONObject jsonObject)
 {
     this.ContentValidationModeEnabled = jsonObject.GetJSONBoolean("contentValidationModeEnabled").IsTrue();
     this.Proxy = new ProxySettings(jsonObject.GetJSONObject("proxy"));
     this.Admin = new AdminSettings(jsonObject.GetJSONObject("admin"));
 }
Exemplo n.º 20
0
 public static void Load(LogicJSONObject jsonObject)
 {
     GamePlaySettings.FriendlyChallengeEnabled = jsonObject.GetJSONBoolean("friendlyChallengeEnabled").IsTrue();
     GamePlaySettings.OpAttackEnabled          = jsonObject.GetJSONBoolean("opAttackEnabled").IsTrue();
     GamePlaySettings.OpRankingEnabled         = jsonObject.GetJSONBoolean("opRankingEnabled").IsTrue();
 }
Exemplo n.º 21
0
        /// <summary>
        ///     Loads this instance.
        /// </summary>
        public override void Load(LogicJSONObject jsonObject)
        {
            LogicJSONNumber lvlObject = jsonObject.GetJSONNumber("lvl");

            if (lvlObject != null)
            {
                this._upgLevel = lvlObject.GetIntValue();
                int maxLvl = this.GetVillageObjectData().GetUpgradeLevelCount();

                if (this._upgLevel >= maxLvl)
                {
                    Debugger.Warning(string.Format("LogicVillageObject::load() - Loaded upgrade level {0} is over max! (max = {1}) id {2} data id {3}",
                                                   lvlObject.GetIntValue(),
                                                   maxLvl,
                                                   this._globalId,
                                                   this._data.GetGlobalID()));
                    this._upgLevel = maxLvl - 1;
                }
                else
                {
                    if (this._upgLevel < -1)
                    {
                        Debugger.Error("LogicVillageObject::load() - Loaded an illegal upgrade level!");
                    }
                }
            }
            else
            {
                Debugger.Error("LogicVillageObject::load - Upgrade level was not found!");
            }

            if (this.GetVillageObjectData().RequiresBuilder)
            {
                this._level.GetWorkerManagerAt(this._villageType).DeallocateWorker(this);
            }

            LogicJSONBoolean lockedObject = jsonObject.GetJSONBoolean("locked");

            if (lockedObject != null)
            {
                this._isLocked = lockedObject.IsTrue();
            }

            if (this._constructionTimer != null)
            {
                this._constructionTimer.Destruct();
                this._constructionTimer = null;
            }

            LogicJSONNumber constTimeObject = jsonObject.GetJSONNumber("const_t");

            if (constTimeObject != null)
            {
                int constTime = constTimeObject.GetIntValue();

                if (!LogicDataTables.GetGlobals().ClampBuildingTimes())
                {
                    if (this._upgLevel < this.GetVillageObjectData().GetUpgradeLevelCount() - 1)
                    {
                        constTime = LogicMath.Min(constTime, this.GetVillageObjectData().GetBuildTime(this._upgLevel + 1));
                    }
                }

                this._constructionTimer = new LogicTimer();
                this._constructionTimer.StartTimer(constTime, this._level.GetLogicTime(), false, -1);

                LogicJSONNumber constTimeEndObject = jsonObject.GetJSONNumber("const_t_end");

                if (constTimeEndObject != null)
                {
                    this._constructionTimer.SetEndTimestamp(constTimeEndObject.GetIntValue());
                }

                LogicJSONNumber conffObject = jsonObject.GetJSONNumber("con_ff");

                if (conffObject != null)
                {
                    this._constructionTimer.SetFastForward(conffObject.GetIntValue());
                }

                LogicVillageObjectData villageObjectData = this.GetVillageObjectData();

                if (villageObjectData.RequiresBuilder && !villageObjectData.AutomaticUpgrades)
                {
                    this._level.GetWorkerManagerAt(this._villageType).AllocateWorker(this);
                }

                this._isUpgrading = this._upgLevel != -1;
            }

            this._upgLevel = LogicMath.Min(this._upgLevel, this.GetVillageObjectData().GetUpgradeLevelCount());

            base.Load(jsonObject);

            this.SetInitialPosition((this.GetVillageObjectData().TileX100 << 9) / 100,
                                    (this.GetVillageObjectData().TileY100 << 9) / 100);
        }
Exemplo n.º 22
0
        /// <summary>
        ///     Loads this instance.
        /// </summary>
        public override void Load(LogicJSONObject jsonObject)
        {
            LogicJSONNumber lvlObject = jsonObject.GetJSONNumber("lvl");

            if (lvlObject != null)
            {
                this._upgLevel = lvlObject.GetIntValue();
                int maxLvl = this.GetTrapData().GetUpgradeLevelCount();

                if (this._upgLevel >= maxLvl)
                {
                    Debugger.Warning(string.Format("LogicTrap::load() - Loaded upgrade level {0} is over max! (max = {1}) id {2} data id {3}",
                                                   lvlObject.GetIntValue(),
                                                   maxLvl,
                                                   this._globalId,
                                                   this._data.GetGlobalID()));
                    this._upgLevel = maxLvl - 1;
                }
                else
                {
                    if (this._upgLevel < -1)
                    {
                        Debugger.Error("LogicTrap::load() - Loaded an illegal upgrade level!");
                    }
                }
            }
            else
            {
                Debugger.Error("LogicTrap::load - Upgrade level was not found!");
            }

            this._level.GetWorkerManagerAt(this._villageType).DeallocateWorker(this);

            if (this._constructionTimer != null)
            {
                this._constructionTimer.Destruct();
                this._constructionTimer = null;
            }

            LogicJSONNumber constTimeObject = jsonObject.GetJSONNumber("const_t");

            if (constTimeObject != null)
            {
                int constTime = constTimeObject.GetIntValue();

                if (!LogicDataTables.GetGlobals().ClampBuildingTimes())
                {
                    if (this._upgLevel < this.GetTrapData().GetUpgradeLevelCount() - 1)
                    {
                        constTime = LogicMath.Min(constTime, this.GetTrapData().GetBuildTime(this._upgLevel + 1));
                    }
                }

                this._constructionTimer = new LogicTimer();
                this._constructionTimer.StartTimer(constTime, this._level.GetLogicTime(), false, -1);

                LogicJSONNumber constTimeEndObject = jsonObject.GetJSONNumber("const_t_end");

                if (constTimeEndObject != null)
                {
                    this._constructionTimer.SetEndTimestamp(constTimeEndObject.GetIntValue());
                }

                LogicJSONNumber conffObject = jsonObject.GetJSONNumber("con_ff");

                if (conffObject != null)
                {
                    this._constructionTimer.SetFastForward(conffObject.GetIntValue());
                }

                this._level.GetWorkerManagerAt(this._villageType).AllocateWorker(this);
                this._upgrading = this._upgLevel != -1;
            }

            LogicJSONBoolean disarmed = jsonObject.GetJSONBoolean("needs_repair");

            if (disarmed != null)
            {
                this._disarmed = disarmed.IsTrue();
            }

            base.Load(jsonObject);
        }