示例#1
0
        public bool Run(NetworkStream stream, string input)
        {
            var proto = new LobbyTeam {
                Team = Convert.ToInt32(input)
            };

            stream.Write(proto.ProtobufTypeAsBytes, 0, 2);
            ProtoBuf.Serializer.SerializeWithLengthPrefix(stream, proto, ProtoBuf.PrefixStyle.Fixed32);
            return(true);
        }
示例#2
0
        private bool HandleTeam(LobbyTeam command, Client client)
        {
            var teamToJoin = Team.From(command.Team);

            if (IsTeamFull(client, teamToJoin))
            {
                return(false);
            }
            client.Info.Team = teamToJoin;
            Lobby.Broadcast("Player " + client.Info.Name + " joined team " + teamToJoin.Name + ".", false, client);
            return(true);
        }
示例#3
0
        protected virtual void OnPlayerTeamChanged(LobbyMember member, LobbyTeam newTeam)
        {
            var packet = new StringPairPacket()
            {
                A = member.Username,
                B = newTeam.Name
            };

            // Broadcast the change
            var msg = MessageHelper.Create((short)OpCodes.LobbyMemberChangedTeam, packet.ToBytes());

            Broadcast(msg);
        }
示例#4
0
        public bool Run(NetworkStream stream, string input)
        {
            var args = Regex.Split(input, @"\s+");

            if (args.Length < 2 || args[1].Length <= 0)
            {
                return(false);
            }

            var proto = new LobbyTeam((int)Team.From(args[1].ToLower()).Index);

            stream.Write(proto.ProtobufTypeAsBytes, 0, 2);
            ProtoBuf.Serializer.SerializeWithLengthPrefix(stream, proto, ProtoBuf.PrefixStyle.Fixed32);
            return(true);
        }