Example #1
0
    private System.Collections.IEnumerator BuildEntityBarsCor()
    {
        yield return(0);

        IEntitySystem entitySystem = ClientGlobal.Instance().GetEntitySystem();

        if (null != entitySystem)
        {
            List <long> entityUids = entitySystem.GetEntityUids();

            if (null != entityUids)
            {
                UIRoleStateBar bar = null;
                int            successCreateCount = 0;
                int            modSeed            = (entityUids.Count % 30);
                modSeed = Mathf.Max(0, modSeed);
                for (int i = 0, max = entityUids.Count; i < max; i++)
                {
                    bar = AddRoleBar(entityUids[i]);
                    if (null != bar)
                    {
                        successCreateCount++;
                        if (modSeed != 0)
                        {
                            if (successCreateCount % modSeed == 0)
                            {
                                //等待下一帧
                                yield return(null);
                            }
                        }
                    }
                }
            }
        }
    }
Example #2
0
    /// <summary>
    /// 添加实体头顶标识
    /// </summary>
    /// <param name="entity"></param>
    private UIRoleStateBar AddRoleBar(IEntity entity)
    {
        if (null == entity || m_dicActiveRoleStateBar.ContainsKey(entity.GetUID()))
        {
            return(null);
        }
        UIRoleStateBar rolebar = GetEmptyRoleStateBar();

        if (null != rolebar)
        {
            if (Application.isEditor)
            {
                if (entity.GetEntityType() == EntityType.EntityType_Player)
                {
                    rolebar.Tran.name = entity.GetName() + entity.GetID().ToString();
                }
                else
                {
                    rolebar.Tran.name = entity.GetName() + "_" + entity.GetID().ToString();
                }
            }
            rolebar.SetVisible(true);
            rolebar.SetData(entity.GetUID());
            m_dicActiveRoleStateBar.Add(entity.GetUID(), rolebar);
            //LateUpdate刷新位置
            LateUpdateChangePos(entity.GetUID());
        }
        return(rolebar);
    }
Example #3
0
 /// <summary>
 /// 释放状态栏
 /// </summary>
 /// <param name="stateBar"></param>
 private void Release(UIRoleStateBar stateBar)
 {
     if (null == stateBar)
     {
         return;
     }
     Release(stateBar.UID);
 }
    /// <summary>
    /// 更新npc任务状态
    /// </summary>
    /// <param name="uid"></param>
    /// <param name="enable"></param>
    /// <param name="statusIcon"></param>
    private void UpdateNpcTaskStatus(long uid, bool enable, string statusIcon = "")
    {
        UIRoleStateBar bar = GetRoleBar(uid);

        if (null != bar)
        {
            bar.UpdateTaskUI(enable, statusIcon);
        }
    }
Example #5
0
    private void UpdateRoleBarPos(long uid)
    {
        UIRoleStateBar roleBar = GetRoleBar(uid);

        if (null != roleBar)
        {
            roleBar.UpdatePositon();
        }
    }
Example #6
0
    /// <summary>
    /// 获取角色状态bar
    /// </summary>
    /// <returns></returns>
    public UIRoleStateBar GetEmptyRoleStateBar()
    {
        UIRoleStateBar bar = null;

        if (m_lstCacheStateBar.Count > 0)
        {
            bar = m_lstCacheStateBar[0];
            m_lstCacheStateBar.RemoveAt(0);
        }
        else
        {
            bar = UIRoleStateBar.Create(GetRoleBarTrans());
        }
        return(bar);
    }
Example #7
0
 private void DoLateUpdateChangePos()
 {
     if (m_lstChangePosIds.Count > 0)
     {
         UIRoleStateBar roleStateBar = null;
         for (int i = 0, max = m_lstChangePosIds.Count; i < max; i++)
         {
             if (!m_dicActiveRoleStateBar.TryGetValue(m_lstChangePosIds[i], out roleStateBar))
             {
                 continue;
             }
             roleStateBar.UpdatePositon();
         }
         m_lstChangePosIds.Clear();
     }
 }
Example #8
0
    /// <summary>
    /// 释放状态栏
    /// </summary>
    /// <param name="uid"></param>
    private void Release(long uid)
    {
        UIRoleStateBar roleStateBar = null;

        if (m_dicActiveRoleStateBar.ContainsKey(uid))
        {
            roleStateBar = m_dicActiveRoleStateBar[uid];
            m_dicActiveRoleStateBar.Remove(uid);
        }

        if (null != roleStateBar && !m_lstCacheStateBar.Contains(roleStateBar))
        {
            roleStateBar.SetVisible(false);
            roleStateBar.Tran.name = "cache";
            m_lstCacheStateBar.Add(roleStateBar);
        }
    }
Example #9
0
    void SetBarVisible(long uid, bool bShow, float alp = 1.0f)
    {
        UIRoleStateBar roleStateBar = null;

        if (m_dicActiveRoleStateBar.ContainsKey(uid))
        {
            roleStateBar = m_dicActiveRoleStateBar[uid];
            if (roleStateBar != null)
            {
                UIWidget widgt = roleStateBar.widget;
                if (widgt != null)
                {
                    if (bShow)
                    {
                        widgt.alpha = alp;
                    }
                    else
                    {
                        widgt.alpha = 0f;
                    }
                }
            }
        }
    }