305 lines
9.5 KiB
C#
305 lines
9.5 KiB
C#
using GCGame.Table;
|
|
using System;
|
|
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using UnityEngine;
|
|
using UnityEngine.UI;
|
|
|
|
public class ChildRenicarNationPanel : MonoBehaviour , ChildRefreshInterface, SyncSingleChildInterface{
|
|
|
|
public static ChildRenicarNationPanel Instance;
|
|
private void OnEnable()
|
|
{
|
|
Instance = this;
|
|
RefreshChildData();
|
|
}
|
|
|
|
private void OnDisable()
|
|
{
|
|
Instance = null;
|
|
}
|
|
|
|
public ChildSwitchBtnPanel _SwitchPanel;
|
|
public ChildSkillPanel _SkillPanel;
|
|
|
|
public Text _CurStateDesc;
|
|
public Text _NextStateDesc;
|
|
public GameObject _CurNextStateDescObj;
|
|
public Text _MaxStateDesc;
|
|
|
|
public Text _CurStateLevelMax;
|
|
public Text _NextStateLevelMax;
|
|
public GameObject _NextStateLevelObj;
|
|
|
|
public List<ChildSkillLevelLimitDesc> _SkillLimitDescList;
|
|
public List<ChildRenicarNationItem> _ItemList;
|
|
|
|
//模型
|
|
public ChildModelAndEffectCtr _ModelEffectCtr;
|
|
|
|
//红点状态
|
|
public GameObject _RedIcon;
|
|
|
|
//
|
|
public GameObject _OperationBtn;
|
|
public void ShowRedIcon(bool isShow)
|
|
{
|
|
_RedIcon.SetActive(isShow);
|
|
}
|
|
|
|
public void RefreshChildData(RetChildren childData = null)
|
|
{
|
|
InitSwitchPanel();
|
|
ShowChildByIndex(0);
|
|
}
|
|
|
|
void InitSwitchPanel()
|
|
{
|
|
_SwitchPanel.InitSwitchPanel(ChildData.ChildPacket == null ? 0 : ChildData.ChildPacket.list.Count);
|
|
}
|
|
|
|
private static int _CurSelectChildIndex = -1;
|
|
public int CurSelectChildIndex
|
|
{
|
|
get { return _CurSelectChildIndex; }
|
|
set { _CurSelectChildIndex = value; }
|
|
}
|
|
|
|
public void ShowChildByIndex(int index)
|
|
{
|
|
_CurSelectChildIndex = index;
|
|
_CurSelectChildIndex = index;
|
|
_ModelEffectCtr.ShowChild(_CurSelectChildIndex);
|
|
ChildPanel.PlayeChildSoundByIndex(_CurSelectChildIndex);
|
|
SetCurSelectChild();
|
|
//刷新技能描述
|
|
InitSkillDescItemList();
|
|
//刷新子女模型
|
|
InitChildModel();
|
|
//刷新当前状态描述
|
|
InitCurStateDesc();
|
|
//刷新技能面板
|
|
InitChildSkillPanel();
|
|
//初始化道具
|
|
InitRenicarItemPanel();
|
|
InitShowOperationBtn();
|
|
|
|
RefreshMenuItemRedState();
|
|
}
|
|
|
|
//选中当前子女
|
|
void SetCurSelectChild()
|
|
{
|
|
SelectCurChildren req = new SelectCurChildren();
|
|
req.childrenGuid = ChildData.GetChildByIndex(_CurSelectChildIndex).guid;
|
|
req.SendMsg();
|
|
}
|
|
public void RefreshMenuItemRedState()
|
|
{
|
|
var stateList = ChildData.GetChildRedStateByIndex(_CurSelectChildIndex);
|
|
var _MenuItemBase = ChildPanel.Instance._MenuItemBase;
|
|
for (int index = 0; index < _MenuItemBase._MenuItemList.Count; index++)
|
|
{
|
|
_MenuItemBase._MenuItemList[index].ShowRedIcon(stateList != null && stateList.Contains(index + 1));
|
|
}
|
|
ShowRedIcon(stateList != null && stateList.Contains(3));
|
|
}
|
|
|
|
public void InitShowOperationBtn()
|
|
{
|
|
var curChildType = GameManager.gameManager.PlayerDataPool.ChildData.GetChildStateTypeTab(ChildData.GetChildByIndex(_CurSelectChildIndex)).Id;
|
|
if(_OperationBtn)
|
|
_OperationBtn.SetActive(curChildType <= GetMaxCanRCStateType());
|
|
}
|
|
|
|
public void OnEmbryoTimeEndCallBack()
|
|
{
|
|
ShowChildByIndex(_CurSelectChildIndex);
|
|
}
|
|
|
|
void InitChildSkillPanel()
|
|
{
|
|
_SkillPanel.InitSkillItem(_CurSelectChildIndex);
|
|
}
|
|
|
|
void InitCurStateDesc()
|
|
{
|
|
if(ChildData.GetChildByIndex(_CurSelectChildIndex) == null)
|
|
{
|
|
_CurNextStateDescObj.SetActive(false);
|
|
_NextStateLevelObj.SetActive(false);
|
|
_MaxStateDesc.gameObject.SetActive(false);
|
|
return;
|
|
}
|
|
|
|
var childStateTypeTab = GameManager.gameManager.PlayerDataPool.ChildData.GetChildStateTypeTab(ChildData.GetChildByIndex(_CurSelectChildIndex));
|
|
var nextChildStateTypeTab = GetNextGradeStateTypeTab(childStateTypeTab.Id);
|
|
if(nextChildStateTypeTab != null)
|
|
{
|
|
_MaxStateDesc.gameObject.SetActive(false);
|
|
_CurNextStateDescObj.SetActive(true);
|
|
_CurStateDesc.text = childStateTypeTab.StateDesc;
|
|
_NextStateDesc.text = nextChildStateTypeTab.StateDesc;
|
|
|
|
_CurStateLevelMax.text = childStateTypeTab.ChildLevelMax + "";
|
|
_NextStateLevelMax.text = nextChildStateTypeTab.ChildLevelMax + "";
|
|
_NextStateLevelObj.SetActive(true);
|
|
}
|
|
else
|
|
{
|
|
_CurNextStateDescObj.SetActive(false);
|
|
_NextStateLevelObj.SetActive(false);
|
|
_MaxStateDesc.gameObject.SetActive(true);
|
|
_MaxStateDesc.text = childStateTypeTab.StateDesc;
|
|
}
|
|
}
|
|
|
|
void InitRenicarItemPanel()
|
|
{
|
|
if(ChildData.GetChildByIndex(_CurSelectChildIndex) == null)
|
|
{
|
|
for (int index = 0; index < _ItemList.Count; index++)
|
|
{
|
|
_ItemList[index].gameObject.SetActive(false);
|
|
}
|
|
|
|
return;
|
|
}
|
|
|
|
var childStateTypeTab = GameManager.gameManager.PlayerDataPool.ChildData.GetChildStateTypeTab(ChildData.GetChildByIndex(_CurSelectChildIndex));
|
|
if(childStateTypeTab == null)
|
|
{
|
|
for (int index = 0; index < _ItemList.Count; index++)
|
|
_ItemList[index].gameObject.SetActive(false);
|
|
return;
|
|
}
|
|
|
|
var maxShowVal = _ItemList.Count > childStateTypeTab.getRenicarNationItemIdCount() ? childStateTypeTab.getRenicarNationItemIdCount() : _ItemList.Count;
|
|
//初始化显示
|
|
for (int index = 0; index < maxShowVal; index++)
|
|
{
|
|
_ItemList[index].gameObject.SetActive(true);
|
|
_ItemList[index].InitItem(childStateTypeTab.GetRenicarNationItemIdbyIndex(index));
|
|
}
|
|
|
|
//隐藏多余item
|
|
for (int index = maxShowVal; index < _ItemList.Count; index++)
|
|
_ItemList[index].gameObject.SetActive(false);
|
|
}
|
|
|
|
void InitSkillDescItemList()
|
|
{
|
|
if(ChildData.GetChildByIndex(_CurSelectChildIndex) == null)
|
|
{
|
|
for (int index = 0; index < _SkillLimitDescList.Count; index++)
|
|
_SkillLimitDescList[index].gameObject.SetActive(false);
|
|
return;
|
|
}
|
|
|
|
for(int index = 0; index < _SkillLimitDescList.Count; index++)
|
|
{
|
|
_SkillLimitDescList[index].gameObject.SetActive(true);
|
|
_SkillLimitDescList[index].InitSkillLimitDesc(_CurSelectChildIndex);
|
|
}
|
|
}
|
|
|
|
void InitChildModel()
|
|
{
|
|
_ModelEffectCtr.ShowChild(_CurSelectChildIndex);
|
|
}
|
|
|
|
public void OnRenicarNationBtn()
|
|
{
|
|
var childData = ChildData.GetChildByIndex(_CurSelectChildIndex);
|
|
if(childData == null)
|
|
{
|
|
Debug.LogError("Child is null");
|
|
return;
|
|
}
|
|
ChildrenFeiSheng req = new ChildrenFeiSheng();
|
|
req.childrenGuid = childData.guid;
|
|
req.level = childData.basic.curLevel;
|
|
req.exp = childData.basic.curExp;
|
|
req.SendMsg();
|
|
}
|
|
|
|
public void RefreshSingleChild(CNode info)
|
|
{
|
|
if (info.guid == ChildData.GetChildByIndex(_CurSelectChildIndex).guid)
|
|
ShowChildByIndex(_CurSelectChildIndex);
|
|
}
|
|
|
|
public List<int> _PerGradeMaxTypeList;
|
|
void GetAllGradeMaxTypeList()
|
|
{
|
|
if (_PerGradeMaxTypeList != null
|
|
&& _PerGradeMaxTypeList.Count > 0)
|
|
return;
|
|
_PerGradeMaxTypeList = new List<int>();
|
|
var _CurGradeMaxType = 1;
|
|
foreach (var tab in TableManager.GetChildrenLevelUp())
|
|
{
|
|
_CurGradeMaxType = tab.Value.CurStateType;
|
|
if (tab.Value.FeiShengFlag != -1)//当前Type进阶下一个Grade需要进阶
|
|
_PerGradeMaxTypeList.Add(_CurGradeMaxType);
|
|
}
|
|
//最后一级
|
|
_PerGradeMaxTypeList.Add(_CurGradeMaxType);
|
|
}
|
|
|
|
public Tab_ChildrenStateType GetCurGradeMaxStateTypeTab(int type)
|
|
{
|
|
GetAllGradeMaxTypeList();
|
|
for(int index = 0; index < _PerGradeMaxTypeList.Count; index++)
|
|
{
|
|
if(type <= _PerGradeMaxTypeList[index])
|
|
{
|
|
var tab = TableManager.GetChildrenStateTypeByID(_PerGradeMaxTypeList[index], 0);
|
|
return tab;
|
|
}
|
|
}
|
|
|
|
return null;
|
|
}
|
|
|
|
public Tab_ChildrenStateType GetNextGradeStateTypeTab(int _CurChildStateType)
|
|
{
|
|
if (_PerGradeMaxTypeList == null
|
|
|| _PerGradeMaxTypeList.Count <= 0)
|
|
GetAllGradeMaxTypeList();
|
|
|
|
if (_PerGradeMaxTypeList == null
|
|
|| _PerGradeMaxTypeList.Count <= 0)
|
|
{
|
|
Debug.LogError("_PerGradeMaxTypeList is null");
|
|
return null;
|
|
}
|
|
|
|
bool isIgnore = true; //需要跳过一个比当前类型大的值(是当前类型的最大值)
|
|
for (int index = 0; index < _PerGradeMaxTypeList.Count; index++)
|
|
{
|
|
if (_CurChildStateType <= _PerGradeMaxTypeList[index])
|
|
{
|
|
if (isIgnore)
|
|
isIgnore = !isIgnore;
|
|
else
|
|
{
|
|
var nextGradeMaxType = _PerGradeMaxTypeList[index];
|
|
var childTypeTab = TableManager.GetChildrenStateTypeByID(nextGradeMaxType, 0);
|
|
return childTypeTab;
|
|
}
|
|
}
|
|
}
|
|
|
|
return null;
|
|
}
|
|
|
|
public int GetMaxCanRCStateType()
|
|
{
|
|
if (_PerGradeMaxTypeList == null
|
|
|| _PerGradeMaxTypeList.Count <= 0)
|
|
GetAllGradeMaxTypeList();
|
|
return _PerGradeMaxTypeList[_PerGradeMaxTypeList.Count - 1];
|
|
}
|
|
}
|