コード例 #1
0
    public string GetInputName(enmActionController actionController)
    {
        KeyCode inputKeyboard = KeyCode.A;
        string  inputName     = "";
        Sprite  inputSprite   = null;

        getInputInfos(actionController, out inputKeyboard, out inputName, out inputSprite);

        return(inputName);
    }
コード例 #2
0
    public Sprite GetInputSprite(enmActionController actionController)
    {
        KeyCode keycode   = KeyCode.A;
        string  nameInput = "";
        Sprite  image     = null;

        getInputInfos(actionController, out keycode, out nameInput, out image);

        return(image);
    }
コード例 #3
0
    /// <summary>
    /// Permet d'obtenir le nom de l'input en fonction de l'action demandé ainsi que du controlleur qui est utilisé.
    /// </summary>
    private void getInputInfos(enmActionController actionController, out KeyCode keyInput, out string nameInput, out Sprite imageInput)
    {
        keyInput   = KeyCode.Ampersand; // Je voulais juste qqc de random puisque ça ne peut pas être null...
        nameInput  = "";
        imageInput = null;

        switch (actionController)
        {
        case enmActionController.InGame_Accept:
        {
            if (_isUsePS4Controller)
            {
                nameInput  = "PS4_X";
                imageInput = PS4ControllerButtons[(int)enmPS4Buttons.PS4_X];
            }
            else if (_isUseXBox360Controller)
            {
                nameInput  = "XBox_A";
                imageInput = XBoxControllerButtons[(int)enmXBoxButtons.XBox_A];
            }
            else if (_isUseOnlyKeyboard)
            {
                nameInput  = "";
                keyInput   = KeyCode.Return;
                imageInput = KeyBoardButtons[(int)enmKeyboardButtons.Key_Enter];
            }
        }
        break;

        case enmActionController.InGame_Cancel:
        {
            if (_isUsePS4Controller)
            {
                nameInput  = "PS4_O";
                imageInput = PS4ControllerButtons[(int)enmPS4Buttons.PS4_O];
            }
            else if (_isUseXBox360Controller)
            {
                nameInput  = "XBox_B";
                imageInput = XBoxControllerButtons[(int)enmXBoxButtons.XBox_B];
            }
            else if (_isUseOnlyKeyboard)
            {
                nameInput  = "";
                keyInput   = KeyCode.Escape;
                imageInput = KeyBoardButtons[(int)enmKeyboardButtons.Key_Escape];
            }
        }
        break;

        case enmActionController.InGame_Action:
        {
            if (_isUsePS4Controller)
            {
                nameInput  = "PS4_X";
                imageInput = PS4ControllerButtons[(int)enmPS4Buttons.PS4_X];
            }
            else if (_isUseXBox360Controller)
            {
                nameInput  = "XBox_A";
                imageInput = XBoxControllerButtons[(int)enmXBoxButtons.XBox_A];
            }
            else if (_isUseOnlyKeyboard)
            {
                nameInput  = "";
                keyInput   = KeyCode.Return;
                imageInput = KeyBoardButtons[(int)enmKeyboardButtons.Key_Enter];          // À voir
            }
        }
        break;

        case enmActionController.InGame_Sword:
        {
            if (_isUsePS4Controller)
            {
                nameInput  = "PS4_Square";
                imageInput = PS4ControllerButtons[(int)enmPS4Buttons.PS4_Square];
            }
            else if (_isUseXBox360Controller)
            {
                nameInput  = "XBox_X";
                imageInput = XBoxControllerButtons[(int)enmXBoxButtons.XBox_X];
            }
            else if (_isUseOnlyKeyboard)
            {
                nameInput  = "";
                keyInput   = KeyCode.LeftShift;
                imageInput = KeyBoardButtons[(int)enmKeyboardButtons.Key_Shift];          // À voir
            }
        }
        break;

        case enmActionController.InGame_Item:
        {
            if (_isUsePS4Controller)
            {
                nameInput  = "PS4_O";
                imageInput = PS4ControllerButtons[(int)enmPS4Buttons.PS4_O];
            }
            else if (_isUseXBox360Controller)
            {
                nameInput  = "XBox_B";
                imageInput = XBoxControllerButtons[(int)enmXBoxButtons.XBox_B];
            }
            else if (_isUseOnlyKeyboard)
            {
                nameInput  = "";
                keyInput   = KeyCode.LeftControl;
                imageInput = KeyBoardButtons[(int)enmKeyboardButtons.Key_Ctrl];          // À voir
            }
        }
        break;

        case enmActionController.InGame_SwitchItem:
        {
            if (_isUsePS4Controller)
            {
                nameInput  = "";
                imageInput = PS4ControllerButtons[(int)enmPS4Buttons.PS4_DPad];
            }
            else if (_isUseXBox360Controller)
            {
                nameInput  = "";
                imageInput = XBoxControllerButtons[(int)enmXBoxButtons.XBox_DPad];
            }
            else if (_isUseOnlyKeyboard)
            {
                nameInput  = "";
                keyInput   = KeyCode.Plus;
                imageInput = KeyBoardButtons[(int)enmKeyboardButtons.Key_Plus];          // À voir
            }
        }
        break;

        case enmActionController.Menu_ChangeToTabLeft:
        {
            if (_isUsePS4Controller)
            {
                nameInput  = "PS4_L1";
                imageInput = PS4ControllerButtons[(int)enmPS4Buttons.PS4_L1];
            }
            else if (_isUseXBox360Controller)
            {
                nameInput  = "XBox_LB";
                imageInput = XBoxControllerButtons[(int)enmXBoxButtons.XBox_LB];
            }
            else if (_isUseOnlyKeyboard)
            {
                nameInput  = "";
                keyInput   = KeyCode.Alpha0;
                imageInput = KeyBoardButtons[(int)enmKeyboardButtons.Key_0];          // À voir
            }
        }
        break;

        case enmActionController.Menu_ChangeToTabRight:
        {
            if (_isUsePS4Controller)
            {
                nameInput  = "PS4_R1";
                imageInput = PS4ControllerButtons[(int)enmPS4Buttons.PS4_R1];
            }
            else if (_isUseXBox360Controller)
            {
                nameInput  = "XBox_RB";
                imageInput = XBoxControllerButtons[(int)enmXBoxButtons.XBox_RB];
            }
            else if (_isUseOnlyKeyboard)
            {
                nameInput  = "";
                keyInput   = KeyCode.Alpha0;
                imageInput = KeyBoardButtons[(int)enmKeyboardButtons.Key_0];          // À voir
            }
        }
        break;

        case enmActionController.Menu_Apply:
        {
            if (_isUsePS4Controller)
            {
                nameInput  = "PS4_X";
                imageInput = PS4ControllerButtons[(int)enmPS4Buttons.PS4_X];
            }
            else if (_isUseXBox360Controller)
            {
                nameInput  = "XBox_A";
                imageInput = XBoxControllerButtons[(int)enmXBoxButtons.XBox_A];
            }
            else if (_isUseOnlyKeyboard)
            {
                nameInput  = "";
                keyInput   = KeyCode.Alpha0;
                imageInput = KeyBoardButtons[(int)enmKeyboardButtons.Key_0];          // À voir
            }
        }
        break;

        case enmActionController.Menu_Save:
        {
            if (_isUsePS4Controller)
            {
                nameInput  = "PS4_Triangle";
                imageInput = PS4ControllerButtons[(int)enmPS4Buttons.PS4_Triangle];
            }
            else if (_isUseXBox360Controller)
            {
                nameInput  = "XBox_Y";
                imageInput = XBoxControllerButtons[(int)enmXBoxButtons.XBox_Y];
            }
            else if (_isUseOnlyKeyboard)
            {
                nameInput  = "";
                keyInput   = KeyCode.Alpha0;
                imageInput = KeyBoardButtons[(int)enmKeyboardButtons.Key_0];          // À voir
            }
        }
        break;

        case enmActionController.Menu_Close:
        {
            if (_isUsePS4Controller)
            {
                nameInput  = "PS4_O";
                imageInput = PS4ControllerButtons[(int)enmPS4Buttons.PS4_O];
            }
            else if (_isUseXBox360Controller)
            {
                nameInput  = "XBox_B";
                imageInput = XBoxControllerButtons[(int)enmXBoxButtons.XBox_B];
            }
            else if (_isUseOnlyKeyboard)
            {
                nameInput  = "";
                keyInput   = KeyCode.Alpha0;
                imageInput = KeyBoardButtons[(int)enmKeyboardButtons.Key_0];          // À voir
            }
        }
        break;

        case enmActionController.Menu_Move:
        {
            if (_isUsePS4Controller)
            {
                nameInput  = "";
                imageInput = PS4ControllerButtons[(int)enmPS4Buttons.PS4_DPad];
            }
            else if (_isUseXBox360Controller)
            {
                nameInput  = "";
                imageInput = XBoxControllerButtons[(int)enmXBoxButtons.XBox_DPad];
            }
            else if (_isUseOnlyKeyboard)
            {
                nameInput  = "";
                keyInput   = KeyCode.Alpha0;
                imageInput = KeyBoardButtons[(int)enmKeyboardButtons.Key_0];          // À voir
            }
        }
        break;

        case enmActionController.Menu_DefineCurrentItem:
        {
            if (_isUsePS4Controller)
            {
                nameInput  = "PS4_Square";
                imageInput = PS4ControllerButtons[(int)enmPS4Buttons.PS4_Square];
            }
            else if (_isUseXBox360Controller)
            {
                nameInput  = "XBox_X";
                imageInput = XBoxControllerButtons[(int)enmXBoxButtons.XBox_X];
            }
            else if (_isUseOnlyKeyboard)
            {
                nameInput  = "";
                keyInput   = KeyCode.Alpha0;
                imageInput = KeyBoardButtons[(int)enmKeyboardButtons.Key_0];          // À voir
            }
        }
        break;

        case enmActionController.Menu_ZoomIn:
        {
            if (_isUsePS4Controller)
            {
                nameInput  = "PS4_R2";
                imageInput = PS4ControllerButtons[(int)enmPS4Buttons.PS4_R2];
            }
            else if (_isUseXBox360Controller)
            {
                nameInput  = "XBox_RT";
                imageInput = XBoxControllerButtons[(int)enmXBoxButtons.XBox_RT];
            }
            else if (_isUseOnlyKeyboard)
            {
                nameInput  = "";
                keyInput   = KeyCode.Alpha0;
                imageInput = KeyBoardButtons[(int)enmKeyboardButtons.Key_0];          // À voir
            }
        }
        break;

        case enmActionController.Menu_ZoomOut:
        {
            if (_isUsePS4Controller)
            {
                nameInput  = "PS4_L2";
                imageInput = PS4ControllerButtons[(int)enmPS4Buttons.PS4_L2];
            }
            else if (_isUseXBox360Controller)
            {
                nameInput  = "XBox_LT";
                imageInput = XBoxControllerButtons[(int)enmXBoxButtons.XBox_LT];
            }
            else if (_isUseOnlyKeyboard)
            {
                nameInput  = "";
                keyInput   = KeyCode.Alpha0;
                imageInput = KeyBoardButtons[(int)enmKeyboardButtons.Key_0];          // À voir
            }
        }
        break;

        case enmActionController.Menu_NavigateMap:
        {
            if (_isUsePS4Controller)
            {
                nameInput  = "";
                imageInput = PS4ControllerButtons[(int)enmPS4Buttons.PS4_LeftJoystick];
            }
            else if (_isUseXBox360Controller)
            {
                nameInput  = "";
                imageInput = XBoxControllerButtons[(int)enmXBoxButtons.XBox_LeftJoystick];
            }
            else if (_isUseOnlyKeyboard)
            {
                nameInput  = "";
                keyInput   = KeyCode.Alpha0;
                imageInput = KeyBoardButtons[(int)enmKeyboardButtons.Key_0];          // À voir
            }
        }
        break;

        case enmActionController.Menu_Open:
        {
            if (_isUsePS4Controller)
            {
                nameInput  = "PS4_Options";
                imageInput = PS4ControllerButtons[(int)enmPS4Buttons.PS4_LeftJoystick];
            }
            else if (_isUseXBox360Controller)
            {
                nameInput  = "XBox_Start";
                imageInput = XBoxControllerButtons[(int)enmXBoxButtons.XBox_LeftJoystick];
            }
            else if (_isUseOnlyKeyboard)
            {
                nameInput  = "";
                keyInput   = KeyCode.Alpha0;
                imageInput = KeyBoardButtons[(int)enmKeyboardButtons.Key_0];          // À voir
            }
        } break;

        case enmActionController.DPad_Horizontal:
        {
            if (_isUsePS4Controller)
            {
                nameInput  = "PS4_DPadHorizontal";
                imageInput = PS4ControllerButtons[(int)enmPS4Buttons.PS4_LeftJoystick];
            }
            else if (_isUseXBox360Controller)
            {
                nameInput  = "XBox_DPadHorizontal";
                imageInput = XBoxControllerButtons[(int)enmXBoxButtons.XBox_LeftJoystick];
            }
            else if (_isUseOnlyKeyboard)
            {
                nameInput  = "";
                keyInput   = KeyCode.Alpha0;
                imageInput = KeyBoardButtons[(int)enmKeyboardButtons.Key_0];          // À voir
            }
        } break;

        case enmActionController.DPad_Vertical:
        {
            if (_isUsePS4Controller)
            {
                nameInput  = "PS4_DPadVertical";
                imageInput = PS4ControllerButtons[(int)enmPS4Buttons.PS4_LeftJoystick];
            }
            else if (_isUseXBox360Controller)
            {
                nameInput  = "XBox_DPadVertical";
                imageInput = XBoxControllerButtons[(int)enmXBoxButtons.XBox_LeftJoystick];
            }
            else if (_isUseOnlyKeyboard)
            {
                nameInput  = "";
                keyInput   = KeyCode.Alpha0;
                imageInput = KeyBoardButtons[(int)enmKeyboardButtons.Key_0];          // À voir
            }
        } break;
        }
    }