Example #1
0
 public bool Add(object key, object obj)
 {
     if (mKeyType == KEY_TYPE.KEY_TYPE_ERROR)
     {
         Type type = key.GetType();
         if (type == intType ||
             type == longType ||
             type == uintType ||
             type == shortType)
         {
             mKeyType = KEY_TYPE.KEY_TYPE_INT;
             IntDic   = new Dictionary <long, object>();
         }
         else if (type == stringType)
         {
             mKeyType  = KEY_TYPE.KEY_TYPE_STRING;
             StringDic = new Dictionary <string, object>();
         }
         else
         {
             GameDebug.LogError("DataTable 不支持的Key类型");
             return(false);
         }
     }
     if (mKeyType == KEY_TYPE.KEY_TYPE_INT)
     {
         return(Add(Convert.ToInt64(key), obj));
     }
     else if (mKeyType == KEY_TYPE.KEY_TYPE_STRING)
     {
         return(Add((string)key, obj));
     }
     return(false);
 }
Example #2
0
 public bool GetKeyPress(KEY_TYPE type)
 {
     if (GetKeyDown(type))
     {
         _state = KEY_STATE.PRESS;
         return(true);
     }
     return(false);
 }
Example #3
0
 public bool GetKeyDown(KEY_TYPE type)
 {
     if (_state != KEY_STATE.DOWN)
     {
         if (Keyboard.IsKeyDown((Key)type))
         {
             _type  = type;
             _state = KEY_STATE.DOWN;
             return(true);
         }
     }
     return(false);
 }
Example #4
0
 private static char keyUpDownMap(char c, KEY_TYPE type)
 {
     if (c == 'a' && type == KEY_TYPE.DOWN) return 'k';
     if (c == 'a' && type == KEY_TYPE.UP) return 'l';
     if (c == 'd' && type == KEY_TYPE.DOWN) return 'o';
     if (c == 'd' && type == KEY_TYPE.UP) return 'p';
     throw new NotImplementedException();
 }
Example #5
0
        public static void keyPress(string c, KEY_TYPE type, bool ignore = false)
        {
            if (!ignore)
                if (TBConst.pid != foregroundPID) return;

            if (c.Length == 1)
            {

                byte b;
                if (type == KEY_TYPE.PRESS)
                    b = char2int(c[0]);
                else
                    b = char2int(keyUpDownMap(c[0], type));
                //SendKeys.SendWait("{r}");

                keybd_event(b, 0, KEYEVENTF_EXTENDEDKEY, 0);

                Thread.Sleep(10);
                keybd_event(b, 0, KEYEVENTF_KEYUP, 0);
                Thread.Sleep(10);

            }
        }
Example #6
0
 public static bool Press(KEY_TYPE type)
 {
     return(InputKey.I.GetKeyPress(type));
 }
Example #7
0
 public static bool Down(KEY_TYPE type)
 {
     return(InputKey.I.GetKeyDown(type));
 }
Example #8
0
 private InputKey()
 {
     _type  = KEY_TYPE.NONE;
     _state = KEY_STATE.UN_PRESS;
 }