예제 #1
0
        protected override void OnStart()
        {
            base.OnStart();

            if (Application.isPlaying)
            {
                // Create north root and place icon north properly
                northRoot      = NJGTools.AddChild(iconRoot.gameObject);
                northRoot.name = "North";
                northRoot.transform.localPosition = Vector3.zero;

                if (northIcon != null)
                {
                    northIcon.transform.parent        = northRoot.transform;
                    northIcon.transform.localRotation = Quaternion.identity;
                }

                // Calculate the border radius for icon culling.
                if (calculateBorder)
                {
                    mapBorderRadius = (rendererTransform.localScale.x / 2f) / 4f;
                }
            }

            UpdateAlignment();

            // Create a gameObject for the ping marker

            /*GameObject go = NJGTools.AddChild(iconRoot);
             * go.name = "_Ping";
             *
             * // Assign Ping type to this marker, 'Ping' type most be created on the editor
             * pingMarker = go.AddComponent<NJGMapItem>();
             * pingMarker.type = "Ping";*/
        }
예제 #2
0
    /// <summary>
    /// Get the map icon entry associated with the specified unit.
    /// </summary>

    protected override UIMapIconBase GetEntry(NJGMapItem item)
    {
        // Try to find an existing entry
        for (int i = 0, imax = mList.Count; i < imax; ++i)
        {
            UIMapIconOnGUI ic = (UIMapIconOnGUI)mList[i];
            if (ic.item == item)
            {
                /*ic.item = item;
                 * ic.sprite = mapOnGUI.GetSprite(item.type);
                 * if (ic.color != item.color) ic.color = item.color;
                 * if (ic.planeRenderer.localScale != GetIconScale(item)) ic.planeRenderer.localScale = GetIconScale(item);*/
                return(ic);
            }
        }

        // See if an unused entry can be reused
        if (mUnused.Count > 0)
        {
            UIMapIconOnGUI ent = (UIMapIconOnGUI)mUnused[mUnused.Count - 1];
            ent.item   = item;
            ent.sprite = mapOnGUI.GetSprite(item.type);
            ent.color  = item.color;
            ent.planeRenderer.localScale = GetIconScale(item);
            mUnused.RemoveAt(mUnused.Count - 1);
            NJGTools.SetActive(ent.gameObject, true);
            mList.Add(ent);
            return(ent);
        }

        // Create this new icon
        GameObject go = NJGTools.AddChild(iconRoot.gameObject);

        go.name = "Icon" + mCount;

        UIMapIconOnGUI mi = go.AddComponent <UIMapIconOnGUI>();

        mi.item   = item;
        mi.sprite = mapOnGUI.GetSprite(item.type);
        mi.color  = item.color;
        mi.planeRenderer.localScale = GetIconScale(item);

        if (mi == null)
        {
            Debug.LogError("Expected to find a Game Map Icon on the prefab to work with", this);
            Destroy(go);
        }
        else
        {
            mCount++;
            mi.item = item;
            mList.Add(mi);
        }
        return(mi);
    }
예제 #3
0
    /// <summary>
    /// Get the map icon entry associated with the specified unit.
    /// </summary>

    protected override UIMapArrowBase GetArrow(Object o)
    {
        NJGMapItem item = (NJGMapItem)o;

        // Try to find an existing entry
        for (int i = 0, imax = mListArrow.Count; i < imax; ++i)
        {
            if (mListArrow[i].item == item)
            {
                UIMapArrowOnGUI ic = (UIMapArrowOnGUI)mListArrow[i];
                //ic.item = item;
                ic.sprite = mapOnGUI.GetArrowSprite(item.type);

                /*ic.color = item.color;
                 * ic.planeRenderer.localScale = iconScale;
                 * ic.child = ent.planeRenderer;*/
                return(ic);
            }
        }

        // See if an unused entry can be reused
        if (mUnusedArrow.Count > 0)
        {
            UIMapArrowOnGUI ent = (UIMapArrowOnGUI)mUnusedArrow[mUnusedArrow.Count - 1];
            ent.item   = item;
            ent.color  = item.color;
            ent.sprite = mapOnGUI.GetArrowSprite(item.type);
            ent.planeRenderer.localScale    = arrowScale;
            ent.planeRenderer.localPosition = new Vector3(0, mapHalfScale.y - item.arrowOffset, -(item.arrowDepth + 1));
            ent.child = ent.planeRenderer;
            mUnusedArrow.RemoveAt(mUnusedArrow.Count - 1);
            NJGTools.SetActive(ent.gameObject, true);
            mListArrow.Add(ent);
            return(ent);
        }

        // Create this new icon
        GameObject go = NJGTools.AddChild(UIMiniMapOnGUI.instance.rendererTransform.parent.gameObject);

        go.name                    = "Arrow" + mArrowCount;
        go.transform.parent        = UIMiniMapOnGUI.instance.arrowRoot.transform;
        go.transform.localPosition = Vector3.zero;
        go.transform.localScale    = Vector3.one;

        UIMapArrowOnGUI mi = go.AddComponent <UIMapArrowOnGUI>();

        mi.item   = item;
        mi.color  = item.color;
        mi.sprite = mapOnGUI.GetArrowSprite(item.type);
        mi.planeRenderer.localScale    = arrowScale;
        mi.planeRenderer.localPosition = new Vector3(0, mapHalfScale.y - item.arrowOffset, -(item.arrowDepth + 1));
        mi.child = mi.planeRenderer;

        if (mi == null)
        {
            Debug.LogError("Expected to find a UIMapArrowOnGUI on the prefab to work with");
            Destroy(go);
        }
        else
        {
            mArrowCount++;
            mi.item = item;
            mListArrow.Add(mi);
        }
        return(mi);
    }