예제 #1
0
            public override void Deserialize(NetworkReader reader)
            {
                base.Deserialize(reader);

                PlayerId = reader.ReadInt32();

                var length = reader.ReadInt32();
                var result = new Dictionary <int, PlayerStats>(length);

                for (var idx = 0; idx < length; ++idx)
                {
                    var playerId = reader.ReadInt32();
                    result[playerId] = new PlayerStats
                    {
                        Id     = playerId,
                        Frags  = reader.ReadInt32(),
                        Deaths = reader.ReadInt32(),
                        Name   = reader.ReadString()
                    };
                }

                BattleStats = new BattleStats()
                {
                    Stats = result
                };
            }
예제 #2
0
        public void ServerGameStarted(Dictionary <int, string> playerNames)
        {
            var players = playerNames
                          .Select(p => new PlayerStats
            {
                Deaths = 0,
                Frags  = 0,
                Id     = p.Key,
                Name   = p.Value
            })
                          .ToDictionary(i => i.Id);

            _battleStats = new BattleStats {
                Stats = players
            };
            ServerSendBattleStatsUpdate();
        }