备份CatanBuilding瘦身独立工程
This commit is contained in:
58
Assets/Scripts/UI/UITopLevel.cs
Normal file
58
Assets/Scripts/UI/UITopLevel.cs
Normal file
@@ -0,0 +1,58 @@
|
||||
using asap.core;
|
||||
using game;
|
||||
using GameCore;
|
||||
using System;
|
||||
using TMPro;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
using UniRx;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
public class OnLvChangeEvent
|
||||
{
|
||||
public int lvl;
|
||||
}
|
||||
|
||||
public class UITopLevel : MonoBehaviour
|
||||
{
|
||||
public Button btn_level;
|
||||
public TMP_Text text_name;
|
||||
public Head head;
|
||||
public TMP_Text text_grade;
|
||||
public GameObject redpoint;
|
||||
PlayerData playerData;
|
||||
IDisposable disposable;
|
||||
void Start()
|
||||
{
|
||||
playerData = GContext.container.Resolve<PlayerData>();
|
||||
IUserService userService = GContext.container.Resolve<IUserService>();
|
||||
text_name.text = userService.DisplayName;
|
||||
head.SetData(userService.AvatarUrl);
|
||||
btn_level.onClick.AddListener(OnClickLevel);
|
||||
text_grade.text = GContext.container.Resolve<PlayerData>().lv.ToString();
|
||||
disposable = GContext.OnEvent<OnLvChangeEvent>().Subscribe(OnLvChange);
|
||||
redpoint.SetActive(GContext.container.Resolve<PlayerFishData>().PTSRed());
|
||||
}
|
||||
async void OnClickLevel()
|
||||
{
|
||||
var _fishingEventData = GContext.container.Resolve<FishingEventData>();
|
||||
if (playerData.OpenGrade)
|
||||
{
|
||||
await UIManager.Instance.ShowUI(UITypes.PlayerGradePanel);
|
||||
GContext.Publish(new HideHomePanelEvent());
|
||||
}
|
||||
else
|
||||
{
|
||||
ToastPanel.Show(_fishingEventData.GetTipforUnlocked(playerData.OpenGradeID));
|
||||
}
|
||||
}
|
||||
public async void OnLvChange(OnLvChangeEvent onLvChangeEvent)
|
||||
{
|
||||
await Task.Delay(1000);
|
||||
text_grade.text = onLvChangeEvent.lvl.ToString();
|
||||
}
|
||||
private void OnDestroy()
|
||||
{
|
||||
disposable?.Dispose();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user