备份CatanBuilding瘦身独立工程
This commit is contained in:
59
Assets/Scripts/UI/Shop/GiftRodSelectePopupPanel.cs
Normal file
59
Assets/Scripts/UI/Shop/GiftRodSelectePopupPanel.cs
Normal file
@@ -0,0 +1,59 @@
|
||||
using asap.core;
|
||||
using GameCore;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine.UI;
|
||||
|
||||
public class GiftRodSelectePopupPanel : BasePanel
|
||||
{
|
||||
private Button _btnClose, _btnConfirm;
|
||||
private List<GiftRodSelectionSlot> _rods;
|
||||
private RodSelectionPackData _rspd;
|
||||
//public Action OnGameObjectDestroy;
|
||||
//private int _chosenRodID;
|
||||
private void Awake()
|
||||
{
|
||||
_rspd = GContext.container.Resolve<RodSelectionPackData>();
|
||||
_btnClose = transform.Find("btn_close").GetComponent<Button>();
|
||||
_btnConfirm = transform.Find("root/btn_confrim/btn_green").GetComponent<Button>();
|
||||
_rods = new List<GiftRodSelectionSlot>();
|
||||
for (int i = 0; i < 3; i++)
|
||||
{
|
||||
_rods.Add(transform.Find($"root/Content/Item{i + 1}").GetComponent<GiftRodSelectionSlot>());
|
||||
}
|
||||
}
|
||||
protected override void Start()
|
||||
{
|
||||
_btnClose.onClick.AddListener(ClosePanel);
|
||||
_btnConfirm.onClick.AddListener(OnClickConfirm);
|
||||
//_chosenRodID = _rspd.RodID;
|
||||
for (int i = 0; i < 3; i++)
|
||||
{
|
||||
_rods[i].InitializeSlot(_rspd.PackRodList[i], _rspd);
|
||||
_rods[i].Toggle.isOn = _rspd.PackRodList[i] == _rspd.RodID;
|
||||
}
|
||||
base.Start();
|
||||
}
|
||||
private void ClosePanel()
|
||||
{
|
||||
UIManager.Instance.DestroyUI(UITypes.GiftRodSelectePopupPanel);
|
||||
}
|
||||
private void OnClickConfirm()
|
||||
{
|
||||
//_rspd.RodID = _chosenRodID;
|
||||
for (int i = 0; i < 3; i++)
|
||||
{
|
||||
if (!_rods[i].Toggle.isOn)
|
||||
continue;
|
||||
_rspd.RodID = _rspd.PackRodList[i];
|
||||
break;
|
||||
}
|
||||
GContext.Publish<GiftRodSelectEvent>(new GiftRodSelectEvent(_rspd.RodID));
|
||||
UIManager.Instance.DestroyUI(UITypes.GiftRodSelectePopupPanel);
|
||||
}
|
||||
//protected override void OnDestroy()
|
||||
//{
|
||||
// OnGameObjectDestroy?.Invoke();
|
||||
// OnGameObjectDestroy = null;
|
||||
//}
|
||||
}
|
||||
Reference in New Issue
Block a user