Ejemplo n.º 1
0
        public void CenterOn(Vector2 p, bool animate = false)
        {
            var start  = GameCamera.transform.localPosition;
            var finish = new Vector3(p.x, p.y, start.z);

            if (animate)
            {
                Ease3.Go(this, start, finish, Constants.TimeTween, v => GameCamera.transform.localPosition = v, null);
            }
            else
            {
                GameCamera.transform.localPosition = finish;
            }
        }
Ejemplo n.º 2
0
 public void SetTargetPosition(Vector3 p, bool animate)
 {
     TargetTarget = new Vector3(p.x, p.y, _t.localPosition.z);
     if (animate)
     {
         AnimateTarget(true);
         if (_easeTargetPosition != null)
         {
             StopCoroutine(_easeTargetPosition);
         }
         _easeTargetPosition = Ease3.Go(this, _t.localPosition, TargetTarget, Constants.TimeTween, v => _t.localPosition = v, null, EaseType.Spring);
     }
     else
     {
         ActivateTarget(false);
         _t.localPosition = TargetTarget;
     }
 }
Ejemplo n.º 3
0
 public void SetTargetPosition(int x, int y, bool animate)
 {
     if (Manager.Instance.TileMap.InsideMap(x, y))
     {
         TargetTarget = new Vector3(x, y, transform.localPosition.z);
         if (animate)
         {
             AnimateTarget(true);
             if (_easeTargetPosition != null)
             {
                 StopCoroutine(_easeTargetPosition);
             }
             _easeTargetPosition = Ease3.Go(this, transform.localPosition, TargetTarget, Constants.TimeTween, v => transform.localPosition = v, null, EaseType.Spring);
         }
         else
         {
             ActivateTarget(false);
             transform.localPosition = TargetTarget;
         }
     }
 }
Ejemplo n.º 4
0
        void Spring(Vector2 delta)
        {
            var p        = GameCamera.transform.localPosition;
            var isDeltaX = !Mathf.Approximately(delta.x, 0f);
            var x        = isDeltaX ? p.x + delta.x : Mathf.RoundToInt(p.x);
            var isDeltaY = !Mathf.Approximately(delta.y, 0f);
            var y        = isDeltaY ? p.y + delta.y : Mathf.RoundToInt(p.y);
            var to       = new Vector3(x, y, p.z);

            if (_spring != null)
            {
                StopCoroutine(_spring);
            }
            _spring = Ease3.Go(this, p, to, Constants.TimeTween, v =>
            {
                GameCamera.transform.localPosition = v;
                if (isDeltaX || isDeltaY)
                {
                    MiniMap.Instance.UpdateMiniMap(v);
                }
            }, () => MiniMap.Instance.UpdateMiniMap(GameCamera.transform.localPosition), EaseType.Spring);
        }
Ejemplo n.º 5
0
        private void Spring(Vector2 delta)
        {
            var p        = GameCamera.transform.localPosition;
            var isDeltaX = !Mathf.Approximately(delta.x, 0f);
            var x        = p.x + delta.x;
            var isDeltaY = !Mathf.Approximately(delta.y, 0f);
            var y        = p.y + delta.y;
            var center   = Map.BackMap.GetCellCenterWorld(new Vector3Int((int)x, (int)y, 0));
            var to       = new Vector3(center.x, center.y, p.z);

            if (_spring != null)
            {
                StopCoroutine(_spring);
            }
            _spring = Ease3.Go(this, p, to, Constants.TimeTween, v =>
            {
                GameCamera.transform.localPosition = v;
                if (isDeltaX || isDeltaY)
                {
                    MiniMap.UpdateMiniMap(v);
                }
            }, () => MiniMap.UpdateMiniMap(GameCamera.transform.localPosition), EaseType.Spring);
        }