コード例 #1
0
ファイル: Parser.cs プロジェクト: cyendra/RavenParser
        public static Factory Get(Type clazz, Type argType)
        {
            if (clazz == null)
            {
                return(null);
            }
            MethodInfo method = clazz.GetMethod(FactoryName,
                                                BindingFlags.Public | BindingFlags.InvokeMethod | BindingFlags.Static,
                                                null,
                                                new Type[] { argType },
                                                null);

            if (method != null)
            {
                MakeDelegate make = delegate(object arg) {
                    return(method.Invoke(null, new object[] { arg }) as ASTree);
                };
                return(new Factory(make));
            }
            ConstructorInfo cons = clazz.GetConstructor(new Type[] { argType });

            if (cons != null)
            {
                MakeDelegate make = delegate(object arg) {
                    return(cons.Invoke(new object[] { arg }) as ASTree);
                };
                return(new Factory(make));
            }
            return(null);
        }
コード例 #2
0
 /// <summary>
 /// Bind delegates to particular make/break input event.
 /// </summary>
 /// <param name="deviceNumber">Device number to bind.</param>
 /// <param name="objectId">Device object to bind to.  E.g., GamePads have thumb sticks, buttons, and triggers, which 
 /// have id's corresponding to XGamePadDevice.GamePadObjects enum values.</param>
 /// <param name="makeDelegate">Delegate to invoke on make events.</param>
 /// <param name="breakDelegate">Delegate to invoke on break events.</param>
 /// <returns>True if binding was succesful.</returns>
 public bool BindCommand(int deviceNumber, int objectId, MakeDelegate makeDelegate, BreakDelegate breakDelegate)
 {
     return BindCommand(deviceNumber, objectId, TorqueInputDevice.Action.None, makeDelegate, breakDelegate);
 }
コード例 #3
0
 /// <summary>
 /// Bind delegates to particular make/break input event.
 /// </summary>
 /// <param name="deviceName">Name of device to bind to, e.g. "gamepad1", "mouse0", "keyboard0".</param>
 /// <param name="inputObject">Name of input object to bind to, e.g. "ThumbStickX", "LeftTriggerButton".</param>
 /// <param name="makeDelegate">Delegate to invoke on make events.</param>
 /// <param name="breakDelegate">Delegate to invoke on break events.</param>
 /// <returns>True if binding is successful.</returns>
 public bool BindCommand(String deviceName, String inputObject, MakeDelegate makeDelegate, BreakDelegate breakDelegate)
 {
     return BindCommand(deviceName, inputObject, TorqueInputDevice.Action.None, makeDelegate, breakDelegate);
 }
コード例 #4
0
        /// <summary>
        /// Bind delegates to particular make/break input event.
        /// </summary>
        /// <param name="deviceName">Name of device to bind to, e.g. "gamepad1", "mouse0", "keyboard0".</param>
        /// <param name="inputObject">Name of input object to bind to, e.g. "ThumbStickX", "LeftTriggerButton".</param>
        /// <param name="modifier">Restrict binding to be in effect only when given modifier is present.  Valid modifiers are 
        /// Shift, Ctrl, LeftClick, MiddleClick, RightClick</param>
        /// <param name="makeDelegate">Delegate to invoke on make events.</param>
        /// <param name="breakDelegate">Delegate to invoke on break events.</param>
        /// <returns>True if binding is successful.</returns>
        public bool BindCommand(String deviceName, String inputObject, TorqueInputDevice.Action modifier, MakeDelegate makeDelegate, BreakDelegate breakDelegate)
        {
            int deviceNumber = InputManager.Instance.FindDevice(deviceName);
            if (deviceNumber == -1)
                return false;

            TorqueInputDevice device = InputManager.Instance.GetDevice(deviceNumber);
            int objectId = device.GetObjectId(inputObject);
            if (objectId == -1)
                return false;

            return BindCommand(deviceNumber, objectId, modifier, makeDelegate, breakDelegate);
        }
コード例 #5
0
        /// <summary>
        /// Bind delegates to particular make/break input event.
        /// </summary>
        /// <param name="deviceNumber">Device number to bind.</param>
        /// <param name="objectId">Device object to bind to.  E.g., GamePads have thumb sticks, buttons, and triggers, which 
        /// have id's corresponding to XGamePadDevice.GamePadObjects enum values.</param>
        /// <param name="modifier">Restrict binding to be in effect only when given modifier is present.  Valid modifiers are 
        /// Shift, Ctrl, LeftClick, MiddleClick, RightClick</param>
        /// <param name="makeDelegate">Delegate to invoke on make events.</param>
        /// <param name="breakDelegate">Delegate to invoke on break events.</param>
        /// <returns>True if binding was succesful.</returns>
        public bool BindCommand(int deviceNumber, int objectId, TorqueInputDevice.Action modifier, MakeDelegate makeDelegate, BreakDelegate breakDelegate)
        {
            if (deviceNumber < 0 || deviceNumber >= InputManager.Instance.GetNumDevices())
                return false;
            TorqueInputDevice device = InputManager.Instance.GetDevice(deviceNumber);
            if (!device.IsValidObject(objectId))
                return false;

            InputNode node = new InputNode();
            node.DeviceNumber = deviceNumber;
            node.ObjectId = objectId;
            node.Modifier = modifier;
            node.Flags = InputNode.ActionFlags.BindCmd;
            node.DeadZoneBegin = 0.0f;
            node.DeadZoneEnd = 0.0f;
            node.ScaleFactor = 1.0f;
            node.MoveIndex = -1;
            node.MakeDelegate = makeDelegate;
            node.BreakDelegate = breakDelegate;
            _SetInputNode(deviceNumber, objectId, modifier, ref node);
            _currentBindIndex = -1;

            return true;
        }
コード例 #6
0
ファイル: Parser.cs プロジェクト: cyendra/RavenParser
 protected Factory(MakeDelegate make)
 {
     make0 = make;
 }