示例#1
0
 /// <summary>
 /// makes a new keyboard button input item
 /// </summary>
 /// <param name="key">the key to check for</param>
 /// <param name="game">a reference to the game</param>
 public KeyboardButtonInputItem(Keys key, SSCGame game)
 {
     Key = key;
     game.Events.On("update", () =>
     {
         KeyboardState = Keyboard.GetState();
     });
 }
示例#2
0
 /// <summary>
 /// makes a new gamepad button input item
 /// </summary>
 /// <param name="button">the button to check for</param>
 /// <param name="player">which gamepad</param>
 /// <param name="game">a reference to the game</param>
 public GamepadButtonInputItem(Buttons button, PlayerIndex player, SSCGame game)
 {
     Button       = button;
     Player       = player;
     GamepadState = null;
     game.Events.On("update", () =>
     {
         GamepadState = GamePad.GetState(Player);
     });
 }
示例#3
0
 /// <summary>
 /// creates a new right side of the keyboard input module
 /// </summary>
 /// <param name="game">a reference to the game</param>
 public RightKeyboardInputModule(SSCGame game) : base(game)
 {
     Name = "Right Keyboard";
     InputItems.Add("jump", new KeyboardButtonInputItem(Keys.Multiply, game));
     InputItems.Add("up", new KeyboardButtonInputItem(Keys.Up, game));
     InputItems.Add("down", new KeyboardButtonInputItem(Keys.Down, game));
     InputItems.Add("left", new KeyboardButtonInputItem(Keys.Left, game));
     InputItems.Add("right", new KeyboardButtonInputItem(Keys.Right, game));
     InputItems.Add("dash", new KeyboardButtonInputItem(Keys.Add, game));
     InputItems.Add("special", new KeyboardButtonInputItem(Keys.Subtract, game));
 }
 /// <summary>
 /// creates a new left side of the keyboard input module
 /// </summary>
 /// <param name="game">a reference to the game</param>
 public LeftKeyboardInputModule(SSCGame game) : base(game)
 {
     Name = "Left Keyboard";
     InputItems.Add("jump", new KeyboardButtonInputItem(Keys.Space, game));
     InputItems.Add("up", new KeyboardButtonInputItem(Keys.W, game));
     InputItems.Add("down", new KeyboardButtonInputItem(Keys.S, game));
     InputItems.Add("left", new KeyboardButtonInputItem(Keys.A, game));
     InputItems.Add("right", new KeyboardButtonInputItem(Keys.D, game));
     InputItems.Add("dash", new KeyboardButtonInputItem(Keys.H, game));
     InputItems.Add("special", new KeyboardButtonInputItem(Keys.J, game));
 }
示例#5
0
 /// <summary>
 /// creates a new lua-based input module
 /// </summary>
 /// <param name="game">a reference to the game</param>
 /// <param name="filename">the lua file's name to load the lua input module from</param>
 public LuaInputModule(SSCGame game, string filename)
 {
     luaInputModuleNum = highestLuaInputModuleNumber++;
     Name  = "Lua-" + Convert.ToString(luaInputModuleNum);
     State = new Lua();
     State.LoadCLRPackage();
     State.DoFile(filename);
     State.GetFunction("OnCreation")?.Call(this, game);
     OnUpdate = State.GetFunction("OnUpdate");
     game.Events.On("update", () =>
     {
         OnUpdate?.Call();
     });
     DoGet = State.GetFunction("Get");
 }
示例#6
0
        /// <summary>
        /// loads the lua ui element from a lua file
        /// </summary>
        /// <param name="filename">the name of the lua file</param>
        /// <param name="game">the game</param>
        /// <returns>the created lua ui element</returns>
        public static LuaUIElement LoadFromFile(string filename, SSCGame game)
        {
            LuaUIElement elem = new LuaUIElement();

            elem.State.LoadCLRPackage();
            elem.State.DoFile(filename);
            elem.State.GetFunction("OnCreation")?.Call(elem, game);
            elem.OnUpdate = elem.State.GetFunction("OnUpdate");
            game.Events.On("update", () =>
            {
                elem.OnUpdate?.Call();
            });
            elem.OnDraw = elem.State.GetFunction("OnDraw");
            //don't event listen for draw here since it requires a spritebatch and my eventemitter isnt that sophisticated
            return(elem);
        }
        /// <summary>
        /// creates a new xbox one controller input module
        /// </summary>
        /// <param name="game">a reference to the game</param>
        /// <param name="player">the player index</param>
        public GamepadInputModule(SSCGame game, PlayerIndex player)
        {
            this.game = game;
            Player    = player;
            Name      = "Gamepad Player " + Convert.ToString((int)Player + 1);
            double deadzone = 0.5;

            InputItems.Add("jump", new GamepadButtonInputItem(Buttons.X, Player, game));
            MultiInputItem up = new MultiInputItem();

            up.InputItems.Add(new GamepadButtonInputItem(Buttons.DPadUp, Player, game));
            GamepadStickInputItem stick = new GamepadStickInputItem(GamepadStick.LeftY, Player, -deadzone, game);

            stick.Invert = true;
            up.InputItems.Add(stick);
            InputItems.Add("up", up);
            MultiInputItem down = new MultiInputItem();

            down.InputItems.Add(new GamepadButtonInputItem(Buttons.DPadDown, Player, game));
            stick        = new GamepadStickInputItem(GamepadStick.LeftY, Player, deadzone, game);
            stick.Invert = true;
            down.InputItems.Add(stick);
            InputItems.Add("down", down);
            MultiInputItem left = new MultiInputItem();

            left.InputItems.Add(new GamepadButtonInputItem(Buttons.DPadLeft, Player, game));
            left.InputItems.Add(new GamepadStickInputItem(GamepadStick.LeftX, Player, -deadzone, game));
            InputItems.Add("left", left);
            MultiInputItem right = new MultiInputItem();

            right.InputItems.Add(new GamepadButtonInputItem(Buttons.DPadRight, Player, game));
            right.InputItems.Add(new GamepadStickInputItem(GamepadStick.LeftX, Player, deadzone, game));
            InputItems.Add("right", right);
            InputItems.Add("dash", new GamepadButtonInputItem(Buttons.A, Player, game));
            InputItems.Add("special", new GamepadButtonInputItem(Buttons.B, Player, game));
        }
 /// <summary>
 /// creates a new keyboard input module
 /// </summary>
 /// <param name="game">a reference to the game</param>
 public KeyboardInputModule(SSCGame game)
 {
     Name      = "Keyboard";
     this.game = game;
 }
 /// <summary>
 /// makes a new gamepad stick input item
 /// </summary>
 /// <param name="button">the stick to check for</param>
 /// <param name="player">which gamepad</param>
 /// <param name="game">a reference to the game</param>
 public GamepadStickInputItem(GamepadStick stick, PlayerIndex player, double deadzone, SSCGame game)
 {
     Stick        = stick;
     Player       = player;
     Deadzone     = deadzone;
     GamepadState = null;
     game.Events.On("update", () =>
     {
         GamepadState = GamePad.GetState(Player);
     });
 }