Exemplo n.º 1
0
 public override void Apply(TouchEvent touchEvent)
 {
     if (touchEvent.GetCurrentState() == TouchPhase.Ended && IsTap(touchEvent))
     {
         Vector3 target;
         if (TouchUtils.TouchPositionToWorldCoords(touchEvent.GetStartPosition(), out target, hero.transform.position.y))
         {
             hero.MoveToTarget(target);
         }
     }
 }
Exemplo n.º 2
0
    private void StartSwipe(TouchEvent touchEvent)
    {
        Vector3 lookPosition;

        if (TouchUtils.TouchPositionToWorldCoords(touchEvent.GetEndPosition(), out lookPosition, 0.5f))
        {
            swipeStarted = true;
            hero.CancelMoveToTarget();
            hero.LookAt(lookPosition, attackTime);
            hero.StartSwipeAttack();
        }
    }
Exemplo n.º 3
0
    private IEnumerator DrawSwipeAttack(TouchEvent touchEvent, float swipeTime = 0.2f)
    {
        int            vertexCount = 0;
        List <Vector2> swipe       = smoothSwipeInput(simplifySwipeInput(touchEvent));

        foreach (Vector2 frame in swipe)
        {
            Vector3 currentTouchWorld;
            TouchUtils.TouchPositionToWorldCoords(frame, out currentTouchWorld, 0.5f);
            lineAttack.numPositions = vertexCount + 1;
            lineAttack.SetPosition(vertexCount++, currentTouchWorld);
            yield return(new WaitForSeconds(swipeTime / swipe.Count));
        }
        swipeStarted = false;
    }