示例#1
0
    public void SetTalkingBossID(uint bossID)
    {
        IEntity en = RoleStateBarManager.GetEntityByUserID <INPC>(bossID);

        if (en != null)
        {
            m_uTalkingBossID = (uint)en.GetProp((int)EntityProp.BaseID);
        }
        else
        {
            m_uTalkingBossID = 0;
        }
        if (m_uTalkingBossID != 0)
        {
            table.BossTalkDataBase db = GameTableManager.Instance.GetTableItem <table.BossTalkDataBase>((uint)m_uTalkingBossID);
            if (db != null)
            {
                table.LangTextDataBase ldb = GameTableManager.Instance.GetTableItem <table.LangTextDataBase>(db.textID);
                if (ldb != null)
                {
                    if (!string.IsNullOrEmpty(ldb.talkVoice))
                    {
                        List <uint> idList = StringUtil.GetSplitStringList <uint>(ldb.talkVoice);
                        if (idList != null && idList.Count > 0)
                        {
                            uint audioID = idList[0];
                            if (audioID != 0)
                            {
                                DataManager.Manager <PetDataManager>().PlayCreateAudio(audioID);
                            }
                        }
                    }
                }
                if (TimerAxis.Instance().IsExist(m_uBossTalkTimerID, this))
                {
                    TimerAxis.Instance().KillTimer(m_uBossTalkTimerID, this);
                }
                TimerAxis.Instance().SetTimer(m_uBossTalkTimerID, db.aliveTime * 1000, this, 1);
                TimerAxis.Instance().SetTimer(m_uRefreshStatusTimerID, 1000, this, 1);
            }
        }
        RefreshAllRoleBarHeadStatus(HeadStatusType.BossSay);
    }
示例#2
0
    /// <summary>
    /// 更新顶部栏状态
    /// </summary>
    public void UpdateHeadStatus(HeadStatusType type, bool adjustPos = true)
    {
        RoleStateBarManager mgr    = DataManager.Manager <RoleStateBarManager>();
        IEntity             entity = RoleStateBarManager.GetEntity(UID);

        if (null == entity)
        {
            return;
        }
        Transform widget = GetWidget(type);

        if (null != widget)
        {
            QuestTraceInfo traceInfo = null;
            bool           visible   = false;
            if (type != HeadStatusType.TaskStatus)
            {
                visible = RoleStateBarManager.IsEntityHeadStatusTypeEnable(entity, type);
            }
            else
            {
                if (RoleStateBarManager.TryGetNPCTraceInfo(entity, out traceInfo))
                {
                    visible = true;
                }
            }
            if (widget.gameObject.activeSelf != visible)
            {
                widget.gameObject.SetActive(visible);
            }
            if (type == HeadStatusType.Title &&
                null != m_particleWidget)
            {
                m_particleWidget.ReleaseParticle();
            }
            if (visible)
            {
                switch (type)
                {
                case HeadStatusType.Hp:
                    if (null != m_hpSlider && null != m_spHpbg && null != m_spHpForg)
                    {
                        float          hpPer = entity.GetProp((int)CreatureProp.Hp) / (float)entity.GetProp((int)CreatureProp.MaxHp);
                        EntityHpSprite hpSp  = RoleStateBarManager.GetEntityHpSpData(entity);
                        if (hpSp != null)
                        {
                            m_spHpbg.spriteName = hpSp.bgSpriteName;
                            m_spHpbg.MakePixelPerfect();
                            m_spHpForg.spriteName = hpSp.spriteName;
                            m_spHpForg.MakePixelPerfect();
                            m_hpSlider.gameObject.SetActive(hpSp.bShow);
                            m_hpSlider.value = hpPer;
                        }
                    }
                    break;

                case HeadStatusType.Name:
                    if (null != m_labName)
                    {
                        m_labName.text = ColorManager.GetColorString(mgr.GetNameColor(entity), entity.GetName());
                    }
                    break;

                case HeadStatusType.Clan:
                    if (null != m_labClanName)
                    {
                        Action <string, int> clanNameDlg = (clanName, getNameSeed) =>
                        {
                            if (getNameSeed >= m_iGetNameSeed)
                            {
                                //保证先后
                                //string name = DataManager.Manager<TextManager>().GetLocalFormatText(LocalTextType.Clan_Commond_shizumingzi, clanName);
                                //labelClan.fontSize = data.m_nFontSize;
                                m_labClanName.text = ColorManager.GetColorString(RoleStateBarManager.GetClanNameColor(entity), clanName);
                            }
                        };
                        RoleStateBarManager.GetRoleBarClanName(entity, clanNameDlg, ++m_iGetNameSeed);
                    }
                    break;

                case HeadStatusType.Title:
                    if (null != m_labTitle)
                    {
                        table.TitleDataBase titleDb = RoleStateBarManager.GetTitleText(entity);
                        if (null != titleDb)
                        {
                            bool visibleTxt = (titleDb.UIState == 0);
                            if (null != m_labTitle)
                            {
                                if (m_labTitle.gameObject.activeSelf != visibleTxt)
                                {
                                    m_labTitle.gameObject.SetActive(visibleTxt);
                                }
                                m_labTitle.text = titleDb.SceneTextUI;
                            }

                            if (null != m_particleWidget)
                            {
                                if (m_particleWidget.gameObject.activeSelf == visibleTxt)
                                {
                                    m_particleWidget.gameObject.SetActive(!visibleTxt);
                                }

                                m_particleWidget.AddParticle(titleDb.FxUI, m_particleRelativeWidget);
                            }
                        }
                    }
                    break;

                case HeadStatusType.Collect:
                    if (null != m_labCollectTips)
                    {
                        m_labCollectTips.color = ColorManager.GetColor32OfType(ColorType.JSXT_CaiJiWu);
                    }
                    break;

                case HeadStatusType.HeadMaskIcon:
                    if (null != m_spHeadMask)
                    {
                        table.NpcHeadMaskDataBase npcmaskDB = RoleStateBarManager.GetNPCHeadMaskDB(entity);
                        string iconName = (null != npcmaskDB) ? npcmaskDB.headMaskIcon : "";
                        UIManager.GetAtlasAsyn(iconName, ref m_headCASD, () =>
                        {
                            if (null != m_spHeadMask)
                            {
                                m_spHeadMask.atlas = null;
                            }
                        }, m_spHeadMask);
                    }
                    break;

                case HeadStatusType.TaskStatus:
                    if (null != m_spTaskStatus && null != traceInfo)
                    {
                        long   uid  = 0;
                        string icon = "";
                        if (RoleStateBarManager.TryGetQuestStatusIcon(traceInfo, out uid, out icon) &&
                            uid == UID)
                        {
                            UIManager.GetAtlasAsyn(icon, ref m_taskCASD, () =>
                            {
                                if (null != m_spTaskStatus)
                                {
                                    m_spTaskStatus.atlas = null;
                                }
                            }, m_spTaskStatus);
                        }
                        else
                        {
                            widget.gameObject.SetActive(false);
                        }
                    }
                    break;

                case HeadStatusType.CampMask:
                {
                    bool isGod = true;
                    int  camp  = entity.GetProp((int)Client.CreatureProp.Camp);
                    if (camp == (int)GameCmd.eCamp.CF_Red)
                    {
                        isGod = false;
                    }
                    if (null != m_tsDemonMask && m_tsDemonMask.gameObject.activeSelf == isGod)
                    {
                        m_tsDemonMask.gameObject.SetActive(!isGod);
                    }

                    if (null != m_tsGodMask && m_tsGodMask.gameObject.activeSelf != isGod)
                    {
                        m_tsGodMask.gameObject.SetActive(isGod);
                    }
                }
                break;

                case HeadStatusType.BossSay:
                {
                    uint npcID = DataManager.Manager <RoleStateBarManager>().GetTalkingBossID();

                    table.BossTalkDataBase db = GameTableManager.Instance.GetTableItem <table.BossTalkDataBase>(npcID);
                    if (db != null)
                    {
                        uint textID = db.textID;
                        table.LangTextDataBase ldb = GameTableManager.Instance.GetTableItem <table.LangTextDataBase>(textID);
                        if (ldb != null)
                        {
                            m_bossText.text = ldb.strText;
                        }
                        m_bossTalk.gameObject.SetActive(visible);
                    }
                    else
                    {
                        m_bossTalk.gameObject.SetActive(false);
                    }
                }
                break;
                }
            }

            if (adjustPos)
            {
                AdjustStatusPos();
            }
        }
    }