Esempio n. 1
0
 protected void UnSelectAll()
 {
     for (int i = 0, imax = selected.Count; i < imax; i++)
     {
         UIMapIconBase ic = selected[i];
         ic.UnSelect();
     }
     selected.Clear();
 }
Esempio n. 2
0
        /// <summary>
        /// Update the icon icon for the specified unit, assuming it's visible.
        /// </summary>

        protected override void UpdateIcon(NJGMapItem item, float x, float y)
        {
            // If the unit is not visible, don't consider it
            bool isVisible = (((x - mapBorderRadius) >= -mapHalfScale.x) &&
                              ((x + mapBorderRadius) <= mapHalfScale.x)) &&
                             (((y - mapBorderRadius) >= -mapHalfScale.y) &&
                              ((y + mapBorderRadius) <= mapHalfScale.y));

            Vector3 newPos = new Vector3(x, y, 0f);

            if (!isVisible)
            {
                return;
            }

            UIMapIconBase icon = GetEntry(item);

            if (icon != null)
            {
                icon.isMapIcon = true;
            }

            if (icon != null && !icon.isValid)
            {
                icon.isValid = true;
                Transform t = icon.cachedTransform;
                if (item.updatePosition)
                {
                    if (t.localPosition != newPos)
                    {
                        t.localPosition = newPos;
                    }
                }

                if (item.rotate)
                {
                    float angle = ((Vector3.Dot(item.cachedTransform.forward, Vector3.Cross(Vector3.up, Vector3.forward)) <= 0f) ? 1f : -1f) * Vector3.Angle(item.cachedTransform.forward, Vector3.forward);
                    t.localEulerAngles = new Vector3(t.localEulerAngles.x, t.localEulerAngles.y, angle);
                }
                else
                {
                    if (t.localEulerAngles != Vector3.zero)
                    {
                        t.localEulerAngles = Vector3.zero;
                    }
                }
            }
        }
Esempio n. 3
0
        /// <summary>
        /// Update the icon icon for the specified unit, assuming it's visible.
        /// </summary>

        protected override void UpdateIcon(NJGMapItem item, float x, float y)
        {
            // If the unit is not visible, don't consider it
            bool isVisible = false;

            if (map.fow.enabled)
            {
                isVisible = (((x - mapBorderRadius) >= -mapHalfScale.x) &&
                             ((x + mapBorderRadius) <= mapHalfScale.x)) &&
                            (((y - mapBorderRadius) >= -mapHalfScale.y) &&
                             ((y + mapBorderRadius) <= mapHalfScale.y));

                if (!item.isRevealed)
                {
                    isVisible = false;
                }
            }
            else
            {
                isVisible = (((x - mapBorderRadius) >= -mapHalfScale.x) &&
                             ((x + mapBorderRadius) <= mapHalfScale.x)) &&
                            (((y - mapBorderRadius) >= -mapHalfScale.y) &&
                             ((y + mapBorderRadius) <= mapHalfScale.y));
            }

            if (!isPanning)
            {
                if (!isVisible && item.haveArrow)
                {
                    if (item.arrow == null)
                    {
                        item.arrow = (UIMapArrowBase)GetArrow(item);
                    }

                    if (item.arrow != null)
                    {
                        if (!NJGTools.GetActive(item.arrow.gameObject))
                        {
                            NJGTools.SetActive(item.arrow.gameObject, true);
                        }
                        item.arrow.UpdateRotation(target.position);
                    }
                }
                else if (isVisible && item.haveArrow)
                {
                    if (item.arrow != null)
                    {
                        if (NJGTools.GetActive(item.arrow.gameObject))
                        {
                            NJGTools.SetActive(item.arrow.gameObject, false);
                        }
                    }
                }
            }

            if (!isVisible)
            {
                return;
            }

            UIMapIconBase icon = GetEntry(item);

            if (icon != null && !icon.isValid)
            {
                icon.isMapIcon = false;
                icon.isValid   = true;
                Transform t      = icon.cachedTransform;
                Vector3   newPos = new Vector3(x, y, 0f);
                if (item.updatePosition)
                {
                    if (t.localPosition != newPos)
                    {
                        t.localPosition = newPos;
                    }
                }

                if (item.rotate)
                {
                    float angle = ((Vector3.Dot(item.cachedTransform.forward, Vector3.Cross(Vector3.up, Vector3.forward)) <= 0f) ? 1f : -1f) * Vector3.Angle(item.cachedTransform.forward, Vector3.forward);
                    t.localEulerAngles = new Vector3(t.localEulerAngles.x, t.localEulerAngles.y, angle);
                }
                else if (!item.rotate && rotateWithPlayer)
                {
                    Vector3 eu = new Vector3(0, 0, -iconRoot.localEulerAngles.z);
                    if (!t.localEulerAngles.Equals(eu))
                    {
                        t.localEulerAngles = eu;
                    }
                }
                else
                if (!t.localEulerAngles.Equals(Vector3.zero))
                {
                    t.localEulerAngles = Vector3.zero;
                }
            }
        }
Esempio n. 4
0
 protected virtual void Delete(UIMapIconBase ent)
 {
     this.mList.Remove(ent);
     this.mUnused.Add(ent);
     NJGTools.SetActive(ent.gameObject, false);
 }