using asap.core; using cfg; using GameCore; using System.Collections; using UnityEngine; using UnityEngine.AddressableAssets; public class HomeSupplyDropPanel : MonoBehaviour { PlayerData playerData; Tables _tables; SupplyDropPopupPanel supplyDropPanel; int ShowSupplyDropIndex = -1; int allCount = 0; bool isShow; public void Init() { _tables = GContext.container.Resolve(); playerData = GContext.container.Resolve(); allCount = _tables.TbSupplyDrop.DataList.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 (!GContext.container.Resolve().IsOpenDrop) { return false; } if (ShowSupplyDropIndex == -1) { return false; } StopCoroutine("Hide"); if (playerData.magnification >= ShowSupplyDropIndex && playerData.magnification < ShowSupplyDropIndex + allCount) { gameObject.SetActive(true); if (!isShow) { LoadSupplyDropPanel(); isShow = true; } if (supplyDropPanel != null) { supplyDropPanel.Show(playerData.magnification - ShowSupplyDropIndex); } StartCoroutine("Hide"); return true; } else { gameObject.SetActive(false); return false; } } async void LoadSupplyDropPanel() { GameObject go = await Addressables.LoadAssetAsync("SupplydropPopupPanel").Task; if (go != null) { var panel = Instantiate(go, transform); supplyDropPanel = panel.transform.Find("root").GetComponent(); supplyDropPanel.Init(); supplyDropPanel.Show(playerData.magnification - ShowSupplyDropIndex); } } IEnumerator Hide() { yield return new WaitForSeconds(2f); gameObject.SetActive(false); } }