Exemplo n.º 1
0
        public InGameMenu(ClickUI clickUi)
        {
            _clickUI = clickUi;
            var ctx = new Buttons.MenuContext {
                X = _menuX, Y = _menuY, Width = _menuWidth, FirstButtonYOffset = 50
            };

            var menu = new UiImage
            {
                Transform = new Transform2(new Rectangle(_menuX, _menuY, _menuWidth, _menuHeight)),
                Image     = "UI/menu-wide-panel.png"
            };

            var mainMenuButton  = Buttons.Text(ctx, 4, "Return to Main Menu", () => Scene.NavigateTo("MainMenu"), () => true);
            var characterStatus = Buttons.Text(ctx, 3, "Character Status", () => Event.Publish(new DisplayCharacterStatusRequested(GameWorld.CurrentCharacter)), () => true);

            _visuals.Add(new ColoredRectangle
            {
                Color     = UiColors.InGameMenu_FullScreenRectangle,
                Transform = new Transform2(new Size2(1920, 1080))
            });
            _visuals.Add(menu);
            _visuals.Add(mainMenuButton);
            _visuals.Add(characterStatus);
            _interceptLayer.Add(new ScreenClickable(HideDisplay));
            _branch.Add(mainMenuButton);
            _branch.Add(characterStatus);
            Input.On(Control.Menu, ToggleMenu);
            Event.Subscribe(EventSubscription.Create <MenuRequested>(x => PresentOptions(), this));
            Event.Subscribe(EventSubscription.Create <SubviewRequested>(x => HideDisplay(), this));
            Event.Subscribe(EventSubscription.Create <SubviewDismissed>(x => PresentOptions(), this));
        }
        public ActionOptionsMenu(ClickUI clickUI)
        {
            _clickUI = clickUI;
            var ctx = new Buttons.MenuContext {
                X = _menuX, Y = _menuY, Width = _menuWidth, FirstButtonYOffset = 30
            };

            var menu = new UiImage
            {
                Transform = new Transform2(new Rectangle(_menuX, _menuY, _menuWidth, _menuHeight)),
                Image     = "UI/menu-tall-panel.png"
            };

            _buttons = new List <TextButton>
            {
                Buttons.Text(ctx, 0, "Hide", () => Select(ActionType.Hide), () => _options.ContainsKey(ActionType.Hide)),
                Buttons.Text(ctx, 1, "Shoot", () => Select(ActionType.Shoot), () => _options.ContainsKey(ActionType.Shoot)),
                Buttons.Text(ctx, 2, "Overwatch", () => Select(ActionType.Overwatch), () => _options.ContainsKey(ActionType.Overwatch)),
                Buttons.Text(ctx, 3, "Pass", () => Select(ActionType.Pass), () => _options.ContainsKey(ActionType.Pass))
            };

            _visuals.Add(menu);
            _buttons.ForEach(x =>
            {
                _visuals.Add(x);
                _branch.Add(x);
            });

            Event.Subscribe <ActionOptionsAvailable>(UpdateOptions, this);
            Event.Subscribe <ActionSelected>(e => HideDisplay(), this);
            Event.Subscribe <ActionCancelled>(x => PresentOptions(), this);
            Event.Subscribe <ActionConfirmed>(x => _options.Clear(), this);
            Event.Subscribe <GameOver>(e => HideDisplay(), this);
        }
Exemplo n.º 3
0
        public GameOverMenu(ClickUI clickUi)
        {
            _clickUI = clickUi;
            var ctx = new Buttons.MenuContext {
                X = _menuX, Y = _menuY, Width = _menuWidth, FirstButtonYOffset = 50
            };

            var mainMenuButton = Buttons.Text(ctx, 7, "Return to Main Menu",
                                              () =>
            {
                AudioPlayer.Instance.StopAll();
                Scene.NavigateTo("MainMenu");
            }, () => true);

            _visuals.Add(_black);
            _fade = new ScreenFade
            {
                ToAlpha   = 255,
                FromAlpha = 0,
                Duration  = TimeSpan.FromSeconds(2)
            };
            _visuals.Add(_fade);
            _visuals.Add(new UiImage
            {
                Image     = "UI/game-over.png",
                Transform = new Transform2(new Vector2(0.5.VW() - 329, 0.3.VH()), new Size2(639, 150))
            });

            _visuals.Add(mainMenuButton);
            _interceptLayer.Add(new ScreenClickable(() => { }));
            _branch.Add(mainMenuButton);
            Event.Subscribe(EventSubscription.Create <GameOver>(e => Enable(), this));
        }
Exemplo n.º 4
0
        public ActionConfirmMenu(ClickUI clickUI)
        {
            _clickUI = clickUI;
            var ctx = new Buttons.MenuContext {
                X = _menuX, Y = _menuY, Width = _menuWidth, FirstButtonYOffset = 30
            };

            _visuals.Add(new UiImage
            {
                Transform = new Transform2(new Rectangle(_menuX, _menuY, _menuWidth, _menuHeight)),
                Image     = "UI/menu-tall-panel.png"
            });

            _confirmButton = new ImageButton("UI/confirm.png", "UI/confirm-hover.png", "UI/confirm-press.png",
                                             new Transform2(new Vector2(UI.OfScreenWidth(0.5f) + 30, _menuY + 64), new Size2(52, 52)), () =>
                                             {;
                                              Hide();
                                              Event.Publish(new ActionConfirmed()); }, () => _isReady);
            var cancelButton = new ImageButton("UI/cancel.png", "UI/cancel-hover.png", "UI/cancel-press.png",
                                               new Transform2(new Vector2(UI.OfScreenWidth(0.5f) - 52 - 30, _menuY + 64), new Size2(52, 52)),
                                               () =>
            {
                Hide();
                Event.Publish(new ActionCancelled());
            });

            _actionLabel = new Label
            {
                Transform       = new Transform2(new Rectangle(_menuX, _menuY + 20, _menuWidth, 52)),
                BackgroundColor = Color.Transparent,
                TextColor       = UiColors.InGame_Text,
                Font            = GuiFonts.Body,
            };

            _visuals.Add(_actionLabel);
            _visuals.Add(_confirmButton);
            _branch.Add(_confirmButton);
            _visuals.Add(cancelButton);
            _branch.Add(cancelButton);
            Event.Subscribe <ActionSelected>(Show, this);
            Event.Subscribe <ActionReadied>(Show, this);
        }