/// <summary>
        /// Input setting for XBox 360's gamepad.
        /// </summary>
        public static void SetupXBox360Joystick()
        {
            float defalutSenstivity = JCS_InputSettings.DEFAULT_SENSITIVITY;
            float defaultDead       = JCS_InputSettings.DEFAULT_DEAD;
            float defaultGravity    = JCS_InputSettings.DEFAULT_GRAVITY;

            for (int joystickNum = 0; joystickNum < GAMEPAD_COUNT; ++joystickNum)
            {
                foreach (JCS_JoystickButton val in JCS_Utility.GetValues <JCS_JoystickButton>())
                {
                    if (val == JCS_JoystickButton.NONE)
                    {
                        continue;
                    }

                    // add axis definition.
                    AddAxis(new InputAxis()
                    {
                        name           = JCS_InputSettings.GetJoystickButtonIdName(joystickNum, val),
                        positiveButton = JCS_InputSettings.GetPositiveNameByLabel(val),
                        dead           = defaultDead,
                        gravity        = defaultGravity,
                        sensitivity    = defalutSenstivity,
                        type           = JCS_InputSettings.GetAxisType(val),
                        invert         = JCS_InputSettings.IsInvert(val),
                        axis           = (int)JCS_InputSettings.GetAxisChannel(val),
                        joyNum         = joystickNum,
                    });
                }
            }
        }
Beispiel #2
0
        /// <summary>
        /// Loop through the key and key what key is pressed.
        /// </summary>
        /// <param name="type"> type of the key pressed option. </param>
        /// <returns> key u pressed. </returns>
        public static KeyCode GetAnyKeyByAction(JCS_KeyActionType type, bool ignorePause = false)
        {
            if (!ignorePause)
            {
                if (JCS_GameManager.instance.GAME_PAUSE)
                {
                    return(KeyCode.None);
                }
            }

            // loop through the key code list
            foreach (KeyCode val in JCS_Utility.GetValues <KeyCode>())
            {
                // if the key is pressed, return it.
                if (GetKeyByAction(type, val))
                {
                    return(val);
                }
            }

            // default return.
            return(KeyCode.None);
        }
        /// <summary>
        /// Initialize the packet handlers array list.
        /// </summary>
        /// <typeparam name="K"></typeparam>
        protected void InitPacketHandlersArray <K>()
            where K : struct, IComparable, IFormattable, IConvertible
        {
            if (typeof(K).BaseType != typeof(Enum))
            {
                throw new InvalidCastException();
            }

            int maxRecvOp = 0;

            foreach (K op in JCS_Utility.GetValues <K>())
            {
                int opId = Convert.ToInt32(op);

                if (opId > maxRecvOp)
                {
                    maxRecvOp = opId;
                }
            }

            mHandlers = new JCS_PacketHandler[maxRecvOp + 1];

            Reset(this.mMode);
        }