Beispiel #1
0
        public SelectLevelView(MainMenuView menu)
        {
            scene = new Scene(ScrollInputs.None);
            Font text = new Font("Content/font.ttf");
            (backButton = new FastButton(text, 22, "Content/button.png", "Content/button_hover.png", "Content/button_pressed.png")
            {
                Position = new Vector2f(500, 600),
                Size = new Vector2f(280, 49),
                Text = "Back to Menu",
                Anchor = AnchorPoints.Left | AnchorPoints.Top
            }).OnClick += BackToMenu;

            string[] files = Directory.GetFiles("Content/Levels/", "*.json");
            for (int i = 0; i < files.Length; i++)
            {
                string file = files[i];
                string name = JsonConvert.DeserializeObject<GameScene>(File.ReadAllText(file)).Name;
                FastButton level = new FastButton(text, 22, "Content/button.png", "Content/button_hover.png", "Content/button_pressed.png")
                {
                    Position = new Vector2f(300, 50 + i * 50),
                    Size = new Vector2f(680, 49),
                    Text = "Play " + name,
                    Anchor = AnchorPoints.Left | AnchorPoints.Top
                };
                level.OnClick += (s, e) =>
                {
                    Next(this, new InGameView(file, this));
                };

                scene.AddComponent(level);
            }

            scene.AddComponent(backButton);
            this.menu = menu;
        }
Beispiel #2
0
        public SettingsView(MainMenuView menu)
        {
            if (File.Exists("settings.json"))
                settings = JsonConvert.DeserializeObject<GameSettings>(File.ReadAllText("settings.json"));
            else
            {
                settings = new GameSettings();
                settings.EnableClouds = true;
            }

            scene = new Scene(ScrollInputs.None);
            (cloudButton = new FastButton(new Font("Content/font.ttf"), 22, "Content/button.png", "Content/button_hover.png", "Content/button_pressed.png")
            {
                Position = new Vector2f(500, 200),
                Size = new Vector2f(280, 49),
                Text = (settings.EnableClouds ? "Disable" : "Enable") + " Clouds",
                Anchor = AnchorPoints.Left | AnchorPoints.Top
            }).OnClick += ToggleClouds;

            (volDownButton = new FastButton(new Font("Content/font.ttf"), 22, "Content/button.png", "Content/button_hover.png", "Content/button_pressed.png")
            {
                Position = new Vector2f(500, 300),
                Size = new Vector2f(40, 49),
                Text = "-",
                Anchor = AnchorPoints.Left | AnchorPoints.Top
            }).OnClick += VolumeDown;

            (volUpButton = new FastButton(new Font("Content/font.ttf"), 22, "Content/button.png", "Content/button_hover.png", "Content/button_pressed.png")
            {
                Position = new Vector2f(740, 300),
                Size = new Vector2f(40, 49),
                Text = "+",
                Anchor = AnchorPoints.Left | AnchorPoints.Top
            }).OnClick += VolumeUp;

            volumeIndicator = new FastText(new Font("Content/font.ttf"), 22)
            {
                Position = new Vector2f(550, 300),
                Size = new Vector2f(180, 49),
                TextAlignment = Alignment.MiddleCenter,
                Text = "Volume: " + settings.Volume + "%",
                Anchor = AnchorPoints.Left | AnchorPoints.Top
            };

            (menuButton = new FastButton(new Font("Content/font.ttf"), 22, "Content/button.png", "Content/button_hover.png", "Content/button_pressed.png")
            {
                Position = new Vector2f(500, 500),
                Size = new Vector2f(280, 49),
                Text = "Back",
                Anchor = AnchorPoints.Left | AnchorPoints.Bottom
            }).OnClick += MenuClick;

            scene.AddComponent(cloudButton);
            scene.AddComponent(menuButton);
            scene.AddComponent(volDownButton);
            scene.AddComponent(volUpButton);
            scene.AddComponent(volumeIndicator);
            this.menu = menu;
        }