// protected override void OnAttach() { base.OnAttach(); //load the HUD screen hudControl = ControlDeclarationManager.Instance.CreateControl( "JigsawPuzzleGame\\JigsawPuzzleGameHUD.gui"); //attach the HUD screen to the this window Controls.Add(hudControl); if (EntitySystemWorld.Instance.IsSingle()) { //hide chat edit box for single mode hudControl.Controls["ChatText"].Visible = false; hudControl.Controls["ChatMessage"].Visible = false; } //ExitToRooms button if (EntitySystemWorld.Instance.IsSingle()) { ((EButton)hudControl.Controls["ExitToRooms"]).Click += delegate(EButton sender) { string mapName = "Maps\\MainDemo\\Map.map"; string spawnPointName = "SpawnPoint_FromJigsawPuzzleGame"; GameWorld.Instance.SetShouldChangeMap(mapName, spawnPointName, null); }; } else { hudControl.Controls["ExitToRooms"].Visible = false; } chatMessageEditBox = (EEditBox)hudControl.Controls["ChatMessage"]; chatMessageEditBox.PreKeyDown += ChatMessageEditBox_PreKeyDown; //find first map camera foreach (Entity entity in Map.Instance.Children) { mapCamera = entity as MapCamera; if (mapCamera != null) { break; } } //for chat support GameNetworkServer server = GameNetworkServer.Instance; if (server != null) { server.ChatService.ReceiveText += Server_ChatService_ReceiveText; } GameNetworkClient client = GameNetworkClient.Instance; if (client != null) { client.ChatService.ReceiveText += Client_ChatService_ReceiveText; } }
// protected override void OnAttach() { base.OnAttach(); //load the HUD screen hudControl = ControlDeclarationManager.Instance.CreateControl( "JigsawPuzzleGame\\JigsawPuzzleGameHUD.gui" ); //attach the HUD screen to the this window Controls.Add( hudControl ); if( EntitySystemWorld.Instance.IsSingle() ) { //hide chat edit box for single mode hudControl.Controls[ "ChatText" ].Visible = false; hudControl.Controls[ "ChatMessage" ].Visible = false; } //ExitToRooms button if( EntitySystemWorld.Instance.IsSingle() ) { ( (EButton)hudControl.Controls[ "ExitToRooms" ] ).Click += delegate( EButton sender ) { string mapName = "Maps\\MainDemo\\Map.map"; string spawnPointName = "SpawnPoint_FromJigsawPuzzleGame"; GameWorld.Instance.SetShouldChangeMap( mapName, spawnPointName, null ); }; } else hudControl.Controls[ "ExitToRooms" ].Visible = false; chatMessageEditBox = (EEditBox)hudControl.Controls[ "ChatMessage" ]; chatMessageEditBox.PreKeyDown += ChatMessageEditBox_PreKeyDown; //find first map camera foreach( Entity entity in Map.Instance.Children ) { mapCamera = entity as MapCamera; if( mapCamera != null ) break; } //for chat support GameNetworkServer server = GameNetworkServer.Instance; if( server != null ) server.ChatService.ReceiveText += Server_ChatService_ReceiveText; GameNetworkClient client = GameNetworkClient.Instance; if( client != null ) client.ChatService.ReceiveText += Client_ChatService_ReceiveText; }
/////////////////////////////////////////// protected override void OnAttach() { base.OnAttach(); //disable check for disconnection GameEngineApp.Instance.Client_AllowCheckForDisconnection = false; //register config fields EngineApp.Instance.Config.RegisterClassParameters( GetType() ); //create window window = ControlDeclarationManager.Instance.CreateControl( "Gui\\MultiplayerLoginWindow.gui" ); Controls.Add( window ); MouseCover = true; BackColor = new ColorValue( 0, 0, 0, .5f ); //initialize controls buttonCreateServer = (EButton)window.Controls[ "CreateServer" ]; buttonCreateServer.Click += CreateServer_Click; buttonConnect = (EButton)window.Controls[ "Connect" ]; buttonConnect.Click += Connect_Click; ( (EButton)window.Controls[ "Exit" ] ).Click += Exit_Click; //generate user name if( string.IsNullOrEmpty( userName ) ) { EngineRandom random = new EngineRandom(); userName = "******" + random.Next( 1000 ).ToString( "D03" ); } editBoxUserName = (EEditBox)window.Controls[ "UserName" ]; editBoxUserName.Text = userName; editBoxUserName.TextChange += editBoxUserName_TextChange; editBoxConnectTo = (EEditBox)window.Controls[ "ConnectTo" ]; editBoxConnectTo.Text = connectToAddress; editBoxConnectTo.TextChange += editBoxConnectTo_TextChange; SetInfo( "", false ); }
/////////////////////////////////////////// protected override void OnAttach() { base.OnAttach(); //disable check for disconnection GameEngineApp.Instance.Client_AllowCheckForDisconnection = false; //register config fields EngineApp.Instance.Config.RegisterClassParameters(GetType()); //create window window = ControlDeclarationManager.Instance.CreateControl( "Gui\\MultiplayerLoginWindow.gui"); Controls.Add(window); MouseCover = true; BackColor = new ColorValue(0, 0, 0, .5f); //initialize controls buttonCreateServer = (EButton)window.Controls["CreateServer"]; buttonCreateServer.Click += CreateServer_Click; buttonConnect = (EButton)window.Controls["Connect"]; buttonConnect.Click += Connect_Click; ((EButton)window.Controls["Exit"]).Click += Exit_Click; //generate user name if (string.IsNullOrEmpty(userName)) { EngineRandom random = new EngineRandom(); userName = "******" + random.Next(1000).ToString("D03"); } editBoxUserName = (EEditBox)window.Controls["UserName"]; editBoxUserName.Text = userName; editBoxUserName.TextChange += editBoxUserName_TextChange; editBoxConnectTo = (EEditBox)window.Controls["ConnectTo"]; editBoxConnectTo.Text = connectToAddress; editBoxConnectTo.TextChange += editBoxConnectTo_TextChange; SetInfo("", false); }
/////////////////////////////////////////// protected override void OnAttach() { base.OnAttach(); //register config fields EngineApp.Instance.Config.RegisterClassParameters(GetType()); //create window window = ControlDeclarationManager.Instance.CreateControl( "Gui\\MultiplayerLobbyWindow.gui"); Controls.Add(window); ((EButton)window.Controls["Exit"]).Click += Exit_Click; buttonStart = (EButton)window.Controls["Start"]; if (GameNetworkServer.Instance != null) { buttonStart.Click += Start_Click; } if (GameNetworkClient.Instance != null) { buttonStart.Enable = false; } listBoxUsers = (EListBox)window.Controls["Users"]; editBoxChatMessage = (EEditBox)window.Controls["ChatMessage"]; editBoxChatMessage.PreKeyDown += editBoxChatMessage_PreKeyDown; //comboBoxMaps { comboBoxMaps = (EComboBox)window.Controls["Maps"]; if (GameNetworkServer.Instance != null) { //dynamic map example comboBoxMaps.Items.Add(new MapItem(dynamicMapExampleText, false)); if (lastMapName == dynamicMapExampleText) { comboBoxMaps.SelectedIndex = comboBoxMaps.Items.Count - 1; } string[] mapList = VirtualDirectory.GetFiles("", "*.map", SearchOption.AllDirectories); foreach (string mapName in mapList) { //check for network support if (VirtualFile.Exists(string.Format("{0}\\NoNetworkSupport.txt", Path.GetDirectoryName(mapName)))) { continue; } bool recommended = mapName.Contains("JigsawPuzzleGame") || mapName.Contains("TankDemo") || mapName.Contains("DeathmatchDemo"); comboBoxMaps.Items.Add(new MapItem(mapName, recommended)); if (mapName == lastMapName) { comboBoxMaps.SelectedIndex = comboBoxMaps.Items.Count - 1; } } comboBoxMaps.SelectedIndexChange += comboBoxMaps_SelectedIndexChange; if (comboBoxMaps.Items.Count != 0 && comboBoxMaps.SelectedIndex == -1) { comboBoxMaps.SelectedIndex = 0; } } else { comboBoxMaps.Enable = false; } } //checkBoxAllowToConnectDuringGame { checkBoxAllowToConnectDuringGame = (ECheckBox)window.Controls[ "AllowToConnectDuringGame"]; if (GameNetworkServer.Instance != null) { checkBoxAllowToConnectDuringGame.CheckedChange += checkBoxAllowToConnectDuringGame_CheckedChange; } else { checkBoxAllowToConnectDuringGame.Enable = false; } } //server specific GameNetworkServer server = GameNetworkServer.Instance; if (server != null) { //for receive map name server.UserManagementService.AddUserEvent += Server_UserManagementService_AddUserEvent; //for chat support server.ChatService.ReceiveText += Server_ChatService_ReceiveText; } //client specific GameNetworkClient client = GameNetworkClient.Instance; if (client != null) { //for receive map name client.CustomMessagesService.ReceiveMessage += Client_CustomMessagesService_ReceiveMessage; //for chat support client.ChatService.ReceiveText += Client_ChatService_ReceiveText; AddMessage(string.Format("Connected to server: \"{0}\"", client.RemoteServerName)); foreach (string serviceName in client.ServerConnectedNode.RemoteServices) { AddMessage(string.Format("Server service: \"{0}\"", serviceName)); } } UpdateControls(); }
/////////////////////////////////////////// protected override void OnAttach() { base.OnAttach(); //register config fields EngineApp.Instance.Config.RegisterClassParameters( GetType() ); //create window window = ControlDeclarationManager.Instance.CreateControl( "Gui\\MultiplayerLobbyWindow.gui" ); Controls.Add( window ); ( (EButton)window.Controls[ "Exit" ] ).Click += Exit_Click; buttonStart = (EButton)window.Controls[ "Start" ]; if( GameNetworkServer.Instance != null ) buttonStart.Click += Start_Click; if( GameNetworkClient.Instance != null ) buttonStart.Enable = false; listBoxUsers = (EListBox)window.Controls[ "Users" ]; editBoxChatMessage = (EEditBox)window.Controls[ "ChatMessage" ]; editBoxChatMessage.PreKeyDown += editBoxChatMessage_PreKeyDown; //comboBoxMaps { comboBoxMaps = (EComboBox)window.Controls[ "Maps" ]; if( GameNetworkServer.Instance != null ) { //dynamic map example comboBoxMaps.Items.Add( new MapItem( dynamicMapExampleText, false ) ); if( lastMapName == dynamicMapExampleText ) comboBoxMaps.SelectedIndex = comboBoxMaps.Items.Count - 1; string[] mapList = VirtualDirectory.GetFiles( "", "*.map", SearchOption.AllDirectories ); foreach( string mapName in mapList ) { //check for network support if( VirtualFile.Exists( string.Format( "{0}\\NoNetworkSupport.txt", Path.GetDirectoryName( mapName ) ) ) ) { continue; } bool recommended = mapName.Contains( "JigsawPuzzleGame" ) || mapName.Contains( "TankDemo" ) || mapName.Contains( "DeathmatchDemo" ); comboBoxMaps.Items.Add( new MapItem( mapName, recommended ) ); if( mapName == lastMapName ) comboBoxMaps.SelectedIndex = comboBoxMaps.Items.Count - 1; } comboBoxMaps.SelectedIndexChange += comboBoxMaps_SelectedIndexChange; if( comboBoxMaps.Items.Count != 0 && comboBoxMaps.SelectedIndex == -1 ) comboBoxMaps.SelectedIndex = 0; } else { comboBoxMaps.Enable = false; } } //checkBoxAllowToConnectDuringGame { checkBoxAllowToConnectDuringGame = (ECheckBox)window.Controls[ "AllowToConnectDuringGame" ]; if( GameNetworkServer.Instance != null ) { checkBoxAllowToConnectDuringGame.CheckedChange += checkBoxAllowToConnectDuringGame_CheckedChange; } else { checkBoxAllowToConnectDuringGame.Enable = false; } } //server specific GameNetworkServer server = GameNetworkServer.Instance; if( server != null ) { //for receive map name server.UserManagementService.AddUserEvent += Server_UserManagementService_AddUserEvent; //for chat support server.ChatService.ReceiveText += Server_ChatService_ReceiveText; } //client specific GameNetworkClient client = GameNetworkClient.Instance; if( client != null ) { //for receive map name client.CustomMessagesService.ReceiveMessage += Client_CustomMessagesService_ReceiveMessage; //for chat support client.ChatService.ReceiveText += Client_ChatService_ReceiveText; AddMessage( string.Format( "Connected to server: \"{0}\"", client.RemoteServerName ) ); foreach( string serviceName in client.ServerConnectedNode.RemoteServices ) AddMessage( string.Format( "Server service: \"{0}\"", serviceName ) ); } UpdateControls(); }