备份CatanBuilding瘦身独立工程
This commit is contained in:
52
Assets/Scripts/UI/Home/HomeTargetBuffPopupPanel.cs
Normal file
52
Assets/Scripts/UI/Home/HomeTargetBuffPopupPanel.cs
Normal file
@@ -0,0 +1,52 @@
|
||||
using asap.core;
|
||||
using UnityEngine;
|
||||
using UniRx;
|
||||
using System;
|
||||
using GameCore;
|
||||
using UnityEngine.UI;
|
||||
using cfg;
|
||||
using Game;
|
||||
|
||||
public class HomeTargetBuffPopupPanel : MonoBehaviour
|
||||
{
|
||||
Image icon_buff;
|
||||
IDisposable disposable;
|
||||
private void Awake()
|
||||
{
|
||||
icon_buff = transform.Find("root/icon_buff").GetComponent<Image>();
|
||||
disposable = GContext.OnEvent<GetBuffPosEvent>().Subscribe(GetBuffPosEvent);
|
||||
}
|
||||
void GetBuffPosEvent(GetBuffPosEvent getBuffPosEvent)
|
||||
{
|
||||
getBuffPosEvent.Pos = icon_buff.transform.position;
|
||||
}
|
||||
private void Start()
|
||||
{
|
||||
var targetWeightInit = GContext.container.Resolve<FishingEventData>().collectingTargetInit;
|
||||
if (targetWeightInit != null)
|
||||
{
|
||||
GContext.container.Resolve<IUIService>().SetImageSprite(icon_buff, targetWeightInit.BuffIcon);
|
||||
}
|
||||
FishBuffTimeData buffData = GContext.container.Resolve<BuffDataCenter>().GetBuffData<CollectionTargetWeight>();
|
||||
if (buffData != null)
|
||||
{
|
||||
FishBuff fishBuff = GContext.container.Resolve<Tables>().TbFishBuff.GetOrDefault(buffData.buffID);
|
||||
if (fishBuff != null)
|
||||
{
|
||||
GContext.Publish(new EventUISound(fishBuff.Audio));
|
||||
}
|
||||
}
|
||||
Close();
|
||||
}
|
||||
async void Close()
|
||||
{
|
||||
await Awaiters.Seconds(2.5f);
|
||||
await Awaiters.NextFrame;
|
||||
UIManager.Instance.DestroyUI(UITypes.HomeTargetBuffPopupPanel);
|
||||
}
|
||||
private void OnDisable()
|
||||
{
|
||||
disposable?.Dispose();
|
||||
disposable = null;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user