94 lines
3.0 KiB
C#
94 lines
3.0 KiB
C#
using asap.core;
|
|
using cfg;
|
|
using GameCore;
|
|
using TMPro;
|
|
using UniRx;
|
|
using UnityEngine;
|
|
using UnityEngine.AddressableAssets;
|
|
using UnityEngine.UI;
|
|
|
|
public class BubbleTaskInfo_2 : MonoBehaviour
|
|
{
|
|
Image require;
|
|
TMP_Text text_title;
|
|
TMP_Text text_title2;
|
|
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_title2.text = 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("info_1/text_title").GetComponent<TMP_Text>();
|
|
text_title2 = transform.Find("info_2/text_title").GetComponent<TMP_Text>();
|
|
//bgTitlePos.enabled = false;
|
|
var tables = GContext.container.Resolve<Tables>();
|
|
IUIService uIService = GContext.container.Resolve<IUIService>();
|
|
text_title2.text = 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();
|
|
}
|
|
}
|