Пример #1
0
 public void OnPointerUp(PointerEventData data)
 {
     if (!twoTap && holdTime > 0)
     {
         Debug.Log("Pointerup");
         if (holdTime > 0.3f)
         {
             if (dragDelta < 0.6f && dragDelta / holdTime < 1.2f)
             {
                 if (hitCol != null && selectedType == 1)
                 {
                     if (hitCtrl != null)
                     {
                         if (hitCtrl.isLocalPlayer)
                         {
                             if (hitCtrl.transform == selected)
                             {
                                 Debug.Log("hold on self");
                                 hitCtrl.Stop();
                                 holdTime = -1;
                                 return;
                             }
                         }
                         Debug.Log("follow");
                         selected.GetComponent <MyController> ().MoveTo(hitCtrl.transform);
                         holdTime = -1;
                         return;
                     }
                     else if (selectedType == 1)
                     {
                         Debug.Log("normal move");
                         selected.GetComponent <MyController> ().MoveTo(hitPos);
                     }
                 }
                 else
                 {
                     Debug.Log("no hitcol or char unselected");
                 }
             }
             else if (dragDelta < 0.35f)
             {
                 Debug.Log("dragSpeed (inch/s) " + (dragDelta / holdTime));
             }
             else
             {
                 Debug.Log("drag " + dragDelta);
             }
         }
         else
         {
             Debug.Log("holdTime " + holdTime);
             if (hitCol != null)
             {
                 if (hitCtrl != null)
                 {
                     if (hitCtrl.isLocalPlayer)
                     {
                         SetSelection(hitCtrl);
                         holdTime = -1;
                         return;
                     }
                     else if (selectedType == 1)
                     {
                         RaycastHit hit;
                         if (CameraView.RaycastScreenWalk(clickPos, out hit))
                         {
                             selected.GetComponent <MyController> ().MoveTo(hit.point);
                         }
                         else
                         {
                             selected.GetComponent <MyController> ().MoveTo(hitPos);
                         }
                     }
                 }
                 else if (selectedType == 1)
                 {
                     selected.GetComponent <MyController> ().MoveTo(hitPos);
                 }
             }
         }
     }
     holdTime = -1;
 }
Пример #2
0
 public void OnPointerUp(PointerEventData data)
 {
     touchCount--;
     touchIds.Remove(data.pointerId);
     if (touchCount < 1 && holdTime > 0)
     {
         RaycastHit hit;
         if (holdTime > 0.3f)
         {
             if (dragDelta < 0.6f && dragDelta / holdTime < 1.2f)
             {
                 if (hitCol != null && selectedType == 1)
                 {
                     if (hitCtrl != null)
                     {
                         if (hitCtrl.team == 0)
                         {
                             if (hitCtrl.transform == selected)
                             {
                                 hitCtrl.Stop();
                                 holdTime = -1;
                                 return;
                             }
                         }
                         selected.GetComponent <MyController> ().MoveTo(hitCtrl.transform);
                         holdTime = -1;
                         return;
                     }
                     else if (hitBut != null)
                     {
                         //var pointer = new PointerEventData(EventSystem.current);
                         //ExecuteEvents.Execute(hitBut.gameObject, pointer, ExecuteEvents.pointerUpHandler);
                         //ExecuteEvents.Execute(hitBut.gameObject, pointer, ExecuteEvents.pointerClickHandler);
                         hitBut.OnPointerUp(data);
                         hitBut.OnPointerClick(data);
                         holdTime = -1;
                         return;
                     }
                     else if (selectedType == 1)
                     {
                         selected.GetComponent <MyController> ().MoveTo(hitPos);
                     }
                 }
             }
         }
         else
         {
             if (hitCol != null)
             {
                 if (hitCtrl != null)
                 {
                     if (hitCtrl.team == 0)
                     {
                         SetSelection(hitCtrl);
                         holdTime = -1;
                         return;
                     }
                     else if (selectedType == 1)
                     {
                         //RaycastHit hit;
                         if (CameraView.RaycastScreenWalk(clickPos, out hit))
                         {
                             selected.GetComponent <MyController> ().MoveTo(hit.point);
                         }
                         else
                         {
                             selected.GetComponent <MyController> ().MoveTo(hitPos);
                         }
                     }
                 }
                 else if (hitBut != null)
                 {
                     //var pointer = new PointerEventData(EventSystem.current);
                     //ExecuteEvents.Execute(hitBut.gameObject, pointer, ExecuteEvents.pointerUpHandler);
                     //ExecuteEvents.Execute(hitBut.gameObject, pointer, ExecuteEvents.pointerClickHandler);
                     hitBut.OnPointerUp(data);
                     hitBut.OnPointerClick(data);
                     holdTime = -1;
                     return;
                 }
                 else if (selectedType == 1)
                 {
                     selected.GetComponent <MyController> ().MoveTo(hitPos);
                 }
             }
         }
         if (hitBut != null)
         {
             hitBut.OnPointerExit(data);
             hitBut.OnPointerUp(data);
         }
     }
     holdTime = -1;
 }