public void LoadDirectAttackState(LogicClientHome home, LogicAvatar homeOwnerAvatar, LogicAvatar visitorAvatar, int secondsSinceLastSave, bool war, bool village2, int currentTimestamp) { if (this.m_state != 0) { Debugger.Error("loadAttackState called from invalid state"); } 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_battleTimer = new LogicTimer(); this.m_battleTimer.StartTimer( LogicDataTables.GetGlobals().GetAttackLengthSecs() + (village2 ? LogicDataTables.GetGlobals().GetAttackVillage2PreparationLengthSecs() : LogicDataTables.GetGlobals().GetAttackPreparationLengthSecs()), this.m_level.GetLogicTime(), false, -1); if (!homeOwnerAvatar.IsClientAvatar()) { Debugger.Error("loadDirectAttackState called and home owner is not client avatar"); } this.m_level.SetMatchType(village2 ? 8 : war ? 7 : 3, null); if (village2) { this.m_level.SetVillageType(1); } this.m_level.SetHome(home, false); this.m_level.SetHomeOwnerAvatar(homeOwnerAvatar); homeOwnerAvatar.SetLevel(this.m_level); this.m_level.SetVisitorAvatar(visitorAvatar); this.m_level.FastForwardTime(secondsSinceLastSave); this.m_level.LoadingFinished(); this.m_replay = new LogicReplay(this.m_level); }
public void LoadVisitState(LogicClientHome home, LogicAvatar homeOwnerAvatar, LogicAvatar visitorAvatar, int currentTimestamp, int secondsSinceLastSave) { if (this.m_state != 0) { Debugger.Error("loadVisitState called from invalid state"); } else { this.m_state = 4; this.m_startTimestamp = currentTimestamp; this.m_configuration.Load((LogicJSONObject)LogicJSONParser.Parse(home.GetGlobalJSON())); this.m_calendar.Load(home.GetCalendarJSON(), currentTimestamp); this.m_level.SetNpcVillage(homeOwnerAvatar.IsNpcAvatar()); this.m_level.SetHome(home, false); this.m_level.SetHomeOwnerAvatar(homeOwnerAvatar); this.m_level.SetVisitorAvatar(visitorAvatar); this.m_level.FastForwardTime(secondsSinceLastSave); homeOwnerAvatar.SetLevel(this.m_level); this.m_level.LoadingFinished(); } }
/// <summary> /// Loads the home state. /// </summary> public void LoadHomeState(LogicClientHome home, LogicAvatar homeOwnerAvatar, int currentTimestamp, int secondsSinceLastSave, int secondsSinceLastMaintenance) { if (home != null) { this._state = 1; if (LogicDataTables.GetGlobals().StartInLastUsedVillage()) { int lastUsedVillage = homeOwnerAvatar.GetVillageToGoTo(); if (!this._level.GetMissionManager().HasTravel(homeOwnerAvatar)) { lastUsedVillage = 0; } if (lastUsedVillage < 0) { Debugger.Warning("VillageToGoTo<0"); } else { if (lastUsedVillage > 1) { Debugger.Warning("VillageToGoTo too big"); } else { this._level.SetVillageType(lastUsedVillage); } } } this._secondsSinceLastMaintenance = secondsSinceLastMaintenance; this._currentTimestamp = currentTimestamp; this._configuration.Load((LogicJSONObject)LogicJSONParser.Parse(home.GetGlobalJSON())); this._calendar.Load(home.GetCalendarJSON(), currentTimestamp); if (this._battleTimer != null) { this._battleTimer.Destruct(); this._battleTimer = null; } this._level.SetHome(home, true); this._level.SetHomeOwnerAvatar(homeOwnerAvatar); this._level.FastForwardTime(secondsSinceLastSave); homeOwnerAvatar.SetLevel(this._level); this._level.LoadingFinished(); this._shieldTime = LogicTime.GetSecondsInTicks(home.GetShieldDurationSeconds()); this._guardTime = LogicTime.GetSecondsInTicks(home.GetGuardDurationSeconds()); this._maintenanceTime = LogicTime.GetSecondsInTicks(home.GetNextMaintenanceSeconds()); int logicTime = this._level.GetLogicTime(); int startGuardTime = logicTime; if (this._shieldTime >= logicTime) { startGuardTime = this._shieldTime; } this._startGuardTime = startGuardTime; if (LogicDataTables.GetGlobals().UseVillageObjects()) { this._level.LoadVillageObjects(); } } }