备份CatanBuilding瘦身独立工程
This commit is contained in:
70
Assets/Scripts/UI/Home/HomeBtnRod.cs
Normal file
70
Assets/Scripts/UI/Home/HomeBtnRod.cs
Normal file
@@ -0,0 +1,70 @@
|
||||
using asap.core;
|
||||
using cfg;
|
||||
using GameCore;
|
||||
using System;
|
||||
using TMPro;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
using UniRx;
|
||||
|
||||
public class HomeBtnRod : MonoBehaviour
|
||||
{
|
||||
Button btn_yugan;
|
||||
Image bg_hud_god_image;
|
||||
Image rawImage;
|
||||
TMP_Text text_grade_rod;
|
||||
TMP_Text text_star_rod;
|
||||
|
||||
PlayerFishData _playerFishData;
|
||||
Tables _tables;
|
||||
string[] bg_hud_gods = { "bg_hud_god_blue", "bg_hud_god_blue", "bg_hud_god_purple", "bg_hud_god_yellow" };
|
||||
IDisposable disposable;
|
||||
RodData rod;
|
||||
private void Awake()
|
||||
{
|
||||
_playerFishData = GContext.container.Resolve<PlayerFishData>();
|
||||
_tables = GContext.container.Resolve<Tables>();
|
||||
btn_yugan = GetComponent<Button>();
|
||||
bg_hud_god_image = transform.Find("bg").GetComponent<Image>();
|
||||
rawImage = transform.Find("mask/icon").GetComponent<Image>();
|
||||
text_grade_rod = transform.Find("text_grade").GetComponent<TMP_Text>();
|
||||
text_star_rod = transform.Find("bg_star/text_star").GetComponent<TMP_Text>();
|
||||
}
|
||||
private void Start()
|
||||
{
|
||||
btn_yugan.onClick.AddListener(async () =>
|
||||
{
|
||||
await UIManager.Instance.ShowUI(UITypes.FishingRodBagPanel);
|
||||
});
|
||||
}
|
||||
private void OnEnable()
|
||||
{
|
||||
btn_yugan.gameObject.SetActive(_playerFishData.IsOpenRod);
|
||||
if (_playerFishData.IsOpenRod)
|
||||
{
|
||||
rod = _tables.GetRodData(GContext.container.Resolve<PlayerData>().equipRodID);
|
||||
text_grade_rod.text = LocalizationMgr.GetFormatTextValue("UI_PlayerGradePanel_2", _playerFishData.GetRodLevel(rod.ID) + 1);
|
||||
text_star_rod.text = _playerFishData.GetRodPiece(rod.ID).ToString();
|
||||
GContext.container.Resolve<IUIService>().SetImageSprite(bg_hud_god_image, bg_hud_gods[rod.Quality - 1], "HomePanel");
|
||||
int skindID = _playerFishData.GetRodSkin(rod.ID);
|
||||
var fishRodSkinData = _tables.TbRodSkinData.GetOrDefault(skindID);
|
||||
if (fishRodSkinData != null)
|
||||
{
|
||||
GContext.container.Resolve<IUIService>().SetImageSprite(rawImage, fishRodSkinData.Avatar, "HomePanel");
|
||||
}
|
||||
}
|
||||
disposable = GContext.OnEvent<ChangeLanguageEvent>().Subscribe(OnChangeLanguage);
|
||||
}
|
||||
void OnChangeLanguage(ChangeLanguageEvent changeLanguageEvent)
|
||||
{
|
||||
text_grade_rod.text = LocalizationMgr.GetFormatTextValue("UI_PlayerGradePanel_2", _playerFishData.GetRodLevel(rod.ID) + 1);
|
||||
}
|
||||
private void OnDisable()
|
||||
{
|
||||
if (disposable != null)
|
||||
{
|
||||
disposable.Dispose();
|
||||
disposable = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user