Beispiel #1
0
    private RoleStateBar CreateHeadText(IEntity entity, List <HeadTipData> lstdata)
    {
        RoleStateBar hudtext = new RoleStateBar(GetHudText(), entity, lstdata);

        if (hudtext != null)
        {
            if (Application.isEditor)
            {
                if (entity.GetEntityType() == EntityType.EntityType_Player)
                {
                    hudtext.mtrans.name = entity.GetName() + entity.GetID().ToString();
                }
                else
                {
                    hudtext.mtrans.name = entity.GetName() + "_" + entity.GetID().ToString();
                }
                hudtext.name = hudtext.mtrans.name;
            }

            m_lstAllStateBar.Add(hudtext);

            return(hudtext);
        }
        return(null);
    }
Beispiel #2
0
    public void SetPlayerTitleVisible(bool visible)
    {
        m_bPlayerTitleVisible = visible;

        for (int i = 0, imax = m_lstAllStateBar.Count; i < imax; i++)
        {
            RoleStateBar bar = m_lstAllStateBar[i];
            if (bar == null)
            {
                continue;
            }
            if (bar.entity == null)
            {
                continue;
            }
            if (bar.entity.GetEntityType() != EntityType.EntityType_Player)
            {
                continue;
            }

            if (bar.entity.GetUID() == ClientGlobal.Instance().MainPlayer.GetUID())
            {
                continue;
            }

            bar.SetWidgetState(HeadTipType.Clan, m_bPlayerTitleVisible);
        }
    }
Beispiel #3
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);
        }
    }
Beispiel #4
0
 public void OnRefreshAllHpSlider()
 {
     for (int i = 0, imax = m_lstAllStateBar.Count; i < imax; i++)
     {
         RoleStateBar bar = m_lstAllStateBar[i];
         if (bar == null)
         {
             continue;
         }
         RefreshHpSlider(bar.entity, bar);
     }
 }
Beispiel #5
0
 void OnChangeName(long uid)
 {
     Client.IEntity entity = ClientGlobal.Instance().GetEntitySystem().FindEntity(uid);
     if (entity != null)
     {
         RoleStateBar bar = GetRoleBarByUID(uid);
         if (bar != null)
         {
             HeadTipData data = new HeadTipData(entity, HeadTipType.Name, GetNameVisible(entity));
             bar.UpdateWidget(data);
         }
     }
 }
Beispiel #6
0
    void SetBarVisible(long uid, bool bShow, float alp = 1.0f)
    {
        RoleStateBar bar = GetRoleBarByUID(uid);

        if (bar != null)
        {
            if (bShow)
            {
                bar.widget.alpha = alp;
            }
            else
            {
                bar.widget.alpha = 0f;
            }
        }
    }
Beispiel #7
0
    private void UpdateNpcHeadMask(Client.INPC npc)
    {
        if (null != npc)
        {
            return;
        }

        RoleStateBar bar    = GetRoleBarByUID(npc.GetUID());
        bool         enable = IsEntityHaveHeadIconMask(npc) && !NpcHeadTipsManager.Instance.IsHaveTips(npc);

        bar.SetWidgetState(HeadTipType.HeadMaskIcon, enable);
        if (enable)
        {
            bar.UpdateWidget(new HeadTipData(npc, HeadTipType.HeadMaskIcon, m_bHpSliderVisible));
        }
    }
Beispiel #8
0
    private void OnRefreshAllClanTitile()
    {
        for (int i = 0, imax = m_lstAllStateBar.Count; i < imax; i++)
        {
            RoleStateBar bar = m_lstAllStateBar[i];
            if (bar == null)
            {
                continue;
            }

            if (bar.entity.GetEntityType() != EntityType.EntityType_Player)
            {
                continue;
            }
            RefreshClanName(bar.entity, bar);
        }
    }
Beispiel #9
0
    private void RemoveBar(Client.stRemoveEntity removeEntiy)
    {
        RoleStateBar bar = GetRoleBarByUID(removeEntiy.uid);

        if (bar != null)
        {
            if (m_lstUnUseStateBarTrans.Count < MAXBAR_NUM)
            {
                m_lstUnUseStateBarTrans.Add(bar.mtrans);
                bar.mtrans.name = "UnUse_" + m_lstUnUseStateBarTrans.Count;
                bar.obj.SetActive(false);
            }
            else
            {
                GameObject.Destroy(bar.mtrans.gameObject);
            }
            m_lstAllStateBar.Remove(bar);
        }
    }
Beispiel #10
0
    private void OnTitleWear(uint uid)
    {
        Client.IEntitySystem es = Client.ClientGlobal.Instance().GetEntitySystem();

        if (es == null)
        {
            return;
        }

        Client.IPlayer entity = es.FindPlayer(uid);
        if (entity != null)
        {
            RoleStateBar bar = GetRoleBarByUID(entity.GetUID());
            if (bar != null)
            {
                bar.UpdateWidget(new HeadTipData(entity, HeadTipType.Title, m_bPlayerTitleVisible));
            }
        }
    }
Beispiel #11
0
    void RefreshHpSlider(Client.IEntity entity, RoleStateBar bar)
    {
        if (entity == null)
        {
            Engine.Utility.Log.Error("RefreshHpSlider entity is null");
            return;
        }
        if (bar == null)
        {
            Engine.Utility.Log.Error("RefreshHpSlider bar is null");
            return;
        }
        bool        addHpSlider = IsNeedHpSlider(entity);
        HeadTipData data        = null;

        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;
            }
            data = new HeadTipData(entity, HeadTipType.Hp, visible);
        }
        else
        {
            data = new HeadTipData(entity, HeadTipType.Hp, addHpSlider);
        }
        if (data != null)
        {
            bar.UpdateWidget(data);
        }
    }
Beispiel #12
0
 private void OnPropUpdate(ref stPropUpdate prop)
 {
     Client.IEntity entity = ClientGlobal.Instance().GetEntitySystem().FindEntity(prop.uid);
     if (prop.nPropIndex == (int)CreatureProp.Hp || prop.nPropIndex == (int)CreatureProp.MaxHp)
     {
         if (entity != null)
         {
             RoleStateBar bar = GetRoleBarByUID(prop.uid);
             if (bar != null)
             {
                 HeadTipData data = new HeadTipData(entity, HeadTipType.Hp, m_bHpSliderVisible);
                 bar.UpdateWidget(data);
             }
         }
     }
     else if (prop.nPropIndex == (int)PlayerProp.GoodNess || prop.nPropIndex == (int)CreatureProp.Camp)
     {
         OnChangeName(prop.uid);
     }
 }
Beispiel #13
0
    private void OnClanNameRefresh(uint clanID, uint uid)
    {
        RoleStateBar bar = GetRoleBarByUID(uid);

        if (bar != null)
        {
            if (clanID != 0)
            {
                Client.IEntitySystem es = Client.ClientGlobal.Instance().GetEntitySystem();

                if (es == null)
                {
                    return;
                }
            }
            else
            {
                bar.SetWidgetState(HeadTipType.Clan, false);
            }
        }
    }
Beispiel #14
0
    public void SetNpcNameVisible(bool visible)
    {
        m_bNpcNameVisible = visible;
        for (int i = 0, imax = m_lstAllStateBar.Count; i < imax; i++)
        {
            RoleStateBar bar = m_lstAllStateBar[i];
            if (bar == null)
            {
                continue;
            }
            if (bar.entity == null)
            {
                continue;
            }
            if (bar.entity.GetEntityType() != EntityType.EntityType_NPC)
            {
                continue;
            }

            bar.SetWidgetState(HeadTipType.Name, m_bNpcNameVisible);
        }
    }
Beispiel #15
0
    public void SetHpSliderVisible(bool visible)
    {
        m_bHpSliderVisible = visible;
        for (int i = 0, imax = m_lstAllStateBar.Count; i < imax; i++)
        {
            RoleStateBar bar = m_lstAllStateBar[i];
            if (bar == null)
            {
                continue;
            }
            if (bar.entity == null)
            {
                continue;
            }
            //             if (bar.entity.GetUID() == ClientGlobal.Instance().MainPlayer.GetUID())
            //             {
            //                 continue;
            //             }

            bar.SetWidgetState(HeadTipType.Hp, m_bHpSliderVisible);
        }
    }
Beispiel #16
0
    //-----------------------------------------------------------------------------------------------
    private void OnStartCollectSlider(ref Client.stUninterruptMagic uninterrupt)
    {
        if (ShowCollectTip(uninterrupt.type))
        {
            Client.IEntitySystem es = Client.ClientGlobal.Instance().GetEntitySystem();

            if (es == null)
            {
                return;
            }

            Client.IEntity entity = es.FindEntity(uninterrupt.uid);
            if (entity != null && Client.ClientGlobal.Instance().IsMainPlayer(entity.GetUID()) == false)
            {
                RoleStateBar bar = GetRoleBarByUID(uninterrupt.uid);
                if (bar != null)
                {
                    HeadTipData data = new HeadTipData(entity, HeadTipType.Collect, true);
                    data.SetCollectType(uninterrupt.type);
                    bar.UpdateWidget(data);
                }
            }
        }
    }
Beispiel #17
0
    void UpdateBarPos(RoleStateBar item)
    {
        if (item == null)
        {
            return;
        }

        Vector3 pos = Vector3.zero;

        //性能优化 先去掉频繁的sendmessage 此处会造成gc modify by zhudianyu
        //if (item.entity.GetEntityType() == EntityType.EntityType_Player)
        //{
        //    bool bRide = (bool)item.entity.SendMessage(Client.EntityMessage.EntityCommond_IsRide, null);
        //    if (bRide)
        //    {
        //        pos = item.GetNodeWorldPos("MountName");
        //    }
        //    else
        //    {
        //        pos = item.GetNodeWorldPos("Name");
        //    }
        //}
        //else
        //{
        //    pos = item.GetNodeWorldPos("Name");
        //}
        pos = item.GetNodeWorldPos("Name");
        //Profiler.BeginSample("WorldToViewportPoint");

        if (m_maincamera == null)
        {
            Engine.Utility.Log.Error("--->>> m_maincamera 为空!!!");
            m_maincamera = Util.MainCameraObj.GetComponent <Camera>();
        }

        pos = m_maincamera.WorldToViewportPoint(pos);
        bool isVisible = (m_maincamera.orthographic || pos.z > 0f) && (!disableIfInvisible || (pos.x > 0f && pos.x <1f && pos.y> 0f && pos.y < 1f));

        if (item.obj.activeSelf != isVisible)
        {
            item.obj.SetActive(isVisible);
        }
        //Profiler.EndSample();
        if (!isVisible)
        {
            return;
        }

        if (m_uicamera == null)
        {
            Engine.Utility.Log.Error("--->>> m_uicamera 为空!!!");
            m_uicamera = Util.UICameraObj.GetComponent <Camera>();
        }

        pos = m_uicamera.ViewportToWorldPoint(pos);
        item.mtrans.position = pos;

        pos   = item.mtrans.localPosition;
        pos.x = Mathf.FloorToInt(pos.x);
        pos.y = Mathf.FloorToInt(pos.y);
        pos.z = 0f;
        item.mtrans.localPosition = pos;
    }
Beispiel #18
0
    void RefreshClanName(Client.IEntity entity, RoleStateBar bar)
    {
        if (entity == null)
        {
            Engine.Utility.Log.Error("AddClanName entity is null");
            return;
        }
        if (bar == null)
        {
            Engine.Utility.Log.Error("AddClanName bar is null");
            return;
        }

        EntityType entityType = entity.GetEntityType();

        if (entityType == EntityType.EntityType_Player)
        {
            uint clanIdLow  = (uint)entity.GetProp((int)CreatureProp.ClanIdLow);
            uint clanIdHigh = (uint)entity.GetProp((int)CreatureProp.ClanIdHigh);
            uint clanId     = (clanIdHigh << 16) | clanIdLow;

            //int clanId = entity.GetProp((int)Client.CreatureProp.ClanId);
            if (clanId != 0)
            {
                DataManager.Manager <ClanManger>().GetClanName((uint)clanId, (namedata) =>
                {
                    string winerCityName = string.Empty;
                    string name          = string.Empty;
                    if (DataManager.Manager <CityWarManager>().GetWinerOfCityWarCityName((uint)clanId, out winerCityName))
                    {
                        //name = namedata.ClanName + winerCityName;
                        name = string.Format("{0}【{1}】", winerCityName, namedata.ClanName);
                    }
                    else
                    {
                        //name = namedata.ClanName;
                        name = string.Format("【{0}】", namedata.ClanName);
                    }

                    bool visible = m_bPlayerClanNameVisible;
                    if (entity.GetUID() == Client.ClientGlobal.Instance().MainPlayer.GetUID())
                    {
                        visible = true;
                    }
                    HeadTipData data = new HeadTipData(entity, HeadTipType.Clan, visible);
                    data.value       = name;
                    bar.UpdateWidget(data);
                });
            }
            else
            {
                bar.SetWidgetState(HeadTipType.Clan, false);
            }
        }
        else if (entity.GetEntityType() == EntityType.EntityType_NPC)
        {
            CityWarTotem cityWarTotemInfo = null;
            if (DataManager.Manager <CityWarManager>().GetCityWarTotemClanName((uint)entity.GetProp((int)Client.EntityProp.BaseID), out cityWarTotemInfo))
            {
                HeadTipData data = new HeadTipData(entity, HeadTipType.Clan, m_bPlayerClanNameVisible);
                data.value = cityWarTotemInfo.clanName;
                bar.UpdateWidget(data);
            }
            else
            {
                bar.SetWidgetState(HeadTipType.Clan, false);
            }
        }
    }
Beispiel #19
0
 /// <summary>
 /// 事件处理
 /// </summary>
 /// <param name="nEventID"></param>
 /// <param name="param"></param>
 public void GlobalEventHandler(int eventID, object param)
 {
     if (eventID == (int)Client.GameEventID.ENTITYSYSTEM_NPCHEADSTATUSCHANGED)
     {
         if (null != param && param is Client.INPC)
         {
             UpdateNpcHeadMask((Client.INPC)param);
         }
     }
     else if (eventID == (int)Client.GameEventID.ENTITYSYSTEM_CREATEENTITY)
     {
         Client.stCreateEntity ce = (Client.stCreateEntity)param;
         OnCretateEntity(ref ce);
     }
     else if (eventID == (int)Client.GameEventID.ENTITYSYSTEM_REMOVEENTITY)
     {
         Client.stRemoveEntity removeEntiy = (Client.stRemoveEntity)param;
         RemoveBar(removeEntiy);
     }
     else if (eventID == (int)Client.GameEventID.ENTITYSYSTEM_PROPUPDATE)
     {
         stPropUpdate prop = (stPropUpdate)param;
         OnPropUpdate(ref prop);
     }
     else if (eventID == (int)Client.GameEventID.ENTITYSYSTEM_HPUPDATE)
     {
         stPropUpdate prop = (stPropUpdate)param;
         OnPropUpdate(ref prop);
     }
     else if (eventID == (int)Client.GameEventID.ENTITYSYSTEM_CHANGENAME)
     {
         stEntityChangename e = (stEntityChangename)param;
         OnChangeName(e.uid);
     }
     else if (eventID == (int)(int)Client.GameEventID.ENTITYSYSTEM_SETHIDE)
     {
         stEntityHide st = (stEntityHide)param;
         OnSetEntityHide(ref st);
         return;
     }
     else if (eventID == (int)(int)Client.GameEventID.TITLE_WEAR)//佩戴称号
     {
         Client.stTitleWear data = (Client.stTitleWear)param;
         OnTitleWear(data.uid);
     }
     else if (eventID == (int)GameEventID.SKILLGUIDE_PROGRESSSTART)
     {
         Client.stUninterruptMagic uninterrupt = (Client.stUninterruptMagic)param;
         OnStartCollectSlider(ref uninterrupt);
     }
     else if (eventID == (int)GameEventID.SKILLGUIDE_PROGRESSBREAK)
     {
         if (param != null)
         {
             stGuildBreak guildbreak = (stGuildBreak)param;
             if (ShowCollectTip(guildbreak.action))
             {
                 long         uid = EntitySystem.EntityHelper.MakeUID(EntityType.EntityType_Player, guildbreak.uid);
                 RoleStateBar bar = GetRoleBarByUID(uid);
                 if (bar != null)
                 {
                     bar.SetWidgetState(HeadTipType.Collect, false);
                 }
             }
         }
     }
     else if (eventID == (int)GameEventID.SKILLGUIDE_PROGRESSEND)
     {
         if (param != null)
         {
             stGuildEnd guildEnd = (stGuildEnd)param;
             if (ShowCollectTip(guildEnd.action))
             {
                 long         uid = EntitySystem.EntityHelper.MakeUID(EntityType.EntityType_Player, guildEnd.uid);
                 RoleStateBar bar = GetRoleBarByUID(uid);
                 if (bar != null)
                 {
                     bar.SetWidgetState(HeadTipType.Collect, false);
                 }
             }
         }
     }
     else if (eventID == (int)Client.GameEventID.CLANQUIT || eventID == (int)Client.GameEventID.CLANJOIN ||
              eventID == (int)Client.GameEventID.CLANREFRESHID || eventID == (int)Client.GameEventID.CITYWARWINERCLANID ||
              eventID == (int)Client.GameEventID.CLANDeclareInfoAdd || eventID == (int)Client.GameEventID.CLANDeclareInfoRemove)
     {
         OnRefreshAllClanTitile();
     }
     else if (eventID == (int)Client.GameEventID.CITYWARTOTEMCLANNAMECHANGE)
     {
         long         uid = EntitySystem.EntityHelper.MakeUID(EntityType.EntityType_NPC, (uint)param);
         RoleStateBar bar = GetRoleBarByUID(uid);
         if (bar != null)
         {
             Client.IEntitySystem es = Client.ClientGlobal.Instance().GetEntitySystem();
             if (es == null)
             {
                 return;
             }
             RefreshClanName(es.FindEntity(uid), bar);
         }
     }
     else if (eventID == (int)Client.GameEventID.SYSTEM_GAME_READY)
     {
         OnRefreshAllHpSlider();
     }
 }