示例#1
0
    private void SwipeHandler(SwipeInfo swipeInfo)
    {
        if (0.1f < (1 - (swipeInfo.startPoint.x / swipeInfo.endPoint.x)) &&
            (1 - (swipeInfo.startPoint.x / swipeInfo.endPoint.x)) < 0.9f)
        {
            if (swipeInfo.startPoint.x < swipeInfo.endPoint.x)
            {
                Debug.Log("Derecha " + swipeInfo.startPoint.x + " " + swipeInfo.endPoint.x + " " + (swipeInfo.duration));
                motor.DoMove(1, Vector2.zero);
            }
        }

        if (0.1f < (1 - (swipeInfo.endPoint.x / swipeInfo.startPoint.x)) &&
            (1 - (swipeInfo.endPoint.x / swipeInfo.startPoint.x)) < 0.9f)
        {
            if (swipeInfo.startPoint.x > swipeInfo.endPoint.x)
            {
                Debug.Log("Izquierda " + swipeInfo.startPoint.x + " " + swipeInfo.endPoint.x + " " + (swipeInfo.duration));
                motor.DoMove(-1, Vector2.zero);
            }
        }



        if (0.25f < (1 - (swipeInfo.startPoint.y / swipeInfo.endPoint.y)) &&
            (1 - (swipeInfo.startPoint.y / swipeInfo.endPoint.y)) < 0.75f)
        {
            if (swipeInfo.duration < 0.1)
            {
                // Swipe Rápido resultando en un Hop
                motor.DoJump(0.5f, swipeInfo.endPoint);
            }
            else
            {
                // Swipe Lento resultando en un Jump
                motor.DoJump(1, swipeInfo.endPoint);
            }
        }
        else
        {
            // Swipe hacia abajo resultado en un slide
            motor.DoSlide(1, Vector2.zero);
        }
    }
示例#2
0
    void OnTriggerEnter(Collider other)
    {
        if (other.gameObject.tag == "Player")
        {
            _character = other.GetComponent("platformerControl") as platformerControl;

            if (DesiredAction == States.Run)
            {
                _character.DoMove(1, Vector2.zero);
            }
            else if (DesiredAction == States.Jump)
            {
                _character.DoJump(1f, Vector2.zero);
            }
            else if (DesiredAction == States.Slide)
            {
                _character.DoSlide(-1, Vector2.zero);
            }

            _character = null;
        }
    }
示例#3
0
 public void Left()
 {
     nextFire = Time.time + fireRate;
     motor.DoMove(-1, Vector2.zero);
 }