备份CatanBuilding瘦身独立工程
This commit is contained in:
99
Assets/Scripts/UI/Social/ClubPromotePopupPanel.cs
Normal file
99
Assets/Scripts/UI/Social/ClubPromotePopupPanel.cs
Normal file
@@ -0,0 +1,99 @@
|
||||
using asap.core;
|
||||
using cfg;
|
||||
using game;
|
||||
using GameCore;
|
||||
using System;
|
||||
using TMPro;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
|
||||
public class ClubPromotePopupPanel : MonoBehaviour
|
||||
{
|
||||
// 当剩余席位不足时按钮置灰,点击弹toast提示:UI_ToastPanel_80 剩余席位不足 Insufficient remaining seats
|
||||
//当副会长没有权限任命副会长时按钮置灰,点击弹toast提示:UI_ToastPanel_81 您没有权限 You don't have permission
|
||||
Action<EMemberRole> OnClickPromote;
|
||||
TMP_Text text_remaining1;
|
||||
TMP_Text text_remaining2;
|
||||
Button btn_promote1;
|
||||
Button btn_promote2;
|
||||
Button btn_close;
|
||||
Button btn_promote_gray1;
|
||||
Button btn_promote_gray2;
|
||||
SocialInfoItemData socialInfoItemData;
|
||||
ClubService _socialData;
|
||||
int allViceCount = 3;
|
||||
int allElderCount = 6;
|
||||
private void Awake()
|
||||
{
|
||||
_socialData = GContext.container.Resolve<ClubService>();
|
||||
text_remaining1 = transform.Find("root/info1/text_remaining").GetComponent<TMP_Text>();
|
||||
text_remaining2 = transform.Find("root/info2/text_remaining").GetComponent<TMP_Text>();
|
||||
btn_promote1 = transform.Find("root/info1/btn_promote/btn_green").GetComponent<Button>();
|
||||
btn_promote2 = transform.Find("root/info2/btn_promote/btn_green").GetComponent<Button>();
|
||||
btn_close = transform.Find("btn_close").GetComponent<Button>();
|
||||
btn_promote_gray1 = transform.Find("root/info1/btn_promote_gray/btn_green").GetComponent<Button>();
|
||||
btn_promote_gray2 = transform.Find("root/info2/btn_promote_gray/btn_green").GetComponent<Button>();
|
||||
allViceCount = GContext.container.Resolve<Tables>().TbGlobalConfig.ClubMaxCoLeaderCount;
|
||||
allElderCount = GContext.container.Resolve<Tables>().TbGlobalConfig.ClubMaxElderCount;
|
||||
}
|
||||
private void Start()
|
||||
{
|
||||
btn_promote1.onClick.AddListener(OnClickPromote1);
|
||||
btn_promote2.onClick.AddListener(OnClickPromote2);
|
||||
btn_close.onClick.AddListener(OnClickClose);
|
||||
btn_promote_gray1.onClick.AddListener(OnClickPromotegray1);
|
||||
btn_promote_gray2.onClick.AddListener(OnClickPromotegray2);
|
||||
|
||||
}
|
||||
public void Init(Action<EMemberRole> onClickPromote, SocialInfoItemData socialInfoItemData, int elderCount, int viceCount)
|
||||
{
|
||||
this.socialInfoItemData = socialInfoItemData;
|
||||
OnClickPromote = onClickPromote;
|
||||
|
||||
btn_promote1.gameObject.SetActive(_socialData.memberRole == EMemberRole.Owner && viceCount < allViceCount);
|
||||
btn_promote_gray1.gameObject.SetActive(_socialData.memberRole != EMemberRole.Owner || viceCount >= allViceCount);
|
||||
text_remaining1.text = LocalizationMgr.GetFormatTextValue("UI_ClubInfoPopupPanel_12", viceCount, allViceCount);
|
||||
|
||||
btn_promote2.gameObject.SetActive(socialInfoItemData.role == EMemberRole.Member && elderCount < allElderCount);
|
||||
btn_promote_gray2.gameObject.SetActive(socialInfoItemData.role != EMemberRole.Member || elderCount >= allElderCount);
|
||||
text_remaining2.text = LocalizationMgr.GetFormatTextValue("UI_ClubInfoPopupPanel_12", elderCount, allElderCount);
|
||||
}
|
||||
void OnClickPromote1()
|
||||
{
|
||||
OnClickPromote?.Invoke(EMemberRole.Vice);
|
||||
OnClickClose();
|
||||
}
|
||||
void OnClickPromote2()
|
||||
{
|
||||
OnClickPromote?.Invoke(EMemberRole.Elder);
|
||||
OnClickClose();
|
||||
}
|
||||
void OnClickPromotegray1()
|
||||
{
|
||||
if (_socialData.memberRole == EMemberRole.Owner)
|
||||
{
|
||||
ToastPanel.Show(LocalizationMgr.GetText("UI_ToastPanel_80"));
|
||||
}
|
||||
else
|
||||
{
|
||||
ToastPanel.Show(LocalizationMgr.GetText("UI_ToastPanel_81"));
|
||||
}
|
||||
}
|
||||
void OnClickPromotegray2()
|
||||
{
|
||||
if (socialInfoItemData.role == EMemberRole.Member)
|
||||
{
|
||||
ToastPanel.Show(LocalizationMgr.GetText("UI_ToastPanel_80"));
|
||||
}
|
||||
else
|
||||
{
|
||||
//用户已经是 长老 等待提示多语言
|
||||
ToastPanel.Show(LocalizationMgr.GetText("UI_ToastPanel_81"));
|
||||
}
|
||||
}
|
||||
void OnClickClose()
|
||||
{
|
||||
UIManager.Instance.DestroyUI(UITypes.ClubPromotePopupPanel);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user