Files
back_cantanBuilding/Assets/Scripts/UI/Home/HomeSupplyDropPanel.cs
2026-05-26 16:15:54 +08:00

59 lines
1.6 KiB
C#

using asap.core;
using cfg;
using GameCore;
using System.Collections;
using UnityEngine;
public class HomeSupplyDropPanel : MonoBehaviour
{
PlayerData playerData;
Tables _tables;
SupplyDropPopupPanel supplyDropPanel;
int ShowSupplyDropIndex = -1;
int allCount = 0;
public void Init()
{
_tables = GContext.container.Resolve<Tables>();
playerData = GContext.container.Resolve<PlayerData>();
supplyDropPanel = transform.Find("SupplyDropPopupPanel/root").GetComponent<SupplyDropPopupPanel>();
supplyDropPanel.Init();
allCount = supplyDropPanel.detailsItems.Count;
var DataList = _tables.TbEnergyDef.DataList;
for (int i = 0; i < DataList.Count; i++)
{
if (DataList[i].SupplyDrop > 0)
{
ShowSupplyDropIndex = i;
break;
}
}
}
public bool Show()
{
if (ShowSupplyDropIndex == -1)
{
return false;
}
StopCoroutine("Hide");
if (playerData.magnification >= ShowSupplyDropIndex && playerData.magnification < ShowSupplyDropIndex + allCount)
{
gameObject.SetActive(true);
supplyDropPanel.Show(playerData.magnification - ShowSupplyDropIndex);
StartCoroutine("Hide");
return true;
}
else
{
gameObject.SetActive(false);
return false;
}
}
IEnumerator Hide()
{
yield return new WaitForSeconds(2f);
gameObject.SetActive(false);
}
}