예제 #1
0
    /// <summary>
    /// 取得头顶名字
    /// </summary>
    /// <param name="moveNode"></param>
    /// <returns></returns>
    static TopName GetTopName(ref MovieNode moveNode)
    {
        TopName tp = null;

        if (!OptimitzedControlPlane.Instance.EnityCreateOptimize)
        {
            tp       = CreateTopNameInstance();
            moveNode = new MovieNode();
            return(tp);
        }

        if (m_CacheTopName.Count > 0)
        {
            tp = m_CacheTopName.Dequeue();
            tp.SetEnable(true);
            moveNode = tp.movieNode;
        }
        else
        {
            if (!AllocTopNamePos(ref moveNode))
            {
                //Debug.LogWarning("Movie空间不足,最多只能容纳:" + MaxColCount * MaxRowCount + "个头顶名!!");
                return(null);
            }
            tp = CreateTopNameInstance();
        }
        return(tp);
    }
예제 #2
0
    /// <summary>
    /// 摧毁指定的Lable
    /// </summary>
    /// <param name="instance">需要清除的Lable</param>
    public static void Destroy(TopName instance)
    {
        if (Movie.GetSingleton <TopNameMovie>() == null)
        {
            return;
        }
        if (null == instance)
        {
            return;
        }
        int id = instance.ID;

        if (instance.movieNode.isValid)
        {
            UnUsedMovieNodeList.Enqueue(instance.movieNode);
        }

        if (TopNameMovie.Instance != null)
        {
            TopNameMovie.Instance.RemoveMovieAS3(instance.Instance);
            instance.Clear();
        }
        if (m_TopNameMap.ContainsKey(id))
        {
            m_TopNameMap[id] = null;
            m_TopNameMap.Remove(id);
        }
        instance = null;
    }
예제 #3
0
    public static void Update()
    {
        if (!bInit)
        {
            return;
        }

        InvalidList.Clear();

        U3D_Render.EntityView view;
        foreach (TopName var in m_TopNameMap.Values)
        {
            TopName tn = var;
            view = EntityFactory.getEntityViewByID(tn.ID);

            if (view == null)
            {
                InvalidList.Enqueue(tn);
                continue;
            }

            if (!tn.Entry)//实体被删除
            {
                InvalidList.Enqueue(tn);
                continue;
            }

            if (!tn.Entry.activeSelf || !view.StateMachine.GetVisible())//实体没有被激活或者不可见
            {
                if (tn.GetEnable())
                {
                    tn.SetEnable(false);
                }
            }
            else//正常的实体
            {
                if (!tn.GetEnable())
                {
                    tn.SetEnable(true);
                }
                tn.OnUpdate();
            }
        }

        while (InvalidList.Count > 0)
        {
            //移除无效的TopName节点
            TopName b = InvalidList.Dequeue();
            if (OptimitzedControlPlane.Instance.EnityCreateOptimize)
            {
                CacheTopName(b);
            }
            else
            {
                TopNameManager.Destroy(b);
            }
        }

        InvalidList.Clear();
    }
예제 #4
0
    /// <summary>
    /// 创建一个头顶名称
    /// </summary>
    /// <param name="entry">实体</param>
    /// <param name="entryId">实体ID</param>
    /// <param name="text">内容</param>
    /// <param name="col">颜色</param>
    /// <returns></returns>
    public static TopName CreateTopName(GameObject entry, int entryId, string text, Color col)
    {
        if (SFGFxMovieManager.Instance == null)
        {
            Trace.LogError("SFGFxMovieManager没有初始化,请不要在Awake或Start中创建!");
            return(null);
        }

        if (!bInit)
        {
            Trace.LogError("GfxLableManager必须初始化!");
            return(null);
        }
        //有可能TopNameMovie还没有创建完成.
        if (TopNameMovie.Instance == null)
        {
            //Trace.LogError("TopNameMovie尚未创建完成,请等待创建完成后再调用。");
            return(null);
        }
        if (m_TopNameMap.ContainsKey(entryId))
        {
            Trace.LogWarning(entryId + "已经有头顶名,返回已有的实例");

            return(m_TopNameMap[entryId]);
        }

        U3D_Render.EntityView objev = EntityFactory.getEntityViewByID(entryId);
        if (!objev.IsValid)
        {
            Trace.LogWarning("实体视图无效!id=" + entryId);
            return(null);
        }
        ENTITY_TYPE entityType = objev.Type;

        MovieNode trs = new MovieNode();


        TopName t = GetTopName(ref trs);

        if (t == null)
        {
            return(t);
        }
        t.Init(entry, entryId, text, col);
        t.CreateBillBorad();
        t.ChangeMovieNode(trs);
        m_TopNameMap.Add(entryId, t);
        index++;
        ChangeMask(EntityFactory.getEntityViewByID(entryId), true);

        //if (!go)
        //{
        //    go = GameObject.CreatePrimitive(PrimitiveType.Plane);

        //    go.renderer.material.SetTexture("_MainTex", TopNameMovie.TopNameRenderTexture);
        //}

        return(t);
    }
예제 #5
0
 public static void SetVisible(int id, bool b)
 {
     if (m_TopNameMap.ContainsKey(id))
     {
         TopName tn = m_TopNameMap[id];
         tn.SetVisible(b);
     }
 }
예제 #6
0
 public static void UpdateTopName(GameObject entry, int entryId, string text, Color col)
 {
     if (m_TopNameMap.ContainsKey(entryId))
     {
         TopName t = m_TopNameMap[entryId];
         t.SetText(text);
         t.SetColor(col);
         t.Entry = entry;
     }
 }
예제 #7
0
    /// <summary>
    /// 创建实例
    /// </summary>
    /// <returns></returns>
    static TopName CreateTopNameInstance()
    {
        Value ins = new Value();

        if (!TopNameMovie.Instance.AttachMovie(ref ins, LableAS3RefernceName, LableAS3RefernceName + System.DateTime.Today.Millisecond, -1))
        {
            Trace.LogError("Flash -- Lable创建失败!");
            ins = null;
            return(null);
        }

        TopName tp = new TopName(ins);

        return(tp);
    }
예제 #8
0
 /// <summary>
 /// 预热
 /// </summary>
 public static void PreWarmTopName()
 {
     if (bPreWarmTopName)
     {
         return;
     }
     bPreWarmTopName = true;
     for (int i = 0; i < CacheCout; i++)
     {
         TopName tp = CreateTopNameInstance();
         tp.Init(CacheTopNameRoot, -1, "temp", Color.white);
         tp.CreateBillBorad();
         tp.ChangeParent(CacheTopNameRoot.transform);
         tp.SetEnable(false);
         m_CacheTopName.Enqueue(tp);
     }
 }
예제 #9
0
    /// <summary>
    /// 缓存
    /// </summary>
    /// <param name="tp"></param>
    static void CacheTopName(TopName tp)
    {
        if (!OptimitzedControlPlane.Instance.EnityCreateOptimize || null == tp)
        {
            return;
        }

        int id = tp.ID;

        if (m_TopNameMap.ContainsKey(id))
        {
            tp.SetEnable(false);
            tp.ChangeParent(CacheTopNameRoot.transform);
            m_CacheTopName.Enqueue(tp);
            m_TopNameMap.Remove(id);
        }
    }