112 lines
2.3 KiB
C#
112 lines
2.3 KiB
C#
// ***********************************************************************
|
|
// Assembly : Game
|
|
// Author : Kimch
|
|
// Created : 2020-12-01
|
|
// Description :
|
|
// Last Modified By :
|
|
// Last Modified On :
|
|
// ***********************************************************************
|
|
// <copyright file= "EquipmentPage" company="Kunpo"></copyright>
|
|
// <summary></summary>
|
|
// ***********************************************************************
|
|
|
|
using UnityEngine;
|
|
using UnityEngine.UI;
|
|
|
|
namespace G.UI
|
|
{
|
|
/// <summary>
|
|
///
|
|
/// </summary>
|
|
public class EquipmentSlotPage : KUIWidget
|
|
{
|
|
#region Field
|
|
|
|
EquipmentSlotItem[] _equipmentSlotItems;
|
|
|
|
#endregion
|
|
|
|
#region Method
|
|
|
|
public void SetEquipment(int index, EntityItemEquipment equipment)
|
|
{
|
|
var equipmentSlot = PlayerProxy.Instance.GetEquipmentSlot(index);
|
|
_equipmentSlotItems[index].SetEquipmentSlot(equipmentSlot);
|
|
}
|
|
|
|
public void SetEquipmentSlot(PlayerProxy.EquipmentSlotInfo slot)
|
|
{
|
|
if (slot != null)
|
|
{
|
|
_equipmentSlotItems[slot.id].SetEquipmentSlot(slot);
|
|
}
|
|
}
|
|
|
|
private void RefreshRedPoint()
|
|
{
|
|
foreach (var slot in _equipmentSlotItems)
|
|
{
|
|
slot.RefreshRedPoint();
|
|
}
|
|
}
|
|
|
|
#endregion
|
|
|
|
#region Mediator
|
|
|
|
readonly int[] _notificationInterests = new int[]
|
|
{
|
|
GlobalDefine.EVENT_WINDOW_CLOSED,
|
|
};
|
|
|
|
public override System.Collections.Generic.IList<int> ListNotificationInterests()
|
|
{
|
|
return _notificationInterests;
|
|
}
|
|
|
|
public override void HandleNotification(PureMVC.Interfaces.INotification notification)
|
|
{
|
|
if (notification.Type == "equipment_detail" || notification.Type == "EquipmentSellBox")
|
|
{
|
|
RefreshRedPoint();
|
|
}
|
|
}
|
|
|
|
#endregion
|
|
|
|
#region Unity
|
|
|
|
private void Awake()
|
|
{
|
|
_equipmentSlotItems = new EquipmentSlotItem[6];
|
|
|
|
var childGo = transform.GetChild(0).gameObject;
|
|
for (int i = 1; i < 6; i++)
|
|
{
|
|
var go = Object.Instantiate(childGo, this.transform);
|
|
go.name = i.ToString();
|
|
_equipmentSlotItems[i] = go.AddComponent<EquipmentSlotItem>();
|
|
}
|
|
_equipmentSlotItems[0] = childGo.AddComponent<EquipmentSlotItem>();
|
|
|
|
for (int i = 0; i < 6; i++)
|
|
{
|
|
_equipmentSlotItems[i].SetEquipmentIndex(i);
|
|
}
|
|
}
|
|
|
|
private void OnEnable()
|
|
{
|
|
RefreshRedPoint();
|
|
RegisterThis();
|
|
}
|
|
|
|
private void OnDisable()
|
|
{
|
|
UnregisterThis();
|
|
}
|
|
|
|
#endregion
|
|
}
|
|
}
|