示例#1
0
        public override void LoadContent()
        {
            //debugTex = ScreenManager.Game.Content.Load<Texture2D>("temperature");
            //debugTex = gameContainer.ContentManager.Load<Texture2D>("temperature");

            Console.Out.WriteLine("LOADING LEVEL...");

            string     json = g_JsonManager.loadJSON("./Content/json/map_params.v");
            JsonObject jo   = g_JsonManager.jsonToJsonObject(json);


            switch (g_MapType)
            {
            case MapType.WORLD:
                if (g_FirstLoad)
                {
                    g_Map = mapFactory.createWorldMap(jo["WORLD", "x"].asInt(),
                                                      jo["WORLD", "y"].asInt(),
                                                      jo["WORLD", "dx"].asInt(),
                                                      jo["WORLD", "dy"].asInt(),
                                                      jo["WORLD", "z"].asFloat(),
                                                      jo["WORLD", "xsize"].asInt(),
                                                      jo["WORLD", "ysize"].asInt(),
                                                      (int)g_Parameters[GAMESCREEN_SEED]);
                    GameSession.WorldMap = g_Map;
                }
                else
                {
                    g_Map = mapFactory.recreateWorldMap(GameSession.WorldMap);
                    GameSession.WorldMap = g_Map;
                }
                break;

            case MapType.CAVE:
                g_Map = mapFactory.createRandomCaveMap(jo["CAVE", "x"].asInt(),
                                                       jo["CAVE", "y"].asInt(),
                                                       jo["CAVE", "prob"].asInt(),
                                                       jo["CAVE", "cell_op_spec"].asBool(),
                                                       jo["CAVE", "iter"].asInt(),
                                                       jo["CAVE", "neighbors"].asInt(),
                                                       (int)g_Parameters[GAMESCREEN_SEED]);
                break;

            case MapType.WILDERNESS:
                g_Map = mapFactory.createRandomForestMap(100,
                                                         100,
                                                         75,
                                                         TerrainType_Old.FOREST_FLOOR,
                                                         TerrainType_Old.FOREST_TREE,
                                                         (int)g_Parameters[GAMESCREEN_SEED]);
                break;

            case MapType.DUNGEON:
                g_Map = mapFactory.createRandomDungeonMap(100, 100, 200, (int)g_Parameters[GAMESCREEN_SEED]);
                break;

            default:
                g_Map = mapFactory.createWorldMap(jo["WORLD", "x"].asInt(),
                                                  jo["WORLD", "y"].asInt(),
                                                  jo["WORLD", "dx"].asInt(),
                                                  jo["WORLD", "dy"].asInt(),
                                                  jo["WORLD", "z"].asFloat(),
                                                  jo["WORLD", "xsize"].asInt(),
                                                  jo["WORLD", "ysize"].asInt(),
                                                  (int)g_Parameters[GAMESCREEN_SEED]);
                break;
            }

            if (g_FirstLoad)
            {
                player = EntityFactory.createPlayer((int)g_Parameters[GAMESCREEN_SKILLLEVEL]);
            }
            else
            {
                if ((bool)g_Parameters[GAMESCREEN_RETURNING])
                {
                    player = EntityFactory.recreatePlayer(GameSession.PlayerState, (Position)g_Parameters[GAMESCREEN_LAST_PLAYER_POSITION]);
                }
                else
                {
                    player = EntityFactory.recreatePlayer(GameSession.PlayerState, new Position(MapFactory.findSafeLocation(g_Map), new Vector2(16, 16)));
                }
            }

            UtilFactory.createTarget();

            mapState            = new MapState();
            mapState.MapType    = g_Map.Map.MapDef.MapType;
            mapState.Seed       = g_Map.Map.Seed;
            mapState.SkillLevel = (int)g_Parameters[GAMESCREEN_SKILLLEVEL];


            EntityFactory.createCamera();

            UIFactory.createHitPointLabel(player, 100, 50, new Point((this.ScreenManager.GraphicsDevice.Viewport.Width - 100) / 2, 0));

            if (!g_FirstLoad && mapState.MapType != MapType.WORLD)
            {
                npcFactory.createWandererTrigger(20, g_Map, (int)g_Parameters[GAMESCREEN_SKILLLEVEL]);
            }

            //create map debug
            EntityFactory.createMapDebug();

            //create lights

            /*
             * for (int i = 0; i <= 5; i++)
             * {
             *  for (int j = 0; j <= 5; j++)
             *  {
             *      //entityFactory.createRandomLight(;)
             *      entityFactory.createStandaloneLight(true, 640, new Vector3(i * 640, j * 640, 100), .1f,
             *          new Vector4(.5f, .5f, .7f, (float)rand.NextDouble()));
             *  }
             * }*/

            //create GeometryMap
            //entityFactory.createGeometryMap();

            //create spatialpartition
            EntityFactory.createSpatialPartition(new Vector2(0, 0), new Vector2(3200, 3200), 4);

            //create mouse
            EntityFactory.createMousePointer();

            //early entity reslove
            ecsInstance.resolve_entities();

            //load system content
            ecsInstance.system_manager.systems_load_content();

            //get geometry map
            //geometry = (GeometryMap)geometryMapper.get(ecsInstance.TagManager.getEntityByTag("GEOMETRY"));

            //setup bus components

            base.LoadContent();
        }