Example #1
0
        public void Usage()
        {
            InputService service = new InputService(null);
            EventPump    pump    = new EventPump(service.CreateDevice(InputDeviceType.Mouse),
                                                 service.CreateDevice(InputDeviceType.Keyboard));

            // We create action mapping.
            ActionMapping mapping = new ActionMapping();

            mapping.InputProvider = new EventProcessor(pump);

            // We create some actions.
            Action castFirebolt = mapping.AddAction("Firebolt");

            castFirebolt.Description = "Cast a firebolt. Damage: 2500";
            castFirebolt.AddTrigger(new ButtonTrigger(KeyCodes.T, true));
            castFirebolt.AddTrigger(new ButtonTrigger(KeyCodes.Key1, true));

            castFirebolt.Event += CastFirebolt;

            // For continious events (movement),
            // you should use direct device pooling, not events.
        }
Example #2
0
 /// <summary>
 /// Creates an action
 /// </summary>
 /// <param name="name"></param>
 internal Action([NotNull] ActionMapping mapping, string name)
 {
     this.mapping = mapping;
     this.name    = name;
 }