Beispiel #1
0
    /// <summary>
    /// 设置已有角色职业信息列表
    /// </summary>
    /// <param name="roleItems"></param>
    public void SetRoleList(List <RoleOperation_LogOnGameServerReturnProto.RoleItem> roleItems, Action <int> selectRoleCallback)
    {
        if (RoleItemObj != null && RoleItemObj.Count > 0)
        {
            for (int i = 0; i < RoleItemObj.Count; i++)
            {
                DestroyImmediate(RoleItemObj[i]);
            }
            RoleItemObj.Clear();
        }

        if (roleItems != null && roleItems.Count > 0)
        {
            for (int i = 0; i < roleItems.Count; i++)
            {
                //开始克隆预设
                GameObject obj = Instantiate <GameObject>(m_RoleItemPrefab.gameObject);
                obj.transform.SetParent(m_RoleListContainer);
                obj.transform.localScale     = Vector3.one;
                obj.transform.localPosition  = Vector3.zero;
                obj.transform.localPosition -= new Vector3(0, 80 * i + 5, 0);

                RoleItemObj.Add(obj);

                UISelectRoleRoleItemView roleItemView = obj.GetComponent <UISelectRoleRoleItemView>();
                roleItemView.SetUI(roleItems[i].RoleNickName, roleItems[i].RoleLevel, roleItems[i].RoleId, roleItems[i].RoleJob, m_RoleHeadSprite[roleItems[i].RoleJob - 1], selectRoleCallback);
            }
        }
    }
    /// <summary>
    /// 设置已有角色
    /// </summary>
    /// <param name="list"></param>
    public void SetRoleList(List <RoleOperation_LogOnGameServerReturnProto.RoleItem> list, Action <int> OnSelectRole)
    {
        ClearRoleListUI();

        for (int i = 0; i < list.Count; i++)
        {
            //克隆UI
            GameObject obj = Instantiate(m_RoleItemPrefab);
            UISelectRoleRoleItemView view = obj.GetComponent <UISelectRoleRoleItemView>();
            if (view != null)
            {
                view.SetUI(list[i].RoleId, list[i].RoleNickName, list[i].RoleLevel, list[i].RoleJob, m_RoleHeadPic[list[i].RoleJob - 1], OnSelectRole);
                m_RoleItemViewList.Add(view);
            }
            obj.transform.parent        = m_RoleListContainer;
            obj.transform.localScale    = Vector3.one;
            obj.transform.localPosition = new Vector3(0, -100 * i, 0);
        }
    }