Esempio n. 1
0
    /// <summary>
    /// 添加或者刷新血条
    /// </summary>
    /// <param name="entity"></param>
    /// <param name="refresh">是否刷新已有的血条</param>
    void AddBar(IEntity entity)
    {
        if (entity == null)
        {
            return;
        }
        List <HeadTipData> lstdata = new List <HeadTipData>();

        lstdata.Add(new HeadTipData(entity, HeadTipType.Name, GetNameVisible(entity)));
        EntityType entityType = entity.GetEntityType();

        if (entityType != EntityType.EntityType_Box)
        {
            bool addHpSlider = IsNeedHpSlider(entity);
            if (addHpSlider)
            {
                bool    visible = true;
                IPlayer player  = ClientGlobal.Instance().MainPlayer;
                if (player == null)
                {
                    return;
                }
                if (entity.GetUID() == player.GetUID())
                {
                    visible = true;
                }
                else
                {
                    visible = m_bHpSliderVisible;
                }
                lstdata.Add(new HeadTipData(entity, HeadTipType.Hp, visible));
            }
            else
            {
                lstdata.Add(new HeadTipData(entity, HeadTipType.Hp, addHpSlider));
            }
            //称号
            int titleId = entity.GetProp((int)PlayerProp.TitleId);
            if (titleId != 0)
            {
                lstdata.Add(new HeadTipData(entity, HeadTipType.Title, m_bPlayerTitleVisible));
            }
        }
        //添加头顶NPC icon
        if (RoleStateBarManager.IsEntityHaveHeadIconMask(entity) &&
            !NpcHeadTipsManager.Instance.IsHaveTips((Client.INPC)entity))
        {
            lstdata.Add(new HeadTipData(entity, HeadTipType.HeadMaskIcon, m_bHpSliderVisible));
        }
        RoleStateBar bar = this.CreateHeadText(entity, lstdata);

        if (bar != null)
        {
            //clan Name
            RefreshClanName(entity, bar);
        }
    }
Esempio n. 2
0
    public void InitInfo(Client.NPCInfo info)
    {
        if (null == m_spMaskIcon)
        {
            m_spMaskIcon = transform.Find("MaskIcon").GetComponent <UISprite>();
        }
        m_type  = (MapScrollItemType)info.type;
        npcInfo = info;
        if (info != null)
        {
            Transform labelTrans = transform.Find("Label");
            bool      visible    = RoleStateBarManager.IsEntityHaveHeadIconMask((uint)info.npcID);
            if (null != m_spMaskIcon)
            {
                if (m_spMaskIcon.gameObject.activeSelf != visible)
                {
                    m_spMaskIcon.gameObject.SetActive(visible);
                }

                if (visible)
                {
                    table.NpcHeadMaskDataBase maskDb = RoleStateBarManager.GetNPCHeadMaskDB((uint)info.npcID);
                    if (null != maskDb)
                    {
                        UIManager.GetAtlasAsyn(maskDb.miniMapMaskIcon, ref m_curIconAsynSeed, () =>
                        {
                            if (null != m_spMaskIcon)
                            {
                                m_spMaskIcon.atlas = null;
                            }
                        }, m_spMaskIcon, false);
                    }
                }
            }
            if (labelTrans != null)
            {
                UILabel label = labelTrans.GetComponent <UILabel>();
                if (label != null)
                {
                    string showText = npcInfo.name;
                    if (npcInfo.pos.x != 0 || npcInfo.pos.y != 0)
                    {
                        string levelStr = string.Empty;

                        table.NpcDataBase ndb = GameTableManager.Instance.GetTableItem <table.NpcDataBase>((uint)npcInfo.npcID);
                        if (ndb != null)
                        {
                            if (ndb.dwType == (int)GameCmd.enumNpcType.NPC_TYPE_NONE)
                            {
                                if (ndb.dwMonsterType != 0)
                                {
                                    levelStr = ndb.dwLevel + "级 ";
                                }
                            }
                        }

                        showText = levelStr + npcInfo.name + "(" + npcInfo.pos.x.ToString() + "," + npcInfo.pos.y.ToString() + ")";
                    }
                    label.text = showText;
                }
            }
        }
    }