Пример #1
0
 public void Release(LeanFinger finger)
 {
     StartCoroutine(ReleaseDelay(finger));
 }
Пример #2
0
 private void OnSelect(LeanFinger finger)
 {
     GameEvents.OnCellSelected(this);
 }
Пример #3
0
 private void OnFingerDown(LeanFinger obj)
 {
     _beginPos = obj.ScreenPosition;
 }
Пример #4
0
 private void FingerUp(LeanFinger finger)
 {
     CountDown._instance.ResetTime();
     pressTime = Time.time - pressTime;        //这里计算了手指从按下到抬起的时间差,如果小于0.2s,则认为是点击,否则是长按
     if (pressTime <= 0.2f)
     {
         ModelManager._instance.offCardQuad.SetActive(ModelManager._instance.isOffCard ? true : false);
         Ray        ray = ModelManager._instance.isOffCard ? ModelManager._instance.offCardCamera.ScreenPointToRay(finger.ScreenPosition) : Camera.main.ScreenPointToRay(finger.ScreenPosition);
         RaycastHit hitInfo;
         if (Physics.Raycast(ray, out hitInfo, 100))
         {
             GameObject gameObj = hitInfo.collider.gameObject;
             if (CurrentSelectable && gameObj.name.Equals(CurrentSelectable.name))
             {
                 //这里相当于点击中了物体,触发Tap事件
                 ModelSelfManager modelselfManager = CurrentSelectable.transform.GetComponent <ModelSelfManager> ();
                 if (modelselfManager)
                 {
                     modelselfManager.HandleTapEvent();
                     ModelManager._instance.currentRotationTransform = CurrentSelectable.transform;
                 }
                 if (CurrentSelectable != null)
                 {
                     if (CurrentSelectable.SelectingFinger == finger || CurrentSelectable.SelectingFinger == null)
                     {
                         Deselect();
                     }
                 }
                 return;
             }
             if (!FunctionModeleManager.Instance.TapWalk)
             {
                 return;
             }
             //确保点击了平面,点击了平面就是行走动画了。
             if (gameObj.name.Equals("Quad") || gameObj.name.Equals("OffCardQuad"))
             {
                 if (ModelManager._instance.isOffCard && ModelManager._instance.offCardModelTransform)
                 {
                     ModelSelfManager modelselfManager = ModelManager._instance.offCardModelTransform.GetComponent <ModelSelfManager> ();
                     if (modelselfManager)
                     {
                         ModelManager._instance.offCardModelIsMoving = true;
                         modelselfManager.HandleTapWalkEvent(finger);
                     }
                 }
                 else
                 {
                     if (ModelManager._instance.currentRotationTransform)
                     {
                         ModelSelfManager modelselfManager = ModelManager._instance.currentRotationTransform.GetComponent <ModelSelfManager> ();
                         if (modelselfManager)
                         {
                             ModelManager._instance.offCardQuad.SetActive(false);
                             ModelManager._instance.currentModelisMoving = true;
                             modelselfManager.HandleTapWalkEvent(finger);
                         }
                     }
                 }
             }
         }
         else
         {
             //没有碰到任何东西,直接忽略
             Utility.LogPrint("touch nothing");
         }
     }
     if (CurrentSelectable != null)
     {
         if (CurrentSelectable.SelectingFinger == finger || CurrentSelectable.SelectingFinger == null)
         {
             Deselect();
         }
     }
 }
Пример #5
0
 protected virtual void OnFingerSwipe(LeanFinger finger)
 {
 }
Пример #6
0
 public virtual void OnFingerSwipe(LeanFinger finger)
 {
 }
Пример #7
0
 private void LeanTouch_OnFingerSwipe(LeanFinger finger)
 {
     OnSwipe?.Invoke(finger.GetWorldPosition(10f), finger.SwipeScaledDelta);
 }
Пример #8
0
 protected override void OnSelect(LeanFinger finger)
 {
     outline.ShowHide_Outline(true);
     Canvas.OpenMainNodeMenu(gameObject);
 }
Пример #9
0
 public override void OnFingerTap(LeanFinger finger, int order, RaycastHit hit)
 {
     base.OnFingerTap(finger, order, hit);
     PerformHitTest(transform.InverseTransformPoint(hit.point));
 }
Пример #10
0
    public void Turn(LeanFinger finger)
    {
        var  tmpA   = tmpDAngle;
        bool rBreak = false;

        tmpDAngle = 0;


        if (canRotate)
        {
            canRotate = false;

            if (finger.Swipe)
            {
                Vector2 AB  = initTouchPos - scrCenter;
                Vector2 BC  = finger.LastScreenPosition - initTouchPos;
                float   ang = Vector2.SignedAngle(AB, BC);
                dir = Mathf.Sign(ang); //* -Mathf.Sign(wlPos.y);

                //if (!swipeSwitch)
                //    dir *= -initQuad.y;
            }
            else if (!finger.Tap)
            {
                var distMax = maxRot + initObjAng - tAngle;
                var distMin = Mathf.Abs(initObjAng - maxRot) + tAngle;
                var distCen = Mathf.Abs(Mathf.Abs(tAngle) - initObjAng);
                var dirRot  = tAngle > initObjAng
                            ?  1
                            : -1;

                //Debug.Log("DIST CEN: " + distCen);
                //Debug.Log("DIST MAX: " + distMax);
                //Debug.Log("Dist MIN: " + distMin);

                if (dirRot != Mathf.Sign(vAngle))
                {
                    if (distCen < distMax && distCen < distMin)
                    {
                        rBreak = true;/*    Debug.Log  ("Centro"); /**/
                    }
                    else if (distMax < distMin)
                    {
                        dir = 1;    /*    Debug.Log("Esquerda"); /**/
                    }
                    else if (distMin < distMax)
                    {
                        dir = -1;   /*    Debug.Log ("Direita"); /**/
                    }
                    else
                    {
                        rBreak = true;/*    Debug.Log  ("Centro"); /**/
                    }
                }
                //else { Debug.LogWarning("f"); }
            }
            else
            {
                //Debug.Log("Tap");
                dir = -initQuad.x;
                if (!swipeSwitch)
                {
                    dir *= -initQuad.y;
                }
            }


            //Debug.Log(finger.Tap + " " + dir + " " + rBreak);
            DOTween.KillAll();
            if ((finger.Swipe || Mathf.Abs(tmpA) > minRot || finger.Tap) && !rBreak)
            {
                //Debug.Log("Ang " + (Mathf.Abs(rAngle) > minRot));
                //Debug.Log                ("Swi " + finger.Swipe);
                //Debug.Log                         ("tap " + Tap);
                //Debug.Log                                  (dir);

                rBreak = false;
                rot   *= Quaternion.Euler(0, 0, turnAngle * dir);
            }

            tAngle = rot.eulerAngles.z;
            mObj.transform.DORotateQuaternion(rot, rTime).OnComplete(() => { canRotate = true; OnTurnEnd.Invoke(); }).SetEase(rotEase);
        }
    }
Пример #11
0
 public void OnSwipe(LeanFinger finger)
 {
 }
Пример #12
0
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using Lean;
using Lean.Touch;

public class swaping : MonoBehaviour {
  public Gridmanager gridmanager;
  protected virtual void OnEnable()
  {
    LeanTouch.OnFingerSwipe+=OnSwipe;

  }
  public void OnSwipe(LeanFinger finger)
  {

    swapTiles(finger);

  }

  // Use this for initialization
  void Start () {
		
	}
	
	// Update is called once per frame
	void Update () {
		
	}
  private void swapTiles(LeanFinger finger)
  {
      //this.transform;
      // get coord
      // get in array
      // swap with other from direction
      // left = 


      Debug.Log(finger);
      // droite

      Camera main = Camera.main;
      Vector3 ray = main.ScreenToWorldPoint(finger.StartScreenPosition);
      Vector2 mousePos2D = new Vector2(ray.x, ray.y);



      RaycastHit2D hit = Physics2D.Raycast(mousePos2D, Vector2.zero);
      Debug.Log(hit);
      if ( hit.collider!=null )  {

      Transform tmp = hit.transform;
      Transform [,] grid = gridmanager.getGrid( );
        Debug.Log("Something was clicked!");

         if ( finger.LastSnapshotScaledDelta.x>0 ) {
        gridmanager.moveRight(hit.transform);
        Debug.Log("droite");
          }
          if ( finger.LastSnapshotScaledDelta.x<0 )
          {
            Debug.Log("gauche");
          }
          //haut
          if ( finger.LastSnapshotScaledDelta.y>0 )
          {
            Debug.Log("haut");
          }
          if ( finger.LastSnapshotScaledDelta.y<0 )
          {
            Debug.Log("bas");
          }
          //if ( input.gettouch(0).deltaposition.x>0 )
          //{
          //  transform currenttmp = tile;
          //  moving currentmoving = tile.getcomponent<moving>( );
          //  grid [currentmoving.x, currentmoving.y]=grid [currentmoving.x+1, currentmoving.y];
          //  grid [currentmoving.x+1, currentmoving.y]=tile;


          //  debug.log("user is swiping to the right");
          //}
    }
  }
}

Пример #13
0
        private void OnLeftSwipe(LeanFinger finger)
        {
            Utils.LogConditional(nameof(InputManager) + " left swipe");

            Swiped?.Invoke(SwipeDirection.Left, finger.GetStartWorldPosition(-10));
        }
Пример #14
0
    protected virtual void OnFingerSet(LeanFinger finger)
    {
        var pos = game.camera.orthographic
            ? game.camera.ScreenToWorldPoint(finger.ScreenPosition)
            : game.camera.ScreenToWorldPoint(new Vector3(finger.ScreenPosition.x, finger.ScreenPosition.y, 10));

        // Query flick note
        if (FlickingNotes.ContainsKey(finger.Index))
        {
            var flickingNote = FlickingNotes[finger.Index];
            var cleared      = flickingNote.UpdateFingerPosition(pos);
            if (cleared)
            {
                FlickingNotes.Remove(finger.Index);
            }
        }

        // Query drag notes
        foreach (var note in TouchableDragNotes)
        {
            if (note == null)
            {
                continue;
            }
            if (note.DoesCollide(pos))
            {
                note.OnTouch(finger.ScreenPosition);
                break; // Query other notes too!
            }
        }

        // If this is a new finger
        if (!HoldingNotes.ContainsKey(finger.Index))
        {
            var switchedToNewNote = false; // If the finger holds a new note

            // Query unheld hold notes
            foreach (var note in TouchableHoldNotes)
            {
                if (note == null)
                {
                    continue;
                }
                if (note.DoesCollide(pos))
                {
                    HoldingNotes.Add(finger.Index, note);
                    note.UpdateFinger(finger.Index, true);
                    switchedToNewNote = true;
                    break;
                }
            }

            // Query held hold notes (i.e. multiple fingers on the same hold note)
            if (!switchedToNewNote)
            {
                foreach (var holdNote in HoldingNotes.Values.Where(holdNote => holdNote.DoesCollide(pos)))
                {
                    HoldingNotes.Add(finger.Index, holdNote);
                    holdNote.UpdateFinger(finger.Index, true);
                    break;
                }
            }
        }
        else // The finger is already holding a note
        {
            var holdNote = HoldingNotes[finger.Index];

            if (holdNote.IsCleared) // If cleared <-- This should be impossible since the note should have called OnNoteCollected
            {
                throw new InvalidOperationException();
                // HoldingNotes.Remove(finger.Index);
            }
            else if (!holdNote.DoesCollide(pos)) // If holding elsewhere
            {
                holdNote.UpdateFinger(finger.Index, false);
                HoldingNotes.Remove(finger.Index);
            }
        }
    }
Пример #15
0
 public virtual void OnFingerMove(LeanFinger finger)
 {
 }
Пример #16
0
 private void OnFingerTap(LeanFinger finger)
 {
     gameStarted = true;
     anim.SetBool("IsGrounded", false);
     rgBody.velocity = new Vector2(rgBody.velocity.x, jumpSpeed);
 }
Пример #17
0
 public virtual void OnFingerTap(LeanFinger finger)
 {
 }
Пример #18
0
 void OnFingerTap(LeanFinger finger)
 {
     StartCoroutine(Example());
 }
Пример #19
0
 public virtual void OnFingerSwipe(LeanFinger finger, int order, RaycastHit hit)
 {
     OnFingerSwipe(finger);
 }
Пример #20
0
    void HandleQuadrant(Quadrant theQuad, LeanFinger finger)
    {
        Direction swipeDirection = DetermineSwipeDirection(finger);

        if (swipeDirection == Direction.None)
        {
            Debug.LogWarning("Direction si null");
            return;
        }
        switch (theQuad)
        {
        //Top Half
        case Quadrant.First:
        case Quadrant.Second:
            if (swipeDirection == Direction.Up)
            {
                if (theQuad == Quadrant.Second)
                {
                    RotateLeft();
                }
                else
                {
                    RotateRight();
                }
            }
            else if (swipeDirection == Direction.Down)
            {
                if (theQuad == Quadrant.Second)
                {
                    RotateRight();
                }
                else
                {
                    RotateLeft();
                }
            }
            else if (swipeDirection == Direction.Left)
            {
                RotateLeft();
            }
            else if (swipeDirection == Direction.Right)
            {
                RotateRight();
            }
            break;

        //Bottom Half
        case Quadrant.Third:
        case Quadrant.Fourth:
            if (swipeDirection == Direction.Up)
            {
                if (theQuad == Quadrant.Third)
                {
                    RotateLeft();
                }
                else
                {
                    RotateRight();
                }
            }
            else if (swipeDirection == Direction.Down)
            {
                if (theQuad == Quadrant.Fourth)
                {
                    RotateLeft();
                }
                else
                {
                    RotateRight();
                }
            }
            else if (swipeDirection == Direction.Left)
            {
                RotateRight();
            }
            else if (swipeDirection == Direction.Right)
            {
                RotateLeft();
            }
            break;
        }
    }
Пример #21
0
 private void LeanTouch_OnFingerTap(LeanFinger finger)
 {
     OnTap?.Invoke(finger.GetWorldPosition(10f));
 }
Пример #22
0
 void HandleFingerTap(LeanFinger finger)
 {
     Debug.Log("我轻点了屏幕哦");
 }
Пример #23
0
 /// <summary>
 /// Event handler for finger down
 /// Handled by derived classes
 /// </summary>
 /// <param name="finger">finger that is down</param>
 protected virtual void OnFingerDown(LeanFinger finger)
 {
 }
Пример #24
0
 void HandleFingerLong(LeanFinger finger)
 {
     Debug.Log("我长按了屏幕哦");
 }
Пример #25
0
    private void OnFingerSet(LeanFinger finger)
    {
        var pos = Camera.main.ScreenToWorldPoint(finger.ScreenPosition);

        // Query chain notes
        foreach (var noteView in OnScreenChainNotes)
        {
            if (noteView == null)
            {
                continue;
            }
            if (noteView.OverlapPoint(pos))
            {
                noteView.Touch(finger.ScreenPosition);
                break; // Note that we want to query hold notes as well so break only
            }
        }

        if (!holdingNotes.ContainsKey(finger.Index))
        {
            var newHold = false;
            // Query again, this time looking for (unholded) hold notes
            foreach (var noteView in OnScreenHoldNotes)
            {
                if (noteView == null)
                {
                    continue;
                }
                if (noteView.OverlapPoint(pos))
                {
                    holdingNotes.Add(finger.Index, (HoldNoteView)noteView);
                    ((HoldNoteView)noteView).StartHoldBy(finger.Index);
                    newHold = true;
                    break;
                }
            }
            if (!newHold)
            {
                foreach (var entry in holdingNotes)
                {
                    var noteView = entry.Value;
                    if (noteView.OverlapPoint(pos))
                    {
                        holdingNotes.Add(finger.Index, noteView);
                        noteView.StartHoldBy(finger.Index);
                        break;
                    }
                }
            }
        }
        else
        {
            // Holding the note already
            var holdNote = holdingNotes[finger.Index];
            var released = false;

            // If note cleared
            if (holdNote.cleared)
            {
                holdingNotes.Remove(finger.Index);
                released = true;
            }
            else
            // If holding elsewhere
            if (!holdNote.OverlapPoint(pos))
            {
                holdNote.StopHoldBy(finger.Index);
                holdingNotes.Remove(finger.Index);
                released = true;
            }

            if (released)
            {
                holdNote.rankedNoteData.release_time = TimeExt.Millis();
                holdNote.rankedNoteData.release_x    = (int)finger.ScreenPosition.x;
                holdNote.rankedNoteData.release_y    = (int)finger.ScreenPosition.y;
            }
        }
    }
Пример #26
0
        private void OnFingerDown(LeanFinger finger)
        {
            var worldPos = finger.GetWorldPosition(10, mainCamera);

            Bus.OnFingerDown.Invoke(worldPos);
        }
Пример #27
0
 void press(LeanFinger finger)
 {
     Pressed = !Pressed;
 }
Пример #28
0
 // eat the unity specific mouse events
 //private void OnMouseDown() { }
 //private void OnMouseUp() { }
 public virtual void OnFingerDown(LeanFinger finger)
 {
 }
Пример #29
0
    public void OnFingerSetEraser(LeanFinger finger)
    {
        if (isEnabled)
        {
            Vector2 PosNow = finger.GetWorldPosition(10, Camera.current);
            for (int i = 0; i < ListLineRenderers.Count; i++)
            {
                Vector2[] Expectline         = ListLineRenderers[i].GetComponent <EdgeCollider2D>().points;
                int       indexForStartErase = -1;
                int       indexForEndErase   = -1;
                GetStartAndEndIndexs(ref indexForStartErase, ref indexForEndErase, Expectline, PosNow);
                if (indexForStartErase == -1)
                {
                    continue;
                }
                if (indexForEndErase != -1)
                {
                    List <Vector3> FirstArrayForLine             = new List <Vector3>();
                    List <Vector2> FirstArrayForLineForCollider  = new List <Vector2>();
                    List <Vector3> SecondArrayForLine            = new List <Vector3>();
                    List <Vector2> SecondArrayForLineForCollider = new List <Vector2>();


                    for (int ii = 0; ii < indexForStartErase; ii++)
                    {
                        FirstArrayForLine.Add(Expectline[ii]);
                        FirstArrayForLineForCollider.Add(Expectline[ii]);
                    }
                    for (int ii = indexForEndErase + 1; ii < Expectline.Length; ii++)
                    {
                        SecondArrayForLine.Add(Expectline[ii]);
                        SecondArrayForLineForCollider.Add(Expectline[ii]);
                    }
                    UpdateQuanityLines();

                    Destroy(ListLineRenderers[i]);
                    ListLineRenderers.RemoveAt(i);

                    GameObject lineRenderer;
                    if (FirstArrayForLine.Count >= 2 || SecondArrayForLine.Count >= 2)
                    {
                        if (FirstArrayForLine.Count >= 2)
                        {
                            lineRenderer = GameObject.Instantiate(LineRenderer);
                            lineRenderer.transform.parent = transform;
                            lineRenderer.GetComponent <LineRenderer>().positionCount =
                                FirstArrayForLine.ToArray().Length;
                            lineRenderer.GetComponent <LineRenderer>()
                            .SetPositions(FirstArrayForLine.ToArray());
                            lineRenderer.GetComponent <EdgeCollider2D>().points =
                                FirstArrayForLineForCollider.ToArray();
                            ListLineRenderers.Add(lineRenderer);
                        }
                        if (SecondArrayForLine.Count >= 2)
                        {
                            lineRenderer = GameObject.Instantiate(LineRenderer);
                            lineRenderer.transform.parent = transform;
                            lineRenderer.GetComponent <LineRenderer>().positionCount =
                                SecondArrayForLine.ToArray().Length;
                            lineRenderer.GetComponent <LineRenderer>()
                            .SetPositions(SecondArrayForLine.ToArray());
                            lineRenderer.GetComponent <EdgeCollider2D>().points =
                                SecondArrayForLineForCollider.ToArray();
                            ListLineRenderers.Add(lineRenderer);
                        }
                        break;
                    }
                }
            }
        }
    }
 public virtual void TapScreen(LeanFinger finger)
 {
     TapScreenVerify(finger.LastScreenPosition, finger);
 }