Esempio n. 1
0
        public MainMenuScreen(OnScreenChanged screenChanged) : base(screenChanged)
        {
            UserInterfaceLoader uiLoader   = UserInterfaceLoader.GetInstance();
            TileLoader          tileLoader = TileLoader.GetInstance();

            tileBrick1Sprite = tileLoader.Get("brick1");
            titleSprite      = uiLoader.Get("title");
            newGameSprite    = uiLoader.Get("newGame");
            loadGameSprite   = uiLoader.Get("loadGame");
            sandboxSprite    = uiLoader.Get("sandbox");
            adventureSprite  = uiLoader.Get("adventure");

            title           = new StaticEntity("Title Card", new Vector2(GameConstants.WINDOW_WIDTH / 2, GameConstants.TILE_SIZE * 2), titleSprite);
            newGameButton   = new StaticEntity("New Game Button", new Vector2(GameConstants.WINDOW_WIDTH / 2, GameConstants.TILE_SIZE * 11 / 2), newGameSprite);
            loadGameButton  = new StaticEntity("Load Game Button", new Vector2(GameConstants.WINDOW_WIDTH / 2, GameConstants.TILE_SIZE * 8), loadGameSprite);
            sandboxButton   = new StaticEntity("Sandbox Button", new Vector2(GameConstants.WINDOW_WIDTH / 2, GameConstants.TILE_SIZE * 21 / 2), sandboxSprite);
            adventureButton = new StaticEntity("Achievements Button", new Vector2(GameConstants.WINDOW_WIDTH / 2, GameConstants.TILE_SIZE * 13), adventureSprite);

            for (int i = 0; i < GameConstants.TILES_WIDE; i++)
            {
                for (int j = 0; j < GameConstants.TILES_HIGH + 1; j++) //The +1 allows us to cover the action bar
                {
                    Vector2    tileLocation = new Vector2(i * GameConstants.TILE_SIZE + GameConstants.TILE_SIZE / 2, j * GameConstants.TILE_SIZE + GameConstants.TILE_SIZE / 2);
                    GridEntity newTile      = new GridEntity("Tile", i, j, 0, tileLocation, GameConstants.TILE_SIZE, tileBrick1Sprite);
                    menuBackground.Add(newTile);
                }
            }
        }