备份CatanBuilding瘦身独立工程
This commit is contained in:
91
Assets/Scripts/UI/Tips/BubbleTaskInfo.cs
Normal file
91
Assets/Scripts/UI/Tips/BubbleTaskInfo.cs
Normal file
@@ -0,0 +1,91 @@
|
||||
using asap.core;
|
||||
using cfg;
|
||||
using GameCore;
|
||||
using TMPro;
|
||||
using UniRx;
|
||||
using UnityEngine;
|
||||
using UnityEngine.AddressableAssets;
|
||||
using UnityEngine.UI;
|
||||
|
||||
public class BubbleTaskInfo : MonoBehaviour
|
||||
{
|
||||
Image require;
|
||||
TMP_Text text_title;
|
||||
GameObject BgTitle;
|
||||
Image bgTitlePos;
|
||||
string curBgTitle;
|
||||
protected CompositeDisposable disposables = new CompositeDisposable();
|
||||
|
||||
private void Start()
|
||||
{
|
||||
var _fishingEventData = GContext.container.Resolve<FishingEventData>();
|
||||
var collectingTarget = _fishingEventData.collectingTarget;
|
||||
if (collectingTarget != null)
|
||||
{
|
||||
CollectingTargetInit init = _fishingEventData.collectingTargetInit;
|
||||
SetInfo(init);
|
||||
}
|
||||
GContext.OnEvent<ChangeLanguageEvent>().Subscribe(OnChangeLanguage).AddTo(disposables);
|
||||
}
|
||||
void OnChangeLanguage(ChangeLanguageEvent changeLanguageEvent = null)
|
||||
{
|
||||
var _fishingEventData = GContext.container.Resolve<FishingEventData>();
|
||||
var collectingTarget = _fishingEventData.collectingTarget;
|
||||
if (collectingTarget != null)
|
||||
{
|
||||
text_title.text = LocalizationMgr.GetText(_fishingEventData.collectingTargetInit.Title_l10n_key);
|
||||
}
|
||||
}
|
||||
|
||||
public void SetInfo(CollectingTargetInit init)
|
||||
{
|
||||
require = transform.Find("btn_icon/icon").GetComponent<Image>();
|
||||
bgTitlePos = transform.Find("bg").GetComponent<Image>();
|
||||
text_title = transform.Find("text_title").GetComponent<TMP_Text>();
|
||||
bgTitlePos.enabled = false;
|
||||
var tables = GContext.container.Resolve<Tables>();
|
||||
IUIService uIService = GContext.container.Resolve<IUIService>();
|
||||
text_title.text = LocalizationMgr.GetText(init.Title_l10n_key);
|
||||
var item = tables.TbItem[init.TokenID];
|
||||
uIService.SetImageSprite(require, item.Icon);
|
||||
ShowFxTitle(init.BgTitle);
|
||||
}
|
||||
async void ShowFxTitle(string bgTitle)
|
||||
{
|
||||
if (BgTitle != null && BgTitle.name != bgTitle)
|
||||
{
|
||||
Addressables.ReleaseInstance(BgTitle);
|
||||
BgTitle = null;
|
||||
}
|
||||
if (!string.IsNullOrEmpty(bgTitle) && BgTitle == null)
|
||||
{
|
||||
if (curBgTitle == bgTitle)
|
||||
{
|
||||
return;
|
||||
}
|
||||
curBgTitle = bgTitle;
|
||||
BgTitle = await Addressables.InstantiateAsync(bgTitle, bgTitlePos.transform).Task;
|
||||
if (BgTitle != null)
|
||||
{
|
||||
if (!enabled || curBgTitle != bgTitle)
|
||||
{
|
||||
Addressables.ReleaseInstance(BgTitle);
|
||||
BgTitle = null;
|
||||
}
|
||||
else
|
||||
{
|
||||
BgTitle.name = bgTitle;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
private void OnDestroy()
|
||||
{
|
||||
if (BgTitle != null)
|
||||
{
|
||||
Addressables.ReleaseInstance(BgTitle);
|
||||
BgTitle = null;
|
||||
}
|
||||
disposables?.Dispose();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user