コード例 #1
0
ファイル: GameView.cs プロジェクト: Gvin/CodeMagic
        protected override bool ProcessKeyPressed(AsciiKey key)
        {
            switch (key.Key)
            {
            case Keys.C:
                OpenSpellBook?.Invoke(this, EventArgs.Empty);
                return(true);

            case Keys.I:
                OpenInventory?.Invoke(this, EventArgs.Empty);
                return(true);

            case Keys.G:
                OpenGroundView?.Invoke(this, EventArgs.Empty);
                return(true);

            case Keys.V:
                OpenPlayerStats?.Invoke(this, EventArgs.Empty);
                return(true);

            case Keys.Escape:
                OpenInGameMenu?.Invoke(this, EventArgs.Empty);
                return(true);
            }

            if (PerformKeyPlayerAction(key.Key))
            {
                return(true);
            }

            return(base.ProcessKeyPressed(key));
        }
コード例 #2
0
ファイル: GameView.cs プロジェクト: Gvin/CodeMagic
        private void InitializeControls()
        {
#if DEBUG
            var cheatsButton = new StandardButton(3)
            {
                Text     = "*",
                Position = new Point(Width - 39, 37)
            };
            cheatsButton.Click += (sender, args) => OpenCheats?.Invoke(this, EventArgs.Empty);
            Add(cheatsButton);
#endif

            var playerStatsControl = new PlayerStatsVisualControl(
                new Rectangle(Width - 40, 1, 39, 65),
                Game);
            AddVisualControl(playerStatsControl);

            gameArea = new GameAreaControl(Game)
            {
                Position = new Point(1, 1)
            };
            Add(gameArea);

            journalScroll = new ScrollBar(Orientation.Vertical, 9)
            {
                Position = new Point(1, Height - 10),
                CanFocus = false,
                Theme    = new ScrollBarTheme
                {
                    Normal = new Cell(Color.White, Color.Black)
                }
            };
            Add(journalScroll);

            journalBox = new JournalBoxControl(Width - 3, 10, journalScroll, Game.Journal)
            {
                Position = new Point(2, Height - 11)
            };
            Add(journalBox);


            openInventoryButton = new StandardButton(30)
            {
                Position = new Point(Width - 39, 22),
                Text     = "[I] Inventory"
            };
            openInventoryButton.Click += (sender, args) => OpenInventory?.Invoke(this, EventArgs.Empty);
            Add(openInventoryButton);

            openSpellBookButton = new StandardButton(30)
            {
                Position = new Point(Width - 39, 25),
                Text     = "[C] Spell Book"
            };
            openSpellBookButton.Click    += (sender, args) => OpenSpellBook?.Invoke(this, EventArgs.Empty);
            openSpellBookButton.IsEnabled = true;
            Add(openSpellBookButton);

            showItemsOnFloorButton = new StandardButton(30)
            {
                Position = new Point(Width - 39, 28),
                Text     = "[G] Check Floor"
            };
            showItemsOnFloorButton.Click += (sender, args) => OpenGroundView?.Invoke(this, EventArgs.Empty);
            Add(showItemsOnFloorButton);

            openPlayerStatsButton = new StandardButton(30)
            {
                Position = new Point(Width - 39, 31),
                Text     = "[V] Player Status"
            };
            openPlayerStatsButton.Click += (sender, args) => OpenPlayerStats?.Invoke(this, EventArgs.Empty);
            Add(openPlayerStatsButton);
        }