备份CatanBuilding瘦身独立工程
This commit is contained in:
60
Assets/Scripts/UI/Home/HomeBuffPopupPanel.cs
Normal file
60
Assets/Scripts/UI/Home/HomeBuffPopupPanel.cs
Normal file
@@ -0,0 +1,60 @@
|
||||
using asap.core;
|
||||
using UnityEngine;
|
||||
using UniRx;
|
||||
using System;
|
||||
using GameCore;
|
||||
using UnityEngine.UI;
|
||||
using TMPro;
|
||||
using cfg;
|
||||
using Game;
|
||||
|
||||
public class HomeBuffPopupPanel : MonoBehaviour
|
||||
{
|
||||
Image icon_buff;
|
||||
TMP_Text text_info;
|
||||
BuffDataCenter buffDataCenter;
|
||||
FishingData fishingData;
|
||||
GameObject root;
|
||||
Animation _ani;
|
||||
IDisposable disposable;
|
||||
private void Awake()
|
||||
{
|
||||
_ani = GetComponent<Animation>();
|
||||
root = transform.Find("root").gameObject;
|
||||
buffDataCenter = GContext.container.Resolve<BuffDataCenter>();
|
||||
fishingData = GContext.container.Resolve<FishingData>();
|
||||
icon_buff = transform.Find("root/icon_buff").GetComponent<Image>();
|
||||
text_info = transform.Find("root/bg/text_info").GetComponent<TMP_Text>();
|
||||
disposable = GContext.OnEvent<GetBuffPosEvent>().Subscribe(GetBuffPosEvent);
|
||||
}
|
||||
void GetBuffPosEvent(GetBuffPosEvent getBuffPosEvent)
|
||||
{
|
||||
getBuffPosEvent.Pos = icon_buff.transform.position;
|
||||
}
|
||||
|
||||
public void Init(FishBuffTimeData fishBuffTimeData)
|
||||
{
|
||||
var buff = GContext.container.Resolve<cfg.Tables>().TbFishBuff.GetOrDefault(fishBuffTimeData.buffID);
|
||||
if (buff != null)
|
||||
{
|
||||
GContext.container.Resolve<IUIService>().SetImageSprite(icon_buff, buff.Icon);
|
||||
text_info.text = LocalizationMgr.GetText(buff.Title_l10n_key);
|
||||
GContext.Publish(new EventUISound(buff.Audio));
|
||||
}
|
||||
root.SetActive(true);
|
||||
_ani.Play("buff_show");
|
||||
}
|
||||
public void Hide()
|
||||
{
|
||||
root.SetActive(false);
|
||||
}
|
||||
public void Close()
|
||||
{
|
||||
UIManager.Instance.DestroyUI(UITypes.HomeBuffPopupPanel);
|
||||
}
|
||||
private void OnDisable()
|
||||
{
|
||||
disposable?.Dispose();
|
||||
disposable = null;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user