Ejemplo n.º 1
0
    public static Controls.Control LoadControl(Controls.Type type, int plNum)
    {
        //Try to load a control
        int  keyInt    = PlayerPrefs.GetInt("MCon_KeyInt_" + plNum + "_" + type, -1);
        int  joyNum    = PlayerPrefs.GetInt("MCon_JoyNum_" + plNum + "_" + type, -1);
        int  axisNum   = PlayerPrefs.GetInt("MCon_AxisNum_" + plNum + "_" + type, -1);
        bool posAxis   = GetBool("MCon_AxisDir_" + plNum + "_" + type, true);
        int  playerNum = plNum;

        Controls.Control c;
        //Now, decide if that worked, or not?
        if (keyInt != -1)
        {
            //Loaded a saved key!
            c = Controls.SetKey(type, keyInt, joyNum, axisNum, posAxis, playerNum);
        }
        else if (joyNum != -1 && axisNum != -1)
        {
            //Loaded a saved axis!
            c = Controls.SetKey(type, keyInt, joyNum, axisNum, posAxis, playerNum);
        }
        else
        {
            //Failed to load a saved control!
            //Debug.Log("Failed to load " + type);
            //c = Controls.SetDefaultControl(type);
            c = null;
        }
        if (c != null)
        {
            c.label = Controls.GetLabelForControl(c);
        }
        return(c);
    }
Ejemplo n.º 2
0
    public static bool CustomTranslation(Controls.Type type, Recon.ControlState state, int playerNum)
    {
        switch (state)
        {
        case Recon.ControlState.Constant:
            switch (type)
            {
                //Platforming
                //case Controls.Type.Jump: return ReInput.players.GetPlayer(0).GetButton("Jump");
                //case Controls.Type.Ability1: return ReInput.players.GetPlayer(0).GetButton("Ability1");
                //case Controls.Type.MoveRight: return ReInput.players.GetPlayer(0).GetButton("Move Right");
                //case Controls.Type.MoveLeft: return ReInput.players.GetPlayer(0).GetButton("Move Left");
            }
            return(false);

        case Recon.ControlState.Down:
            switch (type)
            {
                //case Controls.Type.MenuSelect: return ReInput.players.GetPlayer(0).GetButtonDown("Menu Select");

                //Platforming
                //case Controls.Type.Jump: return ReInput.players.GetPlayer(0).GetButtonDown("Jump");
                //case Controls.Type.Ability1: return ReInput.players.GetPlayer(0).GetButtonDown("Ability1");
                //case Controls.Type.MoveDown: return ReInput.players.GetPlayer(0).GetButtonDown("Move Down");
                //case Controls.Type.MoveRight: return ReInput.players.GetPlayer(0).GetButtonDown("Move Right");
                //case Controls.Type.MoveLeft: return ReInput.players.GetPlayer(0).GetButtonDown("Move Left");
                //case Controls.Type.Respawn: return ReInput.players.GetPlayer(0).GetButtonDown("Respawn");
                //case Controls.Type.Restart: return ReInput.players.GetPlayer(0).GetButtonDown("Restart");

                //menu
                //case Controls.Type.MenuSelect: return ReInput.players.GetPlayer(0).GetButtonDown("Menu Select");
                //case Controls.Type.OpenMenu: return ReInput.players.GetPlayer(0).GetButtonDown("Menu Escape");
                //case Controls.Type.MenuUp: return ReInput.players.GetPlayer(0).GetButtonDown("Menu Up");
                //case Controls.Type.MenuDown: return ReInput.players.GetPlayer(0).GetButtonDown("Menu Down");
                //case Controls.Type.MenuRight: return ReInput.players.GetPlayer(0).GetButtonDown("Menu Right");
                //case Controls.Type.MenuLeft: return ReInput.players.GetPlayer(0).GetButtonDown("Menu Left");
            }
            return(false);

        case Recon.ControlState.Up:
            switch (type)
            {
                //Platforming
                //case Controls.Type.Jump: return ReInput.players.GetPlayer(0).GetButtonUp("Jump");
                //case Controls.Type.Ability1: return ReInput.players.GetPlayer(0).GetButtonUp("Ability1");
                //case Controls.Type.MoveRight: return ReInput.players.GetPlayer(0).GetButtonUp("Move Right");
                //case Controls.Type.MoveLeft: return ReInput.players.GetPlayer(0).GetButtonUp("Move Left");
            }
            return(false);
        }
        return(false);
    }
Ejemplo n.º 3
0
    public static bool Translation(Controls.Type type, ControlState state, int playerNum)
    {
        //Debug.Log(type + ", " + state + ", " + Time.time);
        //playerNum is ignored, as it's defunct
        switch (state)
        {
        case ControlState.Constant:
            switch (type)
            {
            //Platforming
            case Controls.Type.Jump: return(ReInput.players.GetPlayer(0).GetButton("Jump"));

            case Controls.Type.Ability1: return(ReInput.players.GetPlayer(0).GetButton("Ability1"));

            case Controls.Type.MoveRight: return(ReInput.players.GetPlayer(0).GetButton("Move Right"));

            case Controls.Type.MoveLeft: return(ReInput.players.GetPlayer(0).GetButton("Move Left"));

            case Controls.Type.MoveDown: return(ReInput.players.GetPlayer(0).GetButton("Move Down"));

            case Controls.Type.FPSForward: return(ReInput.players.GetPlayer(0).GetButton("FPS Forward"));

            case Controls.Type.FPSBackward: return(ReInput.players.GetPlayer(0).GetButton("FPS Backwards"));

            case Controls.Type.FPSRight: return(ReInput.players.GetPlayer(0).GetButton("FPS Right"));

            case Controls.Type.FPSLeft: return(ReInput.players.GetPlayer(0).GetButton("FPS Left"));

            //case Controls.Type.FPSForward: return GetAxis("FPS Forward", true);
            //case Controls.Type.FPSBackward: return GetAxis("FPS Forward", false);
            //case Controls.Type.FPSRight: return GetAxis("FPS Strafe", true);
            //case Controls.Type.FPSLeft: return GetAxis("FPS Strafe", false);
            case Controls.Type.FPSLookUp: return(GetAxis("FPS Look Vertical", true));

            case Controls.Type.FPSLookDown: return(GetAxis("FPS Look Vertical", false));

            case Controls.Type.FPSLookRight: return(GetAxis("FPS Look Horizontal", true));

            case Controls.Type.FPSLookLeft: return(GetAxis("FPS Look Horizontal", false));
            }
            return(false);

        case ControlState.Down:
            switch (type)
            {
            //Platforming
            case Controls.Type.Jump: return(ReInput.players.GetPlayer(0).GetButtonDown("Jump"));

            case Controls.Type.Ability1: return(ReInput.players.GetPlayer(0).GetButtonDown("Ability1"));

            case Controls.Type.MoveDown: return(ReInput.players.GetPlayer(0).GetButtonDown("Move Down"));

            case Controls.Type.MoveRight: return(ReInput.players.GetPlayer(0).GetButtonDown("Move Right"));

            case Controls.Type.MoveLeft: return(ReInput.players.GetPlayer(0).GetButtonDown("Move Left"));

            case Controls.Type.Respawn: return(ReInput.players.GetPlayer(0).GetButtonDown("Respawn"));

            case Controls.Type.Restart: return(ReInput.players.GetPlayer(0).GetButtonDown("Restart"));

            //menu
            case Controls.Type.MenuSelect: return(ReInput.players.GetPlayer(0).GetButtonDown("Menu Select"));

            case Controls.Type.OpenMenu: return(ReInput.players.GetPlayer(0).GetButtonDown("Menu Escape"));

            case Controls.Type.MenuUp: return(ReInput.players.GetPlayer(0).GetButtonDown("Menu Up"));

            case Controls.Type.MenuDown: return(ReInput.players.GetPlayer(0).GetButtonDown("Menu Down"));

            case Controls.Type.MenuRight: return(ReInput.players.GetPlayer(0).GetButtonDown("Menu Right"));

            case Controls.Type.MenuLeft: return(ReInput.players.GetPlayer(0).GetButtonDown("Menu Left"));

            //FPS
            case Controls.Type.FPSFire: return(ReInput.players.GetPlayer(0).GetButtonDown("FPS Fire"));

            case Controls.Type.FPSCycleWeapon: return(ReInput.players.GetPlayer(0).GetButtonDown("FPS Cycle"));
            }
            return(false);

        case ControlState.Up:
            switch (type)
            {
            //Platforming
            case Controls.Type.Jump: return(ReInput.players.GetPlayer(0).GetButtonUp("Jump"));

            case Controls.Type.Ability1: return(ReInput.players.GetPlayer(0).GetButtonUp("Ability1"));

            case Controls.Type.MoveRight: return(ReInput.players.GetPlayer(0).GetButtonUp("Move Right"));

            case Controls.Type.MoveLeft: return(ReInput.players.GetPlayer(0).GetButtonUp("Move Left"));
            }
            return(false);
        }


        return(false);
    }
Ejemplo n.º 4
0
    public static bool GetInput(Controls.Type type, int playerNum, InputType inputType)
    {
        int result = 0;

        //Handle controllers axis first.
        if (currentControllerMapping == ControllerMapping.Xbox360)
        {
            if (Controls.platform == Controls.Platforms.Windows)
            {
                switch (type)
                {
                //Platformer
                case Controls.Type.Jump: if (GetGenericInput(KeyCode.Joystick1Button0, inputType))
                    {
                        result++;
                    }
                    break;

                case Controls.Type.MoveLeft: if (GetMultiInput(new Int3(1, 1, 0), new Int3(1, 6, 0), inputType))
                    {
                        result++;
                    }
                    break;

                case Controls.Type.MoveRight: if (GetMultiInput(new Int3(1, 1, 1), new Int3(1, 6, 1), inputType))
                    {
                        result++;
                    }
                    break;

                case Controls.Type.MoveDown: if (GetGenericInput(KeyCode.Joystick1Button2, inputType))
                    {
                        result++;
                    }
                    break;

                case Controls.Type.Ability1: if (GetGenericInput(KeyCode.Joystick1Button1, inputType))
                    {
                        result++;
                    }
                    break;

                case Controls.Type.Respawn: if (GetGenericInput(KeyCode.Joystick1Button3, inputType))
                    {
                        result++;
                    }
                    break;

                case Controls.Type.Restart: if (GetGenericInput(KeyCode.Joystick1Button6, inputType))
                    {
                        result++;
                    }
                    break;

                //FPS
                case Controls.Type.FPSForward: if (GetMultiInput(new Int3(1, 2, 0), new Int3(1, 7, 1), inputType))
                    {
                        result++;
                    }
                    break;

                case Controls.Type.FPSBackward: if (GetMultiInput(new Int3(1, 2, 1), new Int3(1, 7, 0), inputType))
                    {
                        result++;
                    }
                    break;

                case Controls.Type.FPSLeft: if (GetMultiInput(new Int3(1, 1, 0), new Int3(1, 6, 0), inputType))
                    {
                        result++;
                    }
                    break;

                case Controls.Type.FPSRight: if (GetMultiInput(new Int3(1, 1, 1), new Int3(1, 6, 1), inputType))
                    {
                        result++;
                    }
                    break;

                case Controls.Type.FPSFire: if (GetMultiInput(KeyCode.Joystick1Button0, new Int3(1, 3, 0), inputType))
                    {
                        result++;
                    }
                    break;

                case Controls.Type.FPSCycleWeapon: if (GetGenericInput(KeyCode.Joystick1Button1, inputType))
                    {
                        result++;
                    }
                    break;

                case Controls.Type.FPSLookLeft: if (GetGenericInput(1, 4, false, inputType))
                    {
                        result++;
                    }
                    break;

                case Controls.Type.FPSLookRight: if (GetGenericInput(1, 4, true, inputType))
                    {
                        result++;
                    }
                    break;

                case Controls.Type.FPSLookUp: if (GetGenericInput(1, 5, false, inputType))
                    {
                        result++;
                    }
                    break;

                case Controls.Type.FPSLookDown: if (GetGenericInput(1, 5, true, inputType))
                    {
                        result++;
                    }
                    break;

                //Menu
                case Controls.Type.MenuLeft: if (GetMultiInput(new Int3(1, 1, 0), new Int3(1, 6, 0), inputType))
                    {
                        result++;
                    }
                    break;

                case Controls.Type.MenuRight: if (GetMultiInput(new Int3(1, 1, 1), new Int3(1, 6, 1), inputType))
                    {
                        result++;
                    }
                    break;

                case Controls.Type.MenuUp: if (GetMultiInput(new Int3(1, 2, 0), new Int3(1, 7, 1), inputType))
                    {
                        result++;
                    }
                    break;

                case Controls.Type.MenuDown: if (GetMultiInput(new Int3(1, 2, 1), new Int3(1, 7, 0), inputType))
                    {
                        result++;
                    }
                    break;

                case Controls.Type.MenuSelect: if (GetGenericInput(KeyCode.Joystick1Button0, inputType))
                    {
                        result++;
                    }
                    break;

                case Controls.Type.OpenMenu: if (GetGenericInput(KeyCode.Joystick1Button7, inputType))
                    {
                        result++;
                    }
                    break;
                }
            }
            if (Controls.platform == Controls.Platforms.OSX)
            {
                switch (type)
                {
                //Platformer
                case Controls.Type.Jump: if (GetGenericInput(KeyCode.Joystick1Button16, inputType))
                    {
                        result++;
                    }
                    break;

                case Controls.Type.MoveLeft: if (GetMultiInput(KeyCode.Joystick1Button7, new Int3(1, 1, 0), inputType))
                    {
                        result++;
                    }
                    break;

                case Controls.Type.MoveRight: if (GetMultiInput(KeyCode.Joystick1Button8, new Int3(1, 1, 1), inputType))
                    {
                        result++;
                    }
                    break;

                case Controls.Type.MoveDown: if (GetMultiInput(KeyCode.Joystick1Button6, KeyCode.Joystick1Button18, inputType))
                    {
                        result++;
                    }
                    break;

                case Controls.Type.Ability1: if (GetGenericInput(KeyCode.Joystick1Button17, inputType))
                    {
                        result++;
                    }
                    break;

                case Controls.Type.Respawn: if (GetGenericInput(KeyCode.Joystick1Button19, inputType))
                    {
                        result++;
                    }
                    break;

                case Controls.Type.Restart: if (GetGenericInput(KeyCode.Joystick1Button10, inputType))
                    {
                        result++;
                    }
                    break;

                //FPS
                case Controls.Type.FPSForward: if (GetMultiInput(new Int3(1, 2, 0), new Int3(1, 7, 1), inputType))
                    {
                        result++;
                    }
                    break;

                case Controls.Type.FPSBackward: if (GetMultiInput(new Int3(1, 2, 1), new Int3(1, 7, 0), inputType))
                    {
                        result++;
                    }
                    break;

                case Controls.Type.FPSLeft: if (GetMultiInput(new Int3(1, 1, 0), new Int3(1, 6, 0), inputType))
                    {
                        result++;
                    }
                    break;

                case Controls.Type.FPSRight: if (GetMultiInput(new Int3(1, 1, 1), new Int3(1, 6, 1), inputType))
                    {
                        result++;
                    }
                    break;

                case Controls.Type.FPSFire: if (GetGenericInput(KeyCode.Joystick1Button16, inputType))
                    {
                        result++;
                    }
                    break;

                case Controls.Type.FPSCycleWeapon: if (GetGenericInput(KeyCode.Joystick1Button17, inputType))
                    {
                        result++;
                    }
                    break;

                case Controls.Type.FPSLookLeft: if (GetGenericInput(1, 3, true, inputType))
                    {
                        result++;
                    }
                    break;

                case Controls.Type.FPSLookRight: if (GetGenericInput(1, 3, false, inputType))
                    {
                        result++;
                    }
                    break;

                case Controls.Type.FPSLookUp: if (GetGenericInput(1, 4, false, inputType))
                    {
                        result++;
                    }
                    break;

                case Controls.Type.FPSLookDown: if (GetGenericInput(1, 4, false, inputType))
                    {
                        result++;
                    }
                    break;

                //Menu
                case Controls.Type.MenuLeft: if (GetMultiInput(KeyCode.Joystick1Button7, new Int3(1, 1, 0), inputType))
                    {
                        result++;
                    }
                    break;

                case Controls.Type.MenuRight: if (GetMultiInput(KeyCode.Joystick1Button8, new Int3(1, 1, 1), inputType))
                    {
                        result++;
                    }
                    break;

                case Controls.Type.MenuUp: if (GetMultiInput(KeyCode.Joystick1Button5, new Int3(1, 2, 0), inputType))
                    {
                        result++;
                    }
                    break;

                case Controls.Type.MenuDown: if (GetMultiInput(KeyCode.Joystick1Button6, new Int3(1, 2, 1), inputType))
                    {
                        result++;
                    }
                    break;

                case Controls.Type.MenuSelect: if (GetGenericInput(KeyCode.Joystick1Button16, inputType))
                    {
                        result++;
                    }
                    break;

                case Controls.Type.OpenMenu: if (GetGenericInput(KeyCode.Joystick1Button9, inputType))
                    {
                        result++;
                    }
                    break;
                }
            }
            if (Controls.platform == Controls.Platforms.Linux)
            {
                switch (type)
                {
                //Platformer
                case Controls.Type.Jump: if (GetGenericInput(KeyCode.Joystick1Button0, inputType))
                    {
                        result++;
                    }
                    break;

                case Controls.Type.MoveLeft: if (GetMultiInput(new Int3(1, 1, 0), new Int3(1, 7, 0), inputType))
                    {
                        result++;
                    }
                    break;

                case Controls.Type.MoveRight: if (GetMultiInput(new Int3(1, 1, 1), new Int3(1, 7, 1), inputType))
                    {
                        result++;
                    }
                    break;

                case Controls.Type.MoveDown: if (GetGenericInput(KeyCode.Joystick1Button2, inputType))
                    {
                        result++;
                    }
                    break;

                case Controls.Type.Ability1: if (GetGenericInput(KeyCode.Joystick1Button1, inputType))
                    {
                        result++;
                    }
                    break;

                case Controls.Type.Respawn: if (GetGenericInput(KeyCode.Joystick1Button3, inputType))
                    {
                        result++;
                    }
                    break;

                case Controls.Type.Restart: if (GetGenericInput(KeyCode.Joystick1Button6, inputType))
                    {
                        result++;
                    }
                    break;

                //FPS
                case Controls.Type.FPSForward: if (GetMultiInput(new Int3(1, 2, 0), new Int3(1, 8, 1), inputType))
                    {
                        result++;
                    }
                    break;

                case Controls.Type.FPSBackward: if (GetMultiInput(new Int3(1, 2, 1), new Int3(1, 8, 0), inputType))
                    {
                        result++;
                    }
                    break;

                case Controls.Type.FPSLeft: if (GetMultiInput(new Int3(1, 1, 0), new Int3(1, 7, 0), inputType))
                    {
                        result++;
                    }
                    break;

                case Controls.Type.FPSRight: if (GetMultiInput(new Int3(1, 1, 1), new Int3(1, 7, 1), inputType))
                    {
                        result++;
                    }
                    break;

                case Controls.Type.FPSFire: if (GetGenericInput(KeyCode.Joystick1Button0, inputType))
                    {
                        result++;
                    }
                    break;

                case Controls.Type.FPSCycleWeapon: if (GetGenericInput(KeyCode.Joystick1Button1, inputType))
                    {
                        result++;
                    }
                    break;

                case Controls.Type.FPSLookLeft: if (GetGenericInput(1, 4, true, inputType))
                    {
                        result++;
                    }
                    break;

                case Controls.Type.FPSLookRight: if (GetGenericInput(1, 4, false, inputType))
                    {
                        result++;
                    }
                    break;

                case Controls.Type.FPSLookUp: if (GetGenericInput(1, 5, false, inputType))
                    {
                        result++;
                    }
                    break;

                case Controls.Type.FPSLookDown: if (GetGenericInput(1, 5, false, inputType))
                    {
                        result++;
                    }
                    break;

                //Menu
                case Controls.Type.MenuLeft: if (GetMultiInput(new Int3(1, 1, 0), new Int3(1, 7, 0), inputType))
                    {
                        result++;
                    }
                    break;

                case Controls.Type.MenuRight: if (GetMultiInput(new Int3(1, 1, 1), new Int3(1, 7, 1), inputType))
                    {
                        result++;
                    }
                    break;

                case Controls.Type.MenuUp: if (GetMultiInput(new Int3(1, 2, 0), new Int3(1, 8, 1), inputType))
                    {
                        result++;
                    }
                    break;

                case Controls.Type.MenuDown: if (GetMultiInput(new Int3(1, 2, 1), new Int3(1, 8, 0), inputType))
                    {
                        result++;
                    }
                    break;

                case Controls.Type.MenuSelect: if (GetGenericInput(KeyCode.Joystick1Button0, inputType))
                    {
                        result++;
                    }
                    break;

                case Controls.Type.OpenMenu: if (GetGenericInput(KeyCode.Joystick1Button7, inputType))
                    {
                        result++;
                    }
                    break;
                }
            }
        }

        //Keyboards/Mouse Buttons second
        switch (type)
        {
        //Platformer
        case Controls.Type.Jump: if (GetGenericInput(KeyCode.Z, inputType))
            {
                result++;
            }
            break;

        case Controls.Type.MoveLeft: if (GetGenericInput(KeyCode.LeftArrow, inputType))
            {
                result++;
            }
            break;

        case Controls.Type.MoveRight: if (GetGenericInput(KeyCode.RightArrow, inputType))
            {
                result++;
            }
            break;

        case Controls.Type.MoveDown: if (GetGenericInput(KeyCode.DownArrow, inputType))
            {
                result++;
            }
            break;

        case Controls.Type.Ability1: if (GetGenericInput(KeyCode.X, inputType))
            {
                result++;
            }
            break;

        case Controls.Type.Respawn: if (GetGenericInput(KeyCode.R, inputType))
            {
                result++;
            }
            break;

        case Controls.Type.Restart: if (GetGenericInput(KeyCode.Q, inputType))
            {
                result++;
            }
            break;

        //FPS
        case Controls.Type.FPSForward: if (GetGenericInput(KeyCode.W, inputType))
            {
                result++;
            }
            break;

        case Controls.Type.FPSBackward: if (GetGenericInput(KeyCode.S, inputType))
            {
                result++;
            }
            break;

        case Controls.Type.FPSLeft: if (GetGenericInput(KeyCode.A, inputType))
            {
                result++;
            }
            break;

        case Controls.Type.FPSRight: if (GetGenericInput(KeyCode.D, inputType))
            {
                result++;
            }
            break;

        case Controls.Type.FPSFire: if (GetMultiInput(KeyCode.Space, MouseButtons.LeftButton, inputType))
            {
                result++;
            }
            break;

        case Controls.Type.FPSCycleWeapon: if (GetGenericInput(KeyCode.E, inputType))
            {
                result++;
            }
            break;

        case Controls.Type.FPSLookLeft: if (GetGenericInput(KeyCode.LeftArrow, inputType))
            {
                result++;
            }
            break;

        case Controls.Type.FPSLookRight: if (GetGenericInput(KeyCode.RightArrow, inputType))
            {
                result++;
            }
            break;

        case Controls.Type.FPSLookUp: if (GetGenericInput(KeyCode.UpArrow, inputType))
            {
                result++;
            }
            break;

        case Controls.Type.FPSLookDown: if (GetGenericInput(KeyCode.DownArrow, inputType))
            {
                result++;
            }
            break;

        //Menu
        case Controls.Type.MenuLeft: if (GetMultiInput(KeyCode.A, KeyCode.LeftArrow, inputType))
            {
                result++;
            }
            break;

        case Controls.Type.MenuRight: if (GetMultiInput(KeyCode.D, KeyCode.RightArrow, inputType))
            {
                result++;
            }
            break;

        case Controls.Type.MenuUp: if (GetMultiInput(KeyCode.W, KeyCode.UpArrow, inputType))
            {
                result++;
            }
            break;

        case Controls.Type.MenuDown: if (GetMultiInput(KeyCode.S, KeyCode.DownArrow, inputType))
            {
                result++;
            }
            break;

        case Controls.Type.MenuSelect: if (GetMultiInput(KeyCode.Return, KeyCode.KeypadEnter, inputType))
            {
                result++;
            }
            break;

        case Controls.Type.OpenMenu: if (GetGenericInput(KeyCode.Escape, inputType))
            {
                result++;
            }
            break;
        }

        if (result > 0)
        {
            return(true);
        }
        else
        {
            return(false);
        }
    }