71 lines
1.9 KiB
C#
71 lines
1.9 KiB
C#
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using UnityEngine;
|
|
using UnityEngine.UI;
|
|
using GCGame.Table;
|
|
|
|
public class ChildRenicarNationItem : CommonItem_Base {
|
|
|
|
public int _ItemIndex;
|
|
public Text _ItemCountDesc;
|
|
|
|
private static CNode _CurChildData = null;
|
|
|
|
public override void OnEnable()
|
|
{
|
|
base.OnEnable();
|
|
InitItem();
|
|
}
|
|
|
|
public override void InitItem(int itemId = -1, int itemCount = 0)
|
|
{
|
|
_CurChildData = GetChildData();
|
|
if (_CurChildData == null)
|
|
{
|
|
gameObject.SetActive(false);
|
|
return;
|
|
}
|
|
gameObject.SetActive(true);
|
|
var childStateTypeTab = GameManager.gameManager.PlayerDataPool.ChildData.GetChildStateTypeTab(_CurChildData);
|
|
_ItemId = childStateTypeTab.GetRenicarNationItemIdbyIndex(_ItemIndex);
|
|
base.InitItem(_ItemId);
|
|
}
|
|
|
|
public CNode GetChildData()
|
|
{
|
|
if (ChildRenicarNationPanel.Instance)
|
|
return ChildData.GetChildByIndex(ChildRenicarNationPanel.Instance.CurSelectChildIndex);
|
|
else
|
|
return null;
|
|
}
|
|
|
|
public override void RefreshItemRemainCount()
|
|
{
|
|
base.RefreshItemRemainCount();
|
|
|
|
if(ChildRenicarNationPanel.Instance)
|
|
{
|
|
if(_CurChildData == null)
|
|
{
|
|
gameObject.SetActive(false);
|
|
return;
|
|
}
|
|
var childStateTypeTab = GameManager.gameManager.PlayerDataPool.ChildData.GetChildStateTypeTab(_CurChildData);
|
|
var itemNeedVal = childStateTypeTab.GetRenicarNationItemValbyIndex(_ItemIndex);
|
|
_ItemCountDesc.EnsureVal(itemNeedVal + "/" + _ItemRemainCount);
|
|
}
|
|
}
|
|
|
|
//这边需要在子女等级变化的时候进行刷新
|
|
public override void Refresh()
|
|
{
|
|
GetChildData();
|
|
if (_CurChildData == null)
|
|
{
|
|
gameObject.SetActive(false);
|
|
return;
|
|
}
|
|
RefreshItemRemainCount();
|
|
}
|
|
}
|