コード例 #1
0
    /// <summary>
    /// handle touch event when this component
    /// is no longer being touched
    /// </summary>
    public override void TouchesFinished(vp_Touch touch)
    {
        if (LastFingerID != touch.FingerID)
        {
            return;
        }

        base.TouchesFinished(touch);

        if (Manager.Player.CurrentWeaponID.Get() > 0)
        {
            if (ChangeOnRelease)
            {
                SetWeapon(touch);
            }
            else
            {
                CurrentItemPosition();
            }
        }

        if (Time.time < m_TouchTime)
        {
            Manager.Player.SetWeapon.TryStart(Manager.Player.CurrentWeaponID.Get() == 0 ? m_LastWeaponID : 0);
        }
    }
コード例 #2
0
    /// <summary>
    /// Fired when a touch event occures
    /// </summary>
    protected override void TouchesBegan(vp_Touch touch)
    {
        if (LastFingerID != -1)
        {
            return;
        }

        if (m_ControllerType == vp_UITouchController.vp_TouchControllerType.StaticJoystick)
        {
            if (Physics.RaycastAll(m_Camera.ScreenPointToRay(touch.Position)).Where(hit => hit.collider == Knob.GetComponent <Collider>()).ToList().Count == 0)
            {
                return;
            }
        }

        if (!RaycastControl(touch))
        {
            return;
        }

        base.TouchesBegan(touch);

        if (m_ControllerType != vp_UITouchController.vp_TouchControllerType.StaticJoystick)
        {
            m_PanelTransform.position = m_Camera.ScreenToWorldPoint(touch.Position); // position joystick at touch
        }
        m_KnobArea.center = m_PanelTransform.position;                               // position the knob area at the joysticks center for constraining
    }
コード例 #3
0
    /// <summary>
    /// Finds position of touch in relation
    /// to where the touch started and decides to
    /// switch to the next or previous weapon if
    /// applicable
    /// </summary>
    protected virtual void SetWeapon(vp_Touch touch)
    {
        LastFingerID = -1;

        if (m_EquippedWeapons.Count > 1)
        {
            if (m_TouchDownPosition.x > m_Camera.ScreenToWorldPoint(touch.Position).x)      // next weapon
            {
                if (m_CurrentItem.Index <= m_EquippedWeapons.Count - 2)
                {
                    Manager.Player.SetNextWeapon.Try();
                }
                else
                {
                    CurrentItemPosition();
                }
            }
            else
            {
                if (m_CurrentItem.Index > 0)
                {
                    Manager.Player.SetPrevWeapon.Try();
                }
                else
                {
                    CurrentItemPosition();
                }
            }
        }
        else
        {
            CurrentItemPosition();
        }
    }
コード例 #4
0
    /// <summary>
    /// When a touch hits this control
    /// </summary>
    protected override void TouchesBegan(vp_Touch touch)
    {
        if (LastFingerID != -1)
        {
            return;
        }

        if (!RaycastControl(touch))
        {
            return;
        }

        base.TouchesBegan(touch);

        m_ButtonReleased = true;

        if (PressControl != null)
        {
            PressControl();
        }

        if (m_TapCount == 2 && DoublePressControl != null)
        {
            DoublePressControl();
        }
    }
コード例 #5
0
    /// <summary>
    /// When a touch is finished with this control
    /// </summary>
    public override void TouchesFinished( vp_Touch touch )
    {
        if ( LastFingerID != touch.FingerID )
            return;

        if((Event != vp_UIButtonState.OnRelease && Event != vp_UIButtonState.OnDoubleRelease) || !RaycastControl(touch))
            LastFingerID = -1;

        if(RaycastControl( touch ))
        {
            m_ButtonUp = true;

            if(ReleaseControl != null)
                ReleaseControl();

            if(m_TapCount == 2 && DoubleReleaseControl != null)
                DoubleReleaseControl();

            if(Event == vp_UIButtonState.OnDoubleRelease && m_TapCount != 2)
            {
                m_LastFingerID = -1;
                m_ButtonUp = false;
            }
        }

        m_ButtonOverride = false;
        m_ButtonReleased = true;
    }
コード例 #6
0
    /// <summary>
    /// When the joystick is moved
    /// </summary>
    protected override void TouchesMoved(vp_Touch touch)
    {
        if (LastFingerID != touch.FingerID)
        {
            return;
        }

        // adjust position and constrain to bounds
        Vector3 defaultPosition = Knob.position;
        Vector3 pos             = ConstrainToBounds(m_Camera.ScreenToWorldPoint(touch.Position));

        if (m_ControllerType == vp_UITouchController.vp_TouchControllerType.TouchPad)
        {
            HandlePadParticles(true);
            pos = m_Camera.ScreenToWorldPoint(touch.Position);
        }

        pos.z         = defaultPosition.z;
        Knob.position = pos;

        // a little math for the controls
        float   maxX     = (m_Knob.localSize.x - m_KnobArea.max.x) / 2;
        float   maxY     = (m_Knob.localSize.y - m_KnobArea.max.y) / 2;
        Vector3 distance = Knob.localPosition - m_DefaultKnobPosition;
        float   x        = Mathf.Clamp(distance.x / maxX, -1 - Deadzone.x, 1 + Deadzone.x);
        float   y        = Mathf.Clamp(distance.y / maxY, -1 - Deadzone.y, 1 + Deadzone.y);
        Vector2 movement = new Vector2(x, y);

        // adjust for threshold x
        if (movement.x <= Deadzone.x && movement.x >= -Deadzone.x)
        {
            movement.x = 0;
        }
        else if (movement.x > 0)
        {
            movement.x -= Deadzone.x;
        }
        else if (movement.x < 0)
        {
            movement.x += Deadzone.x;
        }

        // adjust for threshold y
        if (movement.y <= Deadzone.y && movement.y >= -Deadzone.y)
        {
            movement.y = 0;
        }
        else if (movement.y > 0)
        {
            movement.y -= Deadzone.y;
        }
        else if (movement.y < 0)
        {
            movement.y += Deadzone.y;
        }

        // set raw movement vector
        m_RawMove = movement;
    }
コード例 #7
0
    /// <summary>
    /// When the joystick is moved
    /// </summary>
    protected virtual void TouchesMoved(vp_Touch touch)
    {
        if (LastFingerID != touch.FingerID)
        {
            return;
        }

        m_LookVector = new Vector2(((touch.DeltaPosition * .25f) * RotationSensitivity.x).x, ((touch.DeltaPosition * .25f) * RotationSensitivity.y).y);
    }
コード例 #8
0
    /// <summary>
    /// When the joystick is stationary
    /// </summary>
    protected virtual void TouchesStationary(vp_Touch touch)
    {
        if (LastFingerID != touch.FingerID)
        {
            return;
        }

        m_LookVector = Vector2.zero;
    }
コード例 #9
0
    /// <summary>
    ///
    /// </summary>
    public override void TouchesFinished(vp_Touch touch)
    {
        if (LastFingerID != touch.FingerID)
        {
            return;
        }

        HandlePadParticles(false);

        Manager.Player.Run.TryStop();
        LastFingerID = -1;
    }
コード例 #10
0
ファイル: vp_UITouchLook.cs プロジェクト: Eynaliyev/KNOCKOUT
    /// <summary>
    /// When touch finished reset last finger id
    /// </summary>
    public override void TouchesFinished( vp_Touch touch )
    {
        if ( LastFingerID != touch.FingerID )
            return;

        base.TouchesFinished(touch);

        if(AutoPitchSpeed == 0)
            return;

        vp_Timer.In( AutoPitchDelay, delegate() {
            m_ShouldAutoPitch = true;
        }, m_AutoPitchTimer);
    }
コード例 #11
0
    /// <summary>
    /// execute when this control is touched
    /// </summary>
    protected override void TouchesBegan(vp_Touch touch)
    {
        if (LastFingerID != -1)
        {
            return;
        }

        if (!RaycastControl(touch))
        {
            return;
        }

        base.TouchesBegan(touch);

        m_ShouldAutoPitch = false;
        m_AutoPitchTimer.Cancel();
    }
コード例 #12
0
    /// <summary>
    /// sends touches events created from Input.touches
    /// </summary>
    protected virtual void InputTouches()
    {
        foreach (Touch touch in Input.touches)
        {
            vp_Touch vpTouch = new vp_Touch();
            vpTouch.FingerID      = touch.fingerId;
            vpTouch.Position      = touch.position;
            vpTouch.DeltaPosition = touch.deltaPosition;

            // touch began
            if (touch.phase != TouchPhase.Canceled && touch.phase == TouchPhase.Began && TouchEventBindings["TouchesBegan"] != null)
            {
                TouchEventBindings["TouchesBegan"](vpTouch);
            }

            // touch moved
            if (touch.phase == TouchPhase.Moved && TouchEventBindings["TouchesMoved"] != null)
            {
                TouchEventBindings["TouchesMoved"](vpTouch);
            }

            // has a touched but not moving
            if (touch.phase == TouchPhase.Stationary && TouchEventBindings["TouchesStationary"] != null)
            {
                TouchEventBindings["TouchesStationary"](vpTouch);
            }

            // touch ended
            if (touch.phase == TouchPhase.Ended && TouchEventBindings["TouchesEnded"] != null)
            {
                TouchEventBindings["TouchesEnded"](vpTouch);
            }

            // touch canceled
            if (touch.phase == TouchPhase.Canceled && TouchEventBindings["TouchesCancelled"] != null)
            {
                TouchEventBindings["TouchesCancelled"](vpTouch);
            }

            // touch finished with TouchPhase.Ended or TouchPhase.Canceled
            if (touch.phase == TouchPhase.Ended || touch.phase == TouchPhase.Canceled && TouchEventBindings["TouchesFinished"] != null)
            {
                TouchEventBindings["TouchesFinished"](vpTouch);
            }
        }
    }
コード例 #13
0
    /// <summary>
    /// processed when a touch with this finger id is moved
    /// </summary>
    protected virtual void TouchesMoved(vp_Touch touch)
    {
        if (RequireStayInBounds && (Event == vp_UIButtonState.OnDoubleRelease || Event == vp_UIButtonState.OnRelease) && LastFingerID != 1)
        {
            if (!RaycastControl(touch))
            {
                LastFingerID = -1;
            }
        }

        if (!OverrideTouches)
        {
            return;
        }

        if (Manager == null)
        {
            return;
        }

        if (!RaycastControl(touch))
        {
            return;
        }

        if (!Manager.FingerIDs.ContainsKey(touch.FingerID))
        {
            return;
        }

        if (m_ButtonOverride)
        {
            return;
        }

        List <vp_UIControl> controls = Manager.FingerIDs[touch.FingerID];

        for (int i = 0; i < controls.Count; i++)
        {
            controls[i].TouchesFinished(touch);
        }

        LastFingerID     = touch.FingerID;
        m_ButtonOverride = true;
    }
コード例 #14
0
    /// <summary>
    /// handle touch event when this component
    /// is no longer being touched
    /// </summary>
    public override void TouchesFinished( vp_Touch touch )
    {
        if ( LastFingerID != touch.FingerID )
            return;

        base.TouchesFinished(touch);

        if(Manager.Player.CurrentWeaponIndex.Get() > 0)
        {
           		if(ChangeOnRelease)
                SetWeapon(touch);
            else
                CurrentItemPosition();
        }

        if(Time.time < m_TouchTime)
            Manager.Player.SetWeapon.TryStart(Manager.Player.CurrentWeaponIndex.Get() == 0 ? m_LastWeaponID : 0);
    }
コード例 #15
0
    /// <summary>
    /// When touch finished reset last finger id
    /// </summary>
    public override void TouchesFinished(vp_Touch touch)
    {
        if (LastFingerID != touch.FingerID)
        {
            return;
        }

        base.TouchesFinished(touch);

        if (AutoPitchSpeed == 0)
        {
            return;
        }

        vp_Timer.In(AutoPitchDelay, delegate() {
            m_ShouldAutoPitch = true;
        }, m_AutoPitchTimer);
    }
コード例 #16
0
    /// <summary>
    /// Executes when this control loses focus
    /// </summary>
    public virtual void TouchesFinished(vp_Touch touch)
    {
        if (LastFingerID != touch.FingerID)
        {
            return;
        }

        if (ReleaseControl != null)
        {
            ReleaseControl();
        }

        if (m_TapCount == 2 && DoubleReleaseControl != null)
        {
            DoubleReleaseControl();
        }

        LastFingerID = -1;
    }
コード例 #17
0
    /// <summary>
    /// Process the mouse input
    /// </summary>
    protected virtual void InputMouse()
    {
        if (!Application.isEditor)
        {
            return;
        }

        if (Input.GetMouseButton(0) || Input.GetMouseButtonDown(0) || Input.GetMouseButtonUp(0))
        {
            vp_Touch touch = new vp_Touch();
            touch.FingerID      = 0;
            touch.Position      = Input.mousePosition;
            touch.DeltaPosition = new Vector2(Input.GetAxisRaw("Mouse X"), Input.GetAxisRaw("Mouse Y")) * 4;

            if (Input.GetMouseButtonDown(0) && TouchEventBindings["TouchesBegan"] != null)
            {
                TouchEventBindings["TouchesBegan"](touch);
            }

            if (Input.GetMouseButton(0) && TouchEventBindings["TouchesMoved"] != null)
            {
                TouchEventBindings["TouchesMoved"](touch);
            }

            if (touch.DeltaPosition == Vector2.zero && Input.GetMouseButton(0) && TouchEventBindings["TouchesStationary"] != null)
            {
                TouchEventBindings["TouchesStationary"](touch);
            }

            if (Input.GetMouseButtonUp(0))
            {
                if (TouchEventBindings["TouchesEnded"] != null)
                {
                    TouchEventBindings["TouchesEnded"](touch);
                }
                if (TouchEventBindings["TouchesFinished"] != null)
                {
                    TouchEventBindings["TouchesFinished"](touch);
                }
            }
        }
    }
コード例 #18
0
    /// <summary>
    /// handle touch event when touch begins
    /// </summary>
    protected override void TouchesBegan(vp_Touch touch)
    {
        if (LastFingerID != -1)
        {
            return;
        }

        if (WeaponScroller == null)
        {
            return;
        }

        if (Physics.RaycastAll(m_Camera.ScreenPointToRay(touch.Position)).Where(hit => hit.collider == m_Collider).ToList().Count == 0)
        {
            return;
        }

        m_TouchDownPosition = m_Camera.ScreenToWorldPoint(touch.Position);
        LastFingerID        = touch.FingerID;
        m_TouchTime         = Time.time + WieldTouchDelay;
    }
コード例 #19
0
    /// <summary>
    /// execute when this control is touched
    /// </summary>
    protected virtual void TouchesBegan(vp_Touch touch)
    {
        if (m_Collider == null)
        {
            return;
        }

        if (LastFingerID != -1)
        {
            return;
        }

        if (!RaycastControl(touch))
        {
            return;
        }

        if (PressControl != null)
        {
            PressControl();
        }

        if (Time.time > m_DoubleTapTime)
        {
            m_TapCount = 0;
        }
        if (m_TapCount == 0)
        {
            m_DoubleTapTime = Time.time + (Manager != null ? Manager.DoubleTapTimeout : .25f);
        }
        m_TapCount++;

        if (m_TapCount == 2 && DoublePressControl != null)
        {
            DoublePressControl();
        }

        LastFingerID = touch.FingerID; // cache this finger id
    }
コード例 #20
0
    /// <summary>
    /// handles touch events when the touch is moved
    /// </summary>
    protected virtual void TouchesMoved(vp_Touch touch)
    {
        if (LastFingerID != touch.FingerID)
        {
            return;
        }

        if (Manager.Player.CurrentWeaponID.Get() == 0)
        {
            return;
        }

        Vector3 touchPosition = m_Camera.ScreenToWorldPoint(touch.Position) - m_TouchDownPosition;

        m_NewPosition = new Vector3(m_CachedScrollerPosition.x - m_CurrentItem.Transform.localPosition.x + (((m_CurrentItem.Transform.localScale.x * 2) + (ItemWidth * .5f) * m_EquippedWeapons.Count) * touchPosition.x), m_CachedScrollerPosition.y - m_CurrentItem.Transform.localPosition.y + (touchPosition.x * Angle), m_CachedScrollerPosition.z);

        if ((m_NewPosition - m_CurrentItemDefaultPosition).magnitude > ChangeWeaponThreshold)
        {
            SetWeapon(touch);
        }

        m_LastMoveTime = Time.time + .5f;
    }
コード例 #21
0
    /// <summary>
    /// When a touch is finished with this control
    /// </summary>
    public override void TouchesFinished(vp_Touch touch)
    {
        if (LastFingerID != touch.FingerID)
        {
            return;
        }

        if ((Event != vp_UIButtonState.OnRelease && Event != vp_UIButtonState.OnDoubleRelease) || !RaycastControl(touch))
        {
            LastFingerID = -1;
        }

        if (RaycastControl(touch))
        {
            m_ButtonUp = true;

            if (ReleaseControl != null)
            {
                ReleaseControl();
            }

            if (m_TapCount == 2 && DoubleReleaseControl != null)
            {
                DoubleReleaseControl();
            }

            if (Event == vp_UIButtonState.OnDoubleRelease && m_TapCount != 2)
            {
                m_LastFingerID = -1;
                m_ButtonUp     = false;
            }
        }

        m_ButtonOverride = false;
        m_ButtonReleased = true;
    }
コード例 #22
0
 /// <summary>
 /// Helper method that returns whether or
 /// not a touch hit this control
 /// </summary>
 public virtual bool RaycastControl(vp_Touch touch)
 {
     return(Physics.RaycastAll(m_Camera.ScreenPointToRay(touch.Position)).Where(hit => hit.collider == m_Collider).ToList().Count > 0);
 }
コード例 #23
0
ファイル: vp_UITouchLook.cs プロジェクト: Eynaliyev/KNOCKOUT
    /// <summary>
    /// execute when this control is touched
    /// </summary>
    protected override void TouchesBegan( vp_Touch touch )
    {
        if(LastFingerID != -1)
            return;

        if(!RaycastControl(touch))
            return;

        base.TouchesBegan( touch );

        m_ShouldAutoPitch = false;
        m_AutoPitchTimer.Cancel();
    }
コード例 #24
0
ファイル: vp_UITouchLook.cs プロジェクト: Eynaliyev/KNOCKOUT
    /// <summary>
    /// When the joystick is moved
    /// </summary>
    protected virtual void TouchesMoved( vp_Touch touch )
    {
        if ( LastFingerID != touch.FingerID )
            return;

        m_LookVector = new Vector2(((touch.DeltaPosition*.25f)*RotationSensitivity.x).x, ((touch.DeltaPosition*.25f)*RotationSensitivity.y).y);
    }
コード例 #25
0
ファイル: vp_UITouchLook.cs プロジェクト: Eynaliyev/KNOCKOUT
    /// <summary>
    /// When the joystick is stationary
    /// </summary>
    protected virtual void TouchesStationary( vp_Touch touch )
    {
        if ( LastFingerID != touch.FingerID )
            return;

        m_LookVector = Vector2.zero;
    }
コード例 #26
0
    /// <summary>
    /// When a touch hits this control
    /// </summary>
    protected override void TouchesBegan( vp_Touch touch )
    {
        if(LastFingerID != -1)
            return;

        if(!RaycastControl(touch))
            return;

        base.TouchesBegan(touch);

        m_ButtonReleased = true;

        if(PressControl != null)
            PressControl();

        if(m_TapCount == 2 && DoublePressControl != null)
            DoublePressControl();
    }
コード例 #27
0
    /// <summary>
    /// handles touch events when the touch is moved
    /// </summary>
    protected virtual void TouchesMoved( vp_Touch touch )
    {
        if ( LastFingerID != touch.FingerID )
            return;

        if(Manager.Player.CurrentWeaponIndex.Get() == 0)
            return;

        Vector3 touchPosition = m_Camera.ScreenToWorldPoint( touch.Position ) - m_TouchDownPosition;

        if (m_CurrentItem == null)
            Debug.LogError("Error(" + this + ") m_CurrentItem is null. Please make sure you have added weapon icon gameobjects under the 'WeaponScroller' gameobject. There should be one icon object corresponding to each weapon under the weapon camera (same names).");

        if (m_EquippedWeapons == null)
            Debug.LogError("Error(" + this + ") m_EquippedWeapons is null.");

        m_NewPosition = new Vector3(
            m_CachedScrollerPosition.x - m_CurrentItem.Transform.localPosition.x + (((m_CurrentItem.Transform.localScale.x*2)+(ItemWidth*.5f) * m_EquippedWeapons.Count) * touchPosition.x),
            m_CachedScrollerPosition.y - m_CurrentItem.Transform.localPosition.y + (touchPosition.x * Angle),
            m_CachedScrollerPosition.z);

        if((m_NewPosition-m_CurrentItemDefaultPosition).magnitude > ChangeWeaponThreshold)
            SetWeapon(touch);

        m_LastMoveTime = Time.time + .5f;
    }
コード例 #28
0
    /// <summary>
    /// Finds position of touch in relation
    /// to where the touch started and decides to
    /// switch to the next or previous weapon if
    /// applicable
    /// </summary>
    protected virtual void SetWeapon( vp_Touch touch )
    {
        LastFingerID = -1;

        if(m_EquippedWeapons.Count > 1)
        {
            if(m_TouchDownPosition.x > m_Camera.ScreenToWorldPoint( touch.Position ).x) // next weapon
            {
                if(m_CurrentItem.Index <= m_EquippedWeapons.Count - 2)
                    Manager.Player.SetNextWeapon.Try();
                else
                    CurrentItemPosition();
            }
            else
            {
                if(m_CurrentItem.Index > 0)
                    Manager.Player.SetPrevWeapon.Try();
                else
                    CurrentItemPosition();
            }
        }
        else
        {
            CurrentItemPosition();
        }
    }
コード例 #29
0
ファイル: vp_InputMobile.cs プロジェクト: Eynaliyev/KNOCKOUT
    /// <summary>
    /// sends touches events created from Input.touches
    /// </summary>
    protected virtual void InputTouches()
    {
        foreach(Touch touch in Input.touches)
        {
            vp_Touch vpTouch = new vp_Touch();
            vpTouch.FingerID = touch.fingerId;
            vpTouch.Position = touch.position;
            vpTouch.DeltaPosition = touch.deltaPosition;

            // touch began
            if(touch.phase != TouchPhase.Canceled && touch.phase == TouchPhase.Began && TouchEventBindings["TouchesBegan"] != null)
                TouchEventBindings["TouchesBegan"](vpTouch);

            // touch moved
            if(touch.phase == TouchPhase.Moved && TouchEventBindings["TouchesMoved"] != null)
                TouchEventBindings["TouchesMoved"](vpTouch);

            // has a touched but not moving
            if(touch.phase == TouchPhase.Stationary && TouchEventBindings["TouchesStationary"] != null)
                TouchEventBindings["TouchesStationary"](vpTouch);

            // touch ended
            if(touch.phase == TouchPhase.Ended && TouchEventBindings["TouchesEnded"] != null)
                TouchEventBindings["TouchesEnded"](vpTouch);

            // touch canceled
            if(touch.phase == TouchPhase.Canceled && TouchEventBindings["TouchesCancelled"] != null)
                TouchEventBindings["TouchesCancelled"](vpTouch);

            // touch finished with TouchPhase.Ended or TouchPhase.Canceled
            if(touch.phase == TouchPhase.Ended || touch.phase == TouchPhase.Canceled && TouchEventBindings["TouchesFinished"] != null)
                TouchEventBindings["TouchesFinished"](vpTouch);
        }
    }
コード例 #30
0
ファイル: vp_UIControl.cs プロジェクト: Eynaliyev/KNOCKOUT
    /// <summary>
    /// execute when this control is touched
    /// </summary>
    protected virtual void TouchesBegan( vp_Touch touch )
    {
        if(m_Collider == null)
            return;

        if(LastFingerID != -1)
            return;

        if(!RaycastControl(touch))
            return;

        if(PressControl != null)
            PressControl();

        if(Time.time > m_DoubleTapTime) m_TapCount = 0;
        if(m_TapCount == 0) m_DoubleTapTime = Time.time + (Manager != null ? Manager.DoubleTapTimeout : .25f);
        m_TapCount++;

        if(m_TapCount == 2 && DoublePressControl != null)
            DoublePressControl();

        LastFingerID = touch.FingerID; // cache this finger id
    }
コード例 #31
0
ファイル: vp_UIControl.cs プロジェクト: Eynaliyev/KNOCKOUT
    /// <summary>
    /// Executes when this control loses focus
    /// </summary>
    public virtual void TouchesFinished( vp_Touch touch )
    {
        if ( LastFingerID != touch.FingerID )
            return;

        if(ReleaseControl != null)
            ReleaseControl();

        if(m_TapCount == 2 && DoubleReleaseControl != null)
            DoubleReleaseControl();

        LastFingerID = -1;
    }
コード例 #32
0
    /// <summary>
    /// handle touch event when touch begins
    /// </summary>
    protected override void TouchesBegan( vp_Touch touch )
    {
        if(LastFingerID != -1)
            return;

        if(WeaponScroller == null)
            return;

        if(Physics.RaycastAll(m_Camera.ScreenPointToRay(touch.Position)).Where(hit => hit.collider == m_Collider).ToList().Count == 0)
            return;

        m_TouchDownPosition = m_Camera.ScreenToWorldPoint( touch.Position );
        LastFingerID = touch.FingerID;
        m_TouchTime = Time.time + WieldTouchDelay;
    }
コード例 #33
0
    /// <summary>
    /// processed when a touch with this finger id is moved
    /// </summary>
    protected virtual void TouchesMoved( vp_Touch touch )
    {
        if(RequireStayInBounds && (Event == vp_UIButtonState.OnDoubleRelease || Event == vp_UIButtonState.OnRelease) && LastFingerID != 1)
            if(!RaycastControl(touch))
                LastFingerID = -1;

        if(!OverrideTouches)
            return;

        if(Manager == null)
            return;

        if(!RaycastControl(touch))
            return;

        if(!Manager.FingerIDs.ContainsKey(touch.FingerID))
            return;

        if(m_ButtonOverride)
            return;

        List<vp_UIControl> controls = Manager.FingerIDs[touch.FingerID];
        for(int i=0;i<controls.Count;i++)
            controls[i].TouchesFinished( touch );

        LastFingerID = touch.FingerID;
        m_ButtonOverride = true;
    }
コード例 #34
0
ファイル: vp_UIControl.cs プロジェクト: Eynaliyev/KNOCKOUT
 /// <summary>
 /// Helper method that returns whether or
 /// not a touch hit this control
 /// </summary>
 public virtual bool RaycastControl( vp_Touch touch )
 {
     return Physics.RaycastAll(m_Camera.ScreenPointToRay(touch.Position)).Where(hit => hit.collider == m_Collider).ToList().Count > 0;
 }
コード例 #35
0
ファイル: vp_InputMobile.cs プロジェクト: Eynaliyev/KNOCKOUT
    /// <summary>
    /// Process the mouse input
    /// </summary>
    protected virtual void InputMouse()
    {
        if(!Application.isEditor)
            return;

        if(Input.GetMouseButton(0) || Input.GetMouseButtonDown(0) || Input.GetMouseButtonUp(0))
        {

            vp_Touch touch = new vp_Touch();
            touch.FingerID = 0;
            touch.Position = Input.mousePosition;
            touch.DeltaPosition = new Vector2(Input.GetAxisRaw("Mouse X"), Input.GetAxisRaw("Mouse Y")) * 4;

            if(Input.GetMouseButtonDown(0) && TouchEventBindings["TouchesBegan"] != null)
                TouchEventBindings["TouchesBegan"](touch);

            if(Input.GetMouseButton(0) && TouchEventBindings["TouchesMoved"] != null)
                TouchEventBindings["TouchesMoved"](touch);

            if(touch.DeltaPosition == Vector2.zero && Input.GetMouseButton(0) && TouchEventBindings["TouchesStationary"] != null)
                TouchEventBindings["TouchesStationary"](touch);

            if(Input.GetMouseButtonUp(0))
            {
                if(TouchEventBindings["TouchesEnded"] != null) TouchEventBindings["TouchesEnded"](touch);
                if(TouchEventBindings["TouchesFinished"] != null) TouchEventBindings["TouchesFinished"](touch);
            }
        }
    }