备份CatanBuilding瘦身独立工程
This commit is contained in:
85
Assets/Scripts/UI/Home/HomeGiftButtonPopupPanel.cs
Normal file
85
Assets/Scripts/UI/Home/HomeGiftButtonPopupPanel.cs
Normal file
@@ -0,0 +1,85 @@
|
||||
using asap.core;
|
||||
using cfg;
|
||||
using DG.Tweening;
|
||||
using GameCore;
|
||||
using System;
|
||||
using TMPro;
|
||||
using UniRx;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
|
||||
public class HomeGiftButtonPopupPanel : MonoBehaviour
|
||||
{
|
||||
Image icon_buff;
|
||||
Transform root;
|
||||
//TMP_Text text_info;
|
||||
IDisposable disposable;
|
||||
Item item;
|
||||
private void Awake()
|
||||
{
|
||||
//text_info = transform.Find("root/bg/text_info").GetComponent<TMP_Text>();
|
||||
icon_buff = transform.Find("icon_pig/root/icon_buff").GetComponent<Image>();
|
||||
disposable = GContext.OnEvent<GetGiftBtnPosEvent>().Subscribe(GetBuffPosEvent);
|
||||
int activateItemId = GContext.container.Resolve<FishingEventData>().curActivateItemId;
|
||||
item = GContext.container.Resolve<Tables>().TbItem.GetOrDefault(activateItemId);
|
||||
if (item != null)
|
||||
{
|
||||
//text_info.text = LocalizationMgr.GetText(item.Name_l10n_key);
|
||||
string icon = item.Icon;
|
||||
if (item.SubType == 21)
|
||||
{
|
||||
BargainPackData barginPackData = GContext.container.Resolve<BargainPackData>();
|
||||
if (barginPackData.IsWithinEventTime)
|
||||
{
|
||||
icon = barginPackData.ActiveItemImg;
|
||||
}
|
||||
}
|
||||
else if (item.SubType == 22)
|
||||
{
|
||||
PiggyBankPackData piggyBankPackData = GContext.container.Resolve<PiggyBankPackData>();
|
||||
if (piggyBankPackData.IsWithinEventTime)
|
||||
{
|
||||
icon = piggyBankPackData.ActiveItemImg;
|
||||
}
|
||||
}
|
||||
root = transform.Find(icon);
|
||||
if (root != null)
|
||||
{
|
||||
root.gameObject.SetActive(true);
|
||||
icon_buff = root.Find("root/icon_buff").GetComponent<Image>();
|
||||
}
|
||||
|
||||
//GContext.container.Resolve<IUIService>().SetImageSprite(icon_buff, icon);
|
||||
}
|
||||
}
|
||||
void GetBuffPosEvent(GetGiftBtnPosEvent getBuffPosEvent)
|
||||
{
|
||||
icon_buff.transform.DOMove(getBuffPosEvent.Pos, 0.66f);
|
||||
icon_buff.rectTransform.DOSizeDelta(new Vector2(getBuffPosEvent.width, getBuffPosEvent.width), 0.66f);
|
||||
}
|
||||
private void Start()
|
||||
{
|
||||
Close();
|
||||
}
|
||||
async void Close()
|
||||
{
|
||||
await Awaiters.Seconds(2.7f);
|
||||
UIManager.Instance.DestroyUI(UITypes.HomeGiftButtonPopupPanel);
|
||||
if (item != null)
|
||||
{
|
||||
if (item.SubType == 21)
|
||||
{
|
||||
await UIManager.Instance.ShowUI(UITypes.GiftBargainPopupPanel);
|
||||
}
|
||||
else if (item.SubType == 22)
|
||||
{
|
||||
await UIManager.Instance.ShowUI(UITypes.GiftPiggyBankPopupPanel);
|
||||
}
|
||||
}
|
||||
}
|
||||
private void OnDisable()
|
||||
{
|
||||
disposable?.Dispose();
|
||||
disposable = null;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user