Esempio n. 1
0
        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);
        }
Esempio n. 2
0
        public bool Load(string p)
        {
            bool result;

            using (new CursorKeeper(Cursors.WaitCursor))
            {
                if (!ResetWorld())
                {
                    return(false);
                }

                string p1 = VirtualFileSystem.GetVirtualPathByReal(p);
                if (!MapSystemWorld.MapLoad(p1))
                {
                    result = false;
                }
                else
                {
                    RecordRecentlyLoadedMap(p);
                    UpdateRecentlyLoadedMapIntoMenu();
                    result = true;
                }
                MainForm.Instance.NotifyUpdate();   // Load
                Modified = false;
            }
            return(result);
        }
Esempio n. 3
0
        /// <summary>
        /// 加载地图
        /// </summary>
        /// <param name="p">虚拟路径</param>
        /// <returns></returns>
        public bool MapLoad(string p)
        {
            if (!ResetWorld())
            {
                return(false);
            }

            bool result = MapSystemWorld.MapLoad(p);

            return(result);
        }
Esempio n. 4
0
        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);
        }
Esempio n. 5
0
        public static bool MapLoad(string virtualFileName, bool runSimulation)
        {
            //Destroy old
            WorldDestroy();

            //New
            if (!EntitySystemWorld.Instance.WorldCreate(WorldSimulationTypes.Single,
                                                        EntitySystemWorld.Instance.DefaultWorldType))
            {
                Log.Error("EntitySystemWorld: WorldCreate failed.");
                return(false);
            }

            if (!MapSystemWorld.MapLoad(virtualFileName))
            {
                return(false);
            }

            //run simulation
            EntitySystemWorld.Instance.Simulation = runSimulation;

            return(true);
        }
Esempio n. 6
0
        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);
        }