using asap.core; using game; using GameCore; using System.Collections.Generic; using TMPro; using UnityEngine; using UnityEngine.UI; public class SocialFriendItem : PanelItemBase { public GameObject bg_myself; List rank = new List(); public TMP_Text text_rank; public TMP_Text text_name; public Head head; public TMP_Text lv_text_count; public TMP_Text infiniteBuildingLevel_text_count; public GameObject icon_skyscraper; [SerializeField] private GameObject moreOption; public static GameObject activeMoreOption; [SerializeField] private Button moreOptionBtn; [SerializeField] private Button deleteBtn; [SerializeField] private Button moreOptionCloseBtn; string playFabId; bool isInit; void InitPanel() { Transform rank_panel = transform.Find("rank"); rank.Clear(); for (int i = 0; i < rank_panel.childCount; i++) { rank.Add(rank_panel.GetChild(i).gameObject); } moreOptionBtn.onClick.AddListener(OnMoreOptionClicked); deleteBtn.onClick.AddListener(OnDeleteClicked); moreOptionCloseBtn.onClick.AddListener(OnMoreOptionCloseClicked); isInit = true; } public override void OnInit() { if (!isInit) { InitPanel(); } IUserService userService = GContext.container.Resolve(); playFabId = data.playFabId; bg_myself.SetActive(data.playFabId == userService.UserId); moreOptionBtn.gameObject.SetActive(data.playFabId != userService.UserId); for (int i = 0; i < rank.Count - 1; i++) { rank[i].SetActive(data.rank == i + 1); } rank[^1].SetActive(data.rank >= rank.Count); text_rank.text = data.rank.ToString(); lv_text_count.text = data.lv.ToString(); infiniteBuildingLevel_text_count.text = data.infiniteBuildingLevel.ToString(); if (data.infiniteBuildingLevel > 0) { if (icon_skyscraper != null) { icon_skyscraper.SetActive(true); } } else { if (icon_skyscraper != null) { icon_skyscraper.SetActive(false); } } text_name.text = data.displayName; head.SetData(data.avatarUrl); } private void OnMoreOptionClicked() { if(activeMoreOption != moreOption) { activeMoreOption?.SetActive(false); activeMoreOption = moreOption; } activeMoreOption.SetActive(!activeMoreOption.activeSelf); } private void OnMoreOptionCloseClicked() { activeMoreOption?.SetActive(false); activeMoreOption = null; moreOption.SetActive(false); } private async void OnDeleteClicked() { string title = LocalizationMgr.GetText("UI_FishingSocialPanel_52"); string info = LocalizationMgr.GetText("UI_FishingSocialPanel_53"); string l_Label = LocalizationMgr.GetText("UI_COMMON_cancel"); string r_label = LocalizationMgr.GetText("UI_FishingSocialPanel_31"); GameObject go = await UIManager.Instance.ShowUI(UITypes.NoticeConfirmPopupPanel); var noticeConfirmPopupPanel = go.GetComponent(); noticeConfirmPopupPanel.Init(2, title, info, OnDeleteCancel, OnDeleteConfirm, OnDeleteCancel,l_Label, r_label, true); } private void OnDeleteCancel() { moreOption.SetActive(false); } private async void OnDeleteConfirm() { moreOption.SetActive(false); var service = GContext.container.Resolve(); GameCore.UIManager.ShowWaitingBlock("SocialFriendItemData::Delete"); var success = await service.DeleteFriend(playFabId); GameCore.UIManager.HideWaitingBlock("SocialFriendItemData::Delete"); ToastPanel.Show(LocalizationMgr.GetText(success ? "UI_ToastPanel_112" : "UI_ToastPanel_113")); } } public class SocialFriendItemData { public int rank; public int lv = 1; public int infiniteBuildingLevel = 0; public string playFabId; public string displayName; public string avatarUrl; }