Пример #1
0
 private void _MonitorMousePressedEvent(KeyCode keyCode, KeyActionType actionType)
 {
     if (mousePressed[keyCode - KeyCode.Mouse0])
     {
         ExecuteMouseEventCallback(GetKeyEventIndex(keyCode, actionType), Input.mousePosition, actionType);
     }
 }
Пример #2
0
 private void _MonitorMouseUpEvent(KeyCode keyCode, KeyActionType actionType)
 {
     if (Input.GetKeyUp(keyCode))
     {
         mousePressed[keyCode - KeyCode.Mouse0] = false;
         ExecuteMouseEventCallback(GetKeyEventIndex(keyCode, actionType), Input.mousePosition, actionType);
     }
 }
Пример #3
0
    private PropertyInfo GetPropertyInfo(string propertyName)
    {
        PropertyInfo  propertyInfo = (PropertyInfo)null;
        KeyActionType key          = EnumHelper.Parse <KeyActionType>(this.GetType().Name, KeyActionType.Alias);

        this.Type = key;
        if (!IMAction.DictPropertyInfo.ContainsKey(key))
        {
            IMAction.DictPropertyInfo[key]       = new Dictionary <string, PropertyInfo>();
            IMAction.DictPopUpUIElements[key]    = new Dictionary <string, PropertyInfo>();
            IMAction.sDictDevModeUIElements[key] = new Dictionary <string, PropertyInfo>();
            IMAction.sPositionXPropertyName[key] = string.Empty;
            IMAction.sPositionYPropertyName[key] = string.Empty;
            IMAction.sRadiusPropertyName[key]    = string.Empty;
            foreach (PropertyInfo property in this.GetType().GetProperties(BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic))
            {
                IMAction.DictPropertyInfo[key].Add(property.Name, property);
                object[] customAttributes = property.GetCustomAttributes(typeof(DescriptionAttribute), true);
                if (customAttributes.Length != 0)
                {
                    DescriptionAttribute descriptionAttribute = customAttributes[0] as DescriptionAttribute;
                    if (descriptionAttribute.Description.Contains("IMAP_CanvasElementY"))
                    {
                        IMAction.sPositionXPropertyName[key] = property.Name;
                    }
                    if (descriptionAttribute.Description.Contains("IMAP_CanvasElementX"))
                    {
                        IMAction.sPositionYPropertyName[key] = property.Name;
                    }
                    if (descriptionAttribute.Description.Contains("IMAP_CanvasElementRadius"))
                    {
                        IMAction.sRadiusPropertyName[key] = property.Name;
                    }
                    if (descriptionAttribute.Description.Contains("IMAP_PopupUIElement"))
                    {
                        IMAction.DictPopUpUIElements[key].Add(property.Name, property);
                    }
                    if (descriptionAttribute.Description.Contains("IMAP_DeveloperModeUIElemnt"))
                    {
                        IMAction.sDictDevModeUIElements[key].Add(property.Name, property);
                    }
                }
            }
        }
        if (!string.IsNullOrEmpty(propertyName) && IMAction.DictPropertyInfo[key].ContainsKey(propertyName))
        {
            propertyInfo = IMAction.DictPropertyInfo[key][propertyName];
        }
        return(propertyInfo);
    }
Пример #4
0
        /// <summary> You can get any action to setup it's Press event. </summary>
        public KeyAction GetAction(KeyActionType type)
        {
            for (int i = 0; i < registeredKeys.Count; i++)
            {
                if (registeredKeys[i].type == type)
                {
                    return(registeredKeys[i]);
                }
            }

            var action = new KeyAction(type, KeyCode.K);

            RegisterKey(action);

            return(action);
        }
Пример #5
0
    public void SetActionKey(KeyActionType type, KeyCode code)
    {
        switch (type)
        {
        case KeyActionType.PositiveXMove:
            PositiveXKey = code;
            break;

        case KeyActionType.NegativeXKeyMove:
            NegativeXKey = code;
            break;

        case KeyActionType.PositiveYKeyMove:
            PositiveYKey = code;
            break;

        case KeyActionType.NegativeYKeyMove:
            NegativeYKey = code;
            break;

        case KeyActionType.PositiveShootX:
            PositiveShootXKey = code;
            break;

        case KeyActionType.NegativeShootX:
            NegativeShootXKey = code;
            break;

        case KeyActionType.PositiveShootY:
            PositiveShootYKey = code;
            break;

        case KeyActionType.NegativeShootY:
            NegativeShootYKey = code;
            break;

        case KeyActionType.ReverseTime:
            ReverseTimeKey = code;
            break;

        case KeyActionType.Pause:
            PauseKey = code;
            break;
        }
    }
Пример #6
0
    // 执行鼠标事件回调函数
    private void ExecuteMouseEventCallback(int dicIndex, Vector3 clickPos, KeyActionType actionType)
    {
        foreach (var callbackList in dicPointer[dicIndex].Values)
        {
            foreach (MeCallback _callback in callbackList)
            {
                switch (actionType)
                {
                case KeyActionType.Down:
                    _callback(clickPos);
                    break;

                case KeyActionType.Pressed:
                    _callback(mouseMovement);
                    break;

                case KeyActionType.Up:
                    _callback(clickPos);
                    break;
                }
            }
        }
    }
Пример #7
0
    public KeyCode CodeFromType(KeyActionType type)
    {
        switch (type)
        {
        case KeyActionType.PositiveXMove:
            return(PositiveXKey);

        case KeyActionType.NegativeXKeyMove:
            return(NegativeXKey);

        case KeyActionType.PositiveYKeyMove:
            return(PositiveYKey);

        case KeyActionType.NegativeYKeyMove:
            return(NegativeYKey);

        case KeyActionType.PositiveShootX:
            return(PositiveShootXKey);

        case KeyActionType.NegativeShootX:
            return(NegativeShootXKey);

        case KeyActionType.PositiveShootY:
            return(PositiveShootYKey);

        case KeyActionType.NegativeShootY:
            return(NegativeShootYKey);

        case KeyActionType.ReverseTime:
            return(ReverseTimeKey);

        case KeyActionType.Pause:
            return(PauseKey);
        }
        return(KeyCode.None);
    }
Пример #8
0
 /// <summary>
 /// Creates a KeyAssignment with the given information
 /// and calls MapKey(KeyAssignment keyAssign)
 /// </summary>
 public void MapKey(Keys key, KeyAssignment.KeyAction action, KeyActionType actionType)
 {
     MapKey(new KeyAssignment(key, action, actionType));
 }
Пример #9
0
 public string GetKeyActionName(KeyActionType ui) => keyActionDic.GetValue(ui);
Пример #10
0
 public KeyAction(KeyActionType newType, KeyCode keyToUse, bool haveDoublePress = false)
 {
     type = newType;
     key  = keyToUse;
     this.haveDoublePress = haveDoublePress;
 }
Пример #11
0
 // 获取按键事件对应的字典索引
 /// <summary>
 /// 获取鼠标按键对应的dic索引
 /// </summary>
 /// <param name="keyCode">哪个鼠标按键</param>
 /// <param name="actionType">动作</param>
 /// <returns></returns>
 private int GetKeyEventIndex(KeyCode keyCode, KeyActionType actionType)
 {
     return(3 * ((int)keyCode - (int)KeyCode.Mouse0) + (int)actionType);
 }
Пример #12
0
 public KeyAssignment(Keys key, KeyAction action, KeyActionType actionType)
 {
     _key = key;
     _keyAction = action;
     _actionType = actionType;
 }