备份CatanBuilding瘦身独立工程
This commit is contained in:
58
Assets/Scripts/UI/Home/HomeSupplyDropPanel.cs
Normal file
58
Assets/Scripts/UI/Home/HomeSupplyDropPanel.cs
Normal file
@@ -0,0 +1,58 @@
|
||||
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);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user