示例#1
0
        ///////////////////////////////////////////

        public GameNetworkClient(bool entitySystemServiceEnabled)
        {
            if (instance != null)
            {
                Log.Fatal("GameNetworkClient.GameNetworkClient: instance != null.");
            }
            instance = this;

            //register network services

            //register user management service
            userManagementService = new UserManagementClientNetworkService();
            RegisterService(userManagementService);

            //register custom messages service
            customMessagesService = new CustomMessagesClientNetworkService();
            RegisterService(customMessagesService);

            //register chat service
            chatService = new ChatClientNetworkService(userManagementService);
            RegisterService(chatService);

            //register entity system service
            if (entitySystemServiceEnabled)
            {
                entitySystemService = new EntitySystemClientNetworkService(userManagementService);
                RegisterService(entitySystemService);
            }
        }
        ///////////////////////////////////////////
        public GameNetworkClient( bool entitySystemServiceEnabled )
        {
            if( instance != null )
                Log.Fatal( "GameNetworkClient.GameNetworkClient: instance != null." );
            instance = this;

            //register network services

            //register user management service
            userManagementService = new UserManagementClientNetworkService();
            RegisterService( userManagementService );

            //register custom messages service
            customMessagesService = new CustomMessagesClientNetworkService();
            RegisterService( customMessagesService );

            //register chat service
            chatService = new ChatClientNetworkService( userManagementService );
            RegisterService( chatService );

            //register entity system service
            if( entitySystemServiceEnabled )
            {
                entitySystemService = new EntitySystemClientNetworkService( userManagementService );
                RegisterService( entitySystemService );
            }
        }
 public void SayPrivate( string text, UserManagementClientNetworkService.UserInfo toUser )
 {
     MessageType messageType = GetMessageType( "textToServer" );
     SendDataWriter writer = BeginMessage( messageType );
     writer.Write( text );
     writer.WriteVariableUInt32( toUser.Identifier );
     EndMessage();
 }
        ///////////////////////////////////////////
        public ChatClientNetworkService( UserManagementClientNetworkService userManagementService )
            : base("Chat", 3)
        {
            this.userManagementService = userManagementService;

            //register message types
            RegisterMessageType( "textToServer", 1 );
            RegisterMessageType( "textToClient", 2, ReceiveMessage_TextToClient );
        }
示例#5
0
        ///////////////////////////////////////////

        public ChatClientNetworkService(UserManagementClientNetworkService userManagementService)
            : base("Chat", 3)
        {
            this.userManagementService = userManagementService;

            //register message types
            RegisterMessageType("textToServer", 1);
            RegisterMessageType("textToClient", 2, ReceiveMessage_TextToClient);
        }
        ///////////////////////////////////////////
        public EntitySystemClientNetworkService( UserManagementClientNetworkService userManagementService )
            : base("EntitySystem", 4)
        {
            this.userManagementService = userManagementService;

            //register message types
            for( int n = 0; n < 6; n++ )
            {
                entitySystemInternalMessageTypes[ n ] = RegisterMessageType(
                    string.Format( "entitySystemInternal{0}", n ), (byte)( n + 1 ),
                    ReceiveMessage_EntitySystemInternal );
            }
            RegisterMessageType( "worldCreateBeginToClient", 7,
                ReceiveMessage_WorldCreateBeginToClient );
            RegisterMessageType( "worldCreateEndToClient", 8, ReceiveMessage_WorldCreateEndToClient );

            networkingInterface = new ClientEntitySystemNetworkingInterface( this );
        }
示例#7
0
        ///////////////////////////////////////////

        public EntitySystemClientNetworkService(UserManagementClientNetworkService userManagementService)
            : base("EntitySystem", 4)
        {
            this.userManagementService = userManagementService;

            //register message types
            for (int n = 0; n < 6; n++)
            {
                entitySystemInternalMessageTypes[n] = RegisterMessageType(
                    string.Format("entitySystemInternal{0}", n), (byte)(n + 1),
                    ReceiveMessage_EntitySystemInternal);
            }
            RegisterMessageType("worldCreateBeginToClient", 7,
                                ReceiveMessage_WorldCreateBeginToClient);
            RegisterMessageType("worldCreateEndToClient", 8, ReceiveMessage_WorldCreateEndToClient);

            networkingInterface = new ClientEntitySystemNetworkingInterface(this);
        }
示例#8
0
 void Client_ChatService_ReceiveText( ChatClientNetworkService sender,
     UserManagementClientNetworkService.UserInfo fromUser, string text)
 {
     string userName = fromUser != null ? fromUser.Name : "(null)";
     AddScreenMessage( string.Format( "{0}: {1}", userName, text ) );
 }
示例#9
0
 void Client_ChatService_ReceiveText( ChatClientNetworkService sender,
     UserManagementClientNetworkService.UserInfo fromUser, string text)
 {
 }
示例#10
0
        void ChatService_ReceiveText( ChatClientNetworkService sender,
			UserManagementClientNetworkService.UserInfo fromUser, string text )
        {
            string userName = fromUser != null ? fromUser.Name : "(null)";
            Log( "{0}: {1}", userName, text );
        }
示例#11
0
        void UserManagementService_RemoveUserEvent( UserManagementClientNetworkService sender,
			UserManagementClientNetworkService.UserInfo user )
        {
            listBoxUsers.Items.Remove( user );
        }
示例#12
0
            public Client_Player( uint identifier, string name, bool bot,
				UserManagementClientNetworkService.UserInfo user )
            {
                this.identifier = identifier;
                this.name = name;
                this.bot = bot;
                this.user = user;
                this.team = PlayerTeam.SpectatorPlayer; // Team default = 0 (spectator)
            }
示例#13
0
        public Client_Player Client_GetPlayer(
			UserManagementClientNetworkService.UserInfo user )
        {
            //slowly. need Dictionary.
            foreach( Client_Player player in client_players )
            {
                if( player.User == user )
                    return player;
            }
            return null;
        }
 public Client_Player( uint identifier, string name, bool bot,
     UserManagementClientNetworkService.UserInfo user)
 {
     this.identifier = identifier;
     this.name = name;
     this.bot = bot;
     this.user = user;
 }