public void StartUpgrading(bool ignoreListener) { if (this.m_constructionTimer != null) { this.m_constructionTimer.Destruct(); this.m_constructionTimer = null; } LogicVillageObjectData data = this.GetVillageObjectData(); int constructionTime = data.GetBuildTime(this.GetUpgradeLevel() + 1); this.m_upgrading = true; if (constructionTime <= 0) { this.FinishConstruction(false, true); } else { if (data.IsRequiresBuilder()) { this.m_level.GetWorkerManagerAt(data.GetVillageType()).AllocateWorker(this); } this.EnableComponent(LogicComponentType.RESOURCE_PRODUCTION, false); this.EnableComponent(LogicComponentType.UNIT_PRODUCTION, false); this.EnableComponent(LogicComponentType.UNIT_UPGRADE, false); this.m_constructionTimer = new LogicTimer(); this.m_constructionTimer.StartTimer(constructionTime, this.m_level.GetLogicTime(), true, this.m_level.GetHomeOwnerAvatarChangeListener().GetCurrentTimestamp()); } }
public void FinishUpgrading(bool tick) { if (this.m_timer != null) { LogicAvatar homeOwnerAvatar = this.m_parent.GetLevel().GetHomeOwnerAvatar(); if (homeOwnerAvatar.GetUnitUpgradeLevel(this.m_hero) < this.m_upgLevel || this.m_upgLevel == 0) { homeOwnerAvatar.CommodityCountChangeHelper(1, this.m_hero, 1); } this.m_parent.GetLevel().GetWorkerManagerAt(this.m_parent.GetData().GetVillageType()).DeallocateWorker(this.m_parent); homeOwnerAvatar.SetHeroState(this.m_hero, 3); homeOwnerAvatar.GetChangeListener().CommodityCountChanged(2, this.m_hero, 3); this.SetFullHealth(); this.m_timer.Destruct(); this.m_timer = null; } else { Debugger.Warning("LogicHeroBaseComponent::finishUpgrading called and m_pHero is NULL"); } }
public void StartUpgrading() { if (this.CanStartUpgrading(true)) { ((LogicBuilding)this.m_parent).DestructBoost(); if (this.m_timer != null) { this.m_timer.Destruct(); this.m_timer = null; } LogicAvatar homeOwnerAvatar = this.m_parent.GetLevel().GetHomeOwnerAvatar(); this.m_parent.GetLevel().GetWorkerManagerAt(this.m_parent.GetData().GetVillageType()).AllocateWorker(this.m_parent); this.m_timer = new LogicTimer(); this.m_timer.StartTimer(this.GetTotalSeconds(), this.m_parent.GetLevel().GetLogicTime(), true, this.m_parent.GetLevel().GetHomeOwnerAvatarChangeListener().GetCurrentTimestamp()); this.m_upgLevel = homeOwnerAvatar.GetUnitUpgradeLevel(this.m_hero) + 1; homeOwnerAvatar.SetHeroState(this.m_hero, 1); homeOwnerAvatar.GetChangeListener().CommodityCountChanged(2, this.m_hero, 1); } }
private void Awake() { DontDestroyOnLoad(gameObject); Random r = new Random(); _cachedServerState = new ServerState(); _cachedShootData = new ShootPacket(); _userName = Environment.MachineName + " " + r.Next(100000); LogicTimer = new LogicTimer(OnLogicUpdate); _writer = new NetDataWriter(); _playerManager = new ClientPlayerManager(this); _shootsPool = new GamePool <ShootEffect>(ShootEffectContructor, 100); _packetProcessor = new NetPacketProcessor(); _packetProcessor.RegisterNestedType((w, v) => w.Put(v), reader => reader.GetVector2()); _packetProcessor.RegisterNestedType <PlayerState>(); _packetProcessor.SubscribeReusable <PlayerJoinedPacket>(OnPlayerJoined); _packetProcessor.SubscribeReusable <JoinAcceptPacket>(OnJoinAccept); _packetProcessor.SubscribeReusable <PlayerLeavedPacket>(OnPlayerLeaved); _netManager = new NetManager(this) { AutoRecycle = true, IPv6Enabled = IPv6Mode.Disabled }; _netManager.Start(); }
/// <summary> /// Destructs this instance. /// </summary> public void Destruct() { if (this._level != null) { this._level.Destruct(); this._level = null; } if (this._commandManager != null) { this._commandManager.Destruct(); this._commandManager = null; } if (this._calendar != null) { this._calendar.Destruct(); this._calendar = null; } if (this._battleTimer != null) { this._battleTimer.Destruct(); this._battleTimer = null; } if (this._replay != null) { this._replay.Destruct(); this._replay = null; } this._configuration = null; }
public void ProductionCompleted() { this.m_unit.SetCount(this.GetMaxUnitsInCamp((LogicCharacterData)this.m_unit.GetData())); if (this.m_productionTimer != null) { this.m_productionTimer.Destruct(); this.m_productionTimer = null; } LogicAvatar homeOwnerAvatar = this.m_parent.GetLevel().GetHomeOwnerAvatar(); LogicCombatItemData combatItemData = (LogicCombatItemData)this.m_unit.GetData(); int unitCount = this.m_parent.GetLevel().GetMissionManager().IsVillage2TutorialOpen() ? this.m_unit.GetCount() - homeOwnerAvatar.GetUnitCountVillage2(combatItemData) : this.m_unit.GetCount(); homeOwnerAvatar.CommodityCountChangeHelper(7, this.m_unit.GetData(), unitCount); if (this.m_parent.GetLevel().GetGameListener() != null) { // ? } int state = this.m_parent.GetLevel().GetState(); if (state == 1) { if (this.m_parent.GetListener() != null) { // ? } } }
public int FastForwardProduction(int secs) { if (secs > 0) { if (this.m_unit != null && this.m_unit.GetCount() == 0) { if (this.m_productionTimer == null) { this.m_productionTimer = new LogicTimer(); this.m_productionTimer.StartTimer(this.GetTrainingTime((LogicCharacterData)this.m_unit.GetData()), this.m_parent.GetLevel().GetLogicTime(), false, -1); } int remainingSecs = this.m_productionTimer.GetRemainingSeconds(this.m_parent.GetLevel().GetLogicTime()); if (remainingSecs - secs <= 0) { this.ProductionCompleted(); return(remainingSecs); } this.m_productionTimer.StartTimer(remainingSecs - secs, this.m_parent.GetLevel().GetLogicTime(), false, -1); return(secs); } } return(0); }
/// <summary> /// Called when the training of the unit is finished. /// </summary> public void TrainingFinished() { this._unit.SetCount(this.GetMaxCapacity()); if (this._trainingTimer != null) { this._trainingTimer.Destruct(); this._trainingTimer = null; } LogicAvatar homeOwnerAvatar = this._parent.GetLevel().GetHomeOwnerAvatar(); LogicCombatItemData combatItemData = (LogicCombatItemData)this._unit.GetData(); int unitCount = this._parent.GetLevel().GetMissionManager().IsVillage2TutorialOpen() ? this._unit.GetCount() - homeOwnerAvatar.GetUnitCountVillage2(combatItemData) : this._unit.GetCount(); homeOwnerAvatar.CommodityCountChangeHelper(7, this._unit.GetData(), unitCount); if (this._parent.GetLevel().GetGameListener() != null) { // ? } int state = this._parent.GetLevel().GetState(); if (state == 1) { if (this._parent.GetListener() != null) { // ? } } }
public void LoadNpcDuelState(LogicClientHome home, LogicAvatar homeOwnerAvatar, LogicAvatar visitorAvatar, int currentTimestamp, int secondsSinceLastSave) { if (this.m_state != 0) { Debugger.Error("loadNpcDuelState called from invalid state"); } else { this.m_state = 2; this.m_startTimestamp = currentTimestamp; this.m_configuration.Load((LogicJSONObject)LogicJSONParser.Parse(home.GetGlobalJSON())); this.m_calendar.Load(home.GetCalendarJSON(), currentTimestamp); if (this.m_battleTimer != null) { this.m_battleTimer.Destruct(); this.m_battleTimer = null; } this.m_level.SetMatchType(9, null); this.m_level.SetVillageType(1); this.m_level.SetHome(home, false); this.m_level.SetHomeOwnerAvatar(homeOwnerAvatar); this.m_level.SetVisitorAvatar(visitorAvatar); this.m_level.FastForwardTime(secondsSinceLastSave); this.m_level.LoadingFinished(); this.m_replay = new LogicReplay(this.m_level); } }
/// <summary> /// Destructs this instance. /// </summary> public void Destruct() { if (this._slots.Count != 0) { do { this._slots[0].Destruct(); this._slots.Remove(0); } while (this._slots.Count != 0); } if (this._timer != null) { this._timer.Destruct(); this._timer = null; } if (this._boostTimer != null) { this._boostTimer.Destruct(); this._boostTimer = null; } this._level = null; }
/// <summary> /// Starts the upgrading of the trap. /// </summary> public void StartUpgrading() { if (this._constructionTimer != null) { this._constructionTimer.Destruct(); this._constructionTimer = null; } LogicTrapData data = this.GetTrapData(); this._upgrading = true; int buildTime = data.GetBuildTime(this._upgLevel + 1); if (buildTime <= 0) { this.FinishConstruction(false); } else { this._level.GetWorkerManagerAt(data.GetVillageType()).AllocateWorker(this); this._constructionTimer = new LogicTimer(); this._constructionTimer.StartTimer(buildTime, this._level.GetLogicTime(), true, this._level.GetGameMode().GetCurrentTimestamp()); } }
public void FinishUpgrading(bool tick) { if (this.m_unit != null) { this.m_parent.GetLevel().GetHomeOwnerAvatar().CommodityCountChangeHelper(1, this.m_unit, 1); if (this.m_unit.GetVillageType() == 1 && this.m_unit.GetCombatItemType() == LogicCombatItemData.COMBAT_ITEM_TYPE_CHARACTER) { this.m_parent.GetLevel().GetGameObjectManagerAt(1).RefreshArmyCampSize(); } if (this.m_parent.GetLevel().GetState() == 1) { this.m_parent.GetLevel().GetGameListener() .UnitUpgradeCompleted(this.m_unit, this.m_parent.GetLevel().GetHomeOwnerAvatar().GetUnitUpgradeLevel(this.m_unit), tick); } this.m_unit = null; } else { Debugger.Warning("LogicUnitUpgradeComponent::finishUpgrading called and m_pUnit is NULL"); } if (this.m_timer != null) { this.m_timer.Destruct(); this.m_timer = null; } }
public void StartServer() { DontDestroyOnLoad(gameObject); _logicTimer = new LogicTimer(OnLogicUpdate); _playerManager = new ServerPlayerManager(this); //_packetProcessor = new NetPacketProcessor(); ////register auto serializable vector2 //_packetProcessor.RegisterNestedType((w, v) => w.Put(v), r => r.GetVector2()); ////register auto serializable PlayerState //_packetProcessor.RegisterNestedType<PlayerState>(); //_packetProcessor.SubscribeReusable<JoinPacket, NetPeer>(OnJoinReceived); //_netManager = new NetManager(this) //{ // AutoRecycle = true //}; _netManager = G.CSEngineApp.LiteNet._netManager; _packetProcessor = G.CSEngineApp.LiteNet._packetProcessor; _packetProcessor.RegisterNestedType((w, v) => w.Put(v), r => r.GetVector2()); _packetProcessor.RegisterNestedType <PlayerState>(); _packetProcessor.SubscribeReusable <JoinPacket, NetPeer>(OnJoinReceived); _netManager.Start(10515); _logicTimer.Start(); }
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()); } } }
/// <summary> /// Ticks for update this instance. /// </summary> public void Tick() { if (this.GetRemainingBoostTimeSecs() > 0) { if (this._timer != null) { if (!this.IsBoostPaused()) { this._timer.FastForwardSubticks(4 * this.GetBoostMultiplier() - 4); } } } Boolean prodCompleted = this._timer != null && this._timer.GetRemainingSeconds(this._level.GetLogicTime()) == 0; LogicCombatItemData prodData = this.GetWaitingForSpaceUnit(); if (this._nextProduction > 0) { this._nextProduction = prodCompleted ? 0 : LogicMath.Max(this._nextProduction - 64, 0); } if (this._boostTimer != null && this._boostTimer.GetRemainingSeconds(this._level.GetLogicTime()) <= 0) { this._boostTimer.Destruct(); this._boostTimer = null; } if (prodCompleted || prodData != null) { if (this._nextProduction == 0) { this.ProductionCompleted(false); } } }
public void StopRequestCooldownTime() { if (this.m_requestCooldownTimer != null) { this.m_requestCooldownTimer.Destruct(); this.m_requestCooldownTimer = null; } }
public override void LoadFromSnapshot(LogicJSONObject jsonObject) { if (this.m_timer != null) { this.m_timer.Destruct(); this.m_timer = null; } }
// Use this for initialization void Start() { LogicTimer m_logicTime = new LogicTimer(1f, 5); m_logicTime.AddListener(() => { Debug.Log("logic frame"); }); }
/// <summary> /// Initializes a new instance of the <see cref="LogicSailingTimer"/> class. /// </summary> internal LogicSailingTimer(LogicClientAvatar avatar) { this.Avatar = avatar; this.Timer = new LogicTimer(avatar.Time); this.Heroes = new LogicDataSlot(avatar); this.HeroLevels = new LogicDataSlot(avatar); }
public bool TrainingFinished() { bool success = false; if (this.m_timer != null) { this.m_timer.Destruct(); this.m_timer = null; } if (this.m_slots.Size() > 0) { LogicUnitProductionSlot prodSlot = this.GetCurrentlyTrainedSlot(); int prodIdx = this.GetCurrentlyTrainedIndex(); if (prodSlot != null) { if (prodSlot.GetCount() == 1) { prodSlot.SetTerminate(true); } else { prodSlot.SetCount(prodSlot.GetCount() - 1); LogicUnitProductionSlot previousSlot = this.m_slots[LogicMath.Max(prodIdx - 1, 0)]; if (previousSlot != null && previousSlot.IsTerminate() && previousSlot.GetData().GetGlobalID() == prodSlot.GetData().GetGlobalID()) { previousSlot.SetCount(previousSlot.GetCount() + 1); } else { this.m_slots.Add(prodIdx, new LogicUnitProductionSlot(prodSlot.GetData(), 1, true)); } } } if (this.m_slots.Size() > 0) { LogicCombatItemData nextProductionData = this.GetCurrentlyTrainedUnit(); if (nextProductionData != null && this.m_timer == null) { this.m_timer = new LogicTimer(); this.m_timer.StartTimer(nextProductionData.GetTrainingTime(this.m_level.GetHomeOwnerAvatar().GetUnitUpgradeLevel(nextProductionData), this.m_level, 0), this.m_level.GetLogicTime(), false, -1); success = true; } } } this.MergeSlots(); return(success); }
public override void Load(LogicJSONObject jsonObject) { this.LoadUpgradeLevel(jsonObject); 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 < this.GetVillageObjectData().GetUpgradeLevelCount() - 1) { constTime = LogicMath.Min(constTime, this.GetVillageObjectData().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()); } LogicVillageObjectData villageObjectData = this.GetVillageObjectData(); if (villageObjectData.IsRequiresBuilder() && !villageObjectData.IsAutomaticUpgrades()) { this.m_level.GetWorkerManagerAt(this.m_villageType).AllocateWorker(this); } this.m_upgrading = this.m_upgLevel != -1; } this.m_upgLevel = LogicMath.Clamp(this.m_upgLevel, 0, this.GetVillageObjectData().GetUpgradeLevelCount() - 1); base.Load(jsonObject); this.SetPositionXY((this.GetVillageObjectData().GetTileX100() << 9) / 100, (this.GetVillageObjectData().GetTileY100() << 9) / 100); }
public void StartRequestCooldownTime() { if (this.m_requestCooldownTimer == null) { this.m_requestCooldownTimer = new LogicTimer(); } this.m_requestCooldownTimer.StartTimer(this.GetTotalRequestCooldownTime(), this.m_parent.GetLevel().GetLogicTime(), false, -1); }
public void StartReplayShareCooldownTime() { if (this.m_replayShareCooldownTimer == null) { this.m_replayShareCooldownTimer = new LogicTimer(); } this.m_replayShareCooldownTimer.StartTimer(LogicDataTables.GetGlobals().GetReplayShareCooldown(), this.m_parent.GetLevel().GetLogicTime(), false, -1); }
public void StartArrangedWarCooldownTime() { if (this.m_arrangeWarCooldownTimer == null) { this.m_arrangeWarCooldownTimer = new LogicTimer(); } this.m_arrangeWarCooldownTimer.StartTimer(LogicDataTables.GetGlobals().GetArrangeWarCooldown(), this.m_parent.GetLevel().GetLogicTime(), false, -1); }
/// <summary> /// Destructs this instance. /// </summary> public override void Destruct() { base.Destruct(); if (this._constructionTimer != null) { this._constructionTimer.Destruct(); this._constructionTimer = null; } }
public void CancelClearing() { this.m_level.GetWorkerManagerAt(this.m_data.GetVillageType()).DeallocateWorker(this); if (this.m_clearTimer != null) { this.m_clearTimer.Destruct(); this.m_clearTimer = null; } }
public override void Destruct() { base.Destruct(); if (this.m_timer != null) { this.m_timer.Destruct(); this.m_timer = null; } }
public void Boost() { if (this.m_boostTimer != null) { this.m_boostTimer.Destruct(); this.m_boostTimer = null; } this.m_boostTimer = new LogicTimer(); this.m_boostTimer.StartTimer(this.GetMaxBoostTimeSecs(), this.m_level.GetLogicTime(), false, -1); }
public ServerSerivce() { _serverManager = new ServerManager(); _logicTimer = new LogicTimer(OnUpdateLogic); _packetProcessor = new NetPacketProcessor(); _packetProcessor.RegisterNestedType((w, v) => w.Put(v), r => r.GetVector2()); _packetProcessor.RegisterNestedType <CharacterPacket>(); _packetProcessor.SubscribeReusable <JoinPacket, NetPeer>(OnJoin); _netManager = new NetManager(this, true); }
/// <summary> /// Initializes a new instance of the <see cref="LogicSpellTimer"/> class. /// </summary> public LogicSpellTimer(LogicClientAvatar avatar) { this.Avatar = avatar; this.Spells = new LogicArrayList <LogicSpellData>(); this.SpellIDs = new LogicArrayList <int>(); this.Timer = new LogicTimer(avatar.Time); foreach (int spellId in this.SpellIDs) { this.Spells.Add((LogicSpellData)CSV.Tables.Get(Gamefile.Spells).GetDataWithID(spellId)); } }