예제 #1
0
    void RefreshScroll()
    {
        HSUnityTools.DestroyChildren(RoleParent_RectTransform);
        if (m_params.roleList == null || m_params.roleList.Count <= 0)
        {
            return;
        }

        for (int i = 0; i < m_params.roleList.Count; i++)
        {
            var role = m_params.roleList[i];
            var item = RoleUIItem.Create();
            item.transform.SetParent(RoleParent_RectTransform);
            item.transform.localScale = Vector3.one;

            Button btn = item.GetComponent <Button>();
            BindListener(btn, () =>
            {
                OnItemClick(item);
            });
            bool select = m_params.selectList.Contains(role);
            item.SetSelect(select);
            item.ShowRole(role);
        }
    }
예제 #2
0
    void OnItemClick(RoleUIItem item)
    {
        RoleInstance role  = item.GetShowRole();
        bool         hasIt = m_params.selectList.Contains(role);

        if (hasIt)
        {
            if (m_params.selectList.Count <= 1)
            {
                return;
            }
            if (m_params.mustSelect != null && m_params.mustSelect.Invoke(role))
            {
                GameUtil.DisplayPopinfo("此角色强制上场");
                return;
            }
            m_params.selectList.Remove(role);
            item.SetSelect(false);
        }
        else
        {
            if (m_params.IsFull)
            {
                GameUtil.DisplayPopinfo($"最多只能选择{m_params.maxCount}人");
                return;
            }
            m_params.selectList.Add(role);
            item.SetSelect(true);
        }
    }
예제 #3
0
    void RefreshScrollView()
    {
        HSUnityTools.DestroyChildren(RoleParent_RectTransform);
        if (m_roleList == null || m_roleList.Count <= 0)
        {
            return;
        }
        RoleInstance role;

        for (int i = 0; i < m_roleList.Count; i++)
        {
            role = m_roleList[i];
            var item = RoleUIItem.Create();
            item.transform.SetParent(RoleParent_RectTransform);
            item.transform.localScale = Vector3.one;

            Button btn = item.GetComponent <Button>();
            BindListener(btn, () =>
            {
                OnItemClick(item);
            });
            bool isSelect = (m_currentRole == role);
            if (isSelect)
            {
                m_currentShowItem = item;
            }
            item.SetSelect(isSelect);
            item.ShowRole(role);
        }
    }
예제 #4
0
    void OnItemClick(RoleUIItem item)
    {
        if (m_currentShowItem != null && m_currentShowItem == item)
        {
            return;
        }
        if (m_currentShowItem)
        {
            m_currentShowItem.SetSelect(false);
        }

        m_currentShowItem = item;
        m_currentShowItem.SetSelect(true);

        m_currentRole = m_currentShowItem.GetShowRole();
        RefreshCurrent();
    }