private bool processMouseCoords()
        {
            _lastMousePos = Scene.Instance.view.transform.InverseTransformPoint(UnityEngine.Camera.main.ScreenToWorldPoint(Input.mousePosition));
            Vector3 mousePos = _lastMousePos;
            Vector2 gridPos  = FieldManager.Instance.getGridHexPosition(_lastMousePos);

            _lastMousePos.x = gridPos[0];
            _lastMousePos.y = gridPos[1];

            if (_lastMousePos.x < 0 || _lastMousePos.x >= FieldManager.FIELD_WIDTH || _lastMousePos.y < 0 || _lastMousePos.y >= FieldManager.LAST_VISIBLE_ROW)
            {
                return(false);
            }

            float angleRad = Mathf.Atan2(mousePos.y - FieldManager.Instance.playerArrow.transform.localPosition.y,
                                         mousePos.x - FieldManager.Instance.playerArrow.transform.localPosition.x);
            float angle = Mathf.Rad2Deg * angleRad;

            if (angle < 170 && angle > 10)
            {
                arrowAngle = angleRad;
                FieldManager.Instance.playerArrow.transform.rotation = Quaternion.Euler(0, 0, angle);

                if (!SITween.hasAnyTweening())
                {
                    FieldManager.Instance.currentPlayerBall.rotate(new Vector3(0, 0, angle - 90));
                }
            }

            return(true);
        }
 private void OnMouseDown()
 {
     if (_isEntered && !EventSystem.current.IsPointerOverGameObject())
     {
         if (processMouseCoords())
         {
             if (!SITween.hasAnyTweening())
             {
                 OnBubbleShot();
             }
         }
     }
 }
Exemple #3
0
        public static SITween To(object target, Action <SITween> onUpdate, float time, Action onComplete = null, Action onTweenKill = null)
        {
            SITween tween = new SITween();

            tween.target       = target;
            tween._onUpdate    = onUpdate;
            tween._time        = time;
            tween._onComplete  = onComplete;
            tween._onTweenKill = onTweenKill;

            _tweensToAdd.Add(tween);

            AddToFrameUpdate();

            return(tween);
        }