Exemplo n.º 1
0
    public static float GetInputValue(eInput input, int index = -1)
    {
        if (index >= ControlSetCount || index < -1)
        {
            Logger.LogError($"GetInputValue called with index({index}) out of range");
        }

        float value = 0;
        int   count = 0;

        for (int loop = 0; loop < ControlSetCount; loop++)
        {
            if (ControlSets[loop].GetInputActive(input) && (index == -1 || index == loop))
            {
                value += ControlSets[loop].GetInputValue(input);
                count += 1;
            }
        }

        if (count == 0)
        {
            return(value);
        }

        return(value / count);
    }
Exemplo n.º 2
0
 public bool GetInputActive(eInput input)
 {
     if (!Theatre.CanPlayersMove())
     {
         return(false);
     }
     return(SimpleInput.GetInputActive(input, index: ControlType));
 }
Exemplo n.º 3
0
 public float GetInputValue(eInput input)
 {
     if (!Theatre.CanPlayersMove())
     {
         return(0f);
     }
     return(SimpleInput.GetInputValue(input, index: ControlType));
 }
Exemplo n.º 4
0
 public bool IsInputInState(eInput input, eButtonState state)
 {
     if (!Theatre.CanPlayersMove())
     {
         return(false);
     }
     return(SimpleInput.IsInputInState(input, state, index: ControlType));
 }
Exemplo n.º 5
0
        public bool IsKeyReleased(eInput key)
        {
            if (keys[(int)key])
            {
                UpdateKey(key);
                if (!keys[(int)key])
                {
                    return(true);
                }
            }

            UpdateKey(key);
            return(false);
        }
Exemplo n.º 6
0
    public static bool IsInputInState(eInput input, eButtonState state, int index = -1)
    {
        if (index >= ControlSetCount || index < -1)
        {
            Logger.LogError($"IsInputInState called with index({index}) out of range");
        }

        for (int loop = 0; loop < ControlSetCount; loop++)
        {
            if (ControlSets[loop].GetInputState(input) == state && (index == -1 || index == loop))
            {
                return(true);
            }
        }
        return(false);
    }
Exemplo n.º 7
0
    public static bool GetInputActive(eInput input, int index = -1)
    {
        if (index >= ControlSetCount || index < -1)
        {
            Logger.LogError($"GetInputActive called with index({index}) out of range");
            return(false);
        }

        for (int loop = 0; loop < ControlSetCount; loop++)
        {
            if (ControlSets[loop].GetInputActive(input) && (index == -1 || index == loop))
            {
                return(true);
            }
        }
        return(false);
    }
Exemplo n.º 8
0
        private void UpdateKey(eInput key)
        {
            if (key == eInput.UP)
            {
#if PSM
                if (GamePad.GetState(0).DPad.Up == ButtonState.Pressed)
#else
                if (Keyboard.GetState().IsKeyDown(Keys.W))
#endif
                { keys[(int)key] = true; }
                else
                {
                    keys[(int)key] = false;
                }

                return;
            }

            if (key == eInput.LEFT)
            {
#if PSM
                if (GamePad.GetState(0).DPad.Left == ButtonState.Pressed)
#else
                if (Keyboard.GetState().IsKeyDown(Keys.A))
#endif
                { keys[(int)key] = true; }
                else
                {
                    keys[(int)key] = false;
                }

                return;
            }


            if (key == eInput.DOWN)
            {
#if PSM
                if (GamePad.GetState(0).DPad.Down == ButtonState.Pressed)
#else
                if (Keyboard.GetState().IsKeyDown(Keys.S))
#endif
                { keys[(int)key] = true; }
                else
                {
                    keys[(int)key] = false;
                }

                return;
            }


            if (key == eInput.RIGHT)
            {
#if PSM
                if (GamePad.GetState(0).DPad.Right == ButtonState.Pressed)
#else
                if (Keyboard.GetState().IsKeyDown(Keys.D))
#endif
                { keys[(int)key] = true; }
                else
                {
                    keys[(int)key] = false;
                }

                return;
            }


            if (key == eInput.PRIMARY)
            {
#if PSM
                if (GamePad.GetState(0).Buttons.A == ButtonState.Pressed)
#else
                if (Keyboard.GetState().IsKeyDown(Keys.Space))
#endif
                { keys[(int)key] = true; }
                else
                {
                    keys[(int)key] = false;
                }

                return;
            }

            if (key == eInput.SECONDARY)
            {
                if (Keyboard.GetState().IsKeyDown(Keys.X))
                {
                    keys[(int)key] = true;
                }
                else
                {
                    keys[(int)key] = false;
                }

                return;
            }
        }
Exemplo n.º 9
0
 public bool IsKeyDown(eInput key)
 {
     UpdateKey(key);
     return(keys[(int)key]);
 }
Exemplo n.º 10
0
 public float GetInputValue(eInput input)
 {
     return(Buttons[input].Value);
 }
Exemplo n.º 11
0
 public bool GetInputActive(eInput input)
 {
     return(Buttons[input].Active);
 }
Exemplo n.º 12
0
 public float GetTimeInState(eInput input)
 {
     return(Buttons[input].TimeInState);
 }
Exemplo n.º 13
0
 public eButtonState GetInputState(eInput input)
 {
     return(Buttons[input].State);
 }