示例#1
0
 static void ResetPressInfo()
 {
     ClickPressInfo.Clear();
     ClickCDPressInfo.Clear();
     DoublePressInfo.Clear();
     LongPressInfo.Clear();
     JoyAxisStateInfo.Clear();
 }
示例#2
0
        public static void Register(KeyCode key, float[] para)
        {
            int idx = s_clickPressKeys.FindIndex(x => x._key == key);

            if (idx < 0)
            {
                s_clickPressKeys.Add(new ClickPressInfo(key, para));
            }
            else
            {
                s_clickPressKeys[idx] = new ClickPressInfo(key, para);
            }
        }
示例#3
0
    static Func <bool> CreatePressTestFunc(KeyCode key, KeyPressType pressType, float[] para)
    {
        if (pressType < KeyPressType.JoyStickBegin)
        {
            if (key == KeyCode.None)
            {
                return(() => false);
            }
            int mask = (int)key & KeyMask;                      // use excluder to check key mask
            if (mask != 0)
            {
                key = key - mask;
            }
        }

        switch (pressType)
        {
        default:
        case KeyPressType.Up:                           return(() => Input.GetKeyUp(key) && NotExcluderByOther());

        case KeyPressType.Down:                         return(() => Input.GetKeyDown(key) && NotExcluderByOther());

        case KeyPressType.Press:                        return(() => Input.GetKey(key) && NotExcluderByOther());

        case KeyPressType.UpHPrior:                     return(() => Input.GetKeyUp(key));

        case KeyPressType.PressHPrior:          return(() => Input.GetKey(key));

        case KeyPressType.ClickNoMove:          return(() => key.IsClickNoMove());

        case KeyPressType.Click:                        ClickPressInfo.Register(key, para);             return(() => key.IsClickPress());

        case KeyPressType.ClickCD:                      ClickCDPressInfo.Register(key, para);   return(() => key.IsClickCDPress());

        case KeyPressType.DoublePress:          DoublePressInfo.Register(key, para);    return(() => key.IsDoublePress());

        case KeyPressType.LongPress:            LongPressInfo.Register(key, para);              return(() => key.IsLongPress());

        case KeyPressType.DirU:                         s_keyAxisU = key;       return(delegate { return s_curAxisV > PETools.PEMath.Epsilon; });

        case KeyPressType.DirD:                         s_keyAxisD = key;       return(delegate { return s_curAxisV < -PETools.PEMath.Epsilon; });

        case KeyPressType.DirR:                         s_keyAxisR = key;       return(delegate { return s_curAxisH > PETools.PEMath.Epsilon; });

        case KeyPressType.DirL:                         s_keyAxisL = key;       return(delegate { return s_curAxisH < -PETools.PEMath.Epsilon; });

        case KeyPressType.MouseWheelU:          return(delegate { return Input.GetAxis("Mouse ScrollWheel") > PETools.PEMath.Epsilon; });

        case KeyPressType.MouseWheelD:          return(delegate { return Input.GetAxis("Mouse ScrollWheel") < -PETools.PEMath.Epsilon; });
        }
    }
示例#4
0
        public static bool TryGetValue(KeyCode key, out ClickPressInfo info)
        {
            info = null;

            int idx = s_clickPressKeys.FindIndex(x => x._key == key);

            if (idx < 0)
            {
                return(false);
            }

            info = s_clickPressKeys [idx];
            return(true);
        }
示例#5
0
    public static bool IsClickPress(this KeyCode key)
    {
        ClickPressInfo pressInfo;

        if (Input.GetKeyDown(key) && NotExcluderByOther() && ClickPressInfo.TryGetValue(key, out pressInfo))
        {
            pressInfo._lastDown = Time.time;
        }
        else if (Input.GetKeyUp(key) && NotExcluderByOther() && ClickPressInfo.TryGetValue(key, out pressInfo))
        {
            float deltaTime = Time.time - pressInfo._lastDown;
            if (deltaTime < pressInfo._interval)
            {
                return(true);
            }
        }
        return(false);
    }