Ejemplo n.º 1
0
        public void PlayerLeaveRoom(long playerId)
        {
            _logger.InfoFormat("player leave room {0}", playerId);
            GameOverPlayer gameOverPlayer = null;
            var            evt            = RoomEvent.AllocEvent <LeaveRoomEvent>();

            if (_dictPlayers.ContainsKey(playerId))
            {
                IPlayerInfo player = _dictPlayers[playerId];
                gameOverPlayer = GameOverPlayer.Allocate();
                SetGameOverPlayerValue(gameOverPlayer, player);
                //_gameStatisticData.SetStatisticData(gameOverPlayer, playerInfo, _contexts.session.commonSession.FreeArgs);

                if (player.Token != TestUtility.TestToken)
                {
                    evt.Token = player.Token;
                }

                RemovePlayer(playerId);
                _logger.InfoFormat("player {0} leave room, set statistics complete", playerId);
            }

            evt.PlayerId = playerId;
            evt.Player   = gameOverPlayer;
            _dispatcher.AddEvent(evt);
        }
Ejemplo n.º 2
0
        private void AddHonorData(GameOverPlayer goPlayer, IPlayerInfo playerInfo)
        {
            if (playerInfo.StatisticsData == null)
            {
                return;
            }

            /*if (playerInfo.StatisticsData.KillCount >= 10)
             * {
             *  goPlayer.Honors.Add(EHonorID.HuntingMaster);
             * }*/
            if (playerInfo.StatisticsData.GetFirstBlood)
            {
                goPlayer.Honors.Add(EHonorID.FirstBlood);
            }

            /*if (playerInfo.StatisticsData.PlayerDamage >= 700)
             * {
             *  goPlayer.Honors.Add(EHonorID.OutputExpert);
             * }
             * if (playerInfo.StatisticsData.SaveCount >= 5)
             * {
             *  goPlayer.Honors.Add(EHonorID.Nanny);
             * }
             * if (playerInfo.StatisticsData.PistolKillCount >= 3)
             * {
             *  goPlayer.Honors.Add(EHonorID.WestCowboy);
             * }
             * if (playerInfo.StatisticsData.GrenadeKillCount >= 2)
             * {
             *  goPlayer.Honors.Add(EHonorID.ThunderGod);
             * }*/
        }
Ejemplo n.º 3
0
 public override void SetStatisticData(GameOverPlayer gameOverPlayer, IPlayerInfo playerInfo, IFreeArgs freeArgs)
 {
     gameOverPlayer.Id = playerInfo.PlayerId;
     if (null == playerInfo.StatisticsData)
     {
         Logger.Error("player's statisticsData is null ");
         return;
     }
     gameOverPlayer.Score = playerInfo.StatisticsData.KillCount;
     foreach (EStatisticsID eId in Enum.GetValues(typeof(EStatisticsID)))
     {
         gameOverPlayer.Statistics.Add((int)eId, 0);
     }
     gameOverPlayer.Statistics[(int)EStatisticsID.KillCount]           = playerInfo.StatisticsData.KillCount;
     gameOverPlayer.Statistics[(int)EStatisticsID.HitDownCount]        = playerInfo.StatisticsData.HitDownCount;
     gameOverPlayer.Statistics[(int)EStatisticsID.PlayerDamage]        = Convert.ToInt32(playerInfo.StatisticsData.PlayerDamage);
     gameOverPlayer.Statistics[(int)EStatisticsID.TotalDamage]         = Convert.ToInt32(playerInfo.StatisticsData.TotalDamage);
     gameOverPlayer.Statistics[(int)EStatisticsID.ShootingCount]       = playerInfo.StatisticsData.ShootingCount;
     gameOverPlayer.Statistics[(int)EStatisticsID.ShootingSuccCount]   = playerInfo.StatisticsData.ShootingSuccCount;
     gameOverPlayer.Statistics[(int)EStatisticsID.ShootingPlayerCount] = playerInfo.StatisticsData.ShootingPlayerCount;
     gameOverPlayer.Statistics[(int)EStatisticsID.CritCount]           = playerInfo.StatisticsData.CritCount;
     gameOverPlayer.Statistics[(int)EStatisticsID.TotalMoveDistance]   = Convert.ToInt32(playerInfo.StatisticsData.TotalMoveDistance);
     gameOverPlayer.Statistics[(int)EStatisticsID.VehicleMoveDistance] = Convert.ToInt32(playerInfo.StatisticsData.VehicleMoveDistance);
     gameOverPlayer.Statistics[(int)EStatisticsID.AssistCount]         = playerInfo.StatisticsData.AssistCount;
     gameOverPlayer.Statistics[(int)EStatisticsID.CureVolume]          = Convert.ToInt32(playerInfo.StatisticsData.CureVolume);
     gameOverPlayer.Statistics[(int)EStatisticsID.AccSpeedTime]        = playerInfo.StatisticsData.AccSpeedTime;
     gameOverPlayer.Statistics[(int)EStatisticsID.SaveCount]           = playerInfo.StatisticsData.SaveCount;
     gameOverPlayer.Statistics[(int)EStatisticsID.TotalBeDamage]       = Convert.ToInt32(playerInfo.StatisticsData.TotalBeDamage);
     gameOverPlayer.Statistics[(int)EStatisticsID.DefenseDamage]       = Convert.ToInt32(playerInfo.StatisticsData.DefenseDamage);
     gameOverPlayer.Statistics[(int)EStatisticsID.DeadCount]           = playerInfo.StatisticsData.DeadCount;
     gameOverPlayer.Statistics[(int)EStatisticsID.KillDistance]        = Convert.ToInt32(playerInfo.StatisticsData.MaxKillDistance);
     gameOverPlayer.Statistics[(int)EStatisticsID.DestroyVehicle]      = playerInfo.StatisticsData.DestroyVehicle;
     gameOverPlayer.Statistics[(int)EStatisticsID.UseThrowingCount]    = playerInfo.StatisticsData.UseThrowingCount;
     gameOverPlayer.Statistics[(int)EStatisticsID.IsFullArmed]         = playerInfo.StatisticsData.IsFullArmed ? 1 : 0;
     gameOverPlayer.Statistics[(int)EStatisticsID.EvenKillCount]       = playerInfo.StatisticsData.MaxEvenKillCount;
     gameOverPlayer.Statistics[(int)EStatisticsID.SwimTime]            = playerInfo.StatisticsData.SwimTime;
     gameOverPlayer.Statistics[(int)EStatisticsID.Drown]               = playerInfo.StatisticsData.Drown ? 1 : 0;
     gameOverPlayer.Statistics[(int)EStatisticsID.PoisionDead]         = playerInfo.StatisticsData.PoisionDead ? 1 : 0;
     gameOverPlayer.Statistics[(int)EStatisticsID.DropDead]            = playerInfo.StatisticsData.DropDead ? 1 : 0;
     gameOverPlayer.Statistics[(int)EStatisticsID.KillByVehicle]       = playerInfo.StatisticsData.KillByVehicle ? 1 : 0;
     gameOverPlayer.Statistics[(int)EStatisticsID.KillByPlayer]        = playerInfo.StatisticsData.KillByPlayer ? 1 : 0;
     gameOverPlayer.Statistics[(int)EStatisticsID.KillByAirBomb]       = playerInfo.StatisticsData.KillByAirBomb ? 1 : 0;
     gameOverPlayer.Statistics[(int)EStatisticsID.KillByRifle]         = playerInfo.StatisticsData.KillWithRifle;
     gameOverPlayer.Statistics[(int)EStatisticsID.KillByMachineGun]    = playerInfo.StatisticsData.KillWithMachineGun;
     gameOverPlayer.Statistics[(int)EStatisticsID.KillBySubMachineGun] = playerInfo.StatisticsData.KillWithSubmachineGun;
     gameOverPlayer.Statistics[(int)EStatisticsID.KillByThrowWeapon]   = playerInfo.StatisticsData.KillWithThrowWeapon;
     gameOverPlayer.Statistics[(int)EStatisticsID.KillByMelee]         = playerInfo.StatisticsData.KillWithMelee;
     gameOverPlayer.Statistics[(int)EStatisticsID.KillByPistol]        = playerInfo.StatisticsData.KillWithPistol;
     gameOverPlayer.Statistics[(int)EStatisticsID.KillBySniper]        = playerInfo.StatisticsData.KillWithSniper;
     gameOverPlayer.Statistics[(int)EStatisticsID.KillByShotGun]       = playerInfo.StatisticsData.KillWithShotGun;
     gameOverPlayer.Statistics[(int)EStatisticsID.GameTime]            = playerInfo.StatisticsData.GameTime;
     gameOverPlayer.Statistics[(int)EStatisticsID.GameCount]           = playerInfo.StatisticsData.IsRunaway ? 0 : 1;
     gameOverPlayer.Statistics[(int)EStatisticsID.CritKillCount]       = playerInfo.StatisticsData.CritKillCount;
     gameOverPlayer.Statistics[(int)EStatisticsID.GetFirstBlood]       = playerInfo.StatisticsData.GetFirstBlood ? 1 : 0;
     gameOverPlayer.Statistics[(int)EStatisticsID.TeamCount]           = _dictTeams.Count;
     gameOverPlayer.Statistics[(int)EStatisticsID.DeadTime]            = playerInfo.StatisticsData.DeadTime;
     gameOverPlayer.Statistics[(int)EStatisticsID.AliveTime]           = (playerInfo.StatisticsData.GameTime - playerInfo.StatisticsData.DeadTime) / 1000;
     AddHonorData(gameOverPlayer, playerInfo);
     PlayerReportTrigger(gameOverPlayer, playerInfo, freeArgs);
 }
Ejemplo n.º 4
0
    private IEnumerator InnerSet(StatsTransmission stats)
    {
        yield return(new WaitForSeconds(showAfterSeconds));

        gameObject.SetActive(true);

        if (Player.LocalPlayer.isServer)
        {
            waitingForHostText.gameObject.SetActive(false);
            backButton.gameObject.SetActive(true);
            leaveServerButton.gameObject.SetActive(false);
        }
        else
        {
            waitingForHostText.gameObject.SetActive(true);
            backButton.gameObject.SetActive(false);
            leaveServerButton.gameObject.SetActive(true);
        }

        while (contentTrans.childCount > 0)
        {
            Transform trans = contentTrans.GetChild(0);
            trans.SetParent(null);
            Destroy(trans.gameObject);
        }

        for (int i = 0; i < stats.stats.Length; i++)
        {
            GameOverPlayer gop = Instantiate(playerPrefab, contentTrans);
            gop.Set(stats.names[i], stats.characterTypes[i], stats.stats[i]);
        }
    }
Ejemplo n.º 5
0
 private void SetGameOverPlayerValue(GameOverPlayer gameOverPlayer, IPlayerInfo player)
 {
     if (_gameStatisticData != null)
     {
         _gameStatisticData.SetStatisticData(gameOverPlayer, player, _contexts.session.commonSession.FreeArgs);
     }
 }
Ejemplo n.º 6
0
        public override void Reset()
        {
            base.Reset();

            PlayerId = 0;
            Player   = null;
            Token    = null;
        }
Ejemplo n.º 7
0
 public override void SetStatisticData(GameOverPlayer gameOverPlayer, IPlayerInfo playerInfo, IFreeArgs freeArgs)
 {
     gameOverPlayer.Id = playerInfo.PlayerId;
     if (null == playerInfo.StatisticsData)
     {
         Logger.Error("player's statisticsData is null ");
         return;
     }
     gameOverPlayer.Score = playerInfo.StatisticsData.KillCount;
     foreach (EStatisticsID eId in Enum.GetValues(typeof(EStatisticsID)))
     {
         gameOverPlayer.Statistics.Add((int)eId, 0);
     }
     gameOverPlayer.Statistics[(int)EStatisticsID.KillCount]           = playerInfo.StatisticsData.KillCount;
     gameOverPlayer.Statistics[(int)EStatisticsID.HitDownCount]        = playerInfo.StatisticsData.HitDownCount;
     gameOverPlayer.Statistics[(int)EStatisticsID.PlayerDamage]        = (int)playerInfo.StatisticsData.PlayerDamage;
     gameOverPlayer.Statistics[(int)EStatisticsID.TotalDamage]         = (int)playerInfo.StatisticsData.TotalDamage;
     gameOverPlayer.Statistics[(int)EStatisticsID.ShootingCount]       = playerInfo.StatisticsData.ShootingCount;
     gameOverPlayer.Statistics[(int)EStatisticsID.ShootingSuccCount]   = playerInfo.StatisticsData.ShootingSuccCount;
     gameOverPlayer.Statistics[(int)EStatisticsID.ShootingPlayerCount] = playerInfo.StatisticsData.ShootingPlayerCount;
     gameOverPlayer.Statistics[(int)EStatisticsID.CritCount]           = playerInfo.StatisticsData.CritCount;
     gameOverPlayer.Statistics[(int)EStatisticsID.TotalMoveDistance]   = (int)playerInfo.StatisticsData.TotalMoveDistance;
     gameOverPlayer.Statistics[(int)EStatisticsID.AssistCount]         = playerInfo.StatisticsData.AssistCount;
     gameOverPlayer.Statistics[(int)EStatisticsID.SaveCount]           = playerInfo.StatisticsData.SaveCount;
     gameOverPlayer.Statistics[(int)EStatisticsID.TotalBeDamage]       = (int)playerInfo.StatisticsData.TotalBeDamage;
     gameOverPlayer.Statistics[(int)EStatisticsID.DefenseDamage]       = (int)playerInfo.StatisticsData.DefenseDamage;
     gameOverPlayer.Statistics[(int)EStatisticsID.DeadCount]           = playerInfo.StatisticsData.DeadCount;
     gameOverPlayer.Statistics[(int)EStatisticsID.KillDistance]        = (int)playerInfo.StatisticsData.MaxKillDistance;
     gameOverPlayer.Statistics[(int)EStatisticsID.UseThrowingCount]    = playerInfo.StatisticsData.UseThrowingCount;
     gameOverPlayer.Statistics[(int)EStatisticsID.EvenKillCount]       = playerInfo.StatisticsData.MaxEvenKillCount;
     gameOverPlayer.Statistics[(int)EStatisticsID.KillByRifle]         = playerInfo.StatisticsData.KillWithRifle;
     gameOverPlayer.Statistics[(int)EStatisticsID.KillByMachineGun]    = playerInfo.StatisticsData.KillWithMachineGun;
     gameOverPlayer.Statistics[(int)EStatisticsID.KillBySubMachineGun] = playerInfo.StatisticsData.KillWithSubmachineGun;
     gameOverPlayer.Statistics[(int)EStatisticsID.KillByThrowWeapon]   = playerInfo.StatisticsData.KillWithThrowWeapon;
     gameOverPlayer.Statistics[(int)EStatisticsID.KillByMelee]         = playerInfo.StatisticsData.KillWithMelee;
     gameOverPlayer.Statistics[(int)EStatisticsID.KillByPistol]        = playerInfo.StatisticsData.KillWithPistol;
     gameOverPlayer.Statistics[(int)EStatisticsID.KillBySniper]        = playerInfo.StatisticsData.KillWithSniper;
     gameOverPlayer.Statistics[(int)EStatisticsID.KillByShotGun]       = playerInfo.StatisticsData.KillWithShotGun;
     gameOverPlayer.Statistics[(int)EStatisticsID.GameTime]            = playerInfo.StatisticsData.GameTime;
     gameOverPlayer.Statistics[(int)EStatisticsID.GameCount]           = playerInfo.StatisticsData.IsRunaway ? 0 : 1;
     gameOverPlayer.Statistics[(int)EStatisticsID.CritKillCount]       = playerInfo.StatisticsData.CritKillCount;
     gameOverPlayer.Statistics[(int)EStatisticsID.C4SetCount]          = playerInfo.StatisticsData.C4PlantCount;
     gameOverPlayer.Statistics[(int)EStatisticsID.C4DefuseCount]       = playerInfo.StatisticsData.C4DefuseCount;
     gameOverPlayer.Statistics[(int)EStatisticsID.GetFirstBlood]       = playerInfo.StatisticsData.GetFirstBlood ? 1 : 0;
     if (((PlayerEntity)playerInfo.PlayerEntity).gamePlay.LifeState != (int)EPlayerLifeState.Alive)
     {
         playerInfo.StatisticsData.DeadTime += (int)System.DateTime.Now.Ticks / 10000 - playerInfo.StatisticsData.LastDeadTime;
     }
     gameOverPlayer.Statistics[(int)EStatisticsID.DeadTime] = playerInfo.StatisticsData.DeadTime;
     AddHonorData(gameOverPlayer, playerInfo);
     PlayerReportTrigger(gameOverPlayer, playerInfo, freeArgs);
 }
Ejemplo n.º 8
0
        public override void SetStatisticData(GameOverPlayer gameOverPlayer, IPlayerInfo playerInfo, IFreeArgs freeArgs)
        {
            gameOverPlayer.Id = playerInfo.PlayerId;
            if (null == playerInfo.StatisticsData)
            {
                Logger.Error("player's statisticsData is null ");
                return;
            }
            gameOverPlayer.Score = playerInfo.StatisticsData.KillCount;
            foreach (EStatisticsID eId in Enum.GetValues(typeof(EStatisticsID)))
            {
                gameOverPlayer.Statistics.Add((int)eId, 0);
            }
            int normalKills = playerInfo.StatisticsData.KillCount - playerInfo.StatisticsData.CritKillCount;

            gameOverPlayer.Statistics[(int)EStatisticsID.KillCount]           = playerInfo.StatisticsData.KillCount;
            gameOverPlayer.Statistics[(int)EStatisticsID.HitDownCount]        = playerInfo.StatisticsData.HitDownCount;
            gameOverPlayer.Statistics[(int)EStatisticsID.PlayerDamage]        = Convert.ToInt32(playerInfo.StatisticsData.PlayerDamage);
            gameOverPlayer.Statistics[(int)EStatisticsID.TotalDamage]         = Convert.ToInt32(playerInfo.StatisticsData.TotalDamage);
            gameOverPlayer.Statistics[(int)EStatisticsID.ShootingCount]       = playerInfo.StatisticsData.ShootingCount;
            gameOverPlayer.Statistics[(int)EStatisticsID.ShootingSuccCount]   = playerInfo.StatisticsData.ShootingSuccCount;
            gameOverPlayer.Statistics[(int)EStatisticsID.ShootingPlayerCount] = playerInfo.StatisticsData.ShootingPlayerCount;
            gameOverPlayer.Statistics[(int)EStatisticsID.CritCount]           = playerInfo.StatisticsData.CritCount;
            gameOverPlayer.Statistics[(int)EStatisticsID.TotalMoveDistance]   = Convert.ToInt32(playerInfo.StatisticsData.TotalMoveDistance);
            gameOverPlayer.Statistics[(int)EStatisticsID.AssistCount]         = playerInfo.StatisticsData.AssistCount;
            gameOverPlayer.Statistics[(int)EStatisticsID.SaveCount]           = playerInfo.StatisticsData.SaveCount;
            gameOverPlayer.Statistics[(int)EStatisticsID.TotalBeDamage]       = Convert.ToInt32(playerInfo.StatisticsData.TotalBeDamage);
            gameOverPlayer.Statistics[(int)EStatisticsID.DefenseDamage]       = Convert.ToInt32(playerInfo.StatisticsData.DefenseDamage);
            gameOverPlayer.Statistics[(int)EStatisticsID.DeadCount]           = playerInfo.StatisticsData.DeadCount;
            gameOverPlayer.Statistics[(int)EStatisticsID.KillDistance]        = Convert.ToInt32(playerInfo.StatisticsData.MaxKillDistance);
            gameOverPlayer.Statistics[(int)EStatisticsID.UseThrowingCount]    = playerInfo.StatisticsData.UseThrowingCount;
            gameOverPlayer.Statistics[(int)EStatisticsID.EvenKillCount]       = playerInfo.StatisticsData.MaxEvenKillCount;
            gameOverPlayer.Statistics[(int)EStatisticsID.KillByRifle]         = playerInfo.StatisticsData.KillWithRifle;
            gameOverPlayer.Statistics[(int)EStatisticsID.KillByMachineGun]    = playerInfo.StatisticsData.KillWithMachineGun;
            gameOverPlayer.Statistics[(int)EStatisticsID.KillBySubMachineGun] = playerInfo.StatisticsData.KillWithSubmachineGun;
            gameOverPlayer.Statistics[(int)EStatisticsID.KillByThrowWeapon]   = playerInfo.StatisticsData.KillWithThrowWeapon;
            gameOverPlayer.Statistics[(int)EStatisticsID.KillByMelee]         = playerInfo.StatisticsData.KillWithMelee;
            gameOverPlayer.Statistics[(int)EStatisticsID.KillByPistol]        = playerInfo.StatisticsData.KillWithPistol;
            gameOverPlayer.Statistics[(int)EStatisticsID.KillBySniper]        = playerInfo.StatisticsData.KillWithSniper;
            gameOverPlayer.Statistics[(int)EStatisticsID.KillByShotGun]       = playerInfo.StatisticsData.KillWithShotGun;
            gameOverPlayer.Statistics[(int)EStatisticsID.GameTime]            = playerInfo.StatisticsData.GameTime;
            gameOverPlayer.Statistics[(int)EStatisticsID.GameCount]           = playerInfo.StatisticsData.IsRunaway ? 0 : 1;
            gameOverPlayer.Statistics[(int)EStatisticsID.CritKillCount]       = playerInfo.StatisticsData.CritKillCount;
            gameOverPlayer.Statistics[(int)EStatisticsID.C4SetCount]          = playerInfo.StatisticsData.C4PlantCount;
            gameOverPlayer.Statistics[(int)EStatisticsID.C4DefuseCount]       = playerInfo.StatisticsData.C4DefuseCount;
            gameOverPlayer.Statistics[(int)EStatisticsID.GetFirstBlood]       = playerInfo.StatisticsData.GetFirstBlood ? 1 : 0;
            gameOverPlayer.Statistics[(int)EStatisticsID.DeadTime]            = playerInfo.StatisticsData.DeadTime;
            gameOverPlayer.Statistics[(int)EStatisticsID.NormalKills]         = Math.Max(0, normalKills);
            AddHonorData(gameOverPlayer, playerInfo);
            PlayerReportTrigger(gameOverPlayer, playerInfo, freeArgs);
        }
Ejemplo n.º 9
0
        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);
        }
Ejemplo n.º 10
0
        protected void PlayerReportTrigger(GameOverPlayer gameOverPlayer, IPlayerInfo playerInfo, IFreeArgs freeArgs)
        {
            SimpleParable  unit = new SimpleParable();
            SimpleParaList list = new SimpleParaList();

            unit.SetList(list);
            list.AddFields(new ObjectFields(gameOverPlayer));
            list.AddFields(new ObjectFields(_dictGoPlayers));
            list.AddFields(new ObjectFields(_dictPlayers));
            list.AddFields(new ObjectFields(_dictLeavedPlayers));
            IEventArgs args = freeArgs as IEventArgs;

            if (null != args)
            {
                var playerEntity = playerInfo.PlayerEntity as PlayerEntity;
                args.Trigger(FreeTriggerConstant.PLAYER_REPORT, new TempUnit("report", unit),
                             new TempUnit("current", (FreeData)playerEntity.freeData.FreeData));
            }
        }
Ejemplo n.º 11
0
        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);
        }
Ejemplo n.º 12
0
        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) });
            }
        }
Ejemplo n.º 13
0
        /*public bool IsTeamMode()
         * {
         *  return _teamCapacity > 1;
         * }*/

        public virtual void SetStatisticData(GameOverPlayer gameOverPlayer, IPlayerInfo player, IFreeArgs freeArgs)
        {
        }
Ejemplo n.º 14
0
        public override void DoAction(IEventArgs args)
        {
            IParable unit = args.GetUnit("report");

            if (null != unit && unit is SimpleParable)
            {
                SimpleParable sp = (SimpleParable)unit;

                GameOverPlayer goPlayer = (GameOverPlayer)sp.GetFieldObject(0);
                Dictionary <long, GameOverPlayer> goPlayerList   = (Dictionary <long, GameOverPlayer>)sp.GetFieldObject(1);
                Dictionary <long, IPlayerInfo>    playerInfoList = new Dictionary <long, IPlayerInfo>();
                Dictionary <long, IPlayerInfo>    leavedInfoList = new Dictionary <long, IPlayerInfo>();
                Dictionary <long, IPlayerInfo>    infoList       = (Dictionary <long, IPlayerInfo>)sp.GetFieldObject(2);
                Dictionary <long, IPlayerInfo>    leftList       = (Dictionary <long, IPlayerInfo>)sp.GetFieldObject(3);
                int TeamCapacity = (int)sp.GetFieldObject(4);
                Logger.InfoFormat("reporting player {0}, totoal player {1}, left player {2}", goPlayer.Id, infoList.Count, leftList.Count);
                RankType rankType = (RankType)ranktype;

                IPlayerInfo playerInfo;
                playerInfoList.TryGetValue(goPlayer.Id, out playerInfo);
                if (null == playerInfo)
                {
                    Logger.InfoFormat("no IPlayerInfo of player {0}", goPlayer.Id);
                    return;
                }

                //移除缺少数据的玩家
                IPlayerInfo availablePlayer;
                List <long> keys = infoList.Keys.ToList();
                foreach (long key in keys)
                {
                    infoList.TryGetValue(key, out availablePlayer);
                    if (availablePlayer == null || availablePlayer.StatisticsData == null)
                    {
                        Logger.InfoFormat("player {0} info not available", key);
                        continue;
                    }
                    playerInfoList.Add(key, availablePlayer);
                }
                keys = leftList.Keys.ToList();
                foreach (long key in keys)
                {
                    leftList.TryGetValue(key, out availablePlayer);
                    if (availablePlayer == null || availablePlayer.StatisticsData == null)
                    {
                        Logger.InfoFormat("left player {0} info not available", key);
                        continue;
                    }
                    leavedInfoList.Add(key, availablePlayer);
                }

                //逃跑玩家为所有游戏中的玩家的最后一名
                if (playerInfo.StatisticsData.IsRunaway)
                {
                    playerInfo.StatisticsData.Rank = playerInfoList.Count;
                }

                //编辑器传来的数据
                if (!string.IsNullOrEmpty(fields))
                {
                    string[] items = fields.Split(',');
                    foreach (var item in items)
                    {
                        string[] vs = item.Split('=');
                        if (vs.Length > 1)
                        {
                            goPlayer.Statistics[int.Parse(vs[0])] = args.GetInt(vs[1]);
                        }
                        else
                        {
                            Logger.ErrorFormat("字符串解析错误,请检查模式编辑器: {0}", fields);
                        }
                    }
                }
                //团战模式填入两项人数参数
                if (rankType == RankType.Group)
                {
                    int playerCountRate = 0;
                    int teamCountRate   = 0;
                    foreach (IPlayerInfo ipi in playerInfoList.Values)
                    {
                        if (ipi.StatisticsData.GameJoinTime > 0 && args.Rule.ServerTime - ipi.StatisticsData.GameJoinTime >= 180000L)
                        {
                            playerCountRate++;
                        }
                        if (ipi.Camp == playerInfo.Camp)
                        {
                            teamCountRate++;
                        }
                        Logger.InfoFormat("player id {0} camp {1} game join time {2} played time {3}", ipi.PlayerId, ipi.Camp, ipi.StatisticsData.GameJoinTime, args.Rule.ServerTime - ipi.StatisticsData.GameJoinTime);
                    }
                    Logger.InfoFormat("game total player count {0} report send {1}", playerInfoList.Count, issend);
                    goPlayer.Statistics[(int)EStatisticsID.ModePlayerCount]    = teamCountRate;
                    goPlayer.Statistics[(int)EStatisticsID.SectionPlayerCount] = playerCountRate;
                }

                if (issend)
                {
                    switch (rankType)
                    {
                    case RankType.Group:
                        if (!playerInfo.StatisticsData.IsRunaway)
                        {
                            List <IPlayerInfo> playerSortList = playerInfoList.Values.ToList();
                            GroupRank(playerSortList, playerInfo, TeamCapacity > 1);
                        }
                        break;

                    case RankType.Survival:
                        int modeId = args.GameContext.session.commonSession.RoomInfo.ModeId;
                        if (modeId != GameRules.SoloSurvival && modeId != GameRules.LadderSoloSurvival && modeId != GameRules.AbyssSoloSurvival)
                        {
                            SurvivalRank(playerInfoList.Values.ToList().Union(leavedInfoList.Values.ToList()).ToList(), goPlayerList, args, playerInfo);
                        }
                        break;

                    default:
                        break;
                    }
                    goPlayer.Statistics[(int)EStatisticsID.Rank]    = playerInfo.StatisticsData.Rank;
                    goPlayer.Statistics[(int)EStatisticsID.RankAce] = playerInfo.StatisticsData.Rank == 1 ? 1 : 0;
                    goPlayer.Statistics[(int)EStatisticsID.RankTen] = playerInfo.StatisticsData.Rank <= 10 ? 1 : 0;
                }
                else
                {
                    //不算逃跑的离开玩家的数据保存,否则丢弃数据
                    if (!playerInfo.StatisticsData.IsRunaway && rankType == RankType.Survival)
                    {
                        GameOverPlayer savedGoPlayer = goPlayer.Clone();
                        if (goPlayerList.ContainsKey(savedGoPlayer.Id))
                        {
                            Logger.ErrorFormat("房间GameOverPlayer列表中出现重复ID {0}", savedGoPlayer.Id);
                        }
                        else
                        {
                            goPlayerList.Add(savedGoPlayer.Id, savedGoPlayer);
                        }
                    }
                    //不报告的情况下,将GameOverPlayer ID设为0
                    goPlayer.Id = 0L;
                }
            }
        }
Ejemplo n.º 15
0
        //private List<PlayerEntity> _playerList = new List<PlayerEntity>();

        public override void DoAction(IEventArgs args)
        {
            IParable unit = args.GetUnit("report");

            if (null != unit && unit is SimpleParable)
            {
                SimpleParable sp = (SimpleParable)unit;

                GameOverPlayer goPlayer = (GameOverPlayer)sp.GetFieldObject(0);
                Dictionary <long, GameOverPlayer> goPlayerList   = (Dictionary <long, GameOverPlayer>)sp.GetFieldObject(1);
                Dictionary <long, IPlayerInfo>    playerInfoList = (Dictionary <long, IPlayerInfo>)sp.GetFieldObject(2);
                Dictionary <long, IPlayerInfo>    leavedInfoList = (Dictionary <long, IPlayerInfo>)sp.GetFieldObject(3);

                RankType rankType = (RankType)ranktype;

                IPlayerInfo playerInfo;
                playerInfoList.TryGetValue(goPlayer.Id, out playerInfo);

                if (null == playerInfo)
                {
                    return;
                }
                //逃跑玩家为所有游戏中的玩家的最后一名
                if (playerInfo.StatisticsData.IsRunaway)
                {
                    playerInfo.StatisticsData.Rank = playerInfoList.Count;
                }
                //编辑器传来的数据
                string[] items = fields.Split(',');
                foreach (var item in items)
                {
                    string[] vs = item.Split('=');
                    if (vs.Length > 1)
                    {
                        goPlayer.Statistics[int.Parse(vs[0])] = args.GetInt(vs[1]);
                    }
                    else
                    {
                        Logger.ErrorFormat("字符串解析错误,请检查模式编辑器: {0}", fields);
                    }
                }
                //团战模式填入两项人数参数
                if (rankType == RankType.Group)
                {
                    int playerCountRate = 0;
                    int teamCountRate   = 0;
                    foreach (IPlayerInfo ipi in playerInfoList.Values)
                    {
                        if (ipi.StatisticsData.GameTime >= 3 * 60 * 1000)
                        {
                            playerCountRate++;
                        }
                        if (ipi.Camp == playerInfo.Camp)
                        {
                            teamCountRate++;
                        }
                    }
                    foreach (IPlayerInfo ipi in leavedInfoList.Values)
                    {
                        if (ipi.StatisticsData.GameTime >= 3 * 60 * 1000)
                        {
                            playerCountRate++;
                        }
                    }
                    goPlayer.Statistics[(int)EStatisticsID.ModePlayerCount]    = teamCountRate;
                    goPlayer.Statistics[(int)EStatisticsID.SectionPlayerCount] = playerCountRate;
                }

                if (issend)
                {
                    switch (rankType)
                    {
                    case RankType.Group:
                        if (!playerInfo.StatisticsData.IsRunaway)
                        {
                            List <IPlayerInfo> playerSortList = playerInfoList.Values.ToList();
                            GroupRank(playerSortList);
                        }
                        break;

                    case RankType.Survival:
                        if (args.GameContext.session.commonSession.RoomInfo.ModeId != GameRules.SoloSurvival)
                        {
                            SurvivalRank(playerInfoList.Values.ToList().Union(leavedInfoList.Values.ToList()).ToList(), goPlayerList);
                            Logger.InfoFormat("组队吃鸡模式对玩家进行了排名");
                        }
                        break;

                    default:
                        break;
                    }
                    goPlayer.Statistics[(int)EStatisticsID.Rank]    = playerInfo.StatisticsData.Rank;
                    goPlayer.Statistics[(int)EStatisticsID.RankAce] = playerInfo.StatisticsData.Rank == 1 ? 1 : 0;
                    goPlayer.Statistics[(int)EStatisticsID.RankTen] = playerInfo.StatisticsData.Rank <= 10 ? 1 : 0;
                }
                else
                {
                    //不算逃跑的离开玩家的数据保存,否则丢弃数据
                    if (!playerInfo.StatisticsData.IsRunaway && rankType == RankType.Survival)
                    {
                        GameOverPlayer savedGoPlayer = goPlayer.Clone();
                        if (goPlayerList.ContainsKey(savedGoPlayer.Id))
                        {
                            Logger.ErrorFormat("房间GameOverPlayer列表中出现重复ID {0}", savedGoPlayer.Id);
                        }
                        else
                        {
                            goPlayerList.Add(savedGoPlayer.Id, savedGoPlayer);
                        }
                    }
                    //不报告的情况下,将GameOverPlayer ID设为0
                    goPlayer.Id = 0L;
                }
                Logger.InfoFormat("Player {0} reported, Rank {1}", goPlayer.Id, goPlayer.Statistics[1]);
            }
        }