67 lines
2.2 KiB
C#
67 lines
2.2 KiB
C#
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using TMPro;
|
|
using UnityEngine;
|
|
using UnityEngine.UI;
|
|
|
|
public class SelectGameLeave_DefaultUIItem : MonoBehaviour
|
|
{
|
|
public TextMeshProUGUI tMP_Name;
|
|
public Image sprite_Avatar;
|
|
public Image sprite_AvatarFrame;
|
|
public TextMeshProUGUI tMP_GoldCount;
|
|
public TextMeshProUGUI tMP_DiamodCount;
|
|
public Button btn_StartQuickly;
|
|
public Button btn_FanHui;
|
|
public Button btn_SheZhi;
|
|
[Header("跳转商城")]
|
|
public Button btn_ShopDiamond;
|
|
public Button btn_ShopGlod;
|
|
private void OnEnable()
|
|
{
|
|
GameManager.Instance.OnAvatarChanged += OnAvatarChanged;
|
|
GameManager.Instance.OnAvatarFrameChanged += OnAvatarFrameChanged;
|
|
|
|
if (btn_ShopDiamond != null)
|
|
btn_ShopDiamond.onClick.AddListener(OnClickShopDiamond);
|
|
if (btn_ShopGlod != null)
|
|
btn_ShopGlod.onClick.AddListener(OnClickShopGlod);
|
|
}
|
|
|
|
private void OnDisable()
|
|
{
|
|
if (GameManager.Instance != null)
|
|
{
|
|
GameManager.Instance.OnAvatarChanged -= OnAvatarChanged;
|
|
GameManager.Instance.OnAvatarFrameChanged -= OnAvatarFrameChanged;
|
|
}
|
|
if (btn_ShopDiamond != null)
|
|
btn_ShopDiamond.onClick.RemoveListener(OnClickShopDiamond);
|
|
if (btn_ShopGlod != null)
|
|
btn_ShopGlod.onClick.RemoveListener(OnClickShopGlod);
|
|
}
|
|
|
|
private void OnClickShopDiamond() => UIManager.Instance.Get<UIHomeMain>(UIPanel.HomeMainPanel)
|
|
.subUIManager.ShowAsync(UIPanel.ShopPanel, ShopTab.Diamond);
|
|
private void OnClickShopGlod() => UIManager.Instance.Get<UIHomeMain>(UIPanel.HomeMainPanel)
|
|
.subUIManager.ShowAsync(UIPanel.ShopPanel, ShopTab.Gold);
|
|
|
|
private void OnAvatarChanged(Sprite sprite)
|
|
{
|
|
if (sprite != null) sprite_Avatar.sprite = sprite;
|
|
}
|
|
|
|
private void OnAvatarFrameChanged(Sprite sprite)
|
|
{
|
|
if (sprite_AvatarFrame != null && sprite != null)
|
|
sprite_AvatarFrame.sprite = sprite;
|
|
}
|
|
|
|
public void UpdateData(string name, string gold, string diamod)
|
|
{
|
|
tMP_Name.text = name;
|
|
tMP_GoldCount.text = gold;
|
|
tMP_DiamodCount.text = diamod;
|
|
}
|
|
}
|