public OnClickVisitor(IInputAdapter inputAdapter) { this.inputAdapter = inputAdapter; previousMouseState = inputAdapter.GetMouseState(); mouseState = inputAdapter.GetMouseState(); }
public MonoGameDrawStrategy(SpriteBatch spriteBatch, GraphicsDeviceManager graphicsDeviceManager, ContentManager contentManager, IInputAdapter inputAdapter) { this.spriteBatch = spriteBatch; this.graphicsDeviceManager = graphicsDeviceManager; this.contentManager = contentManager; this.inputAdapter = inputAdapter; }
public void Configure(IInputAdapter typeOfInput, ProjectileId defaultProjectile, Vector2 speed, float fireRatio) { movementController.Configure(this, speed); weaponController.Configure(this, defaultProjectile, fireRatio); _inputAdapter = typeOfInput; isConfigure = true; }
public void flushFrames(IInputAdapter adapter, MocapFrame frame) { if (this._config.SkeletonStreamFlush) { this.frameList.Add(frame); if (this.frameList.Count > this._config.SkeletonStreamFlushSize) { // freeze to serialize List <MocapFrame> serializeList = new List <MocapFrame>(frameList); // Serialize string flushPath = Path.Combine(this.SkeletonStreamPath, (this.skeletonFlushCount.ToString() + ".json")); try { using (StreamWriter sw = new StreamWriter(flushPath)) using (JsonWriter writer = new JsonTextWriter(sw)) { serializer.Serialize(writer, serializeList); } } catch (Exception e) { Logger.Error("Error occurred during flushing frames: {0}", e.ToString()); } this.skeletonFlushCount += 1; // Clear the List this.frameList.Clear(); } } }
// Adds an input adapter to the dependency chain. private void AddInputAdapter(IInputAdapter adapter, ISet <IAdapter> dependencyChain, IInputAdapter[] inputAdapterCollection, IActionAdapter[] actionAdapterCollection, IOutputAdapter[] outputAdapterCollection) { HashSet <MeasurementKey> outputMeasurementKeys = new HashSet <MeasurementKey>(adapter.OutputMeasurementKeys()); // Adds the adapter to the chain dependencyChain.Add(adapter); if ((object)actionAdapterCollection != null) { // Checks all action adapters to determine whether they also need to be // added to the chain as a result of this adapter being added to the chain foreach (IActionAdapter actionAdapter in actionAdapterCollection) { if (actionAdapter.RespectInputDemands && !dependencyChain.Contains(actionAdapter) && outputMeasurementKeys.Overlaps(actionAdapter.InputMeasurementKeys())) { AddActionAdapter(actionAdapter, dependencyChain, inputAdapterCollection, actionAdapterCollection, outputAdapterCollection); } } } if ((object)outputAdapterCollection != null) { // Checks all output adapters to determine whether they also need to be // added to the chain as a result of this adapter being added to the chain foreach (IOutputAdapter outputAdapter in outputAdapterCollection) { if (!dependencyChain.Contains(outputAdapter) && outputMeasurementKeys.Overlaps(outputAdapter.InputMeasurementKeys())) { AddOutputAdapter(outputAdapter, dependencyChain, inputAdapterCollection, actionAdapterCollection, outputAdapterCollection); } } } }
public SGUIDFInput(IInputAdapter @base) { Base = @base; if (@base == null) { throw new NullReferenceException("SDGUIFInput cannot be instantiated without base input!"); } }
public virtual void Start() { input = GetComponent <InputStragety>().GetInput(); comportamiento = GetComponent <ComportamientoEscenario>(); escenario = comportamiento.escenario; controladorDeGrupos = GetComponent <ControladorDeGrupos>(); vidasUI = GetComponent <ControadorDeVidasDeUI>(); }
public Game1() { inputAdapter = new InputAdapter(); graphics = new GraphicsDeviceManager(this); Content.RootDirectory = "Content"; mouseState = inputAdapter.GetMouseState(); keyboardState = inputAdapter.GetKeyboardState(); windowFactory = new WindowFactory(); }
public void Refersh(IInputAdapter adapter) { _states.Clear(); foreach (KeyCode value in Enum.GetValues(typeof(KeyCode))) { _states.Add(value, adapter.KeyDown(value)); } }
private void HandleErrorEvent(IInputAdapter source, Exception e) { Logger.Error("Adapter: {0}, has severe problems: {1}", source.Name, e.Message); Stop(); // keep console open until key is pressed if (Logger.IsDebugEnabled) { Console.ReadKey(); } }
/// <summary> /// Patches the existing routing table with the supplied adapters. /// </summary> /// <param name="producerAdapters">all of the producers</param> /// <param name="consumerAdapters">all of the consumers</param> public void PatchRoutingTable(RoutingTablesAdaptersList producerAdapters, RoutingTablesAdaptersList consumerAdapters) { if (producerAdapters == null) { throw new ArgumentNullException(nameof(producerAdapters)); } if (consumerAdapters == null) { throw new ArgumentNullException(nameof(consumerAdapters)); } foreach (var producerAdapter in producerAdapters.NewAdapter) { IInputAdapter inputAdapter = producerAdapter as IInputAdapter; IActionAdapter actionAdapter = producerAdapter as IActionAdapter; if ((object)inputAdapter != null) { inputAdapter.NewMeasurements += Route; } else if ((object)actionAdapter != null) { actionAdapter.NewMeasurements += Route; } } foreach (var producerAdapter in producerAdapters.OldAdapter) { IInputAdapter inputAdapter = producerAdapter as IInputAdapter; IActionAdapter actionAdapter = producerAdapter as IActionAdapter; if ((object)inputAdapter != null) { inputAdapter.NewMeasurements -= Route; } else if ((object)actionAdapter != null) { actionAdapter.NewMeasurements -= Route; } } Dictionary <IAdapter, Consumer> consumerLookup = new Dictionary <IAdapter, Consumer>(m_globalCache.GlobalDestinationLookup); foreach (var consumerAdapter in consumerAdapters.NewAdapter) { consumerLookup.Add(consumerAdapter, new Consumer(consumerAdapter)); } foreach (var consumerAdapter in consumerAdapters.OldAdapter) { consumerLookup.Remove(consumerAdapter); } m_globalCache = new GlobalCache(consumerLookup, m_globalCache.Version + 1); RouteCount = m_globalCache.GlobalSignalLookup.Count(x => x != null); }
public void Refresh(IInputAdapter adapter) { _buttonStates.Clear(); _chosen = 0; _buttonStates.Add(MouseButton.LeftButton, GetState(adapter, MouseButton.LeftButton)); _buttonStates.Add(MouseButton.RightButton, GetState(adapter, MouseButton.RightButton)); _buttonStates.Add(MouseButton.MiddleButton, GetState(adapter, MouseButton.MiddleButton)); _screenPostion = Utils.ToWorld(adapter.MousePostion()); _rawPostion = adapter.MousePostion(); }
private MouseState GetState(IInputAdapter adapter, MouseButton button) { if (adapter.MouseClicked(button)) { return(MouseState.Clicked); } if (adapter.MouseDown(button)) { return(MouseState.Down); } return(MouseState.Up); }
public LocalCache(RouteMappingHighLatencyLowCpu route, IAdapter adapter) { Enabled = true; m_route = route; IInputAdapter inputAdapter = adapter as IInputAdapter; IActionAdapter actionAdapter = adapter as IActionAdapter; if ((object)inputAdapter != null) { inputAdapter.NewMeasurements += Route; } else if ((object)actionAdapter != null) { actionAdapter.NewMeasurements += Route; } }
public GameManager(RenderAdapter renderAdapter, IUtilsAdapter utilsAdapter, IInputAdapter inputAdapter, IResourceAdapter resoruceAdapter) { _graphics = new GraphicsManager(renderAdapter); Utils.SetAdapter(utilsAdapter); _input = new InputManger(inputAdapter); ResoruceManger.SetAdapter(resoruceAdapter); SetUpGameWindow(); LoadFonts(); _world = new World(_factory, _settings.BackgroundMusicFileName); _ui = new UserInterfaceManger(_factory, _world); Statistics.SetWorld(_world); // Must be called After adapters are set _collsion = new CollsionManger(); _sound = new SoundManger(); }
protected SimpleEventProcessorRunnerBase(IEventProcessor eventProcessor, IInputAdapter inputAdapter, ILogger logger) { InputAdapter = inputAdapter; EventProcessor = eventProcessor; Logger = logger; if (EventProcessor == null) { throw new ArgumentNullException("eventProcessor", "EventProcessor should be specified in order to run the EventSystem"); } if (InputAdapter == null) { throw new ArgumentNullException("inputAdapter", "InputAdapter should be specified in order to run the EventSystem"); } }
public void OnEnable() { this.mouseHandler = new dfInputManager.MouseInputManager(); if (this.adapter == null) { Component component = ( from c in (IEnumerable <Component>)base.GetComponents(typeof(MonoBehaviour)) where typeof(IInputAdapter).IsAssignableFrom(c.GetType()) select c).FirstOrDefault <Component>(); object defaultInput = (IInputAdapter)component; if (defaultInput == null) { defaultInput = new dfInputManager.DefaultInput(); } this.adapter = (IInputAdapter)defaultInput; } }
/// <summary> /// Allows the game to perform any initialization it needs to before starting to run. /// This is where it can query for any required services and load any non-graphic /// related content. Calling base.Initialize will enumerate through any components /// and initialize them as well. /// </summary> protected override void Initialize() { // Initialization logic here screenFactory = new ScreenFactory(); applicationAdapter = new MonoGameApplicationAdapter(this); screenNavigator = new ScreenNavigator(screenFactory, applicationAdapter); inputAdapter = new MonoGameInputAdapter(); onClickVisitor = new OnClickVisitor(inputAdapter); updateVisitor = new DefaultUpdateVisitor(inputAdapter); // Configuration this.IsMouseVisible = true; // base.Initialize(); }
private static void getMouseButtonInfo(IInputAdapter adapter, ref dfMouseButtons buttonsDown, ref dfMouseButtons buttonsReleased, ref dfMouseButtons buttonsPressed) { for (int i = 0; i < 3; i++) { if (adapter.GetMouseButton(i)) { buttonsDown = (dfMouseButtons)((int)buttonsDown | 1 << (i & 31)); } if (adapter.GetMouseButtonUp(i)) { buttonsReleased = (dfMouseButtons)((int)buttonsReleased | 1 << (i & 31)); } if (adapter.GetMouseButtonDown(i)) { buttonsPressed = (dfMouseButtons)((int)buttonsPressed | 1 << (i & 31)); } } }
void Start() { switch (device) { case Device.PC: playerInput = new InputAdapterPC(); break; case Device.Mobile: GameObject joystick = Instantiate(virtualJoystickPrefab); virtualJoystick = joystick.GetComponent <SimpleTouchController>(); UIManager.Instance.AddVirtualJoystick(joystick); playerInput = new InputAdapterMobile(); break; default: break; } }
public LocalCache(RouteMappingDoubleBufferQueue routingTables, IAdapter producerAdapter) { m_localCacheLock = new object(); m_localSignalLookup = new Dictionary <Guid, List <Producer> >(); m_localDestinationLookup = new Dictionary <Consumer, Producer>(); m_routingTables = routingTables; IInputAdapter inputAdapter = producerAdapter as IInputAdapter; IActionAdapter actionAdapter = producerAdapter as IActionAdapter; if ((object)inputAdapter != null) { inputAdapter.NewMeasurements += Route; } else if ((object)actionAdapter != null) { actionAdapter.NewMeasurements += Route; } }
private void HandleFrameAvailable(IInputAdapter source, MocapFrame frame) { /* frame available occurs inside adapter thread * so synchronize access to the stopwatch */ lock (StopwatchLock) { frame.ElapsedMillis = _applicationWatch.ElapsedMilliseconds; Session.Duration = Convert.ToUInt32(_applicationWatch.ElapsedMilliseconds); } /* get a data merger specific to the type of input adapter, * so only a optitrack merger gets frames from an optitrack * input adapter and so forth. */ var merger = _dataMergers.First(m => m.MergerType == source.AdapterType); Logger.Debug("{Frame #{0} available from {1}", frame.ElapsedMillis, source.Config.AdapterType); var mergedFrame = merger.HandleFrame(frame); //get the output from datamerger to output manager _outputManager.ReadyToOutput(mergedFrame); FrameAvailable?.Invoke(frame); }
public void OnEnable() { activeInstances.Add( this ); // Mouse input will be handled by a MouseInputManager instance to // consolidate the complexity of mouse operations mouseHandler = new MouseInputManager(); if( useTouch ) { // Multi-touch input will be handled by a TouchInputHandler instance // to localize code complexity touchHandler = new TouchInputManager( this ); } // If an input adapter has not already been assigned, look for // a replacement or assign the default if( this.adapter == null ) { // Look for a replacement IInputAdapter component var inputAdapter = GetComponents( typeof( MonoBehaviour ) ) .Where( c => c != null && c.GetType() != null && typeof( IInputAdapter ).IsAssignableFrom( c.GetType() ) ) .FirstOrDefault(); // Use the replacement if found, otherwise use the default adapter this.adapter = (IInputAdapter)inputAdapter ?? new DefaultInput(); } Input.simulateMouseWithTouches = !this.useTouch; }
/// <summary> /// Determines the set of adapters in the dependency chain that produces the set of signals in the /// <paramref name="inputMeasurementKeysRestriction"/> and returns the set of input signals required by the /// adapters in the chain and the set of output signals produced by the adapters in the chain. /// </summary> /// <param name="inputMeasurementKeysRestriction">The set of signals that must be produced by the dependency chain.</param> /// <param name="inputAdapterCollection">Collection of input adapters at start of routing table calculation.</param> /// <param name="actionAdapterCollection">Collection of action adapters at start of routing table calculation.</param> /// <param name="outputAdapterCollection">Collection of output adapters at start of routing table calculation.</param> protected virtual ISet<IAdapter> TraverseDependencyChain(ISet<MeasurementKey> inputMeasurementKeysRestriction, IInputAdapter[] inputAdapterCollection, IActionAdapter[] actionAdapterCollection, IOutputAdapter[] outputAdapterCollection) { ISet<IAdapter> dependencyChain = new HashSet<IAdapter>(); if ((object)inputAdapterCollection != null) { foreach (IInputAdapter inputAdapter in inputAdapterCollection) { if (!dependencyChain.Contains(inputAdapter) && inputMeasurementKeysRestriction.Overlaps(inputAdapter.OutputMeasurementKeys())) AddInputAdapter(inputAdapter, dependencyChain, inputAdapterCollection, actionAdapterCollection, outputAdapterCollection); } } if ((object)actionAdapterCollection != null) { foreach (IActionAdapter actionAdapter in actionAdapterCollection) { if (!dependencyChain.Contains(actionAdapter) && inputMeasurementKeysRestriction.Overlaps(actionAdapter.OutputMeasurementKeys())) AddActionAdapter(actionAdapter, dependencyChain, inputAdapterCollection, actionAdapterCollection, outputAdapterCollection); } } return dependencyChain; }
public void ProcessInput( dfInputManager manager, IInputAdapter adapter, Ray ray, dfControl control, bool retainFocusSetting ) { var position = adapter.GetMousePosition(); buttonsDown = dfMouseButtons.None; buttonsReleased = dfMouseButtons.None; buttonsPressed = dfMouseButtons.None; getMouseButtonInfo( adapter, ref buttonsDown, ref buttonsReleased, ref buttonsPressed ); float scroll = adapter.GetAxis( scrollAxisName ); if( !Mathf.Approximately( scroll, 0f ) ) { // By default the mouse wheel is reported in increments of 0.1f, // which is just a useless number for UI, but this can be changed // by the user in the Unity Input Manager. We'll assume that if the // number reported is less than 1 then it is probably safe to // assume that we can massage it for UI purposes. scroll = Mathf.Sign( scroll ) * Mathf.Max( 1, Mathf.Abs( scroll ) ); } mouseMoveDelta = position - lastPosition; lastPosition = position; #region Drag and drop if( dragState == dfDragDropState.Dragging ) { if( buttonsReleased == dfMouseButtons.None ) { // Do nothing if the drag operation is over the source control // and no buttons have been released. if( control == activeControl ) return; if( control != lastDragControl ) { if( lastDragControl != null ) { var dragArgs = new dfDragEventArgs( lastDragControl, dragState, dragData, ray, position ); lastDragControl.OnDragLeave( dragArgs ); } if( control != null ) { var dragArgs = new dfDragEventArgs( control, dragState, dragData, ray, position ); control.OnDragEnter( dragArgs ); } lastDragControl = control; return; } if( control != null ) { if( mouseMoveDelta.magnitude > 1.0f ) { var dragArgs = new dfDragEventArgs( control, dragState, dragData, ray, position ); control.OnDragOver( dragArgs ); } } return; } if( control != null && control != activeControl ) { var dragArgs = new dfDragEventArgs( control, dfDragDropState.Dragging, dragData, ray, position ); control.OnDragDrop( dragArgs ); // If there was no event consumer, or if the event consumer did not // change the state from Dragging (which is not a valid state for // a drop event) then just cancel the operation if( !dragArgs.Used || dragArgs.State == dfDragDropState.Dragging ) dragArgs.State = dfDragDropState.Cancelled; dragArgs = new dfDragEventArgs( activeControl, dragArgs.State, dragArgs.Data, ray, position ); dragArgs.Target = control; activeControl.OnDragEnd( dragArgs ); } else { var cancelState = ( control == null ) ? dfDragDropState.CancelledNoTarget : dfDragDropState.Cancelled; var dragArgs = new dfDragEventArgs( activeControl, cancelState, dragData, ray, position ); activeControl.OnDragEnd( dragArgs ); } dragState = dfDragDropState.None; lastDragControl = null; activeControl = null; lastClickTime = 0f; lastHoverTime = 0f; lastPosition = position; return; } #endregion #region Mouse button pressed if( buttonsPressed != dfMouseButtons.None ) { lastHoverTime = Time.realtimeSinceStartup + manager.hoverStartDelay; if( activeControl != null ) { // If a control has capture, forward all events to it if( activeControl.transform.IsChildOf( manager.transform ) ) { activeControl.OnMouseDown( new dfMouseEventArgs( activeControl, buttonsPressed, 0, ray, position, scroll ) ); } } else if( control == null || control.transform.IsChildOf( manager.transform ) ) { setActive( manager, control, position, ray ); if( control != null ) { dfGUIManager.SetFocus( control ); control.OnMouseDown( new dfMouseEventArgs( control, buttonsPressed, 0, ray, position, scroll ) ); } else if( !retainFocusSetting ) { var focusControl = dfGUIManager.ActiveControl; if( focusControl != null && focusControl.transform.IsChildOf( manager.transform ) ) { focusControl.Unfocus(); } } } if( buttonsReleased == dfMouseButtons.None ) return; } #endregion #region Mouse button released if( buttonsReleased != dfMouseButtons.None ) { lastHoverTime = Time.realtimeSinceStartup + manager.hoverStartDelay; // Mouse up without a control having capture is ignored if( activeControl == null ) { setActive( manager, control, position, ray ); return; } // If the mouse button is released over the same control it was pressed on, // the Click event gets generated (in addition to MouseUp) if( activeControl == control && buttonsDown == dfMouseButtons.None ) { var p2u = activeControl.PixelsToUnits(); var startPosition = activeControlPosition / p2u; var currentPosition = activeControl.transform.position / p2u; // Don't fire click events if the control has been moved since the mouse was down if( Vector3.Distance( startPosition, currentPosition ) <= 1 ) { if( Time.realtimeSinceStartup - lastClickTime < DOUBLECLICK_TIME ) { lastClickTime = 0f; activeControl.OnDoubleClick( new dfMouseEventArgs( activeControl, buttonsReleased, 1, ray, position, scroll ) ); } else { lastClickTime = Time.realtimeSinceStartup; activeControl.OnClick( new dfMouseEventArgs( activeControl, buttonsReleased, 1, ray, position, scroll ) ); } } } // Let the last control know that the button was released whether it was // released over the control or not activeControl.OnMouseUp( new dfMouseEventArgs( activeControl, buttonsReleased, 0, ray, position, scroll ) ); // If all buttons are up, then we need to reset the mouse state if( buttonsDown == dfMouseButtons.None && activeControl != control ) { setActive( manager, null, position, ray ); } return; } #endregion #region Doesn't matter if buttons are down or not if( activeControl != null && activeControl == control ) { if( mouseMoveDelta.magnitude == 0 && Time.realtimeSinceStartup - lastHoverTime > manager.hoverNotifactionFrequency ) { activeControl.OnMouseHover( new dfMouseEventArgs( activeControl, buttonsDown, 0, ray, position, scroll ) ); lastHoverTime = Time.realtimeSinceStartup; } } #endregion #region No buttons down if( buttonsDown == dfMouseButtons.None ) { if( scroll != 0 && control != null ) { setActive( manager, control, position, ray ); control.OnMouseWheel( new dfMouseEventArgs( control, buttonsDown, 0, ray, position, scroll ) ); return; } setActive( manager, control, position, ray ); } #endregion #region Some buttons down else if( buttonsDown != dfMouseButtons.None ) // Some buttons are down { if( activeControl != null ) { // Special case: Another control with a higher RenderOrder is now under the mouse. // This can happen when a control moves, such as when you click on a slider and the // thumb position is updated to be under the mouse (when it wasn't previously) if( control != null && control.RenderOrder > activeControl.RenderOrder ) { // TODO: What to do about this when a control has capture? } // If the mouse was moved notify the control, otherwise nothing to do // NOTE: This is similar to "mouse capture" on Windows Forms if( mouseMoveDelta.magnitude >= DRAG_START_DELTA ) { if( ( buttonsDown & ( dfMouseButtons.Left | dfMouseButtons.Right ) ) != 0 && dragState != dfDragDropState.Denied ) { var dragArgs = new dfDragEventArgs( activeControl ) { Position = position }; activeControl.OnDragStart( dragArgs ); if( dragArgs.State == dfDragDropState.Dragging ) { dragState = dfDragDropState.Dragging; dragData = dragArgs.Data; return; } else { dragState = dfDragDropState.Denied; } } } } } #endregion if( activeControl != null && mouseMoveDelta.magnitude >= 1 ) { var moveArgs = new dfMouseEventArgs( activeControl, buttonsDown, 0, ray, position, scroll ) { MoveDelta = mouseMoveDelta }; activeControl.OnMouseMove( moveArgs ); } }
private static void getMouseButtonInfo( IInputAdapter adapter, ref dfMouseButtons buttonsDown, ref dfMouseButtons buttonsReleased, ref dfMouseButtons buttonsPressed ) { for( int i = 0; i < 3; i++ ) { if( adapter.GetMouseButton( i ) ) { buttonsDown |= (dfMouseButtons)( 1 << i ); } if( adapter.GetMouseButtonUp( i ) ) { buttonsReleased |= (dfMouseButtons)( 1 << i ); } if( adapter.GetMouseButtonDown( i ) ) { buttonsPressed |= (dfMouseButtons)( 1 << i ); } } }
private void Start() { _input = GetComponent <InputStragety>().GetInput(); }
// Adds an output adapter to the dependency chain. private void AddOutputAdapter(IOutputAdapter adapter, ISet<IAdapter> dependencyChain, IInputAdapter[] inputAdapterCollection, IActionAdapter[] actionAdapterCollection, IOutputAdapter[] outputAdapterCollection) { HashSet<MeasurementKey> inputMeasurementKeys = new HashSet<MeasurementKey>(adapter.InputMeasurementKeys()); // Adds the adapter to the chain dependencyChain.Add(adapter); if ((object)inputAdapterCollection != null) { // Checks all input adapters to determine whether they also need to be // added to the chain as a result of this adapter being added to the chain foreach (IInputAdapter inputAdapter in inputAdapterCollection) { if (!dependencyChain.Contains(inputAdapter) && inputMeasurementKeys.Overlaps(inputAdapter.OutputMeasurementKeys())) AddInputAdapter(inputAdapter, dependencyChain, inputAdapterCollection, actionAdapterCollection, outputAdapterCollection); } } if ((object)actionAdapterCollection != null) { // Checks all action adapters to determine whether they also need to be // added to the chain as a result of this adapter being added to the chain foreach (IActionAdapter actionAdapter in actionAdapterCollection) { if (actionAdapter.RespectOutputDemands && !dependencyChain.Contains(actionAdapter) && inputMeasurementKeys.Overlaps(actionAdapter.OutputMeasurementKeys())) AddActionAdapter(actionAdapter, dependencyChain, inputAdapterCollection, actionAdapterCollection, outputAdapterCollection); } } }
/// <summary> /// Starts or stops connect on demand adapters based on current state of demanded input or output signals. /// </summary> /// <param name="inputMeasurementKeysRestriction">The set of signals to be produced by the chain of adapters to be handled.</param> /// <param name="inputAdapterCollection">Collection of input adapters at start of routing table calculation.</param> /// <param name="actionAdapterCollection">Collection of action adapters at start of routing table calculation.</param> /// <param name="outputAdapterCollection">Collection of output adapters at start of routing table calculation.</param> /// <remarks> /// Set the <paramref name="inputMeasurementKeysRestriction"/> to null to use full adapter routing demands. /// </remarks> protected virtual void HandleConnectOnDemandAdapters(ISet<MeasurementKey> inputMeasurementKeysRestriction, IInputAdapter[] inputAdapterCollection, IActionAdapter[] actionAdapterCollection, IOutputAdapter[] outputAdapterCollection) { ISet<IAdapter> dependencyChain; ISet<MeasurementKey> inputSignals; ISet<MeasurementKey> outputSignals; ISet<MeasurementKey> requestedInputSignals; ISet<MeasurementKey> requestedOutputSignals; if (inputMeasurementKeysRestriction.Any()) { // When an input signals restriction has been defined, determine the set of adapters // by walking the dependency chain of the restriction dependencyChain = TraverseDependencyChain(inputMeasurementKeysRestriction, inputAdapterCollection, actionAdapterCollection, outputAdapterCollection); } else { // Determine the set of adapters in the dependency chain for all adapters in the system dependencyChain = TraverseDependencyChain(inputAdapterCollection, actionAdapterCollection, outputAdapterCollection); } // Get the full set of requested input and output signals in the entire dependency chain inputSignals = new HashSet<MeasurementKey>(dependencyChain.SelectMany(adapter => adapter.InputMeasurementKeys())); outputSignals = new HashSet<MeasurementKey>(dependencyChain.SelectMany(adapter => adapter.OutputMeasurementKeys())); // Turn connect on demand input adapters on or off based on whether they are part of the dependency chain if ((object)inputAdapterCollection != null) { foreach (IInputAdapter inputAdapter in inputAdapterCollection) { if (!inputAdapter.AutoStart) { if (dependencyChain.Contains(inputAdapter)) { requestedOutputSignals = new HashSet<MeasurementKey>(inputAdapter.OutputMeasurementKeys()); requestedOutputSignals.IntersectWith(inputSignals); inputAdapter.RequestedOutputMeasurementKeys = requestedOutputSignals.ToArray(); inputAdapter.Enabled = true; } else { inputAdapter.RequestedOutputMeasurementKeys = null; inputAdapter.Enabled = false; } } } } // Turn connect on demand action adapters on or off based on whether they are part of the dependency chain if ((object)actionAdapterCollection != null) { foreach (IActionAdapter actionAdapter in actionAdapterCollection) { if (!actionAdapter.AutoStart) { if (dependencyChain.Contains(actionAdapter)) { if (actionAdapter.RespectInputDemands) { requestedInputSignals = new HashSet<MeasurementKey>(actionAdapter.InputMeasurementKeys()); requestedInputSignals.IntersectWith(outputSignals); actionAdapter.RequestedInputMeasurementKeys = requestedInputSignals.ToArray(); } if (actionAdapter.RespectOutputDemands) { requestedOutputSignals = new HashSet<MeasurementKey>(actionAdapter.OutputMeasurementKeys()); requestedOutputSignals.IntersectWith(inputSignals); actionAdapter.RequestedOutputMeasurementKeys = requestedOutputSignals.ToArray(); } actionAdapter.Enabled = true; } else { actionAdapter.RequestedInputMeasurementKeys = null; actionAdapter.RequestedOutputMeasurementKeys = null; actionAdapter.Enabled = false; } } } } // Turn connect on demand output adapters on or off based on whether they are part of the dependency chain if ((object)outputAdapterCollection != null) { foreach (IOutputAdapter outputAdapter in outputAdapterCollection) { if (!outputAdapter.AutoStart) { if (dependencyChain.Contains(outputAdapter)) { requestedInputSignals = new HashSet<MeasurementKey>(outputAdapter.OutputMeasurementKeys()); requestedInputSignals.IntersectWith(inputSignals); outputAdapter.RequestedInputMeasurementKeys = requestedInputSignals.ToArray(); outputAdapter.Enabled = true; } else { outputAdapter.RequestedInputMeasurementKeys = null; outputAdapter.Enabled = false; } } } } }
public BulkImageResizer(IInputAdapter inputAdapter) { this.inputAdapter = inputAdapter; }
public InputManger(IInputAdapter adapter) { _inputAdapter = adapter ?? throw new NullReferenceException(); }
public DefaultUpdateVisitor(IInputAdapter inputAdapter) { this.inputAdapter = inputAdapter; }
private void Start() { audioSource = salidaDeSonido.GetComponent <AudioSource>(); input = GetComponent <InputStragety>().GetInput(); logicShooting = new LogicShooting(this); }
public void ProcessInput(IInputAdapter adapter, Ray ray, dfControl control, bool retainFocusSetting) { Vector2 mousePosition = adapter.GetMousePosition(); this.buttonsDown = dfMouseButtons.None; this.buttonsReleased = dfMouseButtons.None; this.buttonsPressed = dfMouseButtons.None; dfInputManager.MouseInputManager.getMouseButtonInfo(adapter, ref this.buttonsDown, ref this.buttonsReleased, ref this.buttonsPressed); float axis = adapter.GetAxis("Mouse ScrollWheel"); if (!Mathf.Approximately(axis, 0f)) { axis = Mathf.Sign(axis) * Mathf.Max(1f, Mathf.Abs(axis)); } this.mouseMoveDelta = mousePosition - this.lastPosition; this.lastPosition = mousePosition; if (this.dragState == dfDragDropState.Dragging) { if (this.buttonsReleased == dfMouseButtons.None) { if (control == this.activeControl) { return; } if (control == this.lastDragControl) { if (control != null && Vector2.Distance(mousePosition, this.lastPosition) > 1f) { dfDragEventArgs dfDragEventArg = new dfDragEventArgs(control, this.dragState, this.dragData, ray, mousePosition); control.OnDragOver(dfDragEventArg); } return; } if (this.lastDragControl != null) { dfDragEventArgs dfDragEventArg1 = new dfDragEventArgs(this.lastDragControl, this.dragState, this.dragData, ray, mousePosition); this.lastDragControl.OnDragLeave(dfDragEventArg1); } if (control != null) { dfDragEventArgs dfDragEventArg2 = new dfDragEventArgs(control, this.dragState, this.dragData, ray, mousePosition); control.OnDragEnter(dfDragEventArg2); } this.lastDragControl = control; return; } if (!(control != null) || !(control != this.activeControl)) { dfDragDropState _dfDragDropState = (control != null ? dfDragDropState.Cancelled : dfDragDropState.CancelledNoTarget); dfDragEventArgs dfDragEventArg3 = new dfDragEventArgs(this.activeControl, _dfDragDropState, this.dragData, ray, mousePosition); this.activeControl.OnDragEnd(dfDragEventArg3); } else { dfDragEventArgs dfDragEventArg4 = new dfDragEventArgs(control, dfDragDropState.Dragging, this.dragData, ray, mousePosition); control.OnDragDrop(dfDragEventArg4); if (!dfDragEventArg4.Used || dfDragEventArg4.State == dfDragDropState.Dragging) { dfDragEventArg4.State = dfDragDropState.Cancelled; } dfDragEventArg4 = new dfDragEventArgs(this.activeControl, dfDragEventArg4.State, dfDragEventArg4.Data, ray, mousePosition) { Target = control }; this.activeControl.OnDragEnd(dfDragEventArg4); } this.dragState = dfDragDropState.None; this.lastDragControl = null; this.activeControl = null; this.lastClickTime = 0f; this.lastHoverTime = 0f; this.lastPosition = mousePosition; return; } if (this.buttonsReleased != dfMouseButtons.None) { this.lastHoverTime = Time.realtimeSinceStartup + 0.25f; if (this.activeControl == null) { this.setActive(control, mousePosition, ray); return; } if (this.activeControl == control && this.buttonsDown == dfMouseButtons.None) { if (Time.realtimeSinceStartup - this.lastClickTime >= 0.25f) { this.lastClickTime = Time.realtimeSinceStartup; this.activeControl.OnClick(new dfMouseEventArgs(this.activeControl, this.buttonsReleased, 1, ray, mousePosition, axis)); } else { this.lastClickTime = 0f; this.activeControl.OnDoubleClick(new dfMouseEventArgs(this.activeControl, this.buttonsReleased, 1, ray, mousePosition, axis)); } } this.activeControl.OnMouseUp(new dfMouseEventArgs(this.activeControl, this.buttonsReleased, 0, ray, mousePosition, axis)); if (this.buttonsDown == dfMouseButtons.None && this.activeControl != control) { this.setActive(null, mousePosition, ray); } return; } if (this.buttonsPressed != dfMouseButtons.None) { this.lastHoverTime = Time.realtimeSinceStartup + 0.25f; if (this.activeControl == null) { this.setActive(control, mousePosition, ray); if (control != null) { control.OnMouseDown(new dfMouseEventArgs(control, this.buttonsPressed, 0, ray, mousePosition, axis)); } else if (!retainFocusSetting) { dfControl activeControl = dfGUIManager.ActiveControl; if (activeControl != null) { activeControl.Unfocus(); } } } else { this.activeControl.OnMouseDown(new dfMouseEventArgs(this.activeControl, this.buttonsPressed, 0, ray, mousePosition, axis)); } return; } if (this.activeControl != null && this.activeControl == control && this.mouseMoveDelta.magnitude == 0f && Time.realtimeSinceStartup - this.lastHoverTime > 0.1f) { this.activeControl.OnMouseHover(new dfMouseEventArgs(this.activeControl, this.buttonsDown, 0, ray, mousePosition, axis)); this.lastHoverTime = Time.realtimeSinceStartup; } if (this.buttonsDown == dfMouseButtons.None) { if (axis != 0f && control != null) { this.setActive(control, mousePosition, ray); control.OnMouseWheel(new dfMouseEventArgs(control, this.buttonsDown, 0, ray, mousePosition, axis)); return; } this.setActive(control, mousePosition, ray); } else if (this.activeControl != null) { if (control != null) { control.RenderOrder <= this.activeControl.RenderOrder; } if (this.mouseMoveDelta.magnitude >= 2f && (this.buttonsDown & (dfMouseButtons.Left | dfMouseButtons.Right)) != dfMouseButtons.None && this.dragState != dfDragDropState.Denied) { dfDragEventArgs dfDragEventArg5 = new dfDragEventArgs(this.activeControl) { Position = mousePosition }; this.activeControl.OnDragStart(dfDragEventArg5); if (dfDragEventArg5.State == dfDragDropState.Dragging) { this.dragState = dfDragDropState.Dragging; this.dragData = dfDragEventArg5.Data; return; } this.dragState = dfDragDropState.Denied; } } if (this.activeControl != null && this.mouseMoveDelta.magnitude >= 1f) { dfMouseEventArgs dfMouseEventArg = new dfMouseEventArgs(this.activeControl, this.buttonsDown, 0, ray, mousePosition, axis) { MoveDelta = this.mouseMoveDelta }; this.activeControl.OnMouseMove(dfMouseEventArg); } }
/// <summary> /// Determines the set of adapters in the dependency chain for all adapters in the system which are either not connect or demand or are demanded. /// </summary> /// <param name="inputAdapterCollection">Collection of input adapters at start of routing table calculation.</param> /// <param name="actionAdapterCollection">Collection of action adapters at start of routing table calculation.</param> /// <param name="outputAdapterCollection">Collection of output adapters at start of routing table calculation.</param> protected virtual ISet<IAdapter> TraverseDependencyChain(IInputAdapter[] inputAdapterCollection, IActionAdapter[] actionAdapterCollection, IOutputAdapter[] outputAdapterCollection) { ISet<IAdapter> dependencyChain = new HashSet<IAdapter>(); if ((object)inputAdapterCollection != null) { foreach (IInputAdapter inputAdapter in inputAdapterCollection) { if (inputAdapter.AutoStart && !dependencyChain.Contains(inputAdapter)) AddInputAdapter(inputAdapter, dependencyChain, inputAdapterCollection, actionAdapterCollection, outputAdapterCollection); } } if ((object)actionAdapterCollection != null) { foreach (IActionAdapter actionAdapter in actionAdapterCollection) { if (actionAdapter.AutoStart && !dependencyChain.Contains(actionAdapter)) AddActionAdapter(actionAdapter, dependencyChain, inputAdapterCollection, actionAdapterCollection, outputAdapterCollection); } } if ((object)outputAdapterCollection != null) { foreach (IOutputAdapter outputAdapter in outputAdapterCollection) { if (outputAdapter.AutoStart && !dependencyChain.Contains(outputAdapter)) AddOutputAdapter(outputAdapter, dependencyChain, inputAdapterCollection, actionAdapterCollection, outputAdapterCollection); } } return dependencyChain; }
// Start is called before the first frame update void Start() { rigidbody2D = GetComponent <Rigidbody2D>(); input = GetComponent <InputStragety>().GetInput(); logicMovment = new LogicMovment(this); }
public void Configure() { _input = GetComponent <PacmanOfMap>().InputStragety.GetInput(); }