예제 #1
0
        private void SubRoundEnd()
        {
            if (!ScoreIsPlaying())
            return;

              _nextRoundTime = TimeSpan.Zero;
              _subRoundTime = TimeSpan.Zero;

              _waitingNextRound = true;

              PlayerTeam winnerTeam = null;

              if (AlphaCaptains.Count() > BetaCaptains.Count())
              {
            winnerTeam = Room.TeamManager[Team.Alpha];
              }
              else if (BetaCaptains.Count() > AlphaCaptains.Count())
              {
            winnerTeam = Room.TeamManager[Team.Beta];
              }
              else
              {
            var scores = new Dictionary<Team, uint>();
            foreach (var team in Room.TeamManager.Values)
            {
              var score = team.PlayersPlaying.Sum(plr => plr.RoomInfo.Stats.TotalScore);
              scores.Add(team.Team, (uint)score);
            }

            var max = scores.Values.Max();
            winnerTeam = Room.TeamManager.Values.FirstOrDefault(t => scores[t.Team] == max);
              }

              if (winnerTeam?.Team == Team.Alpha)
              {
            AlphaWins++;
              }

              if (winnerTeam?.Team == Team.Beta)
              {
            BetaWins++;
              }

              if (winnerTeam?.Team != Team.Neutral)
              {
            winnerTeam.Score++;
            Room.Broadcast(new CaptainSubRoundWinAckMessage((int)Team.Beta, false));
              }

              if (Room.TeamManager.Values.Any(team => team.Score > Room.Options.ScoreLimit))
            return;

              if (CurrentRound - 1 > Room.Options.TimeLimit.Minutes)
            return;

              Room.Broadcast(new GameEventMessageAckMessage(GameEventMessage.NextRoundIn,
              (ulong)SCaptainNextroundTime.TotalMilliseconds, 0, 0, ""));
        }
예제 #2
0
        public override void Update(AccurateDelta delta)
        {
            base.Update(delta);

              var teamMgr = Room.TeamManager;
              try
              {
            if (Room.GameState == GameState.Playing &&
            !StateMachine.IsInState(GameRuleState.EnteringResult) &&
            !StateMachine.IsInState(GameRuleState.Result) &&
            RoundTime >= TimeSpan.FromSeconds(5))
            {
              var min = teamMgr.Values.Min(team =>
              team.Keys.Count(plr => plr.RoomInfo.HasLoaded));

              if (min == 0 && !Room.Options.IsFriendly)
            StateMachine.Fire(GameRuleStateTrigger.StartResult);

              if (teamMgr.Values.Any(team => team.Score > Room.Options.ScoreLimit))
            StateMachine.Fire(GameRuleStateTrigger.StartResult);

              if (CurrentRound - 1 > Room.Options.TimeLimit.Minutes)
            StateMachine.Fire(GameRuleStateTrigger.StartResult);

              if (CurrentRound > 0)
              {
            if (_waitingNextRound)
            {
              _nextRoundTime += delta.delta;

              if (_nextRoundTime >= SCaptainNextroundTime)
              {
                NextRound();
              }
            }
            else
            {
              foreach (var plr in PlayersCaptain.Where(x => !ValidPlayer(x.Key)))
              {
                PlayersCaptain.TryRemove(plr.Key, out _);
              }

              if ((!AlphaCaptains.Any() || !BetaCaptains.Any()) /* &&
                                Room.TeamManager.PlayersPlaying.Count() > 1 && !Room.Options.IsFriendly*/)
                SubRoundEnd();

              _subRoundTime += delta.delta;
              if (_subRoundTime >= SCaptainRoundTime)
                SubRoundEnd();
            }
              }
            }
              }
              catch (Exception e)
              {
            Room.Logger.Error(e.ToString());
              }
        }