Esempio n. 1
0
    // Update is called once per frame
    void Update()
    {
        if (Application.isMobilePlatform)
        {
            int c = Input.touchCount;
            if (c > 0)
            {
                OnGetDirection(Input.GetTouch(c - 1));
                LineDrawer_GL.addLine(new Color(1, 1, 1, 0.5f), lineWidth, posStart, currentPos, 4, 8);
            }
            else
            {
                onRelease();
                magnitude = 0;
            }

            /*
             *
             * if (c >= 2) {
             *  UISystem.Log("- Set Ship speed -");
             *  OnGetDirection(Input.GetTouch(0));
             *  OnGetMagnitude(Input.GetTouch(1));
             *  //UISystem.Log("\nMagnitude = " + magnitude);
             * } else if(c > 0) {
             *  OnGetDirection(Input.GetTouch(0));
             *  //magnitude = 0;
             * } else {
             *  onRelease();
             *  magnitude = 0;
             * }
             */
        }
        else
        {
            if (Input.GetMouseButtonDown(0))
            {
                onDirectionStart(Input.mousePosition);
            }
            else if (Input.GetMouseButton(0))
            {
                if (OnUI)
                {
                    return;
                }

                OnUpdateDirection(Input.mousePosition);
                LineDrawer_GL.addLine(new Color(1, 1, 1, 0.1f), lineWidth, posStart, currentPos, 4, 8);
            }
            else
            {
                onRelease();
            }
        }
    }
Esempio n. 2
0
 void Start()
 {
     //Check if on camera
     main = GetComponent <Camera>();
     if (main == null)
     {
         Debug.LogError("Error - parent != Camera");
         Destroy(this);
         return;
     }
     instance = this;
 }
Esempio n. 3
0
    public void OnGetDirection(Touch touch)
    {
        if (OnUI)
        {
            return;
        }

        if (touchReset || touch.phase == TouchPhase.Began)
        {
            onDirectionStart(touch.position, touch.fingerId);
            return;
        }
        else if (touch.phase == TouchPhase.Ended)
        {
            onRelease();
        }
        OnUpdateDirection(touch.position);
        LineDrawer_GL.addLine(new Color(1, 1, 1, 0.1f), lineWidth, posStart, currentPos, 4, 8);
    }