Esempio n. 1
0
        void Update()
        {
#if UNITY_EDITOR || UNITY_STANDALONE || UNITY_LINUX
            if (Input.GetMouseButtonDown(0))
            {
                Debug.Log("mouse left button down");
            }

            if (Input.GetMouseButtonDown(1))
            {
                Debug.Log("mouse right button down");
                var        mousePosition = Input.mousePosition;
                var        ray           = Camera.main.ScreenPointToRay(mousePosition);
                RaycastHit Hit;
                Physics.Raycast(ray, out Hit);
                if (TouchEvent != null)
                {
                    var touchResult = new TouchResult();
                    touchResult.firstTouchScreenPos = mousePosition;
                    touchResult.hitInfo             = Hit;
                    TouchEvent(this, touchResult);
                }
            }
#endif
        }
Esempio n. 2
0
    void Resolve(Vector2 touchPos, int fingerID)
    {
        TouchInfo touchInfo = touchInfos.Find(t => t.touchID == fingerID);

        if (touchInfo == null)
        {
            return;
        }

        Vector3 startPosition = touchInfo.touchPos;
        Vector3 newPosition   = touchPos;

        float distance  = Vector3.Distance(startPosition, newPosition);
        float deltaTime = Time.time - touchInfo.time;

        Vector3 direction = newPosition - startPosition;

        direction.Normalize();

        TouchResult touchResult = new TouchResult(distance, deltaTime, direction);

        Swipeable swipeable = touchInfo.touchedObject.GetComponent <Swipeable>();

        if (distance < clickDistanceThreshold)
        {
            swipeable.Touched(touchResult);
        }
        else
        {
            swipeable.Swipe(touchResult);
        }

        touchInfos.Remove(touchInfo);
    }
Esempio n. 3
0
 public void Touched(TouchResult touchResult)
 {
     if (onTouched != null) {
         onTouched(touchResult);
     } else {
      //   Debug.LogError("Delegate for onTouched was not defined on GameObject: " + gameObject.name);
     }
 }
Esempio n. 4
0
 public void processDelegates(TouchResult touch)
 {
     foreach (TapDelegate tempDelegate in delegates)
     {
         if (tempDelegate != null)
         {
             tempDelegate(touch);
         }
     }
 }
Esempio n. 5
0
 public void Touched(TouchResult touchResult)
 {
     if (onTouched != null)
     {
         onTouched(touchResult);
     }
     else
     {
         //   Debug.LogError("Delegate for onTouched was not defined on GameObject: " + gameObject.name);
     }
 }
    public List <TouchResult> GetGesture(Touch[] touches)
    {
        RemovePreviousTapGesture();
        DetectBeginTouches(touches);

        foreach (Touch touch in touches)
        {
            TouchResult foundGesture = touchGestureList.Find(i => i.FingerId == touch.fingerId);
            if (foundGesture == null || foundGesture.Type == 0)
            {
                TapCheck(touch);
                MovementCheck(touch);
            }
            else
            {
                if (touch.phase == TouchPhase.Ended)
                {
                    if (foundGesture.Type == 3 || foundGesture.Type == 4) // if foundGesture is scale or rotate, if one touch is ended, do not want second touch to be removed or continue returing gesture
                    {
                        foreach (var i in foundGesture.Touch)
                        {
                            UpdateListGesture(i, 6); // change to dead gesture for each linked touch
                        }
                    }
                    if (foundGesture.Type == 2)
                    {
                        UpdateListGesture(touch, 6);
                    }
                    else // not scale or rotate
                    {
                        touchGestureList.Remove(foundGesture);
                    }
                }
                else // not touch.ended. Therefore will update the locked gesture with the new touch
                {
                    UpdateListTouches(touch, touch);
                }
            }
        }
        return(touchGestureList);
    }
Esempio n. 7
0
    void OnSwipe(TouchResult touchResult)
    {
        float dot   = Vector2.Dot(new Vector2(0, 1), touchResult.direction);
        float angle = Vector2.Angle(new Vector2(1, 0f), touchResult.direction);



        if (dot < 0)
        {
            angle = 360 - angle;
        }

        int trancheDangle;

        // Base
        if (angle > 260)
        {
            trancheDangle = 0;
        }
        else if (angle >= 0 && angle <= 100)
        {
            trancheDangle = 1;
        }
        else if (angle > 100 && angle <= 180)
        {
            trancheDangle = 2;
        }
        else
        {
            trancheDangle = 3;
        }

        GameSharedData.GetLocalPlayer().GetComponent <PlayerAuthorityScript>().CmdChangeMinionSide(name, unitID.GetPlayerIndex());

        string nameToGo = GameSharedData.GetPlayerNumberNext(GameSharedData.GetLocalPlayer().GetComponent <Unit_ID>(), trancheDangle).name;

        Debug.Log(trancheDangle + " " + nameToGo);
        GameSharedData.GetLocalPlayer().GetComponent <PlayerAuthorityScript>().CmdOrderMinionToMoveTo(name, nameToGo);
    }
Esempio n. 8
0
    void OnSwipe(TouchResult touchResult)
    {
        float dot = Vector2.Dot(new Vector2(0, 1), touchResult.direction);
        float angle = Vector2.Angle(new Vector2(1, 0f), touchResult.direction);


      

        if (dot < 0)
        {
            angle = 360 - angle;
        }

        int trancheDangle;
        // Base
        if (angle > 260)
        {
            trancheDangle = 0;
        }
        else if (angle >= 0 && angle <= 100)
        {
            trancheDangle = 1;
        }
        else if (angle > 100 && angle <= 180)
        {
            trancheDangle = 2;
        }
        else
        {
            trancheDangle = 3;
        }

        GameSharedData.GetLocalPlayer().GetComponent<PlayerAuthorityScript>().CmdChangeMinionSide(name, unitID.GetPlayerIndex());
        
        string nameToGo = GameSharedData.GetPlayerNumberNext(GameSharedData.GetLocalPlayer().GetComponent<Unit_ID>(), trancheDangle).name;
        Debug.Log(trancheDangle + " " + nameToGo);
        GameSharedData.GetLocalPlayer().GetComponent<PlayerAuthorityScript>().CmdOrderMinionToMoveTo(name, nameToGo);
    }
Esempio n. 9
0
 void OnSwipe(TouchResult touchResult)
 {
     Debug.Log("Swiped");
 }
Esempio n. 10
0
 void OnTouched(TouchResult touchResult)
 {
     Debug.Log("Touched");
 }
Esempio n. 11
0
 void OnTouched(TouchResult touchResult)
 {
     _unit_ID.GetComponent <PlayerAuthorityScript>().CmdSpawnUnit(_typeToSpawn);
     Debug.Log("Touched");
 }
Esempio n. 12
0
 // Use this for initialization
 void Start()
 {
     TouchManager.I = this;
     result         = new TouchResult();
 }
Esempio n. 13
0
    void Resolve(Vector2 touchPos, int fingerID)
    {
        TouchInfo touchInfo = touchInfos.Find(t => t.touchID == fingerID);
        if (touchInfo == null) {
            return;
        }

        Vector3 startPosition = touchInfo.touchPos;
        Vector3 newPosition = touchPos;

        float distance = Vector3.Distance(startPosition, newPosition);
        float deltaTime = Time.time - touchInfo.time;

        Vector3 direction = newPosition - startPosition;
        direction.Normalize();

        TouchResult touchResult = new TouchResult(distance, deltaTime, direction);

        Swipeable swipeable = touchInfo.touchedObject.GetComponent<Swipeable>();
        if (distance < clickDistanceThreshold) {
            swipeable.Touched(touchResult);
        } else {
            swipeable.Swipe(touchResult);
        }

        touchInfos.Remove(touchInfo);
    }
Esempio n. 14
0
 void OnTouched (TouchResult touchResult)
 {
     Debug.Log("Touched");
 }
Esempio n. 15
0
 void OnTouched(TouchResult touchResult)
 {
     GameSharedData.GetLocalPlayer().GetComponent<PlayerAuthorityScript>().CmdOrderMinionToStop(name);
  }
Esempio n. 16
0
    void OnTouched(TouchResult touchResult)
    {

        _unit_ID.GetComponent<PlayerAuthorityScript>().CmdSpawnUnit(_typeToSpawn);
        Debug.Log("Touched");
    }
Esempio n. 17
0
 void OnSwipe(TouchResult touchResult)
 {
     Debug.Log("Swiped");
 }
Esempio n. 18
0
 void OnTouched(TouchResult touchResult)
 {
     GameSharedData.GetLocalPlayer().GetComponent <PlayerAuthorityScript>().CmdOrderMinionToStop(name);
 }