public void Stop() { if (!this.IsRunning) { return; } this._notificationsAboutStart = 3; this.IsStarted = false; WCell.RealmServer.Global.World.Broadcast(string.Format( "War in {0} has ended. Light scores {1} vs {2} dark scores.", (object)this.Town, (object)this.LightScores, (object)this.DarkScores)); this.IsRunning = false; this.SetNextWarParametrs(); lock (this.JoinLock) { foreach (Character character in this.LightScores > this.DarkScores ? this.LightTeam.Values : this.DarkTeam.Values) { if (this.MvpCharacter == null) { this.MvpCharacter = character; } else if ((int)this.MvpCharacter.BattlegroundActPoints < (int)character.BattlegroundActPoints) { this.MvpCharacter = character; } } Asda2BattlegroundHandler.SendWiningFactionInfoResponse(this.Town, this.WiningFactionId, this.MvpCharacter == null ? "[No character]" : this.MvpCharacter.Name); if (this.MvpCharacter != null) { ServerApp <WCell.RealmServer.RealmServer> .IOQueue.AddMessage((Action)(() => { BattlegroundResultRecord battlegroundResultRecord = new BattlegroundResultRecord(this.Town, this.MvpCharacter.Name, this.MvpCharacter.EntityId.Low, this.LightScores, this.DarkScores); battlegroundResultRecord.CreateLater(); this.CurrentWarResultRecordGuid = battlegroundResultRecord.Guid; Asda2BattlegroundMgr.ProcessBattlegroundResultRecord(battlegroundResultRecord); })); } foreach (Character character in this.LightTeam.Values) { this.ProcessEndWar(character); } foreach (Character character in this.DarkTeam.Values) { this.ProcessEndWar(character); } foreach (Asda2WarPoint point in this.Points) { point.Status = Asda2WarPointStatus.NotOwned; point.OwnedFaction = (short)-1; Asda2BattlegroundHandler.SendUpdatePointInfoResponse((IRealmClient)null, point); } WCell.RealmServer.Global.World.TaskQueue.CallDelayed(60000, new Action(this.KickAll)); } }
public void Update(int dt) { if (Status == Asda2WarPointStatus.Owned) { //gain scores each one minute to team _timeToNextGainPoints -= dt; if (_timeToNextGainPoints <= 0) { BattleGround.GainScores(OwnedFaction, CharacterFormulas.FactionWarPointsPerTicForCapturedPoints); _timeToNextGainPoints += CharacterFormulas.DefaultTimeGainExpReward; } } if (_isCapturing) { _tomeToCaprute -= dt; if (_tomeToCaprute <= 0) { //point captured Status = Asda2WarPointStatus.Owned; Asda2BattlegroundHandler.SendUpdatePointInfoResponse(null, this); Asda2BattlegroundHandler.SendWarCurrentActionInfoResponse(BattleGround, BattleGroundInfoMessageType.SuccessToCompletelyOccuptyTheNumOccupationPoints, Id, null, OwnedFaction); Asda2BattlegroundHandler.SendWarCurrentActionInfoResponse(BattleGround, BattleGroundInfoMessageType.TheOtherSideHasTemporarilyOccupiedTheNumOccupationPoint, Id, null, (short?)(OwnedFaction == 0 ? 1 : 0)); BattleGround.GainScores(OwnedFaction, CharacterFormulas.FactionWarPointsPerTicForCapturedPoints); _isCapturing = false; } } else { if (CapturingCharacter == null || !BattleGround.IsStarted) { return; } _timeToStartCapturing -= dt; if (_timeToStartCapturing <= 0) { _tomeToCaprute = CharacterFormulas.DefaultCaptureTime; _isCapturing = true; OwnedFaction = CapturingCharacter.Asda2FactionId; CapturingCharacter.GainActPoints(1); BattleGround.GainScores(CapturingCharacter, 1); Status = Asda2WarPointStatus.Capturing; Asda2BattlegroundHandler.SendUpdatePointInfoResponse(null, this); Asda2BattlegroundHandler.SendWarCurrentActionInfoResponse(BattleGround, BattleGroundInfoMessageType.SuccessToTemporarilyOccuptyTheNumOccupationPoints, Id, null, CapturingCharacter.Asda2FactionId); Asda2BattlegroundHandler.SendWarCurrentActionInfoResponse(BattleGround, BattleGroundInfoMessageType.TheOtherSideHasTemporarilyOccupiedTheNumOccupationPoint, Id, null, (short?)(CapturingCharacter.Asda2FactionId == 1 ? 0 : 1)); Asda2BattlegroundHandler.SendOccupyingPointStartedResponse(CapturingCharacter.Client, Id, OcupationPointStartedStatus.Fail); CapturingCharacter.CurrentCapturingPoint = null; CapturingCharacter = null; _timeToNextGainPoints = CharacterFormulas.DefaultTimeGainExpReward; } } }
public void Stop() { if (!IsRunning) { return; } _notificationsAboutStart = 3; IsStarted = false; World.Broadcast(string.Format("ÇáÍÑÈ Ýí {0} ÇäÊåÊ.. äÞÇØ ÇáäæÑ {1} ÖÏ {2} äÞÇØ ÇáÙáÇã", Town, LightScores, DarkScores)); IsRunning = false; SetNextWarParametrs(); //Notify players war ended. lock (JoinLock) { //find mvp foreach (var character in LightScores > DarkScores ? LightTeam.Values : DarkTeam.Values) { if (MvpCharacter == null) { MvpCharacter = character; continue; } if (MvpCharacter.BattlegroundActPoints < character.BattlegroundActPoints) { MvpCharacter = character; } } Asda2BattlegroundHandler.SendWiningFactionInfoResponse(Town, WiningFactionId, MvpCharacter == null ? "[áÇ ÃÍÏ]" : MvpCharacter.Name); if (MvpCharacter != null) { //create db records about war RealmServer.IOQueue.AddMessage(() => { var warResRec = new BattlegroundResultRecord(Town, MvpCharacter.Name, MvpCharacter.EntityId.Low, LightScores, DarkScores); warResRec.CreateLater(); CurrentWarResultRecordGuid = warResRec.Guid; Asda2BattlegroundMgr.ProcessBattlegroundResultRecord(warResRec); }); } foreach (var character in LightTeam.Values) { ProcessEndWar(character); if (WiningFactionId == 0) { Asda2TitleChecker.OnWinWar(character); } else { Asda2TitleChecker.OnLoseWar(character); } } foreach (var character in DarkTeam.Values) { ProcessEndWar(character); if (WiningFactionId == 1) { Asda2TitleChecker.OnWinWar(character); } else { Asda2TitleChecker.OnLoseWar(character); } } foreach (var asda2WarPoint in Points) { asda2WarPoint.Status = Asda2WarPointStatus.NotOwned; asda2WarPoint.OwnedFaction = -1; Asda2BattlegroundHandler.SendUpdatePointInfoResponse(null, asda2WarPoint); } World.TaskQueue.CallDelayed(60000, KickAll); } }
public void Update(int dt) { if (this.Status == Asda2WarPointStatus.Owned) { this._timeToNextGainPoints -= dt; if (this._timeToNextGainPoints <= 0) { this.BattleGround.GainScores(this.OwnedFaction, CharacterFormulas.FactionWarPointsPerTicForCapturedPoints); this._timeToNextGainPoints += CharacterFormulas.DefaultTimeGainExpReward; } } if (this._isCapturing) { this._tomeToCaprute -= dt; if (this._tomeToCaprute > 0) { return; } this.Status = Asda2WarPointStatus.Owned; Asda2BattlegroundHandler.SendUpdatePointInfoResponse((IRealmClient)null, this); Asda2BattlegroundHandler.SendWarCurrentActionInfoResponse(this.BattleGround, BattleGroundInfoMessageType.SuccessToCompletelyOccuptyTheNumOccupationPoints, this.Id, (Character)null, new short?(this.OwnedFaction)); Asda2BattlegroundHandler.SendWarCurrentActionInfoResponse(this.BattleGround, BattleGroundInfoMessageType.TheOtherSideHasTemporarilyOccupiedTheNumOccupationPoint, this.Id, (Character)null, new short?(this.OwnedFaction == (short)0 ? (short)1 : (short)0)); this.BattleGround.GainScores(this.OwnedFaction, CharacterFormulas.FactionWarPointsPerTicForCapturedPoints); this._isCapturing = false; } else { if (this.CapturingCharacter == null || !this.BattleGround.IsStarted) { return; } this._timeToStartCapturing -= dt; if (this._timeToStartCapturing > 0) { return; } this._tomeToCaprute = CharacterFormulas.DefaultCaptureTime; this._isCapturing = true; this.OwnedFaction = this.CapturingCharacter.Asda2FactionId; this.CapturingCharacter.GainActPoints((short)1); this.BattleGround.GainScores(this.CapturingCharacter, (short)1); this.Status = Asda2WarPointStatus.Capturing; Asda2BattlegroundHandler.SendUpdatePointInfoResponse((IRealmClient)null, this); Asda2BattlegroundHandler.SendWarCurrentActionInfoResponse(this.BattleGround, BattleGroundInfoMessageType.SuccessToTemporarilyOccuptyTheNumOccupationPoints, this.Id, (Character)null, new short?(this.CapturingCharacter.Asda2FactionId)); Asda2BattlegroundHandler.SendWarCurrentActionInfoResponse(this.BattleGround, BattleGroundInfoMessageType.TheOtherSideHasTemporarilyOccupiedTheNumOccupationPoint, this.Id, (Character)null, new short?(this.CapturingCharacter.Asda2FactionId == (short)1 ? (short)0 : (short)1)); Asda2BattlegroundHandler.SendOccupyingPointStartedResponse(this.CapturingCharacter.Client, this.Id, OcupationPointStartedStatus.Fail); this.CapturingCharacter.CurrentCapturingPoint = (Asda2WarPoint)null; this.CapturingCharacter = (Character)null; this._timeToNextGainPoints = CharacterFormulas.DefaultTimeGainExpReward; } }