/// <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(); } } }
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 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(); } } }
/// <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) { 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(); } }
/// <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(); }
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(); } }
/// <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); }
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 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> /// 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); }
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); }
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); }