protected override void OnDetach() { 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; } 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; } base.OnDetach(); }
void SayChatMessage() { string text = editBoxChatMessage.Text.Trim(); if (string.IsNullOrEmpty(text)) { return; } GameNetworkServer server = GameNetworkServer.Instance; if (server != null) { server.ChatService.SayToAll(text); } GameNetworkClient client = GameNetworkClient.Instance; if (client != null) { client.ChatService.SayToAll(text); } editBoxChatMessage.Text = ""; }
void Create() { if (GameNetworkServer.Instance != null) { Log("Error: Already created"); return; } GameNetworkServer server = new GameNetworkServer("NeoAxis Chat Server", EngineVersionInformation.Version, 128, false); server.UserManagementService.AddUserEvent += UserManagementService_AddUserEvent; server.UserManagementService.RemoveUserEvent += UserManagementService_RemoveUserEvent; server.ChatService.ReceiveText += ChatService_ReceiveText; int port = 56565; string error; if (!server.BeginListen(port, out error)) { Log("Error: " + error); Destroy(); return; } Log("Server has been created"); Log("Listening port {0}...", port); buttonCreate.Enabled = false; buttonDestroy.Enabled = true; }
bool MapLoad(string fileName) { MapDestroy(); WorldType worldType = EntitySystemWorld.Instance.DefaultWorldType; GameNetworkServer server = GameNetworkServer.Instance; if (!EntitySystemWorld.Instance.WorldCreate(WorldSimulationTypes.DedicatedServer, worldType, server.EntitySystemService.NetworkingInterface)) { Log("Error: EntitySystemWorld.Instance.WorldCreate failed."); return(false); } if (!MapSystemWorld.MapLoad(fileName)) { MapDestroy(); return(false); } //run simulation EntitySystemWorld.Instance.Simulation = true; Log("Map loaded"); return(true); }
// 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; } }
private void timer1_Tick(object sender, EventArgs e) { GameNetworkServer server = GameNetworkServer.Instance; if (server != null) { server.Update(); } }
protected override void OnTick(float delta) { base.OnTick(delta); if (needMapLoadName != null) { string name = needMapLoadName; needMapLoadName = null; ServerOrSingle_MapLoad(name, EntitySystemWorld.Instance.DefaultWorldType, false); } if (needMapCreateForDynamicMapExample) { needMapCreateForDynamicMapExample = false; DynamicCreatedMapExample.ServerOrSingle_MapCreate(); } if (needWorldLoadName != null) { string name = needWorldLoadName; needWorldLoadName = null; WorldLoad(name); } if (EngineConsole.Instance != null) { EngineConsole.Instance.DoTick(delta); } controlManager.DoTick(delta); //update server GameNetworkServer server = GameNetworkServer.Instance; if (server != null) { server.Update(); } //update client GameNetworkClient client = GameNetworkClient.Instance; if (client != null) { client.Update(); //check for disconnection if (client_AllowCheckForDisconnection) { if (client.Status == NetworkConnectionStatuses.Disconnected) { Client_DisconnectFromServer(); Log.Error("Disconnected from server.\n\nReason: \"{0}\"", client.DisconnectionReason); } } } }
public void Server_DestroyServer(string reason) { GameNetworkServer server = GameNetworkServer.Instance; if (server != null) { server.Dispose(reason); SuspendWorkingWhenApplicationIsNotActive = true; } }
void checkBoxAllowToConnectDuringGame_CheckedChange(CheckBox sender) { //send AllowToConnectDuringGame to clients GameNetworkServer server = GameNetworkServer.Instance; if (server != null) { server.CustomMessagesService.SendToAllClients("Lobby_AllowToConnectDuringGame", checkBoxAllowToConnectDuringGame.Checked.ToString()); } }
void Server_UserManagementService_AddUserEvent(UserManagementServerNetworkService sender, UserManagementServerNetworkService.UserInfo user) { GameNetworkServer server = GameNetworkServer.Instance; //send map name to new client server.CustomMessagesService.SendToClient(user.ConnectedNode, "Lobby_MapName", SelectedMapName); //send AllowToConnectDuringGame flag to new client server.CustomMessagesService.SendToClient(user.ConnectedNode, "Lobby_AllowToConnectDuringGame", checkBoxAllowToConnectDuringGame.Checked.ToString()); }
void comboBoxMaps_SelectedIndexChange(ComboBox sender) { lastMapName = SelectedMapName; //send map name to clients GameNetworkServer server = GameNetworkServer.Instance; if (server != null) { server.CustomMessagesService.SendToAllClients("Lobby_MapName", SelectedMapName); } }
private void timer1_Tick(object sender, EventArgs e) { GameNetworkServer server = GameNetworkServer.Instance; if (server != null) { server.Update(); } if (WinFormsAppEngineApp.Instance != null) { WinFormsAppEngineApp.Instance.DoTick(); } }
void Create() { if (GameNetworkServer.Instance != null) { Log("Error: Server already created"); return; } string mapName = comboBoxMaps.SelectedItem as string; if (string.IsNullOrEmpty(mapName)) { Log("Error: You should choose a start map"); return; } GameNetworkServer server = new GameNetworkServer("NeoAxis Game Server", EngineVersionInformation.Version, 128, true); server.UserManagementService.AddUserEvent += UserManagementService_AddUserEvent; server.UserManagementService.RemoveUserEvent += UserManagementService_RemoveUserEvent; server.ChatService.ReceiveText += ChatService_ReceiveText; int port = 56565; string error; if (!server.BeginListen(port, out error)) { Log("Error: " + error); Destroy(); return; } Log("Server has been created"); Log("Listening port {0}...", port); buttonCreate.Enabled = false; buttonDestroy.Enabled = true; comboBoxMaps.Enabled = false; //load a map Log("Loading map \"{0}\"...", mapName); MapLoad(mapName); }
protected override void OnDetach() { //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; } base.OnDetach(); }
private bool MapLoad(string fileName) { MapDestroy(false); Log("Loading map \"{0}\"...", fileName); WorldType worldType = EntitySystemWorld.Instance.DefaultWorldType; GameNetworkServer server = GameNetworkServer.Instance; if (!EntitySystemWorld.Instance.WorldCreate(WorldSimulationTypes.DedicatedServer, worldType, server.EntitySystemService.NetworkingInterface)) { Log("Error: EntitySystemWorld.Instance.WorldCreate failed."); return(false); } if (!MapSystemWorld.MapLoad(fileName)) { MapDestroy(false); onMapEnd(); return(false); } else { onMapStart(); } //run simulation EntitySystemWorld.Instance.Simulation = true; GameNetworkServer.Instance.EntitySystemService.WorldWasCreated(); Log("Map loaded"); buttonMapLoad.Enabled = false; buttonMapUnload.Enabled = true; buttonMapChange.Enabled = true; checkPrivateServer.Enabled = false; ntbMapTime.Enabled = false; return(true); }
protected override bool OnMouseDown(EMouseButtons button) { //If atop openly any window to not process if (Controls.Count != 1) { return(base.OnMouseDown(button)); } switch (button) { case EMouseButtons.Left: { tryingToMovePiece = GetPieceByCursor(); if (tryingToMovePiece != null) { if (EntitySystemWorld.Instance.IsServer()) { //server GameNetworkServer server = GameNetworkServer.Instance; tryingToMovePiece.Server_MoveBegin(server.UserManagementService.ServerUser); } else if (EntitySystemWorld.Instance.IsClientOnly()) { //client tryingToMovePiece.Client_MoveTryToBegin(); } else { //single mode tryingToMovePiece.Single_MoveBegin(); } Vec2 cursorPosition; GetGameAreaCursorPosition(out cursorPosition); tryingToMovePieceOffset = tryingToMovePiece.Position.ToVec2() - cursorPosition; return(true); } } break; } return(base.OnMouseDown(button)); }
void Start_Click(Button sender) { if (string.IsNullOrEmpty(SelectedMapName)) { return; } GameNetworkServer server = GameNetworkServer.Instance; //AllowToConnectDuringGame server.AllowToConnectNewClients = checkBoxAllowToConnectDuringGame.Checked; if (SelectedMapName == exampleOfProceduralMapCreationText) { GameEngineApp.Instance.SetNeedRunExampleOfProceduralMapCreation(); } else { GameEngineApp.Instance.SetNeedMapLoad(SelectedMapName); } }
void Start_Click(EButton sender) { if (string.IsNullOrEmpty(SelectedMapName)) { return; } GameNetworkServer server = GameNetworkServer.Instance; //AllowToConnectDuringGame server.AllowToConnectNewClients = checkBoxAllowToConnectDuringGame.Checked; if (SelectedMapName == dynamicMapExampleText) { GameEngineApp.Instance.SetNeedMapCreateForDynamicMapExample(); } else { GameEngineApp.Instance.SetNeedMapLoad(SelectedMapName); } }
// Start is called before the first frame update void Start() { Screen.SetResolution(1366, 768, false); gameServer = GameNetworkServer.Instance; errorMsgBox = gameObject.AddComponent <ErrorMsgBox>(); (GameObject.Find("input_ip_addr_field")).GetComponent <InputField>().text = "52.141.58.88"; (GameObject.Find("input_ip_addr_field")).GetComponent <InputField>().interactable = false; GameObject.Find("sign_up_btn").GetComponent <Button>().interactable = false; if (errorMsgBox != null) { Debug.Log("errorMsgBox Init"); errorMsgBox.Init(); } else { Debug.LogWarning("errorMsgBox is null"); } }
private void CreateServer_Click(Button sender) { //if (string.IsNullOrEmpty(serverUserName)) if (string.IsNullOrEmpty(Program.username)) { SetInfo("Invalid user name.", true); return; } SetInfo("Creating server...", false); GameNetworkServer server = new GameNetworkServer(createServerName.ToString(), EngineVersionInformation.Version, 128, true); //int port = 229; string error; if (!server.BeginListen(createserverport, out error)) { SetInfo("Server Listen Error: " + error, true); server.Dispose(""); return; } //create user for server server.UserManagementService.CreateServerUser(Program.username); //close all windows foreach (Control control in GameEngineApp.Instance.ControlManager.Controls) { control.SetShouldDetach(); } //create lobby window MultiplayerLobbyWindow lobbyWindow = new MultiplayerLobbyWindow(); GameEngineApp.Instance.ControlManager.Controls.Add(lobbyWindow); GameEngineApp.Instance.Server_OnCreateServer(); }
// Start is called before the first frame update void Start() { gameServer = GameNetworkServer.Instance; errorMsgBox = gameObject.AddComponent <ErrorMsgBox>(); Text userIDText = GameObject.Find("id_txt").GetComponent <Text>(); roomEnterRes = new RoomEnterResPacket(); roomEnterRes.Result = ERROR_CODE.DUMMY_CODE; userIDText.text = GameNetworkServer.Instance.LocalUserID; isWatingEnterRoomRes = false; if (errorMsgBox != null) { errorMsgBox.Init(); } else { Debug.LogWarning("errorMsgBox is null"); } Debug.Log("start Lobby Scene"); }
void CreateServer_Click(Button sender) { if (string.IsNullOrEmpty(userName)) { SetInfo("Invalid user name.", true); return; } SetInfo("Creating server...", false); GameNetworkServer server = new GameNetworkServer("NeoAxis Server", EngineVersionInformation.Version, 128, true); int port = 56565; string error; if (!server.BeginListen(port, out error)) { SetInfo("Error: " + error, true); server.Dispose(""); return; } //create user for server server.UserManagementService.CreateServerUser(userName); //close this window SetShouldDetach(); //create lobby window MultiplayerLobbyWindow lobbyWindow = new MultiplayerLobbyWindow(); GameEngineApp.Instance.ControlManager.Controls.Add(lobbyWindow); GameEngineApp.Instance.Server_OnCreateServer(); }
void Create() { if (GameNetworkServer.Instance != null) { Log("Error: Server already created"); return; } //public GameNetworkServer(string serverName, string serverVersion, int maxConnections, string serverPassword, //bool entitySystemServiceEnabled) //: base(serverName, serverVersion, maxConnections) GameNetworkServer server = new GameNetworkServer("NeoAxis Game Server", EngineVersionInformation.Version, 128, true); server.UserManagementService.AddUserEvent += UserManagementService_AddUserEvent; server.UserManagementService.RemoveUserEvent += UserManagementService_RemoveUserEvent; server.ChatService.ReceiveText += ChatService_ReceiveText; server.CustomMessagesService.ReceiveMessage += CustomMessagesService_ReceiveMessage; int port = 56565; string error; if (!server.BeginListen(port, out error)) { Log("Error: " + error); Destroy(); return; } Log("Server has been created"); Log("Listening port {0}...", port); buttonCreate.Enabled = false; buttonDestroy.Enabled = true; buttonMapLoad.Enabled = true; }
private void Create() { if (GameNetworkServer.Instance != null) { Log("Error: Server already created"); return; } if (serverName == "" || serverName == null) { Log("Set Server Name first, then we can add your server"); return; } else { serverName = textServerName.Text.ToString(); } if (PortTextBox.Text == "" || PortTextBox.Text == null) { Log("Invalid server port set, please set 1 to 65535"); return; } else { port = int.Parse(PortTextBox.Text); } GameNetworkServer server = new GameNetworkServer(serverName, EngineVersionInformation.Version, 128, serverPassword, true); server.UserManagementService.AddUserEvent += UserManagementService_AddUserEvent; server.UserManagementService.RemoveUserEvent += UserManagementService_RemoveUserEvent; server.ChatService.ReceiveText += ChatService_ReceiveText; server.CustomMessagesService.ReceiveMessage += CustomMessagesService_ReceiveMessage; // server.CustomMessagesService.ReceiveMessage += SpawnInfo; string error; if (!server.BeginListen(port, out error)) { Log("Error: " + error); Destroy(); servercreated = false; maploaded = false; return; } else { servercreated = true; } //load map at startup if (comboBoxMaps.SelectedItem != null) { //Create(); string mapName = comboBoxMaps.SelectedItem as string; if (!MapLoad(mapName)) { return; } mapname = mapName; //if (makePrivate == false) //{ // Log("Server has been made public."); //} //else //{ // Log("Server has been set private."); //} SqlAdd(); if (Program.AKsqlcon.State.ToString() == "Open") { SQLCon.Text = "Connection Active";; SQLCon.BackColor = Color.LightGreen; } else { SQLCon.Text = "Connection Lost";; SQLCon.BackColor = Color.Red; } } Log("Server has been created"); Log("Listening port {0}...", port); buttonCreate.Enabled = false; buttonDestroy.Enabled = true; buttonMapLoad.Enabled = true; checkPrivateServer.Enabled = false; ntbMapTime.Enabled = 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); MouseCover = true; BackColor = new ColorValue(0, 0, 0, .5f); ((Button)window.Controls["Exit"]).Click += Exit_Click; buttonStart = (Button)window.Controls["Start"]; if (GameNetworkServer.Instance != null) { buttonStart.Click += Start_Click; } if (GameNetworkClient.Instance != null) { buttonStart.Enable = false; } listBoxUsers = (ListBox)window.Controls["Users"]; editBoxChatMessage = (EditBox)window.Controls["ChatMessage"]; editBoxChatMessage.PreKeyDown += editBoxChatMessage_PreKeyDown; //comboBoxMaps { comboBoxMaps = (ComboBox)window.Controls["Maps"]; if (GameNetworkServer.Instance != null) { //procedural map creation comboBoxMaps.Items.Add(new MapItem(exampleOfProceduralMapCreationText, false, false)); if (lastMapName == exampleOfProceduralMapCreationText) { comboBoxMaps.SelectedIndex = comboBoxMaps.Items.Count - 1; } string[] mapList = VirtualDirectory.GetFiles("", "*.map", SearchOption.AllDirectories); foreach (string mapName in mapList) { //check for network support bool noMultiplayerSupport = VirtualFile.Exists( string.Format("{0}\\NoNetworkSupport.txt", Path.GetDirectoryName(mapName))); bool recommended = false; //mapName.Contains( "TankDemo" ); comboBoxMaps.Items.Add(new MapItem(mapName, recommended, noMultiplayerSupport)); 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 = (CheckBox)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(); }
void UpdateUserList() { //server GameNetworkServer server = GameNetworkServer.Instance; if (server != null) { UserManagementServerNetworkService userService = server.UserManagementService; bool shouldUpdate = false; if (userService.Users.Count == listBoxUsers.Items.Count) { int index = 0; foreach (UserManagementServerNetworkService.UserInfo user in userService.Users) { if (user != listBoxUsers.Items[index]) { shouldUpdate = true; } index++; } } else { shouldUpdate = true; } if (shouldUpdate) { //update list box listBoxUsers.Items.Clear(); foreach (UserManagementServerNetworkService.UserInfo user in userService.Users) { listBoxUsers.Items.Add(user); } } } //client GameNetworkClient client = GameNetworkClient.Instance; if (client != null) { UserManagementClientNetworkService userService = client.UserManagementService; bool shouldUpdate = false; if (userService.Users.Count == listBoxUsers.Items.Count) { int index = 0; foreach (UserManagementClientNetworkService.UserInfo user in userService.Users) { if (user != listBoxUsers.Items[index]) { shouldUpdate = true; } index++; } } else { shouldUpdate = true; } if (shouldUpdate) { //update list box listBoxUsers.Items.Clear(); foreach (UserManagementClientNetworkService.UserInfo user in userService.Users) { listBoxUsers.Items.Add(user); } } } }
public bool ServerOrSingle_MapLoad(string fileName, WorldType worldType, bool noChangeWindows) { GameNetworkServer server = GameNetworkServer.Instance; EControl mapLoadingWindow = null; //show map loading window if (!noChangeWindows) { mapLoadingWindow = ControlDeclarationManager.Instance.CreateControl( "Gui\\MapLoadingWindow.gui"); if (mapLoadingWindow != null) { mapLoadingWindow.Text = fileName; controlManager.Controls.Add(mapLoadingWindow); } RenderScene(); } DeleteAllGameWindows(); MapSystemWorld.MapDestroy(); //create world if need if (World.Instance == null || World.Instance.Type != worldType) { WorldSimulationTypes worldSimulationType; EntitySystemWorld.NetworkingInterface networkingInterface = null; if (server != null) { worldSimulationType = WorldSimulationTypes.ServerAndClient; networkingInterface = server.EntitySystemService.NetworkingInterface; } else { worldSimulationType = WorldSimulationTypes.Single; } if (!EntitySystemWorld.Instance.WorldCreate(worldSimulationType, worldType, networkingInterface)) { Log.Fatal("GameEngineApp: MapLoad: EntitySystemWorld.WorldCreate failed."); } } //Subcribe to callbacks during map loading. We will render scene from callback. LongOperationCallbackManager.Subscribe(LongOperationCallbackManager_LoadingCallback, mapLoadingWindow); //load map if (!MapSystemWorld.MapLoad(fileName)) { if (mapLoadingWindow != null) { mapLoadingWindow.SetShouldDetach(); } LongOperationCallbackManager.Unsubscribe(); return(false); } //inform clients about world created if (server != null) { server.EntitySystemService.InformClientsAfterWorldCreated(); } //Simulate physics for 5 seconds. That the physics has fallen asleep. if (EntitySystemWorld.Instance.IsServer() || EntitySystemWorld.Instance.IsSingle()) { SimulatePhysicsForLoadedMap(5); } //Update shadow settings. This operation can be slow because need update all //shaders if shadow technique changed. Map.Instance.UpdateSceneManagerShadowSettings(); fullscreenFadingRemainingFrames = 35; LongOperationCallbackManager.Unsubscribe(); //Error foreach (EControl control in controlManager.Controls) { if (control is MessageBoxWindow && !control.IsShouldDetach()) { return(false); } } if (!noChangeWindows) { CreateGameWindowForMap(); } //play music if (!noChangeWindows) { if (GameMap.Instance != null) { GameMusic.MusicPlay(GameMap.Instance.GameMusic, true); } } EntitySystemWorld.Instance.ResetExecutedTime(); return(true); }
public static bool ServerOrSingle_MapCreate() { GameNetworkServer server = GameNetworkServer.Instance; Control mapLoadingWindow = null; //show map loading window mapLoadingWindow = ControlDeclarationManager.Instance.CreateControl("Gui\\MapLoadingWindow.gui"); if (mapLoadingWindow != null) { mapLoadingWindow.Text = "Procedural map creation"; GameEngineApp.Instance.ControlManager.Controls.Add(mapLoadingWindow); } //delete all GameWindow's GameEngineApp.Instance.DeleteAllGameWindows(); MapSystemWorld.MapDestroy(); EngineApp.Instance.RenderScene(); //create world if need WorldType worldType = EntitySystemWorld.Instance.DefaultWorldType; if (World.Instance == null || World.Instance.Type != worldType) { WorldSimulationTypes worldSimulationType; EntitySystemWorld.NetworkingInterface networkingInterface = null; if (server != null) { worldSimulationType = WorldSimulationTypes.ServerAndClient; networkingInterface = server.EntitySystemService.NetworkingInterface; } else { worldSimulationType = WorldSimulationTypes.Single; } if (!EntitySystemWorld.Instance.WorldCreate(worldSimulationType, worldType, networkingInterface)) { Log.Fatal("ExampleOfProceduralMapCreation: ServerOrSingle_MapCreate: EntitySystemWorld.Instance.WorldCreate failed."); } } //create map GameMapType gameMapType = EntityTypes.Instance.GetByName("GameMap") as GameMapType; if (gameMapType == null) { Log.Fatal("ExampleOfProceduralMapCreation: ServerOrSingle_MapCreate: \"GameMap\" type is not defined."); } GameMap gameMap = (GameMap)Entities.Instance.Create(gameMapType, World.Instance); gameMap.ShadowFarDistance = 60; gameMap.ShadowColor = new ColorValue(.5f, .5f, .5f); //create MapObjects ServerOrSingle_CreateEntities(); //post create map gameMap.PostCreate(); //inform clients about world created if (server != null) { server.EntitySystemService.WorldWasCreated(); } //Error foreach (Control control in GameEngineApp.Instance.ControlManager.Controls) { if (control is MessageBoxWindow && !control.IsShouldDetach()) { return(false); } } GameEngineApp.Instance.CreateGameWindowForMap(); //play music if (GameMap.Instance != null) { GameMusic.MusicPlay(GameMap.Instance.GameMusic, true); } return(true); }
protected override void OnRender() { base.OnRender(); bool thisUserIsMovingPiece = false; //render borders for moving pieces by users foreach (Entity entity in Map.Instance.Children) { JigsawPuzzlePiece piece = entity as JigsawPuzzlePiece; if (piece != null) { //server if (EntitySystemWorld.Instance.IsServer()) { if (piece.Server_MovingByUser != null) { GameNetworkServer server = GameNetworkServer.Instance; if (server.UserManagementService.ServerUser == piece.Server_MovingByUser) { thisUserIsMovingPiece = true; } RenderPieceSelectionBorder(piece, true); } } //client if (EntitySystemWorld.Instance.IsClientOnly()) { if (piece.Client_MovingByUser != null) { GameNetworkClient client = GameNetworkClient.Instance; if (client.UserManagementService.ThisUser == piece.Client_MovingByUser) { thisUserIsMovingPiece = true; } RenderPieceSelectionBorder(piece, true); } } //single mode if (EntitySystemWorld.Instance.IsSingle()) { if (piece.ServerOrSingle_Moving) { thisUserIsMovingPiece = true; RenderPieceSelectionBorder(piece, true); } } } } //render border for mouse over piece if (!thisUserIsMovingPiece) { JigsawPuzzlePiece piece = GetPieceByCursor(); if (piece != null) { RenderPieceSelectionBorder(piece, false); } } }