Esempio n. 1
0
        public override void LoadContent()
        {
            //create backdrop
            UIFactory.createFrame(null, new Point(0, 0), s_Container.GraphicsDevice.Viewport.Height, s_Container.GraphicsDevice.Viewport.Width, "Title");


            //create menu
            Entity e = ecs_instance.create();

            int   border   = 10;
            int   spacing  = 5;
            int   height   = 38;
            int   width    = 100;
            Point screen   = new Point(s_Container.GraphicsDevice.Viewport.Width, s_Container.GraphicsDevice.Viewport.Height);
            Point location = new Point(screen.X / 2 - (width + 2 * border) / 2, screen.Y / 2);

            s_ButtonMenu = new ButtonMenu(e, null, ecs_instance, 3, location, height, width, border, spacing);


            s_ButtonMenu.init();

            s_ButtonMenu.Frame.background_name  = "frame";
            s_ButtonMenu.Frame.background_color = Color.Black;
            s_ButtonMenu.Frame.transparency     = 0.75f;

            s_ButtonMenu.Buttons[0].background_name  = "test_dialog";
            s_ButtonMenu.Buttons[0].background_color = Color.Gray;
            s_ButtonMenu.Buttons[0].transparency     = 1f; //0.75f;
            s_ButtonMenu.Buttons[0].border           = 10;
            s_ButtonMenu.Buttons[0].font_name        = "General";
            s_ButtonMenu.Buttons[0].autosize         = false;
            s_ButtonMenu.Buttons[0].center_text      = true;
            s_ButtonMenu.Buttons[0].text             = "New Game";
            s_ButtonMenu.Buttons[0].text_color       = Color.White;
            s_ButtonMenu.Buttons[0].mouse_enter     += change_button_on_hover;
            s_ButtonMenu.Buttons[0].mouse_press     += change_button_on_press;
            s_ButtonMenu.Buttons[0].mouse_leave     += change_button_on_leave;
            s_ButtonMenu.Buttons[0].mouse_click     += OnMouseClickNewGame;

            s_ButtonMenu.Buttons[1].background_name  = "test_dialog";
            s_ButtonMenu.Buttons[1].background_color = Color.Gray;
            s_ButtonMenu.Buttons[1].transparency     = 1f;
            s_ButtonMenu.Buttons[1].border           = 10;
            s_ButtonMenu.Buttons[1].font_name        = "General";
            s_ButtonMenu.Buttons[1].autosize         = false;
            s_ButtonMenu.Buttons[1].center_text      = true;
            s_ButtonMenu.Buttons[1].text             = "World Gen";
            s_ButtonMenu.Buttons[1].text_color       = Color.White;
            s_ButtonMenu.Buttons[1].mouse_enter     += change_button_on_hover;
            s_ButtonMenu.Buttons[1].mouse_press     += change_button_on_press;
            s_ButtonMenu.Buttons[1].mouse_leave     += change_button_on_leave;
            s_ButtonMenu.Buttons[1].mouse_click     += OnMouseClickWorldGen;

            s_ButtonMenu.Buttons[2].background_name  = "test_dialog";
            s_ButtonMenu.Buttons[2].background_color = Color.Gray;
            s_ButtonMenu.Buttons[2].transparency     = 1f;
            s_ButtonMenu.Buttons[2].border           = 10;
            s_ButtonMenu.Buttons[2].font_name        = "General";
            s_ButtonMenu.Buttons[2].autosize         = false;
            s_ButtonMenu.Buttons[2].center_text      = true;
            s_ButtonMenu.Buttons[2].text             = "Exit Game";
            s_ButtonMenu.Buttons[2].text_color       = Color.White;
            s_ButtonMenu.Buttons[2].mouse_enter     += change_button_on_hover;
            s_ButtonMenu.Buttons[2].mouse_press     += change_button_on_press;
            s_ButtonMenu.Buttons[2].mouse_leave     += change_button_on_leave;
            s_ButtonMenu.Buttons[2].mouse_click     += OnMouseClickExit;


            s_ButtonMenu.assemble();

            UserInterface ui = new UserInterface(s_ButtonMenu.Form);

            ecs_instance.add_component(e, ui);

            ecs_instance.resolve(e);

            //load the json start screen file
            s_json = s_JsonManager.loadJSON(GameConfig.root_dir + "/Content/json/start_screen.v");

            //create mouse pointer
            s_Frame = UIFactory.createMousePointer(InputManager.getMousePosition(), 10, 10, "pointer", OnMousePointerUpdate);

            //early entity reslove
            ecs_instance.resolve_entities();

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

            base.LoadContent();
        }
Esempio n. 2
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();
        }