Exemple #1
0
        private void Update()
        {
            if (_NavElement == null)
            {
                return;
            }

            if (!DeusaldSharp.MathUtils.AreFloatsEquals(_PreviousExtraOffset, _ExtraOffset))
            {
                _NavElement.ExtraOffset = _ExtraOffset;
                _PreviousExtraOffset    = _ExtraOffset;
            }

            float rotation = transform.rotation.eulerAngles.z * Mathf.Deg2Rad;

            if (!DeusaldSharp.MathUtils.AreFloatsEquals(_PreviousRotation, rotation))
            {
                _NavElement.Rotation = rotation;
                _PreviousRotation    = rotation;
            }

            Vector2 position = _Transform.position;

            if (_PreviousPosition != position)
            {
                _NavElement.Position = MainNav2D.ToVec2(position);
                _PreviousPosition    = position;
            }
        }
Exemple #2
0
 public void Init(NavElement navElement, MainNav2D mainNav2D)
 {
     _MainNav             = mainNav2D;
     _NavElement          = navElement;
     _PreviousExtraOffset = 0f;
     _PreviousPosition    = Vector2.zero;
     _PreviousRotation    = 0f;
     navElement.NavElementPointsRefreshed += RefreshPoints;
     RefreshPoints(this, EventArgs.Empty);
 }
Exemple #3
0
        private void RefreshPoints(object sender, EventArgs eventArgs)
        {
            DeusaldSharp.Vector2[] points = _NavElement.NavElementPoints;
            _Points = new Vector2[points.Length];

            for (int i = 0; i < _Points.Length; ++i)
            {
                _Points[i] = MainNav2D.ToVec2(points[i]);
            }
        }