public virtual void GameOver(bool forceOver) { var msg = GameOverMessage.Allocate(); msg.HallRoomId = this.HallRoomId; if (!forceOver) { try { foreach (var player in _dictPlayers.Values) { var gameOverPlayer = GameOverPlayer.Allocate(); SetGameOverPlayerValue(gameOverPlayer, player); //_gameStatisticData.SetStatisticData(gameOverPlayer, playerInfo, _contexts.session.commonSession.FreeArgs); msg.Players.Add(gameOverPlayer); } if (_dictGoPlayers.Count > 0) { foreach (var gameOverPlayer in _dictGoPlayers.Values) { msg.Players.Add(gameOverPlayer); } } msg.TotalPlayer = _dictPlayers.Count + _dictGoPlayers.Count; } catch (Exception e) { _logger.ErrorFormat("GameOver ... Error:{0}", e.StackTrace); } } else { Dispose(); } IFreeRule rule = _contexts.session.commonSession.FreeArgs.Rule; msg.BattleStartTime = rule.StartTime + rule.GameStartTime; msg.BattleEndTime = rule.StartTime + rule.GameEndTime; var evt = RoomEvent.AllocEvent <GameOverEvent>(); evt.HallRoomId = HallRoomId; evt.Message = msg; _dispatcher.AddEvent(evt); }
public virtual void GameOver(bool forceOver) { var msg = GameOverMessage.Allocate(); msg.HallRoomId = this.HallRoomId; if (!forceOver) { try { foreach (var player in _dictPlayers.Values) { var gameOverPlayer = GameOverPlayer.Allocate(); SetGameOverPlayerValue(gameOverPlayer, player); //_gameStatisticData.SetStatisticData(gameOverPlayer, playerInfo, _contexts.session.commonSession.FreeArgs); msg.Players.Add(gameOverPlayer); _logger.InfoFormat("游戏结束时战报玩家ID {0} 排名 {1}", gameOverPlayer.Id, gameOverPlayer.Statistics[1]); } if (_dictGoPlayers.Count > 0) { foreach (var gameOverPlayer in _dictGoPlayers.Values) { msg.Players.Add(gameOverPlayer); } } _logger.InfoFormat("游戏结束时战报玩家数 {0}", msg.Players.Count); } catch (Exception e) { _logger.ErrorFormat("GameOver ... Error:{0}", e.StackTrace); } } Dispose(); var evt = RoomEvent.AllocEvent <GameOverEvent>(); evt.HallRoomId = HallRoomId; evt.Message = msg; _dispatcher.AddEvent(evt); }
public override void DoAction(IEventArgs args) { var msg = GameOverMessage.Allocate(); msg.HallRoomId = args.GameContext.session.commonSession.RoomInfo.HallRoomId; FreeGameRule rule = (FreeGameRule)args.Rule; foreach (PlayerEntity player in args.GameContext.player.GetInitializedPlayerEntities()) { SimpleParable sp = new SimpleParable(); SimpleParaList paras = new SimpleParaList(); sp.SetList(paras); var gameOverPlayer = GameOverPlayer.Allocate(); paras.AddFields(new ObjectFields(gameOverPlayer)); gameOverPlayer.Id = player.playerInfo.PlayerId; args.Act(action, new TempUnit[] { new TempUnit("basic", sp) }); } }