public override void Execute(INotification notification) { RegisterTouchVO registerTouchVO = notification.Body as RegisterTouchVO; TouchProxy touchProxy = Facade.RetrieveProxy(TouchProxy.NAME) as TouchProxy; touchProxy.TouchEngineComponent.RegisterTouchDown(registerTouchVO.gameObject, registerTouchVO.includeChildren, registerTouchVO.callback); }
private void Update() { TouchProxy.Update(); #if UNITY_EDITOR if (Input.GetKeyDown(KeyCode.S)) { Application.CaptureScreenshot(string.Format("pix_it_all_{0}.png", System.DateTime.Now.Ticks)); } #endif }
private void Update() { if (IsDuringSmoothScale()) { UpdateSmoothZoom(); } if (TouchProxy.GetTouchCount() == 0) { UpdateSpring(); } }
protected bool GetFakeTouches(out TouchProxy[] touches) { touches = null; // Simulate touch with mouse (if any) TouchPhase tf = TouchPhase.Stationary; if (Input.GetMouseButtonDown(0)) { tf = TouchPhase.Began; } else if (Input.GetMouseButton(0)) { tf = TouchPhase.Moved; } else if (Input.GetMouseButtonUp(0)) { tf = TouchPhase.Ended; } else { return(false); } Vector2 mousePosition = new Vector2(Input.mousePosition.x, Input.mousePosition.y); if (Input.GetKey(KeyCode.LeftControl)) { touches = new TouchProxy[2]; if (tf == TouchPhase.Began) { m_fakeSecondPosition = new Vector2(mousePosition.x - 200, mousePosition.y); } touches [1] = new TouchProxy(m_fakeSecondPosition, tf, 1); } else { touches = new TouchProxy[1]; } touches [0] = new TouchProxy(mousePosition, tf, 0); return(true); }
public override void Execute(INotification notification) { TouchProxy touchProxy = Facade.RetrieveProxy(TouchProxy.NAME) as TouchProxy; TouchEngine touchEngine = (TouchEngine)notification.Body; GameObject touchEngineGameObject = touchProxy.TouchEngineGameObject; ITouchEngineComponent touchEngineComponent = touchProxy.TouchEngineComponent; if (touchEngineComponent != null) { touchEngineComponent.Destroy(); } if (touchEngineGameObject == null) { touchEngineGameObject = new GameObject("Touch"); } switch (touchEngine) { case TouchEngine.LeanTouch: touchEngineComponent = touchEngineGameObject.AddComponent <LeanTouchEngineComponent>(); break; default: touchEngineComponent = null; break; } if (touchEngineComponent == null) { return; } touchEngineComponent.Initialize(); touchProxy.TouchEngine = touchEngine; touchProxy.TouchEngineGameObject = touchEngineGameObject; touchProxy.TouchEngineComponent = touchEngineComponent; }
void PerformPan(TouchProxy touch) { Vector3 worldTouchPosition = m_camera.ScreenToWorldPoint(new Vector3(touch.m_position.x, touch.m_position.y, -m_camera.transform.position.z)); //Note down the touch ID and position when the touch begins... if (touch.m_phase == TouchPhase.Began) { m_scrollTouchID = touch.m_fingerId; m_panStartPosition = worldTouchPosition; } else if (touch.m_fingerId == m_scrollTouchID) { m_speed = -(worldTouchPosition - m_panStartPosition); m_speedAverageQueue.Enqueue(m_speed); } m_panPerformed = true; }
protected override void Awake() { Application.targetFrameRate = 60; TouchProxy.Init(); Options = new Options(); Options.Load(); Persistent = new Persistent(); Persistent.Load(); ImageManager = new ImageManager(); ImageManager.Init(); ImageManager.LoadImages(); PlayerProgress = new PlayerProgress(); Purchaser = new Purchaser(); Purchaser.PurchaseFinished += Purchaser_PurchaseFinished; Purchaser.InitializePurchasing(); }
void PerformZoom(TouchProxy touchZero, TouchProxy touchOne) { // Find the position in the previous frame of each touch. Vector2 touchZeroPrevPos = touchZero.m_position - touchZero.m_deltaPosition; Vector2 touchOnePrevPos = touchOne.m_position - touchOne.m_deltaPosition; // Find the magnitude of the vector (the distance) between the touches in each frame. float prevTouchDeltaMag = (touchZeroPrevPos - touchOnePrevPos).magnitude; float touchDeltaMag = (touchZero.m_position - touchOne.m_position).magnitude; // Find the difference in the distances between each frame. float deltaMagnitudeDiff = prevTouchDeltaMag - touchDeltaMag; // ... change the orthographic size based on the change in distance between the touches. m_camera.orthographicSize += deltaMagnitudeDiff * m_zoomSpeed; // Make sure the orthographic size never drops below zero. m_camera.orthographicSize = Mathf.Max(m_camera.orthographicSize, m_minSize); m_camera.orthographicSize = Mathf.Min(m_camera.orthographicSize, m_maxSize); m_zoomPerformed = true; }
// Use real touches if available, otherwise simulate touches with mouse. // Holding left control is used to simulate double finger touch protected bool GetTouches(out TouchProxy[] touches) { bool AnyTouch = GetRealTouches(out touches); if (!AnyTouch) { AnyTouch = GetFakeTouches(out touches); } if (AnyTouch) { // Average the positions (due to unity bug making touches update at another rate than frames) // Also calculate the delta position that correspond to this. for (int i = 0; i < touches.Length; i++) { TouchProxy t = touches [i]; if (t.m_phase == TouchPhase.Began) { id2positionAverage [t.m_fingerId] = new FixedSizedVector2Queue(3); id2positionAverage [t.m_fingerId].Enqueue(t.m_position); id2previousPosition [t.m_fingerId] = t.m_position; t.m_deltaPosition = new Vector2(0, 0); } else { id2positionAverage [t.m_fingerId].Enqueue(t.m_position); t.m_position = id2positionAverage [t.m_fingerId].Average(); t.m_deltaPosition = t.m_position - id2previousPosition [t.m_fingerId]; id2previousPosition [t.m_fingerId] = t.m_position; } } } return(AnyTouch); }
protected bool GetRealTouches(out TouchProxy[] touches) { touches = null; if (Input.touchCount == 0) { return(false); } touches = new TouchProxy[Input.touchCount]; for (int i = 0; i < Input.touchCount; i++) { Touch t = Input.touches [i]; touches [i] = new TouchProxy(t.position, t.phase, t.fingerId); if (i == 0) { m_fpsTouchHandle.text = "Touch FPS: " + (1f / t.deltaTime).ToString("N0"); } } return(true); }
public override void Execute(INotification notification) { TouchProxy touchProxy = Facade.RetrieveProxy(TouchProxy.NAME) as TouchProxy; touchProxy.TouchEngineComponent.UnRegisterAll(notification.Body as GameObject); }
public override Ssg.Touch GetTouch(int index) { return(TouchProxy.GetTouch(index)); }
public override int GetTouchCount() { return(TouchProxy.GetTouchCount()); }