Esempio n. 1
0
        public Tile GetTileInDirection(LocalKeyInfo keyInfo, Location mapLocation)
        {
            switch (keyInfo.Key)
            {
            case ConsoleKey.UpArrow:
                mapLocation.Top--;
                break;

            case ConsoleKey.DownArrow:
                mapLocation.Top++;
                break;

            case ConsoleKey.LeftArrow:
                mapLocation.Left--;
                break;

            case ConsoleKey.RightArrow:
                mapLocation.Left++;
                break;

            default:
                break;
            }

            return(this.GetTileForLocation(mapLocation));
        }
Esempio n. 2
0
        private static void Load()
        {
            Status.ClearInfo();
            Status.Info = "Start a New game, or Load an existing (S/L)?";
            Status.WriteToStatus();

            ConsoleKeyInfo consoleKeyInfo = Console.ReadKey(true);
            var            localKeyInfo   = new LocalKeyInfo(consoleKeyInfo);

            XDocument doc;

            switch (localKeyInfo.Key)
            {
            case ConsoleKey.S:
                doc = XDocument.Load(@".\new.sav");
                break;

            case ConsoleKey.L:
                doc = XDocument.Load(@".\game.sav");
                break;

            default:
                Program.Load();
                return;
            }

            map.Load(doc.Descendants("Tiles"));
        }
Esempio n. 3
0
        public bool execute(LocalKeyInfo keyInfo)
        {
            var mapTile = this.map.GetPlayerTile();
            this.map.MoveMobile(keyInfo, mapTile);
            this.map.Outdated = true;

            return false;
        }
Esempio n. 4
0
        public Tile MoveMobile(LocalKeyInfo keyInfo, Tile mobileMapTile)
        {
            var mapLocation = new Location(mobileMapTile.Location.Left, mobileMapTile.Location.Top);

            var tileToMoveTo = this.GetTileInDirection(keyInfo, mapLocation);

            return(this.MoveMobile(mobileMapTile, tileToMoveTo));
        }
Esempio n. 5
0
        public bool execute(LocalKeyInfo keyInfo)
        {
            var mapTile = this.map.GetPlayerTile();

            this.map.MoveMobile(keyInfo, mapTile);
            this.map.Outdated = true;

            return(false);
        }
Esempio n. 6
0
        public bool Equals(LocalKeyInfo p)
        {
            // If parameter is null return false:
            if ((object)p == null)
            {
                return false;
            }

            // Return true if the fields match:
            return (Key == p.Key) && (Modifiers == p.Modifiers);
        }
Esempio n. 7
0
        public bool Equals(LocalKeyInfo p)
        {
            // If parameter is null return false:
            if ((object)p == null)
            {
                return(false);
            }

            // Return true if the fields match:
            return((Key == p.Key) && (Modifiers == p.Modifiers));
        }
Esempio n. 8
0
        public bool execute(LocalKeyInfo keyInfo)
        {
            Tile tile = this.map.GetPlayerTile();
            StringBuilder s = new StringBuilder();

            if (tile.Mobile.HasEquipableItems)
            {
                s.Append("Equipable Items:").Append(Environment.NewLine);

                var equipableItems = tile.Mobile.Items.Where(it => it.IsEquipable());

                int i = 1;
                foreach (var item in equipableItems)
                {
                    item.ListTag = InventoryCommand.Letters[i];
                    s.Append("   ").Append(InventoryCommand.Letters[i]).Append(") ");
                    s.Append(item.Name).Append(Environment.NewLine);
                    i++;
                }

                s.Append(Environment.NewLine).Append("Press letter of item to equip: ");
                Status.Info = s.ToString();
                Console.Clear();
                Status.WriteToStatus();

                var itemKey = Console.ReadKey(true);

                var itemToWear = equipableItems.Where(e => e.ListTag.ToUpper() == itemKey.KeyChar.ToString().ToUpper()).First();

                tile.Mobile.WearItem(itemToWear);

                s.Append(Environment.NewLine).Append(Environment.NewLine).Append("You are now wearing => ").Append(itemToWear.Name);
            }
            else
            {
                s.Append("You have no equipable items.").Append(Environment.NewLine);
            }

            s.Append(Environment.NewLine).Append(Environment.NewLine).Append("Press any key to conintue");

            Status.Info = s.ToString();
            Console.Clear();
            Status.WriteToStatus();

            Console.ReadKey(true);

            Status.ClearInfo();
            Console.Clear();
            this.map.Outdated = true;

            return true;
        }
Esempio n. 9
0
        public bool execute(LocalKeyInfo keyInfo)
        {
            Tile          tile = this.map.GetPlayerTile();
            StringBuilder s    = new StringBuilder();

            if (tile.Mobile.HasEquipableItems)
            {
                s.Append("Equipable Items:").Append(Environment.NewLine);

                var equipableItems = tile.Mobile.Items.Where(it => it.IsEquipable());

                int i = 1;
                foreach (var item in equipableItems)
                {
                    item.ListTag = InventoryCommand.Letters[i];
                    s.Append("   ").Append(InventoryCommand.Letters[i]).Append(") ");
                    s.Append(item.Name).Append(Environment.NewLine);
                    i++;
                }

                s.Append(Environment.NewLine).Append("Press letter of item to equip: ");
                Status.Info = s.ToString();
                Console.Clear();
                Status.WriteToStatus();

                var itemKey = Console.ReadKey(true);

                var itemToWear = equipableItems.Where(e => e.ListTag.ToUpper() == itemKey.KeyChar.ToString().ToUpper()).First();

                tile.Mobile.WearItem(itemToWear);

                s.Append(Environment.NewLine).Append(Environment.NewLine).Append("You are now wearing => ").Append(itemToWear.Name);
            }
            else
            {
                s.Append("You have no equipable items.").Append(Environment.NewLine);
            }

            s.Append(Environment.NewLine).Append(Environment.NewLine).Append("Press any key to conintue");

            Status.Info = s.ToString();
            Console.Clear();
            Status.WriteToStatus();

            Console.ReadKey(true);

            Status.ClearInfo();
            Console.Clear();
            this.map.Outdated = true;

            return(true);
        }
Esempio n. 10
0
        private static bool HandleInput()
        {
            bool nonTurnAction = true;

            ConsoleKeyInfo keyInfo      = Console.ReadKey(true);
            var            localKeyInfo = new LocalKeyInfo(keyInfo);

            Status.ClearInfo();
            Status.WriteToStatusLine("");

            nonTurnAction = game.CommandActivated(localKeyInfo);

            return(nonTurnAction);
        }
Esempio n. 11
0
        private static bool HandleInput()
        {
            bool nonTurnAction = true;

            ConsoleKeyInfo keyInfo = Console.ReadKey(true);
            var localKeyInfo = new LocalKeyInfo(keyInfo);

            Status.ClearInfo();
            Status.WriteToStatusLine("");

            nonTurnAction = game.CommandActivated(localKeyInfo);

            return nonTurnAction;
        }
Esempio n. 12
0
        public bool execute(LocalKeyInfo keyInfo)
        {
            Tile tile           = this.map.GetPlayerTile();
            var  availableItems = AvailableItems.Instance;

            if (tile.HasItem())
            {
                Status.Info = availableItems.All[tile.TypeId].Description;
            }
            else
            {
                Status.Info = Map.availableTiles[tile.TypeId].Description;
            }

            return(true);
        }
Esempio n. 13
0
        public bool execute(LocalKeyInfo keyInfo)
        {
            Tile tile = this.map.GetPlayerTile();
            if (tile.HasItem())
            {
                tile.Mobile.Items.Add(tile.Item);
                Status.Info = "You take " + tile.Item.Name + ".";
                tile.Item = null;
            }
            else
            {
                Status.Info = "This is nothing to pick up here.";
            }

            return false;
        }
Esempio n. 14
0
        public bool execute(LocalKeyInfo keyInfo)
        {
            Tile tile = this.map.GetPlayerTile();
            var availableItems = AvailableItems.Instance;

            if (tile.HasItem())
            {
                Status.Info = availableItems.All[tile.TypeId].Description;
            }
            else
            {
                Status.Info = Map.availableTiles[tile.TypeId].Description;
            }

            return true;
        }
Esempio n. 15
0
        public bool execute(LocalKeyInfo keyInfo)
        {
            Tile tile = this.map.GetPlayerTile();

            if (tile.HasItem())
            {
                tile.Mobile.Items.Add(tile.Item);
                Status.Info = "You take " + tile.Item.Name + ".";
                tile.Item   = null;
            }
            else
            {
                Status.Info = "This is nothing to pick up here.";
            }

            return(false);
        }
Esempio n. 16
0
        public bool CommandActivated(LocalKeyInfo keyInfo)
        {
            bool nonTurnAction = true;

            try
            {
                nonTurnAction = commands[keyInfo].execute(keyInfo);
            }
            //TODO add logging...
            catch (Exception e)
            {
                Status.WriteToStatusLine(keyInfo.Key + " key is not bound to a command.  Press any key to continue");
                Console.ReadKey(true);
                Status.ClearInfo();
                Status.WriteToStatusLine(string.Empty);
            }

            return(nonTurnAction);
        }
Esempio n. 17
0
        public bool CommandActivated(LocalKeyInfo keyInfo)
        {
            bool nonTurnAction = true;

            try
            {
                nonTurnAction = commands[keyInfo].execute(keyInfo);
            }
                //TODO add logging...
            catch (Exception e)
            {
                Status.WriteToStatusLine(keyInfo.Key + " key is not bound to a command.  Press any key to continue");
                Console.ReadKey(true);
                Status.ClearInfo();
                Status.WriteToStatusLine(string.Empty);
            }

            return nonTurnAction;
        }
Esempio n. 18
0
        public override bool Equals(System.Object obj)
        {
            // If parameter is null return false.
            if (obj == null)
            {
                return(false);
            }

            // If parameter cannot be cast to Point return false.
            LocalKeyInfo p = obj as LocalKeyInfo;

            if ((System.Object)p == null)
            {
                return(false);
            }

            // Return true if the fields match:
            return((Key == p.Key) && (Modifiers == p.Modifiers));
        }
Esempio n. 19
0
        public bool execute(LocalKeyInfo keyInfo)
        {
            //TODO MWK Copied fromInventoryCommand. Just coded and testing.


            Tile          tile = this.map.GetPlayerTile();
            StringBuilder s    = new StringBuilder();

            var equipedItems = tile.Mobile.EquipedItemSet.EquipedItems.Where(ei => ei.Item != null).Select(ei => ei.Item);

            if (equipedItems.Count() > 0)
            {
                s.Append("Equiped items:").Append(Console.Out.NewLine);

                int i = 1;
                foreach (Item item in equipedItems)
                {
                    s.Append("   ").Append(InventoryCommand.Letters[i]).Append(") ");
                    s.Append(item.Name).Append(Console.Out.NewLine);
                    i++;
                }
            }
            else
            {
                s.Append("You have no equiped items").Append(Console.Out.NewLine);
            }

            s.Append(Console.Out.NewLine).Append("Press any key to continue.").Append(Console.Out.NewLine);

            Status.Info = s.ToString();

            Console.Clear();
            Status.WriteToStatus();

            Console.ReadKey(true);
            Status.ClearInfo();

            Console.Clear();

            this.map.Outdated = true;

            return(true);
        }
        public bool execute(LocalKeyInfo keyInfo)
        {
            //TODO MWK Copied fromInventoryCommand. Just coded and testing.

            Tile tile = this.map.GetPlayerTile();
            StringBuilder s = new StringBuilder();

            var equipedItems = tile.Mobile.EquipedItemSet.EquipedItems.Where(ei => ei.Item != null).Select(ei => ei.Item);
            if (equipedItems.Count() > 0)
            {
                s.Append("Equiped items:").Append(Console.Out.NewLine);

                int i = 1;
                foreach (Item item in equipedItems)
                {
                    s.Append("   ").Append(InventoryCommand.Letters[i]).Append(") ");
                    s.Append(item.Name).Append(Console.Out.NewLine);
                    i++;
                }
            }
            else
            {
                s.Append("You have no equiped items").Append(Console.Out.NewLine);
            }

            s.Append(Console.Out.NewLine).Append("Press any key to continue.").Append(Console.Out.NewLine);

            Status.Info = s.ToString();

            Console.Clear();
            Status.WriteToStatus();

            Console.ReadKey(true);
            Status.ClearInfo();

            Console.Clear();

            this.map.Outdated = true;

            return true;
        }
Esempio n. 21
0
        public bool execute(LocalKeyInfo keyInfo)
        {
            Tile tile = this.map.GetPlayerTile();
            StringBuilder s = new StringBuilder();

            if (tile.Mobile.Items.Count > 0)
            //if (tile.Mobile.HasEquipableItems)
            {
                s.Append("Player Inventory:").Append(Console.Out.NewLine);

                int i = 1;
                foreach (var item in tile.Mobile.Items)
                {
                    item.ListTag = Letters[i];
                    s.Append("   ").Append(Letters[i]).Append(") ");
                    s.Append(item.Name).Append(Console.Out.NewLine);
                    i++;
                }
            }
            else
            {
                s.Append("Your inventory is empty!!").Append(Console.Out.NewLine);
            }

            s.Append(Console.Out.NewLine).Append("Press any key to continue.").Append(Console.Out.NewLine);

            Status.Info = s.ToString();

            Console.Clear();
            Status.WriteToStatus();

            Console.ReadKey(true);
            Status.ClearInfo();

            Console.Clear();

            this.map.Outdated = true;

            return true;
        }
Esempio n. 22
0
        public bool execute(LocalKeyInfo keyInfo)
        {
            Tile          tile = this.map.GetPlayerTile();
            StringBuilder s    = new StringBuilder();

            if (tile.Mobile.Items.Count > 0)
            //if (tile.Mobile.HasEquipableItems)
            {
                s.Append("Player Inventory:").Append(Console.Out.NewLine);

                int i = 1;
                foreach (var item in tile.Mobile.Items)
                {
                    item.ListTag = Letters[i];
                    s.Append("   ").Append(Letters[i]).Append(") ");
                    s.Append(item.Name).Append(Console.Out.NewLine);
                    i++;
                }
            }
            else
            {
                s.Append("Your inventory is empty!!").Append(Console.Out.NewLine);
            }

            s.Append(Console.Out.NewLine).Append("Press any key to continue.").Append(Console.Out.NewLine);

            Status.Info = s.ToString();

            Console.Clear();
            Status.WriteToStatus();

            Console.ReadKey(true);
            Status.ClearInfo();

            Console.Clear();

            this.map.Outdated = true;

            return(true);
        }
Esempio n. 23
0
        public bool execute(LocalKeyInfo keyInfo)
        {
            Status.ClearInfo();
            Status.Info = "Which direction?";
            Status.WriteToStatus();

            ConsoleKeyInfo consoleKeyInfo = Console.ReadKey(true);
            var localKeyInfo = new LocalKeyInfo(consoleKeyInfo);

            //TODO -- Taking key input exists in more than one place now, REFACTOR

            var mapTile = map.GetPlayerTile();

            var mapLocation = new Location(mapTile.Location.Left, mapTile.Location.Top);

            var tileToUse = this.map.GetTileInDirection(localKeyInfo, mapLocation);

            if (tileToUse.TypeId == Constants.TypeIds.Door)
            {
                this.map.ToggleDoor(tileToUse, false);
            }
            else if (tileToUse.TypeId == Constants.TypeIds.OpenDoor)
            {
                this.map.ToggleDoor(tileToUse, true);
            }
            else
            {
                Status.Info = "That can't be opened or closed.  Press any key to continue.";
                Status.WriteToStatus();
                Console.ReadKey(true);
            }

            Status.ClearInfo();

            this.map.Outdated = true;

            return false;
        }
Esempio n. 24
0
        public bool execute(LocalKeyInfo keyInfo)
        {
            Status.ClearInfo();
            Status.Info = "Which direction?";
            Status.WriteToStatus();

            ConsoleKeyInfo consoleKeyInfo = Console.ReadKey(true);
            var            localKeyInfo   = new LocalKeyInfo(consoleKeyInfo);

            //TODO -- Taking key input exists in more than one place now, REFACTOR

            var mapTile = map.GetPlayerTile();

            var mapLocation = new Location(mapTile.Location.Left, mapTile.Location.Top);

            var tileToUse = this.map.GetTileInDirection(localKeyInfo, mapLocation);

            if (tileToUse.TypeId == Constants.TypeIds.Door)
            {
                this.map.ToggleDoor(tileToUse, false);
            }
            else if (tileToUse.TypeId == Constants.TypeIds.OpenDoor)
            {
                this.map.ToggleDoor(tileToUse, true);
            }
            else
            {
                Status.Info = "That can't be opened or closed.  Press any key to continue.";
                Status.WriteToStatus();
                Console.ReadKey(true);
            }

            Status.ClearInfo();

            this.map.Outdated = true;

            return(false);
        }
Esempio n. 25
0
        public bool execute(LocalKeyInfo keyInfo)
        {
            Status.ClearInfo();
            Status.Info = "Which direction?";
            Status.WriteToStatus();

            ConsoleKeyInfo consoleKeyInfo = Console.ReadKey(true);
            var localKeyInfo = new LocalKeyInfo(consoleKeyInfo);

            //TODO -- Taking key input exists in more than one place now, REFACTOR

            var mapTile = map.GetPlayerTile();
            var mapLocation = new Location(mapTile.Location.Left, mapTile.Location.Top);
            var tile = this.map.GetTileInDirection(localKeyInfo, mapLocation);

            if (tile.Mobile is INonPlayerCharacter)
            {
                tile.Mobile.HitPoints -= 5;
                var message = "You hit " + tile.Mobile.HitMessage + ".";
                if (tile.Mobile.IsDead())
                {
                    //TODO -- This logic should probably be moved.
                    //TODO -- The death message should be moved to the specific mobile (and then later to config)
                    message += "You killed it!!!";
                    tile.Mobile = null;
                    map.Outdated = true;
                }

                Status.Info = message;
            }
            else
            {
                Status.Info = "Not a valid target.";
            }

            return false;
        }
Esempio n. 26
0
        public bool execute(LocalKeyInfo keyInfo)
        {
            bool quit = true;

            Status.ClearInfo();
            Status.Info = "Really quit(Y or N)?";
            Status.WriteToStatus();

            var consoleKeyInfo = Console.ReadKey(true);

            if (consoleKeyInfo.Key == ConsoleKey.Y)
            {
                Status.Info = "Save(Y or N)?";
                Status.WriteToStatus();

                consoleKeyInfo = Console.ReadKey(true);

                if (consoleKeyInfo.Key == ConsoleKey.Y)
                {
                    Program.Save();
                }
            }
            else if (consoleKeyInfo.Key == ConsoleKey.N)
            {
                Status.ClearInfo();
                Status.Info = "Returning to game.";
                quit = false;
            }
            else
            {
                this.execute(keyInfo);
            }

            Program.Quit = quit;

            return true;
        }
Esempio n. 27
0
        public bool execute(LocalKeyInfo keyInfo)
        {
            bool quit = true;

            Status.ClearInfo();
            Status.Info = "Really quit(Y or N)?";
            Status.WriteToStatus();

            var consoleKeyInfo = Console.ReadKey(true);

            if (consoleKeyInfo.Key == ConsoleKey.Y)
            {
                Status.Info = "Save(Y or N)?";
                Status.WriteToStatus();

                consoleKeyInfo = Console.ReadKey(true);

                if (consoleKeyInfo.Key == ConsoleKey.Y)
                {
                    Program.Save();
                }
            }
            else if (consoleKeyInfo.Key == ConsoleKey.N)
            {
                Status.ClearInfo();
                Status.Info = "Returning to game.";
                quit        = false;
            }
            else
            {
                this.execute(keyInfo);
            }

            Program.Quit = quit;

            return(true);
        }
Esempio n. 28
0
        public bool execute(LocalKeyInfo keyInfo)
        {
            Status.ClearInfo();
            Status.Info = "Which direction?";
            Status.WriteToStatus();

            ConsoleKeyInfo consoleKeyInfo = Console.ReadKey(true);
            var            localKeyInfo   = new LocalKeyInfo(consoleKeyInfo);

            //TODO -- Taking key input exists in more than one place now, REFACTOR

            var mapTile     = map.GetPlayerTile();
            var mapLocation = new Location(mapTile.Location.Left, mapTile.Location.Top);
            var tile        = this.map.GetTileInDirection(localKeyInfo, mapLocation);

            if (tile.Mobile is INonPlayerCharacter)
            {
                tile.Mobile.HitPoints -= 5;
                var message = "You hit " + tile.Mobile.HitMessage + ".";
                if (tile.Mobile.IsDead())
                {
                    //TODO -- This logic should probably be moved.
                    //TODO -- The death message should be moved to the specific mobile (and then later to config)
                    message     += "You killed it!!!";
                    tile.Mobile  = null;
                    map.Outdated = true;
                }

                Status.Info = message;
            }
            else
            {
                Status.Info = "Not a valid target.";
            }

            return(false);
        }
Esempio n. 29
0
        private static void Load()
        {
            Status.ClearInfo();
            Status.Info = "Start a New game, or Load an existing (S/L)?";
            Status.WriteToStatus();

            ConsoleKeyInfo consoleKeyInfo = Console.ReadKey(true);
            var localKeyInfo = new LocalKeyInfo(consoleKeyInfo);

            XDocument doc;

            switch (localKeyInfo.Key)
            {
                case ConsoleKey.S:
                    doc = XDocument.Load(@".\new.sav");
                    break;

                case ConsoleKey.L:
                    doc = XDocument.Load(@".\game.sav");
                    break;

                default:
                    Program.Load();
                    return;
            }

            map.Load(doc.Descendants("Tiles"));
        }
Esempio n. 30
0
        public Tile GetTileInDirection(LocalKeyInfo keyInfo, Location mapLocation)
        {
            switch (keyInfo.Key)
            {
                case ConsoleKey.UpArrow:
                    mapLocation.Top--;
                    break;

                case ConsoleKey.DownArrow:
                    mapLocation.Top++;
                    break;

                case ConsoleKey.LeftArrow:
                    mapLocation.Left--;
                    break;

                case ConsoleKey.RightArrow:
                    mapLocation.Left++;
                    break;

                default:
                    break;
            }

            return this.GetTileForLocation(mapLocation);
        }
Esempio n. 31
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
        }
Esempio n. 32
0
        public Tile MoveMobile(LocalKeyInfo keyInfo, Tile mobileMapTile)
        {
            var mapLocation = new Location(mobileMapTile.Location.Left, mobileMapTile.Location.Top);

            var tileToMoveTo = this.GetTileInDirection(keyInfo, mapLocation);

            return this.MoveMobile(mobileMapTile, tileToMoveTo);
        }
Esempio n. 33
0
 public void SetCommand(LocalKeyInfo keyInfo, ICommand command)
 {
     commands.Add(keyInfo, command);
 }
Esempio n. 34
0
 public void SetCommand(LocalKeyInfo keyInfo, ICommand command)
 {
     commands.Add(keyInfo, command);
 }
Esempio n. 35
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
        }