Example #1
0
        private void Update()
        {
            bool        isDown       = Input.GetMouseButton(0);
            EInputPhase currentPhase = (EInputPhase)Phase.GetValue();
            EInputPhase newPhase     = EInputPhase.None;

            if (isDown)
            {
                switch (currentPhase)
                {
                case EInputPhase.None:
                    newPhase = EInputPhase.Begin;
                    break;

                case EInputPhase.Begin:
                    newPhase = EInputPhase.Hold;
                    break;

                case EInputPhase.Hold:
                    newPhase = EInputPhase.Hold;
                    break;
                }

                Vector2 oldPosition = Position.GetValue();
                Vector2 newPosition = Input.mousePosition;
                newPosition.y = m_Camera.pixelHeight;

                if (oldPosition != newPosition)
                {
                    Position.SetValue(newPosition);
                }
            }
            else
            {
                switch (currentPhase)
                {
                case EInputPhase.Hold:
                    newPhase = EInputPhase.End;
                    break;

                case EInputPhase.End:
                    newPhase = EInputPhase.None;
                    break;
                }
            }

            if (currentPhase != newPhase)
            {
                Phase.SetValue((int)newPhase);
                Debug.Log($"Input phase: {newPhase}");
            }
        }
Example #2
0
        protected override void HandleInput()
        {
            if (m_IsLeaving)
            {
                return;
            }

            EInputPhase phase = (EInputPhase)m_InputController.Phase.GetValue();

            if (phase == EInputPhase.End)
            {
                LeaveState();
                m_Animator.SetTrigger("tUp");
            }
        }
    //
    private void RaycastMouseInput(EInputPhase phase)
    {
        RaycastHit hit = new RaycastHit ();
        Ray ray ;

        ray = _mainCamera.ScreenPointToRay (Input.mousePosition);

        if(Physics.Raycast (ray, out hit, 1000, mask) )
        {
            CoreInputZone zone = hit.collider.GetComponent(typeof(CoreInputZone)) as CoreInputZone;

            if(zone == null)
                return;

            HandleTouchZone(zone, (Vector3)Input.mousePosition, phase);
        }
    }
Example #4
0
    //
    private void HandleTouchZone(CoreInputZone zone, Vector3 inputPos, EInputPhase phase)
    {
        zone.InputPos = inputPos;

        switch(phase)
        {
        case EInputPhase.BEGIN:
            zone.InputBegin();
            break;

        case EInputPhase.STAY:
            zone.InputStay();
            break;

        case EInputPhase.END:
            zone.InputEnd();
            break;
        }
    }
    //
    private void RaycastTouchInput(Touch touch, EInputPhase phase)
    {
        RaycastHit hit = new RaycastHit ();
        Ray ray ;

        ray = _mainCamera.ScreenPointToRay (touch.position);

        if(Physics.Raycast (ray, out hit, mask) )
        {
            CoreInputZone zone = hit.collider.GetComponent(typeof(CoreInputZone)) as CoreInputZone;

            if(zone == null)
                return;

            zone.CurrentTouch = touch;

            HandleTouchZone(zone, zone.InputPos, phase);
        }
    }