Game-Design / Sprint3_actual / KeysAndCommands.cs
KeysAndCommands.cs
Raw
using System;
using System.Collections.Generic;
using System.Text;
using Microsoft.Xna.Framework.Input;
using Sprint3_actual.Commands;

namespace Sprint3_actual
{
    static class KeysAndCommands
    {

        public static HashSet<Keys> getKeySet(String type)
        {
            HashSet<Keys> keySet = new HashSet<Keys>();

            switch (type)
            {
                case "Movement":

                    keySet.Add(Keys.W);
                    keySet.Add(Keys.A);
                    keySet.Add(Keys.S);
                    keySet.Add(Keys.D);
                    keySet.Add(Keys.Up);
                    keySet.Add(Keys.Left);
                    keySet.Add(Keys.Down);
                    keySet.Add(Keys.Right);
                    break;

                case "Action":

                    keySet.Add(Keys.N);
                    keySet.Add(Keys.Z);
                    keySet.Add(Keys.E);
                    keySet.Add(Keys.D1);
                    keySet.Add(Keys.D2);
                    keySet.Add(Keys.D3);
                    keySet.Add(Keys.D4);
                    keySet.Add(Keys.D5);
                    keySet.Add(Keys.D6);
                    break;

                case "Control":

                    keySet.Add(Keys.Q);
                    keySet.Add(Keys.I);
                    keySet.Add(Keys.Escape);
                    keySet.Add(Keys.OemComma);
                    break;

                default:
                    break;

            }
                    return keySet;
        }

        public static Dictionary<Keys, ICommand> LoadCommands(Game1 Game1)
        {
            Dictionary<Keys, ICommand> controllerMappings = new Dictionary<Keys, ICommand>();
            controllerMappings.Add(Keys.Q, new QuitCommand(Game1));
            controllerMappings.Add(Keys.I, new EnterInventoryCommand());
            controllerMappings.Add(Keys.Escape, new LeaveInventoryCommand());
            controllerMappings.Add(Keys.OemComma, new MuteCommand(Game1));

            controllerMappings.Add(Keys.W, new LinkMoveUpCommand(Game1));
            controllerMappings.Add(Keys.A, new LinkMoveLeftCommand(Game1));
            controllerMappings.Add(Keys.S, new LinkMoveDownCommand(Game1));
            controllerMappings.Add(Keys.D, new LinkMoveRightCommand(Game1));
            controllerMappings.Add(Keys.Up, new InventoryMoveUpCommand(Game1));
            controllerMappings.Add(Keys.Left, new InventoryMoveLeftCommand(Game1));
            controllerMappings.Add(Keys.Down, new InventoryMoveDownCommand(Game1));
            controllerMappings.Add(Keys.Right, new InventoryMoveRightCommand(Game1));

            controllerMappings.Add(Keys.N, new LinkAttackCommand(Game1));
            controllerMappings.Add(Keys.Z, new LinkItemUseCommand(Game1));
            controllerMappings.Add(Keys.E, new DamagedLinkCommand(Game1));

            return controllerMappings;
        }

        public static ICommand getIdleCommand(Game1 Game1)
        {
            return new LinkMoveIdleCommand(Game1);
        }
    }
}