Пример #1
0
    /// <summary>
    /// 刷新头顶所有状态
    /// </summary>
    /// <param name="status"></param>
    private void RefreshAllHeadStatus(HeadStatusType status)
    {
        IEntity entity     = null;
        long    uid        = 0;
        var     enumerator = m_dicActiveRoleStateBar.GetEnumerator();

        while (enumerator.MoveNext())
        {
            if (null == enumerator.Current.Value)
            {
                continue;
            }
            entity = RoleStateBarManager.GetEntity(enumerator.Current.Key);
            if (null == entity)
            {
                continue;
            }
            switch (status)
            {
            case HeadStatusType.Hp:
                break;

            case HeadStatusType.Name:
                break;

            case HeadStatusType.Clan:
            {
                if (entity.GetEntityType() != EntityType.EntityType_Player &&
                    entity.GetEntityType() != EntityType.EntityType_NPC)
                {
                    continue;
                }
            }
            break;

            case HeadStatusType.Title:
            {
                if (entity.GetEntityType() != EntityType.EntityType_Player)
                {
                    continue;
                }
            }
            break;

            case HeadStatusType.Collect:
                break;

            case HeadStatusType.HeadMaskIcon:
            case HeadStatusType.TaskStatus:
            {
                if (entity.GetEntityType() != EntityType.EntityType_NPC)
                {
                    continue;
                }
            }
            break;
            }
            enumerator.Current.Value.UpdateHeadStatus(status);
        }
    }
Пример #2
0
    /// <summary>
    /// 实体创建
    /// </summary>
    /// <param name="ce"></param>
    private void OnCretateEntity(Client.stCreateEntity ce)
    {
        IEntity entity = RoleStateBarManager.GetEntity(ce.uid);

        if (entity == null)
        {
            Engine.Utility.Log.Error("找不到对象------------{0}", ce.uid);
            return;
        }

        if (entity.GetEntityType() == EntityType.EntityType_Pet)
        {
            return;
        }

        if (entity.GetEntityType() == EntityType.EntityType_NPC)
        {
            table.NpcDataBase npctable = GameTableManager.Instance.GetTableItem <table.NpcDataBase>((uint)entity.GetProp((int)Client.EntityProp.BaseID));
            if (npctable != null)
            {
                if (npctable.dwType == (uint)GameCmd.enumNpcType.NPC_TYPE_TRAP)
                {
                    return;
                }
            }
        }
        AddRoleBar(entity);
    }
Пример #3
0
    /// 添加实体头顶标识
    /// </summary>
    /// <param name="uid"></param>
    private UIRoleStateBar AddRoleBar(long uid)
    {
        IEntity entity = RoleStateBarManager.GetEntity(uid);

        if (null == entity)
        {
            Engine.Utility.Log.Error("RoleStateBarPanel GetEntity Failed UID = " + uid);
            return(null);
        }
        return(AddRoleBar(entity));
    }
Пример #4
0
    /// <summary>
    /// 更新位置
    /// </summary>
    public void UpdatePositon()
    {
        if (!Visible)
        {
            return;
        }
        if (UID == 0)
        {
            return;
        }
        Client.IEntity entity = RoleStateBarManager.GetEntity(UID);
        if (entity == null)
        {
            return;
        }

        RoleStateBarManager mgr = DataManager.Manager <RoleStateBarManager>();
        Vector3             pos = Vector3.zero;

        if (entity.GetEntityType() == EntityType.EntityType_Player)
        {
            bool bRide = (bool)entity.SendMessage(Client.EntityMessage.EntityCommond_IsRide, null);
            if (bRide)
            {
                pos = mgr.GetNodeWorldPos(UID, "MountName", offsetY);
            }
            else
            {
                pos = mgr.GetNodeWorldPos(UID, "Name", offsetY);
            }
        }
        else
        {
            pos = mgr.GetNodeWorldPos(UID, "Name", offsetY);
        }

        Camera mainCamera = Util.MainCameraObj.GetComponent <Camera>();
        Camera uiCamera   = Util.UICameraObj.GetComponent <Camera>();

        if (null == uiCamera || null == mainCamera)
        {
            return;
        }
        pos = mainCamera.WorldToViewportPoint(pos);
        //bool isVisible = (mainCamera.orthographic || pos.z > 0f) && (/*!disableIfInvisible || */(pos.x > 0f && pos.x < 1f && pos.y > 0f && pos.y < 1f));
        //if (Visible != isVisible)
        //{
        //    SetVisible(isVisible);
        //    if (Visible)
        //    {
        //        AdjustStatusPos();
        //    }
        //}
        pos = uiCamera.ViewportToWorldPoint(pos);
        m_tsTran.position = pos;
        pos   = m_tsTran.localPosition;
        pos.x = Mathf.FloorToInt(pos.x);
        pos.y = Mathf.FloorToInt(pos.y);
        pos.z = 0f;
        m_tsTran.localPosition = pos;
    }
Пример #5
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();
            }
        }
    }