public override bool CheckForRoundEnd() { if ((double)Math.Abs(this._morale) >= 1.0) { return(true); } bool flag1 = this.Mission.AttackerTeam.ActiveAgents.Count > 0; bool flag2 = this.Mission.DefenderTeam.ActiveAgents.Count > 0; if (flag1 & flag2) { return(false); } if (!this.SpawnComponent.AreAgentsSpawning()) { return(true); } bool[] flagArray = new bool[2]; if (this.UseGold()) { foreach (NetworkCommunicator networkPeer in GameNetwork.NetworkPeers) { MissionPeer component = networkPeer.GetComponent <MissionPeer>(); if (component?.Team != null && component.Team.Side != BattleSideEnum.None && !flagArray[(int)component.Team.Side]) { string strValue = MultiplayerOptions.OptionType.CultureTeam1.GetStrValue(); if (component.Team.Side != BattleSideEnum.Attacker) { strValue = MultiplayerOptions.OptionType.CultureTeam2.GetStrValue(); } if (this.GetCurrentGoldForPeer(component) >= MultiplayerClassDivisions.GetMinimumTroopCost(MBObjectManager.Instance.GetObject <BasicCultureObject>(strValue))) { flagArray[(int)component.Team.Side] = true; } } } } return(!flag1 && !flagArray[1] || !flag2 && !flagArray[0]); }
private void OnRoundEnd() { foreach (FlagCapturePoint allCapturePoint in this.AllCapturePoints) { if (!allCapturePoint.IsDeactivated) { allCapturePoint.SetMoveNone(); } } RoundEndReason roundEndReason = RoundEndReason.Invalid; bool flag1 = (double)this.RoundController.RemainingRoundTime <= 0.0 && !this.CheckIfOvertime(); int num1 = -1; for (int index = 0; index < 2; ++index) { int num2 = index * 2 - 1; if (flag1 && (double)num2 * (double)this._morale > 0.0 || !flag1 && (double)num2 * (double)this._morale >= 1.0) { num1 = index; break; } } CaptureTheFlagCaptureResultEnum roundResult = CaptureTheFlagCaptureResultEnum.NotCaptured; if (num1 >= 0) { roundResult = num1 == 0 ? CaptureTheFlagCaptureResultEnum.DefendersWin : CaptureTheFlagCaptureResultEnum.AttackersWin; this.RoundController.RoundWinner = num1 == 0 ? BattleSideEnum.Defender : BattleSideEnum.Attacker; roundEndReason = flag1 ? RoundEndReason.RoundTimeEnded : RoundEndReason.GameModeSpecificEnded; } else { bool flag2 = this.Mission.AttackerTeam.ActiveAgents.Count > 0; bool flag3 = this.Mission.DefenderTeam.ActiveAgents.Count > 0; if (flag2 & flag3) { if ((double)this._morale > 0.0) { roundResult = CaptureTheFlagCaptureResultEnum.AttackersWin; this.RoundController.RoundWinner = BattleSideEnum.Attacker; } else if ((double)this._morale < 0.0) { roundResult = CaptureTheFlagCaptureResultEnum.DefendersWin; this.RoundController.RoundWinner = BattleSideEnum.Defender; } else { roundResult = CaptureTheFlagCaptureResultEnum.Draw; this.RoundController.RoundWinner = BattleSideEnum.None; } roundEndReason = RoundEndReason.RoundTimeEnded; } else if (flag2) { roundResult = CaptureTheFlagCaptureResultEnum.AttackersWin; this.RoundController.RoundWinner = BattleSideEnum.Attacker; roundEndReason = RoundEndReason.SideDepleted; } else if (flag3) { roundResult = CaptureTheFlagCaptureResultEnum.DefendersWin; this.RoundController.RoundWinner = BattleSideEnum.Defender; roundEndReason = RoundEndReason.SideDepleted; } else { foreach (NetworkCommunicator networkPeer in GameNetwork.NetworkPeers) { MissionPeer component = networkPeer.GetComponent <MissionPeer>(); if (component?.Team != null && component.Team.Side != BattleSideEnum.None) { string strValue = MultiplayerOptions.OptionType.CultureTeam1.GetStrValue(); if (component.Team.Side != BattleSideEnum.Attacker) { strValue = MultiplayerOptions.OptionType.CultureTeam2.GetStrValue(); } if (this.GetCurrentGoldForPeer(component) >= MultiplayerClassDivisions.GetMinimumTroopCost(MBObjectManager.Instance.GetObject <BasicCultureObject>(strValue))) { this.RoundController.RoundWinner = component.Team.Side; roundEndReason = RoundEndReason.SideDepleted; roundResult = component.Team.Side == BattleSideEnum.Attacker ? CaptureTheFlagCaptureResultEnum.AttackersWin : CaptureTheFlagCaptureResultEnum.DefendersWin; break; } } } } } if (roundResult == CaptureTheFlagCaptureResultEnum.NotCaptured) { return; } this.RoundController.RoundEndReason = roundEndReason; this.HandleRoundEnd(roundResult); }