示例#1
0
        private static void InitCommands()
        {
            //TODO -- eventually move the selection of key bindings to the ui in game


            //TODO Is there a better way??

            var bindings = ReadConfig("KeyBindings");

            ICommand     command  = null;
            ConsoleKey   key      = ConsoleKey.A;
            LocalKeyInfo localKey = null;

            foreach (var binding in bindings)
            {
                switch (binding.Value)
                {
                case "a":
                    key = ConsoleKey.A;
                    break;

                case "e":
                    key = ConsoleKey.E;
                    break;

                case "UpArrow":
                    key = ConsoleKey.UpArrow;
                    break;

                case "DownArrow":
                    key = ConsoleKey.DownArrow;
                    break;

                case "RightArrow":
                    key = ConsoleKey.RightArrow;
                    break;

                case "LeftArrow":
                    key = ConsoleKey.LeftArrow;
                    break;

                case "i":
                    key = ConsoleKey.I;
                    break;

                case "l":
                    key = ConsoleKey.L;
                    break;

                case "o":
                    key = ConsoleKey.O;
                    break;

                case "p":
                    key = ConsoleKey.P;
                    break;

                case "w":
                    key = ConsoleKey.W;
                    break;

                default:
                    continue;
                }


                switch (binding.Key)
                {
                case "Attack":
                    command  = new AttackCommand(map);
                    localKey = new LocalKeyInfo(key, false, false, false);
                    break;

                case "DisplayEquipment":
                    command  = new DisplayEquipmentCommand(map);
                    localKey = new LocalKeyInfo(key, false, false, false);
                    break;

                case "Inventory":
                    command  = new InventoryCommand(map);
                    localKey = new LocalKeyInfo(key, false, false, false);
                    break;

                case "Look":
                    command  = new LookCommand(map);
                    localKey = new LocalKeyInfo(key, false, false, false);
                    break;

                case "MoveUp":
                    command  = new MoveMapPlayerCommand(map);
                    localKey = new LocalKeyInfo(key, false, false, false);
                    break;

                case "MoveDown":
                    command  = new MoveMapPlayerCommand(map);
                    localKey = new LocalKeyInfo(key, false, false, false);
                    break;

                case "MoveRight":
                    command  = new MoveMapPlayerCommand(map);
                    localKey = new LocalKeyInfo(key, false, false, false);
                    break;

                case "MoveLeft":
                    command  = new MoveMapPlayerCommand(map);
                    localKey = new LocalKeyInfo(key, false, false, false);
                    break;

                case "OpenClose":
                    command  = new OpenCloseCommand(map);
                    localKey = new LocalKeyInfo(key, false, false, false);
                    break;

                case "PickUp":
                    command  = new PickUpCommand(map);
                    localKey = new LocalKeyInfo(key, false, false, false);
                    break;

                case "Wear":
                    command  = new WearCommand(map);
                    localKey = new LocalKeyInfo(key, false, false, false);
                    break;

                default:
                    break;
                }

                game.SetCommand(localKey, command);
            }

            //var lookCommand = new LookCommand(map);
            //lk = new LocalKeyInfo(ConsoleKey.L, false, false, false);
            //game.SetCommand(lk, lookCommand);

            #region Non Bindable Keys

            var quitCommand = new QuitCommand(map);
            var lk          = new LocalKeyInfo(ConsoleKey.Q, false, false, false);
            game.SetCommand(lk, quitCommand);

            #endregion
        }
示例#2
0
        private static void InitCommands()
        {
            //TODO -- eventually move the selection of key bindings to the ui in game

            //TODO Is there a better way??

            var bindings = ReadConfig("KeyBindings");

            ICommand command = null;
            ConsoleKey key = ConsoleKey.A;
            LocalKeyInfo localKey = null;

            foreach (var binding in bindings)
            {

                switch (binding.Value)
                {
                    case "a":
                        key = ConsoleKey.A;
                        break;
                    case "e":
                        key = ConsoleKey.E;
                        break;
                    case "UpArrow":
                        key = ConsoleKey.UpArrow;
                        break;
                    case "DownArrow":
                        key = ConsoleKey.DownArrow;
                        break;
                    case "RightArrow":
                        key = ConsoleKey.RightArrow;
                        break;
                    case "LeftArrow":
                        key = ConsoleKey.LeftArrow;
                        break;
                    case "i":
                        key = ConsoleKey.I;
                        break;
                    case "l":
                        key = ConsoleKey.L;
                        break;
                    case "o":
                        key = ConsoleKey.O;
                        break;
                    case "p":
                        key = ConsoleKey.P;
                        break;
                    case "w":
                        key = ConsoleKey.W;
                        break;
                    default:
                        continue;
                }

                switch (binding.Key)
                {
                    case "Attack":
                        command = new AttackCommand(map);
                        localKey = new LocalKeyInfo(key, false, false, false);
                        break;
                    case "DisplayEquipment":
                        command = new DisplayEquipmentCommand(map);
                        localKey = new LocalKeyInfo(key, false, false, false);
                        break;
                    case "Inventory":
                        command = new InventoryCommand(map);
                        localKey = new LocalKeyInfo(key, false, false, false);
                        break;
                    case "Look":
                        command = new LookCommand(map);
                        localKey = new LocalKeyInfo(key, false, false, false);
                        break;
                    case "MoveUp":
                        command = new MoveMapPlayerCommand(map);
                        localKey = new LocalKeyInfo(key, false, false, false);
                        break;
                    case "MoveDown":
                        command = new MoveMapPlayerCommand(map);
                        localKey = new LocalKeyInfo(key, false, false, false);
                        break;
                    case "MoveRight":
                        command = new MoveMapPlayerCommand(map);
                        localKey = new LocalKeyInfo(key, false, false, false);
                        break;
                    case "MoveLeft":
                        command = new MoveMapPlayerCommand(map);
                        localKey = new LocalKeyInfo(key, false, false, false);
                        break;
                    case "OpenClose":
                        command = new OpenCloseCommand(map);
                        localKey = new LocalKeyInfo(key, false, false, false);
                        break;
                    case "PickUp":
                        command = new PickUpCommand(map);
                        localKey = new LocalKeyInfo(key, false, false, false);
                        break;
                    case "Wear":
                        command = new WearCommand(map);
                        localKey = new LocalKeyInfo(key, false, false, false);
                        break;
                    default:
                        break;
                }

                game.SetCommand(localKey, command);
            }

            //var lookCommand = new LookCommand(map);
            //lk = new LocalKeyInfo(ConsoleKey.L, false, false, false);
            //game.SetCommand(lk, lookCommand);

            #region Non Bindable Keys

            var quitCommand = new QuitCommand(map);
            var lk = new LocalKeyInfo(ConsoleKey.Q, false, false, false);
            game.SetCommand(lk, quitCommand);

            #endregion
        }