コード例 #1
0
        public QuickSelectPane() : base(Settings.Config.WindowWidth - Settings.Config.ToolPaneWidth + 1, 3)
        {
            textSurface.Font = Settings.Config.ScreenFont;
            textSurface.DefaultBackground = Settings.Color_MenuBack;
            textSurface.DefaultForeground = Settings.Color_TitleText;

            currentCharSet = 0;

            keys = new AsciiKey[] { AsciiKey.Get(Microsoft.Xna.Framework.Input.Keys.F1), AsciiKey.Get(Microsoft.Xna.Framework.Input.Keys.F2), AsciiKey.Get(Microsoft.Xna.Framework.Input.Keys.F3),
                                    AsciiKey.Get(Microsoft.Xna.Framework.Input.Keys.F4), AsciiKey.Get(Microsoft.Xna.Framework.Input.Keys.F5), AsciiKey.Get(Microsoft.Xna.Framework.Input.Keys.F6),
                                    AsciiKey.Get(Microsoft.Xna.Framework.Input.Keys.F7), AsciiKey.Get(Microsoft.Xna.Framework.Input.Keys.F8), AsciiKey.Get(Microsoft.Xna.Framework.Input.Keys.F9),
                                    AsciiKey.Get(Microsoft.Xna.Framework.Input.Keys.F10), AsciiKey.Get(Microsoft.Xna.Framework.Input.Keys.F11), AsciiKey.Get(Microsoft.Xna.Framework.Input.Keys.F12) };

            if (System.IO.File.Exists("quickselect.json"))
            {
                CharacterSets = SadConsole.Serializer.Load <int[][]>("quickselect.json");
                Characters    = CharacterSets[0];
            }
            else
            {
                Characters       = new int[] { (char)176, (char)177, (char)178, (char)219, (char)223, (char)220, (char)221, (char)222, (char)254, (char)250, (char)249, (char)0 };
                CharacterSets    = new int[3][];
                CharacterSets[0] = Characters;
                CharacterSets[1] = new int[] { (char)218, (char)191, (char)192, (char)217, (char)196, (char)179, (char)195, (char)180, (char)193, (char)194, (char)197, (char)0 };
                CharacterSets[2] = new int[] { (char)201, (char)187, (char)200, (char)188, (char)205, (char)186, (char)204, (char)185, (char)202, (char)203, (char)206, (char)0 };
            }

            UseMouse    = false;
            UseKeyboard = false;

            UsePixelPositioning = true;
            Position            = new Point(0, SadConsole.Global.WindowHeight - TextSurface.AbsoluteArea.Height);
        }
コード例 #2
0
        public void Update(IList <AsciiKey> keysDown)
        {
            var dx = 0;
            var dy = 0;

            if (keysDown.Contains(AsciiKey.Get(Keys.Left)) || keysDown.Contains(AsciiKey.Get(Keys.A)))
            {
                dx = -1;
            }
            else if (keysDown.Contains(AsciiKey.Get(Keys.Right)) || keysDown.Contains(AsciiKey.Get(Keys.D)))
            {
                dx = 1;
            }

            if (keysDown.Contains(AsciiKey.Get(Keys.Up)) || keysDown.Contains(AsciiKey.Get(Keys.W)))
            {
                dy = -1;
            }
            else if (keysDown.Contains(AsciiKey.Get(Keys.Down)) || keysDown.Contains(AsciiKey.Get(Keys.S)))
            {
                dy = 1;
            }

            if (dx != 0 || dy != 0)
            {
                var position = this.Parent.Position;
                position.X += dx;
                position.Y += dy;
            }
        }
コード例 #3
0
        override public void Update(double elapsedSeconds)
        {
            var keysPressed = SadConsole.Global.KeyboardState.KeysPressed;
            var keysDown    = SadConsole.Global.KeyboardState.KeysDown;

            var oldPlayerX = this.player.Position.X;
            var oldPlayerY = this.player.Position.Y;

            this.player.Get <MoveToKeyboardComponent>().Update(keysPressed);

            // Glorious hack. TODO: query the map tile for this + list of blocking objects
            if (!this.map[this.player.Position.X, this.player.Position.Y].IsWalkable)
            {
                this.player.Position.X = oldPlayerX;
                this.player.Position.Y = oldPlayerY;
            }

            if (oldPlayerX != this.player.Position.X || oldPlayerY != this.player.Position.Y)
            {
                EventBus.Instance.Broadcast("Player moved", player);
            }

            if (IsShiftKeyDown(keysDown) && keysDown.Any(k => k.Key == Keys.OemPeriod) &&
                this.map[this.player.Position.X, this.player.Position.Y] is StairsDownTile)
            {
                // TODO: un-hardcode the new current floor
                EventBus.Instance.Broadcast("Player used stairs", "1F");
            }

            if (keysPressed.Contains(AsciiKey.Get(Keys.Escape)))
            {
                System.Environment.Exit(0);
            }
        }
コード例 #4
0
        protected override bool ProcessKeyPressed(AsciiKey key)
        {
            switch (key.Key)
            {
            case Keys.R:
                RemoveSpell?.Invoke(this, EventArgs.Empty);
                return(true);

            case Keys.E:
                EditSpell?.Invoke(this, EventArgs.Empty);
                return(true);

            case Keys.Up:
            case Keys.W:
                MoveSelectionUp();
                return(true);

            case Keys.Down:
            case Keys.S:
                MoveSelectionDown();
                return(true);

            case Keys.Escape:
                OnExit();
                return(true);
            }

            return(base.ProcessKeyPressed(key));
        }
コード例 #5
0
        public override bool ProcessKeyboard(KeyboardInfo info)
        {
            if (info.KeysPressed.Contains(AsciiKey.Get(Microsoft.Xna.Framework.Input.Keys.I)))
            {
                if (!inventoryConsole.IsVisible)
                {
                    inventoryConsole.Show();
                }
                else
                {
                    inventoryConsole.Hide();
                }
            }
            if (info.KeysPressed.Contains(AsciiKey.Get(Microsoft.Xna.Framework.Input.Keys.P)))
            {
                if (!characterStatusConsole.IsVisible)
                {
                    characterStatusConsole.Show();
                }
                else
                {
                    characterStatusConsole.Hide();
                }
            }

            if (!characterStatusConsole.ProcessKeyboard(info) && !inventoryConsole.ProcessKeyboard(info))
            {
                return(dungeonViewConsole.ProcessKeyboard(info));
            }
            return(true);
        }
コード例 #6
0
        private Command Use_Has_Item(AsciiKey press, IBeing being)
        {
            var dir = DirectionOf(press);

            if (dir != CmdDirection.None)
            {
                priorUsedItem = thisUsedItem;
                thisUsedItem  = null;
                return(FinishedCommand(CmdAction.Use, dir, priorUsedItem));
            }

            //1.+: 'Use' inventory suggesting uses?
            if (press.Key == Keys.OemQuestion)
            {
                return(ShowInventory(being, i => i.IsUsable));
            }
            if (press.Key == Keys.Escape)
            {
                return(CancelMultiStep("cancelled."));
            }

            if ('a' <= press.Character && press.Character <= 'z')
            {
                return(Use_Pick_Item(press, being));
            }

            WriteLine($"The key [{PressRep(press)}] does not match an inventory item or a direction.  Pick another.");
            return(commandIncomplete);

            //  Some of this needs to end up in Action system
            //    var targetPoint = PointInDirection(Player.Point, direction);
            //    WriteLine(direction.ToString());
            //    _usingItem.ApplyTo(Map[targetPoint], this, direction);  // the magic
        }
コード例 #7
0
        public Command Use_Pick_Item(AsciiKey press, IBeing being)
        {
            if (press.Key == Keys.Escape)
            {
                return(CancelMultiStep("cancelled."));
            }

            var selectedIndex = AlphaIndexOfKeyPress(press);

            if (selectedIndex < 0 || being.Inventory.Count() <= selectedIndex)
            {
                return(SameStep($"The key [{PressRep(press)}] does not match an inventory item.  Pick another."));
            }

            var item = being.Inventory.ElementAt(selectedIndex);

            if (!item.IsUsable)
            {
                return(SameStep($"The {Describer.Describe(item)} is not a usable item.  Pick another."));
            }

            thisUsedItem = item;

            return(NextStepIs(
                       Use_Has_Item,
                       $"Direction to use the {Describer.Describe(thisUsedItem)}, or [a-z?] to choose item: ", being));
        }
コード例 #8
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));
        }
コード例 #9
0
 protected override bool ProcessKeyPressed(AsciiKey key)
 {
     if (key.Key == Keys.Escape)
     {
         ContinueGame?.Invoke(this, EventArgs.Empty);
         return(true);
     }
     return(base.ProcessKeyPressed(key));
 }
コード例 #10
0
ファイル: GameView.cs プロジェクト: Gvin/CodeMagic
        protected override bool ProcessKeyDown(AsciiKey key)
        {
            if (PerformKeyPlayerAction(key.Key))
            {
                return(true);
            }

            return(base.ProcessKeyDown(key));
        }
コード例 #11
0
        public override bool ProcessKeyboard(KeyboardInfo info)
        {
            if (!this.gameOver)
            {
                if (info.KeysPressed.Contains(AsciiKey.Get(Keys.Down)) || info.KeysPressed.Contains(AsciiKey.Get(Keys.S)))
                {
                    this.MovePlayerBy(new Point(0, 1), info);
                }
                else if (info.KeysPressed.Contains(AsciiKey.Get(Keys.Up)) || info.KeysPressed.Contains(AsciiKey.Get(Keys.W)))
                {
                    this.MovePlayerBy(new Point(0, -1), info);
                }

                if (info.KeysPressed.Contains(AsciiKey.Get(Keys.Right)) || info.KeysPressed.Contains(AsciiKey.Get(Keys.D)))
                {
                    this.MovePlayerBy(new Point(1, 0), info);
                }
                else if (info.KeysPressed.Contains(AsciiKey.Get(Keys.Left)) || info.KeysPressed.Contains(AsciiKey.Get(Keys.A)))
                {
                    this.MovePlayerBy(new Point(-1, 0), info);
                }
                else if (info.KeysPressed.Contains(AsciiKey.Get(Keys.Space)))
                {
                    this.MovePlayerBy(new Point(0, 0), info);
                }

                if (info.KeysPressed.Contains(AsciiKey.Get(Keys.Space)))
                {
                    var switches = this.objects.Where(o => o.Data is Switch);
                    var player   = this.objects.Single(o => o.Data is Player);
                    foreach (var s in switches)
                    {
                        if ((Math.Abs(s.Position.X - player.Position.X) + Math.Abs(s.Position.Y - player.Position.Y)) <= 1)
                        {
                            (s.Data as Switch).Flip();
                            this.currentMap.FlipSwitches();

                            foreach (var w in switches)
                            {
                                w.RenderCells[0].ActualForeground = new Color(s.Data.Colour.R, s.Data.Colour.G, s.Data.Colour.B);
                            }

                            showMessageCallback("You flip the switch.");
                        }
                    }
                }
            }
            else
            {
                if (info.KeysPressed.Any())
                {
                    Game.Stop();
                }
            }
            return(false);
        }
コード例 #12
0
ファイル: CheatsView.cs プロジェクト: Gvin/CodeMagic
        protected override bool ProcessKeyPressed(AsciiKey key)
        {
            switch (key.Key)
            {
            case Keys.Escape:
                Exit?.Invoke(this, EventArgs.Empty);
                return(true);
            }

            return(base.ProcessKeyPressed(key));
        }
コード例 #13
0
        protected void Queue(params Keys[] xnaKeys)
        {
            var state = new KeyboardState(xnaKeys, false, true);

            foreach (var xnaKey in xnaKeys)
            {
                var key = AsciiKey.Get(xnaKey, state);
                //var key = new AsciiKey { Character = (char)xnaKey, Key = xnaKey };
                _inQ.Enqueue(key);
            }
        }
コード例 #14
0
ファイル: Messager.cs プロジェクト: Coleoid/CopperBend
 private void HandleMessagesPending()
 {
     for (AsciiKey k = GetNextKeyPress(); k.Key != Keys.None; k = GetNextKeyPress())
     {
         if (k.Key == Keys.Space)
         {
             ResetMessagesSentSincePause();
             GameMode.PopEngineMode();
             ShowMessages();  // ...which may have enough messages to pend us again.
         }
     }
 }
コード例 #15
0
        public string Readable(AsciiKey press)
        {
            if (32 <= press.Character && press.Character <= 126)
            {
                return(press.Character.ToString());
            }

            if (1 <= press.Character && press.Character <= 26)
            {
                return($"Ctrl-{(char)(press.Character + 64)}");
            }

            return(press.Key switch
            {
                Keys.Escape => "Esc",
                _ => "[NP]"
            });
コード例 #16
0
ファイル: SpellBookView.cs プロジェクト: Gvin/CodeMagic
        protected override bool ProcessKeyPressed(AsciiKey key)
        {
            switch (key.Key)
            {
            case Keys.Escape:
                Exit?.Invoke(this, EventArgs.Empty);
                return(true);

            case Keys.E:
                EditSpell?.Invoke(this, EventArgs.Empty);
                return(true);

            case Keys.R:
                RemoveSpell?.Invoke(this, EventArgs.Empty);
                return(true);

            case Keys.C:
                CastSpell?.Invoke(this, EventArgs.Empty);
                return(true);

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

            case Keys.T:
                SaveToLibrary?.Invoke(this, EventArgs.Empty);
                return(true);

            case Keys.L:
                LoadFromLibrary?.Invoke(this, EventArgs.Empty);
                return(true);

            case Keys.Up:
            case Keys.W:
                MoveSelectionUp();
                return(true);

            case Keys.Down:
            case Keys.S:
                MoveSelectionDown();
                return(true);

            default:
                return(false);
            }
        }
コード例 #17
0
 public CmdDirection DirectionOf(AsciiKey press)
 {
     return(press.Key switch
     {
         Keys.Left => CmdDirection.West,
         Keys.Right => CmdDirection.East,
         Keys.Up => CmdDirection.North,
         Keys.Down => CmdDirection.South,
         Keys.NumPad1 => CmdDirection.Southwest,
         Keys.NumPad2 => CmdDirection.South,
         Keys.NumPad3 => CmdDirection.Southeast,
         Keys.NumPad4 => CmdDirection.West,
         Keys.NumPad6 => CmdDirection.East,
         Keys.NumPad7 => CmdDirection.Northwest,
         Keys.NumPad8 => CmdDirection.North,
         Keys.NumPad9 => CmdDirection.Northeast,
         _ => CmdDirection.None,
     });
コード例 #18
0
        private static string PressRep(AsciiKey press)
        {
            string rep;

            if (press.Character == 0)
            {
                rep = press.Key.ToString();
            }
            else if (20 <= press.Character && press.Character <= 127)
            {
                rep = press.Character.ToString();
            }
            else
            {
                rep = "???";
            }
            return(rep);
        }
コード例 #19
0
        private static Key?AsciiKeyToCommonKey(AsciiKey key)
        {
            object toReturn = null;

            // Simple characters like A/S/D/F
            if (Enum.TryParse(typeof(Key), key.Character.ToString(), true, out toReturn))
            {
                return((Key)toReturn);
            }
            // Complex keys like . (OemPeriod)
            else if (Enum.TryParse(typeof(Key), key.Key.ToString(), true, out toReturn))
            {
                return((Key)toReturn);
            }
            else
            {
                return(null);
            }
        }
コード例 #20
0
        public override bool ProcessKeyboard(KeyboardInfo info)
        {
            //TODO: Have this use Colored strings and make it so an item of type Equipment is equippable.(or unequippable)
            if (this.IsVisible)
            {
                if (info.KeysPressed.Contains(AsciiKey.Get(Keys.J)))
                {
                    DropMode = DropMode == true ? false : true;
                }
                foreach (var k in inventory.inventory)
                {
                    if (info.KeysPressed.Contains(AsciiKey.Get((Keys)((int)char.ToUpper(k.Key)))))
                    {
                        if (DropMode)
                        {
                            SadConsole.Consoles.Window.Prompt(GetItemMessage(k), "Drop", "Cancel", (r) => { drop_prompt(r, k.Value); });
                        }
                        else
                        {
                            switch (k.Value.GetComponent <Item>(ComponentType.Item).ItemType)
                            {
                            case ItemType.Food:
                                SadConsole.Consoles.Window.Prompt(GetItemMessage(k), "Eat", "Cancel", (r) => { food_prompt(r, k.Value); });
                                break;

                            case ItemType.Equipment:
                                SadConsole.Consoles.Window.Prompt(GetItemMessage(k), "Equip/UnEquip", "Cancel", (r) => { equipment_prompt(r, k.Value); });
                                break;

                            case ItemType.Potion:
                                SadConsole.Consoles.Window.Prompt(GetItemMessage(k), "Drink", "Cancel", (r) => { potion_prompt(r, k.Value); });
                                break;

                            default:
                                break;
                            }
                        }
                    }
                }
            }
            return(base.ProcessKeyboard(info));
        }
コード例 #21
0
        public Command Drop_main(AsciiKey press, IBeing being)
        {
            if (press.Key == Keys.Escape)
            {
                return(CancelMultiStep("Drop cancelled."));
            }
            if (press.Character == '?')
            {
                return(ShowInventory(being, i => true));
            }

            var item = ItemInInventoryLocation(press, being);

            if (item == null)
            {
                return(SameStep($"Nothing in inventory slot {press.Character}."));
            }

            return(FinishedCommand(CmdAction.Drop, CmdDirection.None, item));
        }
コード例 #22
0
 public override bool ProcessKeyboard(KeyboardInfo info)
 {
     if (info.KeysPressed.Contains(AsciiKey.Get(Microsoft.Xna.Framework.Input.Keys.Down)))
     {
         ViewConsole.MovePlayerBy(new Point(0, 1));
     }
     else if (info.KeysPressed.Contains(AsciiKey.Get(Microsoft.Xna.Framework.Input.Keys.Up)))
     {
         ViewConsole.MovePlayerBy(new Point(0, -1));
     }
     else if (info.KeysPressed.Contains(AsciiKey.Get(Microsoft.Xna.Framework.Input.Keys.Right)))
     {
         ViewConsole.MovePlayerBy(new Point(1, 0));
     }
     else if (info.KeysPressed.Contains(AsciiKey.Get(Microsoft.Xna.Framework.Input.Keys.Left)))
     {
         ViewConsole.MovePlayerBy(new Point(-1, 0));
     }
     return(false);
 }
コード例 #23
0
        public void UpdateMovesPlayerPositionToWasdKeys()
        {
            var e         = new Entity();
            var component = new MoveToKeyboardComponent(e);

            e.Position.X = 3;
            e.Position.Y = 3;

            var keys = new List <AsciiKey>()
            {
                AsciiKey.Get(Keys.W)
            };

            component.Update(keys);
            Assert.That(e.Position.X, Is.EqualTo(3));
            Assert.That(e.Position.Y, Is.EqualTo(2));

            keys = new List <AsciiKey>()
            {
                AsciiKey.Get(Keys.D)
            };
            component.Update(keys);
            Assert.That(e.Position.X, Is.EqualTo(4));
            Assert.That(e.Position.Y, Is.EqualTo(2));

            keys = new List <AsciiKey>()
            {
                AsciiKey.Get(Keys.S)
            };
            component.Update(keys);
            Assert.That(e.Position.X, Is.EqualTo(4));
            Assert.That(e.Position.Y, Is.EqualTo(3));

            keys = new List <AsciiKey>()
            {
                AsciiKey.Get(Keys.A)
            };
            component.Update(keys);
            Assert.That(e.Position.X, Is.EqualTo(3));
            Assert.That(e.Position.Y, Is.EqualTo(3));
        }
コード例 #24
0
        public void UpdateMovesPlayerPositionToArrowKeys()
        {
            var e         = new Entity();
            var component = new MoveToKeyboardComponent(e);

            e.Position.X = 5;
            e.Position.Y = 7;

            var keys = new List <AsciiKey>()
            {
                AsciiKey.Get(Keys.Up)
            };

            component.Update(keys);
            Assert.That(e.Position.X, Is.EqualTo(5));
            Assert.That(e.Position.Y, Is.EqualTo(6));

            keys = new List <AsciiKey>()
            {
                AsciiKey.Get(Keys.Right)
            };
            component.Update(keys);
            Assert.That(e.Position.X, Is.EqualTo(6));
            Assert.That(e.Position.Y, Is.EqualTo(6));

            keys = new List <AsciiKey>()
            {
                AsciiKey.Get(Keys.Down)
            };
            component.Update(keys);
            Assert.That(e.Position.X, Is.EqualTo(6));
            Assert.That(e.Position.Y, Is.EqualTo(7));

            keys = new List <AsciiKey>()
            {
                AsciiKey.Get(Keys.Left)
            };
            component.Update(keys);
            Assert.That(e.Position.X, Is.EqualTo(5));
            Assert.That(e.Position.Y, Is.EqualTo(7));
        }
コード例 #25
0
        public void UpdateMovesPlayerToNextFloorIfPlayerStandsAboveStairsDownAndShiftDotKeysAreDown(Keys shiftKey)
        {
            // Arrange
            const int StairsX = 3;
            const int StairsY = 3;

            var player = new Entity();

            player.Set(new MoveToKeyboardComponent(player));
            var system = new MovementSystem(player);

            var map = new ArrayMap <AbstractMapTile>(5, 5);

            for (var y = 0; y < map.Height; y++)
            {
                for (var x = 0; x < map.Width; x++)
                {
                    map[x, y] = new FloorTile();
                }
            }

            map[StairsX, StairsY] = new StairsDownTile();
            EventBus.Instance.Broadcast("Map changed", map);

            player.Position.X = StairsX;
            player.Position.Y = StairsY;

            SadConsole.Global.KeyboardState.KeysDown.Add(AsciiKey.Get(shiftKey));
            SadConsole.Global.KeyboardState.KeysDown.Add(AsciiKey.Get(Keys.OemPeriod));

            bool usedStairs = false;

            EventBus.Instance.Register <string>("Player used stairs", (floorNumber) => usedStairs = true);

            // Act
            system.Update(0);

            // Assert
            Assert.That(usedStairs, Is.True);
        }
コード例 #26
0
        public void UpdateChangesPlayerPositionIfNewPositionIsWalkable(bool isDestinationWalkable)
        {
            // Arrange
            var player = new Entity();
            var system = new MovementSystem(player);

            player.Set(new MoveToKeyboardComponent(player));
            player.Position.X = 3;
            system.Add(player);
            player.Position.Y = 3;

            var playerMoved = false;

            var map = new ArrayMap <AbstractMapTile>(5, 5);

            for (var y = 0; y < map.Height; y++)
            {
                for (var x = 0; x < map.Width; x++)
                {
                    map[x, y] = new FloorTile();
                }
            }

            map[player.Position.X - 1, player.Position.Y].IsWalkable = isDestinationWalkable;
            SadConsole.Global.KeyboardState.KeysPressed.Add(AsciiKey.Get(Keys.Left));

            // Update the map in the movement system
            EventBus.Instance.Broadcast("Map changed", map);
            EventBus.Instance.Register <Player>("Player moved", (data) => playerMoved = true);

            var expectedX = isDestinationWalkable ? player.Position.X - 1 : player.Position.X;

            // Act
            system.Update(0);

            // Assert
            Assert.That(player.Position.X, Is.EqualTo(expectedX));       // Position changed
            Assert.That(playerMoved, Is.EqualTo(isDestinationWalkable)); // Event fired (or not)
        }
コード例 #27
0
        public Command Wield_main(AsciiKey press, IBeing being)
        {
            if (press.Key == Keys.Escape)
            {
                return(CancelMultiStep("Wield cancelled."));
            }

            //0.2: Perhaps only 'likely' wields by default?
            if (press.Key == Keys.OemQuestion)
            {
                return(ShowInventory(being, i => true));
            }

            var item = ItemInInventoryLocation(press, being);

            if (item == null)
            {
                return(SameStep($"Nothing in inventory slot {press.Character}."));
            }

            return(FinishedCommand(CmdAction.Wield, CmdDirection.None, item));
        }
コード例 #28
0
        public override bool ProcessKeyboard(KeyboardInfo info)
        {
            bool didPlayerAct = false;

            if (!Game.CommandSystem.IsPlayerTurn)
            {
                Game.CommandSystem.ActivateMonsters();
            }

            if (info.KeysPressed.Contains(AsciiKey.Get(Microsoft.Xna.Framework.Input.Keys.Down)))
            {
                MapConsole.MovePlayerBy(new Point(0, 1));
                didPlayerAct = true;
            }
            else if (info.KeysPressed.Contains(AsciiKey.Get(Microsoft.Xna.Framework.Input.Keys.Up)))
            {
                MapConsole.MovePlayerBy(new Point(0, -1));
                didPlayerAct = true;
            }

            if (info.KeysPressed.Contains(AsciiKey.Get(Microsoft.Xna.Framework.Input.Keys.Right)))
            {
                MapConsole.MovePlayerBy(new Point(1, 0));
                didPlayerAct = true;
            }
            else if (info.KeysPressed.Contains(AsciiKey.Get(Microsoft.Xna.Framework.Input.Keys.Left)))
            {
                MapConsole.MovePlayerBy(new Point(-1, 0));
                didPlayerAct = true;
            }

            if (didPlayerAct)
            {
                Game.CommandSystem.EndPlayerTurn();
            }

            return(false);
        }
コード例 #29
0
        public override bool ProcessKeyboard(KeyboardInfo info)
        {
            bool keyHit = false;

            var newPosition = player.Position;

            if (info.KeysPressed.Contains(AsciiKey.Get(Keys.Up)))
            {
                newPosition.Y -= 1;
                keyHit         = true;
            }
            else if (info.KeysPressed.Contains(AsciiKey.Get(Keys.Down)))
            {
                newPosition.Y += 1;
                keyHit         = true;
            }

            if (info.KeysPressed.Contains(AsciiKey.Get(Keys.Left)))
            {
                newPosition.X -= 1;
                keyHit         = true;
            }
            else if (info.KeysPressed.Contains(AsciiKey.Get(Keys.Right)))
            {
                newPosition.X += 1;
                keyHit         = true;
            }

            // Test location
            if (map.IsWalkable(newPosition.X, newPosition.Y))
            {
                player.Position = newPosition;

                UpdatePlayerView();
            }

            return(keyHit || base.ProcessKeyboard(info));
        }
コード例 #30
0
ファイル: PlayerInventoryView.cs プロジェクト: Gvin/CodeMagic
        protected override bool ProcessKeyPressed(AsciiKey key)
        {
            switch (key.Key)
            {
            case Keys.U:
                UseItem?.Invoke(this, EventArgs.Empty);
                return(true);

            case Keys.E:
                EquipItem?.Invoke(this, EventArgs.Empty);
                return(true);

            case Keys.Z:
                EquipHoldableItemLeft?.Invoke(this, EventArgs.Empty);
                return(true);

            case Keys.X:
                EquipHoldableItemRight?.Invoke(this, EventArgs.Empty);
                return(true);

            case Keys.T:
                TakeOffItem?.Invoke(this, EventArgs.Empty);
                return(true);

            case Keys.D:
                DropItem?.Invoke(this, EventArgs.Empty);
                return(true);

            case Keys.A:
                DropStack?.Invoke(this, EventArgs.Empty);
                return(true);

            case Keys.C:
                CheckScroll?.Invoke(this, EventArgs.Empty);
                return(true);
            }
            return(base.ProcessKeyPressed(key));
        }