Exemplo n.º 1
0
 public void OnPointerDown(PointerEventData eventData)
 {
     if ((DateTime.Now - lastClickTime).TotalMilliseconds < 500)
     {
         GameLogicHandler.onRightClick(eventData.position);
     }
     lastClickTime = DateTime.Now;
 }
Exemplo n.º 2
0
    public void Update()
    {
        float widthBoarder    = Screen.width * 0.10f;
        float heightBoarder   = Screen.height * 0.10f;
        int   validTouchCount = 0;

        if (Input.touchCount > 0)
        {
            for (int i = 0; i < Input.touchCount; i++)
            {
                Touch touch = Input.GetTouch(i);
                lastTouch = touch;
                if (touch.position.x > widthBoarder && touch.position.x < Screen.width - widthBoarder && touch.position.y > heightBoarder)
                {
                    validTouchCount++;
                    if (isDraging && lastPosition != null)
                    {
                        UpdateVirtualAxes(new Vector2(touch.position.x, touch.position.y) - lastPosition);
                    }
                    pressedTime += Time.deltaTime;
                    if (pressedTime > 0.1f)
                    {
                        isDraging    = true;
                        lastPosition = touch.position;
                    }
                    if (isPressed == false)
                    {
                        isPressed = true;
                    }
                    lastPosition = touch.position;
                }
            }
        }
        if (validTouchCount <= 0)
        {
            if (isPressed && pressedTime < 0.3f)
            {
                if ((DateTime.Now - lastClickTime).TotalMilliseconds < 500)
                {
                    GameLogicHandler.onRightClick(lastTouch.position);
                }
                lastClickTime = DateTime.Now;
            }
            if (isPressed)
            {
                UpdateVirtualAxes(Vector3.zero);
                pressedTime = 0;
                isDraging   = false;
                isPressed   = false;
            }
        }
    }
Exemplo n.º 3
0
 void Update()
 {
     if (startGame)
     {
         //if (Time.frameCount % 30 == 0) {
         //    System.GC.Collect();
         //}
         deltaTime += Time.deltaTime;
         Timer.doSyncTick();
         //Cursor.visible = true;
         GameLogicHandler.onUpdate();
     }
 }
Exemplo n.º 4
0
    void UpdateVirtualAxes(Vector3 value)
    {
        if (Math.Abs(value.x) < 4 && Math.Abs(value.y) < 4)
        {
            value = Vector3.zero;
            GameLogicHandler.onLeftClick(lastPosition);
        }
#if UNITY_EDITOR
        value = value * 0.1f;
#else
        value = value * 0.1f;
#endif
        m_HorizontalVirtualAxis.Update(value.x);

        m_VerticalVirtualAxis.Update(value.y);
    }