protected virtual void Update() { touches = Input.touches; for (int i = 0; i < touches.Length; i++) { if (touches[i].phase == TouchPhase.Began) { InputObserver.OnInputDown(new TouchInputArgs(touches[i].fingerId, touches[i], touches[i].position, touches[i].deltaPosition)); } if (touches[i].phase == TouchPhase.Moved) { InputObserver.OnInput(new TouchInputArgs(touches[i].fingerId, touches[i], touches[i].position, touches[i].deltaPosition)); } if (touches[i].phase == TouchPhase.Stationary) { InputObserver.OnInput(new TouchInputArgs(touches[i].fingerId, touches[i], touches[i].position, touches[i].deltaPosition)); } if (touches[i].phase == TouchPhase.Ended) { InputObserver.OnInputUp(new TouchInputArgs(touches[i].fingerId, touches[i], touches[i].position, touches[i].deltaPosition)); } if (touches[i].phase == TouchPhase.Canceled) { InputObserver.OnInputUp(new TouchInputArgs(touches[i].fingerId, touches[i], touches[i].position, touches[i].deltaPosition)); } } }
private void OnCompleted(object sender, EventArgs e) { InputObserver <Message> transport = (InputObserver <Message>)sender; transport.Unsubscribe(); observers.Remove(transport); }
protected virtual void Update() { for (int i = 0; i < joystickAxis.Length; i++) { joystickAxis[i] = Input.GetAxis("Joy1Axis" + (i + 1)); InputObserver.OnInput(new JoystickAxisInputArgs(i + 1, joystickAxis[i])); } }
protected override void Awake() { base.Awake(); m_InputObserver = new InputObserver(); #if UNITY_EDITOR m_InputObserver.RequireInputNotification(new InputObserverData(HandledInputs.KEY_R, ResetShotDebug), new InputObserverData(HandledInputs.KEY_D, DebugPerfectShot)); #endif }
public void AddInput(IInput <Message> transport) { var res = observers.Find(x => x.TransportName.Equals(transport.GetName())); if (!(res is null)) { return; } var tobserver = new InputObserver <Message>(transport.GetName()); tobserver.Subscribe(transport); tobserver.NextReceived += OnNext; tobserver.Completed += OnCompleted; tobserver.ExceptionReceived += OnException; observers.Add(tobserver); }
protected virtual void Update() { for (int i = 0; i < keyCodes.Length; i++) { if (Input.GetKeyDown(keyCodes[i])) { InputObserver.OnInputDown(new KeyInputArgs(keyCodes[i])); } if (Input.GetKey(keyCodes[i])) { InputObserver.OnInput(new KeyInputArgs(keyCodes[i])); } if (Input.GetKeyUp(keyCodes[i])) { InputObserver.OnInputUp(new KeyInputArgs(keyCodes[i])); } } }
protected virtual void Update() { if (Input.GetMouseButtonDown(0)) { InputObserver.OnInputDown(new MouseInputArgs(Input.mousePosition)); mouseButtonPosition = Input.mousePosition; } if (Input.GetMouseButton(0)) { Vector2 delta = (Vector2)Input.mousePosition - mouseButtonPosition; InputObserver.OnInput(new MouseInputArgs(Input.mousePosition, delta)); mouseButtonPosition = Input.mousePosition; } if (Input.GetMouseButtonUp(0)) { Vector2 delta = (Vector2)Input.mousePosition - mouseButtonPosition; InputObserver.OnInputUp(new MouseInputArgs(Input.mousePosition, delta)); } }
public void RemoveObserver(InputObserver observer) { this.observers.Remove (observer); }
public void AddObserver(InputObserver observer) { this.observers.Add (observer); }