备份CatanBuilding瘦身独立工程
This commit is contained in:
94
Assets/Scripts/UI/Home/SupplyDropInfoPopupPanel.cs
Normal file
94
Assets/Scripts/UI/Home/SupplyDropInfoPopupPanel.cs
Normal file
@@ -0,0 +1,94 @@
|
||||
using asap.core;
|
||||
using cfg;
|
||||
using GameCore;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
|
||||
public class SupplyDropInfoPopupPanel : MonoBehaviour
|
||||
{
|
||||
Button _btnClose;
|
||||
Button btnMask;
|
||||
SupplyDropPopupPanel supplyDropPanel;
|
||||
List<GameObject> selects;
|
||||
int indexCurrent = 0;
|
||||
int ShowSupplyDropIndex = 6;
|
||||
int allCount = 0;
|
||||
Button btn_right;
|
||||
Button btn_left;
|
||||
private void Awake()
|
||||
{
|
||||
_btnClose = transform.Find("btn_close").GetComponent<Button>();
|
||||
btnMask = transform.Find("mask").GetComponent<Button>();
|
||||
supplyDropPanel = transform.Find("root").GetComponent<SupplyDropPopupPanel>();
|
||||
supplyDropPanel.Init();
|
||||
selects = new List<GameObject>();
|
||||
btn_right = transform.Find("root/btn_right").GetComponent<Button>();
|
||||
btn_left = transform.Find("root/btn_left").GetComponent<Button>();
|
||||
allCount = supplyDropPanel.detailsItems.Count;
|
||||
Transform sliding = transform.Find("root/Sliding");
|
||||
int count = sliding.childCount;
|
||||
for (int i = 0; i < count; i++)
|
||||
{
|
||||
GameObject obj = sliding.GetChild(i).Find("Select").gameObject;
|
||||
selects.Add(obj);
|
||||
obj.SetActive(false);
|
||||
}
|
||||
var _tables = GContext.container.Resolve<Tables>();
|
||||
var playerData = GContext.container.Resolve<PlayerData>();
|
||||
var DataList = _tables.TbEnergyDef.DataList;
|
||||
for (int i = 0; i < DataList.Count; i++)
|
||||
{
|
||||
if (DataList[i].SupplyDrop > 0)
|
||||
{
|
||||
ShowSupplyDropIndex = i;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (playerData.magnification >= ShowSupplyDropIndex && playerData.magnification < ShowSupplyDropIndex + allCount)
|
||||
{
|
||||
indexCurrent = playerData.magnification - ShowSupplyDropIndex;
|
||||
}
|
||||
Show();
|
||||
}
|
||||
private void Start()
|
||||
{
|
||||
_btnClose.onClick.AddListener(OnClickClose);
|
||||
btnMask.onClick.AddListener(OnClickClose);
|
||||
btn_right.onClick.AddListener(OnClickRight);
|
||||
btn_left.onClick.AddListener(OnClickLeft);
|
||||
}
|
||||
|
||||
void OnClickRight()
|
||||
{
|
||||
indexCurrent++;
|
||||
if (indexCurrent >= allCount)
|
||||
{
|
||||
indexCurrent = 0;
|
||||
}
|
||||
Show();
|
||||
}
|
||||
|
||||
void OnClickLeft()
|
||||
{
|
||||
indexCurrent--;
|
||||
if (indexCurrent < 0)
|
||||
{
|
||||
indexCurrent = allCount - 1;
|
||||
}
|
||||
Show();
|
||||
}
|
||||
|
||||
void Show()
|
||||
{
|
||||
supplyDropPanel.Show(indexCurrent);
|
||||
for (int i = 0; i < selects.Count; i++)
|
||||
{
|
||||
selects[i].SetActive(i == indexCurrent);
|
||||
}
|
||||
}
|
||||
void OnClickClose()
|
||||
{
|
||||
UIManager.Instance.DestroyUI(UITypes.SupplyDropInfoPopupPanel);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user