103 lines
4.5 KiB
C#
103 lines
4.5 KiB
C#
using asap.core;
|
|
using game;
|
|
using GameCore;
|
|
using TMPro;
|
|
using UnityEngine.UI;
|
|
using UniRx;
|
|
using System.Collections.Generic;
|
|
using UnityEngine;
|
|
public class ChangeTabEvent
|
|
{
|
|
public int index;
|
|
}
|
|
public class PlayerGradePanel : BasePanel
|
|
{
|
|
Button btn_close;
|
|
TMP_Text text_grade;
|
|
TMP_Text text_skyscraper;
|
|
GameObject skyscraper;
|
|
TMP_Text text_name;
|
|
TMP_Text text_id;
|
|
Button btn_edit;
|
|
Head head;
|
|
Button btn_benefit;
|
|
List<Toggle> toggles = new List<Toggle>();
|
|
List<GameObject> selected_tab = new List<GameObject>();
|
|
List<GameObject> root = new List<GameObject>();
|
|
List<GameObject> redpoint = new List<GameObject>();
|
|
private void Awake()
|
|
{
|
|
btn_close = transform.Find("root/btn_close").GetComponent<Button>();
|
|
text_grade = transform.Find("root/bg_title/text_grade").GetComponent<TMP_Text>();
|
|
skyscraper = transform.Find("root/bg_title/icon_skyscraper").gameObject;
|
|
text_skyscraper = transform.Find("root/bg_title/icon_skyscraper/text_num").GetComponent<TMP_Text>();
|
|
head = transform.Find("root/bg_title/btn_head").GetComponent<Head>();
|
|
text_name = transform.Find("root/bg_title/text_name").GetComponent<TMP_Text>();
|
|
text_id = transform.Find("root/bg_title/text_grade/text_id").GetComponent<TMP_Text>();
|
|
btn_edit = transform.Find("root/bg_title/text_name/btn_edit").GetComponent<Button>();
|
|
btn_benefit = transform.Find("root/bg_title/btn_benefit").GetComponent<Button>();
|
|
root.Add(transform.Find("root/root_reward").gameObject);
|
|
root.Add(transform.Find("root/root_progress").gameObject);
|
|
root.Add(transform.Find("root/root_achievement").gameObject);
|
|
for (int i = 0; i < 3; i++)
|
|
{
|
|
redpoint.Add(transform.Find($"root/tab/redpoint_tab{i + 1}").gameObject);
|
|
selected_tab.Add(transform.Find($"root/tab/selected_tab{i + 1}").gameObject);
|
|
toggles.Add(transform.Find($"root/tab/text_tab{i + 1}").GetComponent<Toggle>());
|
|
Toggle toggle = toggles[i];
|
|
int index = i;
|
|
toggle.onValueChanged.AddListener((isOn) =>
|
|
{
|
|
selected_tab[index].SetActive(isOn);
|
|
root[index].SetActive(isOn);
|
|
});
|
|
root[i].SetActive(i == 0);
|
|
selected_tab[i].SetActive(i == 0);
|
|
toggle.isOn = i == 0;
|
|
}
|
|
}
|
|
void ShowTab(int index)
|
|
{
|
|
toggles[index].isOn = true;
|
|
}
|
|
protected override void Start()
|
|
{
|
|
GContext.OnEvent<GetCurSelectMapEvent>().Subscribe(GetCurSelectMap).AddTo(disposables);
|
|
GContext.OnEvent<ChangeTabEvent>().Subscribe((e) => ShowTab(e.index)).AddTo(disposables);
|
|
oldPanelName = PanelName;
|
|
base.Start();
|
|
btn_close.onClick.AddListener(() => { UIManager.Instance.DestroyUI(UITypes.PlayerGradePanel); });
|
|
btn_edit.onClick.AddListener(() => { _ = UIManager.Instance.GetUIAsync(UITypes.PlayerHeadPopupPanel); });
|
|
btn_benefit.onClick.AddListener(() => { _ = UIManager.Instance.GetUIAsync(UITypes.PlayerGradeBenefitPopupPanel); });
|
|
text_id.text = $"ID: {GContext.container.Resolve<IUserService>().CustomId}";
|
|
text_name.text = GContext.container.Resolve<IUserService>().DisplayName;
|
|
head.SetData(GContext.container.Resolve<IUserService>().AvatarUrl);
|
|
text_grade.text = GContext.container.Resolve<PlayerData>().lv.ToString();
|
|
GContext.OnEvent<ChangeAvatarEvent>().Subscribe(OnChangeAvatar).AddTo(disposables);
|
|
redpoint[1].SetActive(GContext.container.Resolve<PlayerFishData>().PTSRed());
|
|
string InfiniteBuildingLevel = GContext.container.Resolve<PlayerData>().InfiniteBuildingLevel;
|
|
skyscraper.gameObject.SetActive(InfiniteBuildingLevel != "0");
|
|
text_skyscraper.text = InfiniteBuildingLevel;
|
|
//新手引导
|
|
GContext.container.Resolve<GuideDataCenter>().InspectTriggerGuide(name);
|
|
|
|
}
|
|
void GetCurSelectMap(GetCurSelectMapEvent getCurSelectMapEvent)
|
|
{
|
|
if (getCurSelectMapEvent.type != 0)
|
|
{
|
|
redpoint[1].SetActive(GContext.container.Resolve<PlayerFishData>().PTSRed());
|
|
}
|
|
}
|
|
void OnChangeAvatar(ChangeAvatarEvent data)
|
|
{
|
|
head.SetData(GContext.container.Resolve<IUserService>().AvatarUrl);
|
|
text_name.text = GContext.container.Resolve<IUserService>().DisplayName;
|
|
}
|
|
private void OnDisable()
|
|
{
|
|
RestartShowHomeUIEvent restartShowHomeUIEvent = new RestartShowHomeUIEvent();
|
|
GContext.Publish(restartShowHomeUIEvent);
|
|
}
|
|
}
|