// ***********************************************************************
// Assembly : Game
// Author : Kimch
// Created : 2021-04-20
// Description :
// Last Modified By :
// Last Modified On :
// ***********************************************************************
//
//
// ***********************************************************************
namespace G.UI
{
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
using static G.PlayerProxy;
///
///
///
partial class EquipmentWindow
{
#region Field
#pragma warning disable CS0649 // 从未对字段赋值,字段将一直保持其默认值 null
[KUIFlag]
Button _btnBack;
[KUIFlag]
KUIList _listSlots;
[KUIFlag]
GameObject __goSelectSlot;
[KUIFlag]
GameObject __goPanel1;
[KUIFlag]
GameObject __goPanel2;
#pragma warning restore CS0649 // 从未对字段赋值,字段将一直保持其默认值 null
private EquipmentUpgradeWidget _upgradeWidget;
private EquipmentSlotWidget _selectSlotWidget;
private readonly List _slotWidgets = new List(6);
#endregion
#region Method
///
///
///
public void InitView()
{
SetViewData();
_listSlots.AddTemplate(true);
_btnBack.onClick.AddListener(this.OnBackBtnClick);
_selectSlotWidget = __goSelectSlot.GetComponent();
_upgradeWidget = __goPanel1.GetComponent();
}
///
///
///
public void RefreshView()
{
EquipmentSlotInfo firstSlot = null;
_slotWidgets.Clear();
_listSlots.Clear();
var slots = PlayerProxy.Instance.GetEquipmentSlots();
for (int i = 0; i < slots.Length; i++)
{
if (slots[i].equipment != null)
{
var slotW = _listSlots.GetItem();
slotW.SetData(slots[i]);
_slotWidgets.Add(slotW);
if (firstSlot == null)
{
firstSlot = slots[i];
}
}
}
if (this.data is EquipmentSlotInfo equipmentSlot)
{
SetSelect(equipmentSlot);
}
else
{
SetSelect(firstSlot);
}
}
private void RefreshSlot()
{
foreach (var slotWidget in _slotWidgets)
{
slotWidget.Refresh();
}
_selectSlotWidget.Refresh();
_upgradeWidget.Refresh();
}
private void SetSelect(EquipmentSlotInfo equipmentSlot)
{
_selectSlotWidget.SetData(equipmentSlot);
_upgradeWidget.SetData(equipmentSlot);
}
///
///
///
public void UpdateView()
{
}
private void OnBackBtnClick()
{
CloseWindow(this);
}
#endregion
}
}