Example #1
0
        private bool EvaluateTriggerDevice(TriggerDevice trigger, PhysicalStatus status)
        {
            var device = getDevice(status, trigger.Device.Source, trigger.Device.Gateway);

            if (device != null)
            {
                return(((TriggerDevice)trigger).Triggered(device));
            }
            return(false);
        }
Example #2
0
 public void AddTrigger()
 {
     if (puzzleType == PuzzleType.None)
     {
         return;
     }
     trigger = Instantiate(triggerPrefabs[(int)puzzleType]) as TriggerDevice;
     trigger.transform.parent        = this.transform;
     trigger.transform.localPosition = new Vector3(this.size.x / 2,
                                                   1.0f + trigger.gameObject.GetComponent <Collider>().bounds.extents.y,
                                                   this.size.z / 2);
     trigger.thisRoom = this;
 }
Example #3
0
 ITrigger GetKey( int keyCode, TriggerDevice source )
 {
     return _listeners.Keys.Where( k => k.Source == source && k.KeyCode == keyCode )
         .FirstOrDefault();
 }
Example #4
0
 void FireKeyDown( int keyCode, TriggerDevice device )
 {
     if( KeyDown != null ) KeyDown( this, new KeyDownEventArgs( keyCode, device ) );
 }
 public KeyDownEventArgs( int keyCode, TriggerDevice device )
     : base()
 {
     KeyCode = keyCode;
     Source = device;
 }
Example #6
0
 public Trigger(int keyCode, TriggerDevice source)
 {
     KeyCode = keyCode;
     Source = source;
 }
Example #7
0
        void OnConfigChanged( object sender, ConfigChangedEventArgs e )
        {
            if( e.MultiPluginId.Any( u => u.UniqueId == InputTrigger.PluginId.UniqueId ) && ( e.Key == "TriggerCode" || e.Key == "TriggerDevice" ) )
            {
                if( _currentDevice == TriggerDevice.Keyboard ) //If we were listening to a keyboard key, unregister it.
                    KeyboardDriver.Service.UnregisterCancellableKey( _keyCode );

                if( e.Key == "TriggerCode" ) //Retrieving the new code.
                    _keyCode = (int)e.Value;
                else if( e.Key == "TriggerDevice" ) //Retrieving the new TriggerDevice
                {
                    TriggerDevice temp = TriggerDevice.None;
                    if( Enum.TryParse<TriggerDevice>( e.Value.ToString(), out temp ) )
                        _currentDevice = temp;
                }

                if( _currentDevice == TriggerDevice.Keyboard ) //If we are now listening to a keyboard key, register it
                    KeyboardDriver.Service.RegisterCancellableKey( _keyCode );
            }
        }
Example #8
0
        public void Start()
        {
            ListenToKeyDown = true;

            _keyCode = Configuration.User.GetOrSet( "TriggerCode", 122 );
            _currentDevice = Configuration.User.GetOrSet( "TriggerDevice", TriggerDevice.Keyboard );
            if( _currentDevice == TriggerDevice.Keyboard )
                KeyboardDriver.Service.RegisterCancellableKey( _keyCode );

            Configuration.ConfigChanged += OnConfigChanged;
        }