예제 #1
0
        /// <summary>
        /// 创建头顶信息实例
        /// </summary>
        /// <param name="objev"></param>
        /// <param name="entityID"></param>
        /// <param name="host"></param>
        /// <param name="ptr"></param>
        /// <param name="nLen"></param>
        /// <returns></returns>
        public UTopName CreateTopName(EntityView objev, IntPtr ptr, int nLen)
        {
            if (!bInit)
            {
                Trace.LogError("UTopNameManager必须初始化!");
                return(null);
            }
            if (EntityView.isNullOrEmpty(objev))
            {
                Trace.LogWarning("TopName--实体视图无效!");
                return(null);
            }
            int entityID = objev.ID;

            //如果表里面已含,则更新信息并返回
            if (m_TopNameMap.ContainsKey(entityID))
            {
                Trace.LogWarning(entityID + "已经有TopName,返回已有的实例");
                UTopName ut = m_TopNameMap[entityID];
                //接受逻辑层信息并更新
                SetNameInfo(ptr, nLen, ut);
                return(ut);
            }
            //分配一个节点
            TopNameNode bcn = new TopNameNode();
            UTopName    utn = GetTopName(ref bcn);

            if (null == utn)
            {
                return(null);
            }
            utn.CreatBillBoard();
            utn.ChangeCanvasNode(bcn);
            utn.Init(objev);

            m_TopNameMap.Add(entityID, utn);

            SetNameInfo(ptr, nLen, utn);

            if (objev.Property)
            {
                int nMatchType = objev.Property.GetNumProp(ENTITY_PROPERTY.PROPERTY_MATCHTYPE);
                int nRankScore = objev.Property.GetNumProp(ENTITY_PROPERTY.PROPERTY_RANKSCORE);
                int nRankGrade = objev.Property.GetNumProp(ENTITY_PROPERTY.PROPERTY_RANKGRADE);
                int nRankIcon  = GameLogicAPI.getRankIconIDByGrade(nMatchType, nRankGrade);
                if (nRankIcon > 0)
                {
                    utn.SetRankLv(nRankIcon);
                }
                int nSex = objev.Property.GetNumProp(ENTITY_PROPERTY.PROPERTY_SEX);
                utn.SetSex(nSex);
            }

            return(utn);
        }
예제 #2
0
        /// <summary>
        /// 实例化创建头顶称号
        /// </summary>
        /// <param name="bcn">节点信息</param>
        /// <returns></returns>
        private UTopName InstanceUTopName(TopNameNode bcn)
        {
            GameObject go = TopNamePrefabRes.InstanceMainRes();

            if (RectPosition(go, bcn))
            {
                UTopName ut = go.GetComponent <UTopName>();
                ut.resNode = TopNamePrefabRes;
                return(ut);
            }
            return(null);
        }
예제 #3
0
파일: UTopName.cs 프로젝트: zwong91/Titan
        /// <summary>
        /// 根据节点信息,算出贴图纹理像素起始和结束值,在rt贴图上取像素赋值给公告板
        /// </summary>
        /// <param name="trs"></param>
        public void ChangeCanvasNode(TopNameNode trs)
        {
            if (!m_BillBoard)
            {
                return;
            }
            m_CanvasNode = trs;

            m_BillBoard.SetPixelSize((int)m_CanvasNode.vSize.x, (int)m_CanvasNode.vSize.y);
            //根据在画布上的位置算出贴图上对应的位置
            Vector2 texStart = UTopNameManager.TransformTextureOffsetFromPixelPos(m_CanvasNode.start);
            Vector2 texEnd   = UTopNameManager.TransformTextureOffsetFromPixelPos(m_CanvasNode.end);

            m_BillBoard.SetTextureOffset(texStart, texEnd);
        }
예제 #4
0
        private bool AllocTopNamePos(ref TopNameNode tnn)
        {
            Vector2 topNameSize = new Vector2(TopNameCell_Width, TopNameCell_Height);

            tnn.isValid = false;
            if (m_UnUseCanvasNodeList.Count > 0)
            {
                TopNameNode tn = m_UnUseCanvasNodeList.Dequeue();
                tnn.RowIndex = tn.RowIndex;
                tnn.ColIndex = tn.ColIndex;
                tnn.start.x  = TopNameCell_Width * tn.RowIndex;
                tnn.start.y  = TopNameCell_Height * tn.ColIndex;
                tnn.end.x    = tn.start.x + topNameSize.x;
                tnn.end.y    = tn.start.y + topNameSize.y;
                tnn.vSize    = topNameSize;
                tnn.isValid  = true;
            }
            else
            {
                tnn         = new TopNameNode();
                tnn.start.x = TopNameCell_Width * currentRowIndex;
                tnn.start.y = TopNameCell_Height * currentColIndex;

                tnn.end.x    = tnn.start.x + topNameSize.x;
                tnn.end.y    = tnn.start.y + topNameSize.y;
                tnn.vSize    = topNameSize;
                tnn.RowIndex = currentRowIndex;
                tnn.ColIndex = currentColIndex;
                currentRowIndex++;
                if (currentRowIndex >= MaxRowCount)
                {
                    currentColIndex++;
                    if (currentColIndex >= MaxColCount)
                    {
                        return(false);
                    }
                    currentRowIndex = 0;
                }
                tnn.isValid = true;
            }
            return(true);
        }
예제 #5
0
        private UTopName GetTopName(ref TopNameNode canvNode)
        {
            UTopName ut = null;

            if (m_CacheTopName.Count > 0)
            {
                ut       = m_CacheTopName.Dequeue();
                canvNode = ut.CanvasNode;
                ut.RefreshTexture();
            }
            else
            {
                if (!AllocTopNamePos(ref canvNode))
                {
                    return(null);
                }
                ut = InstanceUTopName(canvNode);
            }
            return(ut);
        }
예제 #6
0
        /// <summary>
        /// 调整实例的位置
        /// </summary>
        /// <param name="go">实例GameObject</param>
        /// <param name="bcn">节点信息</param>
        /// <returns></returns>
        private bool RectPosition(GameObject go, TopNameNode bcn)
        {
            if (go == null || bcn.start == null)
            {
                return(false);
            }

            RectTransform rt = go.transform.GetComponent <RectTransform>();

            if (rt == null || renderCanvas == null)
            {
                return(false);
            }

            rt.SetParent(renderCanvas, false);
            rt.anchorMin        = new Vector2(0, 0);
            rt.anchorMax        = new Vector2(0, 0);
            rt.pivot            = new Vector2(0, 0);
            rt.anchoredPosition = new Vector2(bcn.start.x, bcn.start.y);
            return(true);
        }
예제 #7
0
 //预加载
 public void PreWarmTopName()
 {
     if (bPreWarmTopName)
     {
         return;
     }
     bPreWarmTopName = true;
     for (int i = 0; i < TopNameCacheCount; i++)
     {
         TopNameNode canvNode = new TopNameNode();
         if (!AllocTopNamePos(ref canvNode))
         {
             continue;
         }
         UTopName utn = InstanceUTopName(canvNode);
         utn.CreatBillBoard();
         utn.ChangeParent(CacheTopNameRoot.transform);
         utn.Init(null);
         utn.ChangeParent(CacheTopNameRoot.transform);
         utn.SetEnable(false);
         utn.ChangeCanvasNode(canvNode);
         m_CacheTopName.Enqueue(utn);
     }
 }