コード例 #1
0
            public override void OnUpdate()
            {
                StringBuilder text = new StringBuilder("");

                //GameNetworkServer
                GameNetworkServer server = GameNetworkServer.Instance;

                if (server != null)
                {
                    text.Append("Server:\n");
                    foreach (NetworkNode.ConnectedNode connectedNode in server.ConnectedNodes)
                    {
                        GetConnectedNodeData(connectedNode, text);
                    }
                    text.Append("\n");
                }

                //GameNetworkClient
                GameNetworkClient client = GameNetworkClient.Instance;

                if (client != null && client.Status == NetworkConnectionStatuses.Connected)
                {
                    text.Append("Client:\n");
                    GetConnectedNodeData(client.ServerConnectedNode, text);
                    text.Append("\n");
                }

                if (text.Length == 0)
                {
                    text.Append("No connections");
                }

                //EntitySystem statistics
                if (EntitySystemWorld.Instance != null)
                {
                    EntitySystemWorld.NetworkingInterface networkingInterface =
                        EntitySystemWorld.Instance._GetNetworkingInterface();
                    if (networkingInterface != null)
                    {
                        string[] lines = networkingInterface.GetStatisticsAsText();
                        foreach (string line in lines)
                        {
                            text.AppendFormat("-   {0}\n", line);
                        }
                    }
                }

                PageControl.Controls["Data"].Text = text.ToString();
            }
コード例 #2
0
ファイル: GameEngineApp.cs プロジェクト: gsaone/forklift
        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);
        }
コード例 #3
0
        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);
        }