示例#1
0
文件: MapWorld.cs 项目: nistck/Jx
        public bool CreateNew()
        {
            NewConfig cfg = AskForNewMapConfig();

            if (!cfg.State)
            {
                return(false);
            }

            if (!ResetWorld())
            {
                return(false);
            }

            if (string.IsNullOrEmpty(MapTypeName))
            {
                Log.Warning("MainForm: MapNew: Map type is not defined. (Base\\Constants\\MapEditor.config: \"mapTypeForNewMaps\" attribute)");
                return(false);
            }
            MapType mapType = EntityTypes.Instance.GetByName(MapTypeName) as MapType;

            if (mapType == null)
            {
                Log.Fatal("MainForm: MapNew: Map type \"{0}\" is not defined or it is not a MapType (Base\\Constants\\MapEditor.config: \"mapTypeForNewMaps\" attribute).", this.MapTypeName);
                return(false);
            }
            if (!MapSystemWorld.MapCreate(mapType))
            {
                Log.Fatal("MapSystemWorld.MapCreate failed.");
                return(false);
            }

            /*
             * if (cfg.CreateObjects)
             * {
             *  if (cfg.HeightmapTerrain)
             *  {
             *      Entity entity = Entities.Instance.Create("HeightmapTerrain", Map.Instance);
             *      entity.PostCreate();
             *  }
             *  if (cfg.Sun)
             *  {
             *      Sun sun = (Sun)Entities.Instance.Create("Sun", Map.Instance);
             *      sun.Position = new Vec3(0f, 0f, 7f);
             *      sun.Rotation = new Angles(319f, 6f, 94f).ToQuat();
             *      sun.SpecularColor = new ColorValue(1f, 1f, 1f);
             *      sun.PostCreate();
             *  }
             *  if (cfg.SkyBox)
             *  {
             *      Entity entity2 = Entities.Instance.Create("SkyBox", Map.Instance);
             *      entity2.PostCreate();
             *  }
             *  if (cfg.Fog)
             *  {
             *      Fog fog = (Fog)Entities.Instance.Create("Fog", Map.Instance);
             *      fog.Mode = FogMode.Exp2;
             *      fog.ExpDensity = 0.004f;
             *      fog.Color = new ColorValue(0.5764706f, 0.7607843f, 0.854901969f);
             *      fog.PostCreate();
             *  }
             *  if (cfg.MapCompositorManager)
             *  {
             *      Entity entity3 = Entities.Instance.Create("MapCompositorManager", Map.Instance);
             *      entity3.PostCreate();
             *  }
             *  if (cfg.SpawnPoint)
             *  {
             *      Entity entity4 = Entities.Instance.Create("SpawnPoint", Map.Instance);
             *      entity4.PostCreate();
             *  }
             *  Map.Instance.EditorCameraPosition = new Vec3(2.551017f, -8.274409f, 7.529152f);
             *  Map.Instance.EditorCameraDirection = new SphereDir(1.961945f, -0.4550026f);
             * }
             * //*/
            MainForm.Instance.NotifyUpdate();   // CreateNew

            Directory.CreateDirectory(VirtualFileSystem.GetRealPathByVirtual(cfg.MapDirectory));
            string text = Path.Combine(cfg.MapDirectory, "Map.map");

            Save(text);
            Modified = false;
            return(true);
        }