345 lines
11 KiB
C#
345 lines
11 KiB
C#
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using UnityEngine;
|
|
using GCGame.Table;
|
|
using Games.LogicObj;
|
|
|
|
public class ChildData{
|
|
|
|
/// <summary>
|
|
/// 子女初始化数据 名称 模型ID
|
|
/// </summary>
|
|
public class ChildInitData
|
|
{
|
|
public int childLevel;
|
|
public string childName;
|
|
public int childFashionId;
|
|
public long childGuid;
|
|
public int childGender;
|
|
public ChildInitData()
|
|
{
|
|
childLevel = -1;
|
|
childName = "";
|
|
childFashionId = -1;
|
|
childGuid = -1;
|
|
childGender = -1;
|
|
}
|
|
public ChildInitData(int level, string name, int fashionId, long guid, int gender)
|
|
{
|
|
childLevel = level;
|
|
childName = name;
|
|
childFashionId = fashionId;
|
|
childGuid = guid;
|
|
childGender = gender;
|
|
}
|
|
}
|
|
public ChildInitData CurCarryChildData = new ChildInitData();
|
|
|
|
//最外层红点显示
|
|
public bool _IsShowIconRedState = false;
|
|
private static ChildData _Instance;
|
|
public static ChildData Instance
|
|
{
|
|
get { return _Instance; }
|
|
set { _Instance = value; }
|
|
}
|
|
|
|
private int _ChildCount = 0;
|
|
public int ChildCount
|
|
{
|
|
get { return _ChildCount; }
|
|
private set { _ChildCount = value; }
|
|
}
|
|
|
|
public Dictionary<long, int> _ChildAdventureRecorDic;
|
|
|
|
public static CNode GetChildByGuid(long guid)
|
|
{
|
|
if (ChildPacket == null)
|
|
return null;
|
|
|
|
for(int index = 0; index < ChildPacket.list.Count; index++)
|
|
{
|
|
if (ChildPacket.list[index].guid == guid)
|
|
return ChildPacket.list[index];
|
|
}
|
|
|
|
return null;
|
|
}
|
|
|
|
public static CNode GetChildByIndex(int index)
|
|
{
|
|
if (index == -1)
|
|
return null;
|
|
|
|
if (ChildPacket == null)
|
|
return null;
|
|
|
|
if (index > ChildPacket.list.Count - 1)
|
|
return null;
|
|
return ChildPacket.list[index];
|
|
}
|
|
|
|
private static RetChildren _ChildPacket = null;
|
|
public static RetChildren ChildPacket
|
|
{
|
|
get { return _ChildPacket; }
|
|
set { _ChildPacket = value; }
|
|
}
|
|
|
|
/// <summary>
|
|
/// 上线同步或者更新孩子信息或者主动请求时同步
|
|
/// </summary>
|
|
/// <param name="packet"></param>
|
|
public void RefreshChildData(RetChildren packet)
|
|
{
|
|
ChildPacket = packet;
|
|
|
|
if(_ChildAdventureRecorDic != null)
|
|
{
|
|
for(int index = 0; index < ChildPacket.list.Count; index++)
|
|
{
|
|
if (_ChildAdventureRecorDic.ContainsKey(ChildPacket.list[index].guid))
|
|
ChildPacket.list[index].randomEvent.reserved = _ChildAdventureRecorDic[ChildPacket.list[index].guid];
|
|
}
|
|
|
|
_ChildAdventureRecorDic.Clear();
|
|
_ChildAdventureRecorDic = null;
|
|
}
|
|
|
|
_ChildCount = packet.list.Count;
|
|
|
|
if (ChildPanel.Instance)
|
|
{
|
|
ChildPanel.Instance._MenuItemContainerBase.ShowNoDataPanel(packet.list.Count <= 0);
|
|
ChildPanel.Instance.RefreshChildData(ChildPacket);
|
|
}
|
|
|
|
if (CommonItem_Base.Instance)
|
|
CommonItem_Base.Instance.Refresh();
|
|
}
|
|
|
|
public Tab_CharModel GetCharModelTab(CNode _CurChildData)
|
|
{
|
|
if (_CurChildData == null)
|
|
return null;
|
|
|
|
var childLevelUpTab = TableManager.GetChildrenLevelUpByID(_CurChildData.basic.curLevel, 0);
|
|
if (childLevelUpTab == null)
|
|
{
|
|
Debug.LogError("childLevelUpTab is null : " + _CurChildData.basic.curLevel);
|
|
return null;
|
|
}
|
|
|
|
var childStateTypeTab = TableManager.GetChildrenStateTypeByID(childLevelUpTab.CurStateType, 0);
|
|
if(childStateTypeTab == null)
|
|
{
|
|
Debug.LogError("childStateTypeTab is null : " + childLevelUpTab.CurStateType);
|
|
return null;
|
|
}
|
|
|
|
var charModelTab = TableManager.GetCharModelByID(_CurChildData.basic.gender == 0
|
|
? childStateTypeTab.BoyModelId : childStateTypeTab.GirlModelId, 0);
|
|
return charModelTab;
|
|
}
|
|
|
|
public Tab_ChildrenStateType GetChildStateTypeTab(CNode _CurChildData)
|
|
{
|
|
var childLevelUpTab= TableManager.GetChildrenLevelUpByID(_CurChildData.basic.curLevel, 0);
|
|
if(childLevelUpTab == null)
|
|
{
|
|
Debug.LogError("childLevelUpTab is null : " + _CurChildData.basic.curLevel);
|
|
return null;
|
|
}
|
|
|
|
var childStateTypeTab = TableManager.GetChildrenStateTypeByID(childLevelUpTab.CurStateType, 0);
|
|
if(childStateTypeTab == null)
|
|
{
|
|
Debug.LogError("childStateTypeTab is null : " + childLevelUpTab.CurStateType);
|
|
return null;
|
|
}
|
|
return childStateTypeTab;
|
|
}
|
|
|
|
public void RefreshSingleChildData(SynOneChildren childData)
|
|
{
|
|
if(GetChildByGuid(childData.info.guid) != null)
|
|
{
|
|
for(int index = 0; index < ChildPacket.list.Count; index++)
|
|
{
|
|
if(ChildPacket.list[index].guid == childData.info.guid)
|
|
{
|
|
ChildPacket.list[index] = childData.info;
|
|
break;
|
|
}
|
|
}
|
|
}else
|
|
{
|
|
ChildPacket.list.Add(childData.info);
|
|
}
|
|
|
|
//刷新子面板
|
|
if (ChildInfoPanel.Instance && ChildInfoPanel.Instance.gameObject.activeInHierarchy)
|
|
ChildInfoPanel.Instance.RefreshSingleChild(childData.info);
|
|
if (ChildStudyPanel.Instance && ChildStudyPanel.Instance.gameObject.activeInHierarchy)
|
|
ChildStudyPanel.Instance.RefreshSingleChild(childData.info);
|
|
if (ChildRenicarNationPanel.Instance && ChildRenicarNationPanel.Instance.gameObject.activeInHierarchy)
|
|
ChildRenicarNationPanel.Instance.RefreshSingleChild(childData.info);
|
|
}
|
|
|
|
public static Tab_ChildrenSkillParam GetSkillPatamTabByType(int skillType)
|
|
{
|
|
foreach(var tab in TableManager.GetChildrenSkillParam())
|
|
{
|
|
if (tab.Value.Type == skillType)
|
|
return tab.Value;
|
|
}
|
|
return null;
|
|
}
|
|
|
|
public static List<CFState> _ChildFashionStateList = new List<CFState>();
|
|
|
|
public void RefreshChildFashionStateList(RetChildFashion packet)
|
|
{
|
|
for (int index = 0; index < packet.CFList.Count; index++)
|
|
{
|
|
CFState state = new CFState();
|
|
state.childGuid = packet.CFList[index].childGuid;
|
|
state.CFId = packet.CFList[index].CFId;
|
|
state.COFList = new List<int>();
|
|
for (int fIndex = 0; fIndex < packet.CFList[index].COFList.Count; fIndex++)
|
|
{
|
|
state.COFList.Add(packet.CFList[index].COFList[fIndex]);
|
|
}
|
|
|
|
RefreshChildFashionStateList(state);
|
|
}
|
|
if (ChildFashionPanel.Instance)
|
|
ChildFashionPanel.Instance.RefreshFashionPanel();
|
|
}
|
|
|
|
void RefreshChildFashionStateList(CFState state)
|
|
{
|
|
for(int index = 0; index < _ChildFashionStateList.Count; index++)
|
|
{
|
|
if(_ChildFashionStateList[index].childGuid == state.childGuid)
|
|
{
|
|
_ChildFashionStateList[index] = state;
|
|
return;
|
|
}
|
|
}
|
|
_ChildFashionStateList.Add(state);
|
|
}
|
|
|
|
public static CFState GetChildFashionStateByIndex(int index)
|
|
{
|
|
var childGuid = GetChildByIndex(index).guid;
|
|
return GetChildFashionStateByGuid(childGuid);
|
|
}
|
|
|
|
public static CFState GetChildFashionStateByGuid(long guid)
|
|
{
|
|
if (_ChildFashionStateList == null || _ChildFashionStateList.Count < 1)
|
|
return null;
|
|
|
|
for(int index = 0; index < _ChildFashionStateList.Count; index++)
|
|
{
|
|
if (_ChildFashionStateList[index].childGuid == guid)
|
|
return _ChildFashionStateList[index];
|
|
}
|
|
|
|
return null;
|
|
}
|
|
|
|
public static int GetChildCurDressedFashionIdByIndex(int childIndex)
|
|
{
|
|
var childData = GetChildByIndex(childIndex);
|
|
if (childData == null)
|
|
{
|
|
Debug.LogError("Child is null from GetChildCurPutOnFashionIdByIndex : " + childIndex);
|
|
return -1;
|
|
}
|
|
|
|
if (_ChildFashionStateList == null || _ChildFashionStateList.Count < 1)
|
|
return -1;
|
|
|
|
for (int index = 0; index < _ChildFashionStateList.Count; index++)
|
|
{
|
|
if (_ChildFashionStateList[index].childGuid == childData.guid)
|
|
return _ChildFashionStateList[index].CFId;
|
|
}
|
|
|
|
return -1;
|
|
}
|
|
|
|
public int GetChildCurPutOnFashionIdByGuid(long guid)
|
|
{
|
|
if (_ChildFashionStateList == null || _ChildFashionStateList.Count < 1)
|
|
return -1;
|
|
|
|
for (int index = 0; index < _ChildFashionStateList.Count; index++)
|
|
{
|
|
if (_ChildFashionStateList[index].childGuid == guid)
|
|
return _ChildFashionStateList[index].CFId;
|
|
}
|
|
|
|
return -1;
|
|
}
|
|
|
|
//红点结构
|
|
public static List<ChildRedStateStruct> _ChildRedStateList = null;
|
|
public void RefreshChildRedStateList(SyncChildrenShowState packet)
|
|
{
|
|
if(_ChildRedStateList == null)
|
|
_ChildRedStateList = new List<ChildRedStateStruct>();
|
|
|
|
for (int index = 0; index < packet.list.Count; index++)
|
|
{
|
|
var childRedStateInfo = GetChildRedStateByGuid(packet.list[index].childGuid);
|
|
if (childRedStateInfo == null)
|
|
{
|
|
_ChildRedStateList.Add(packet.list[index]);
|
|
} else
|
|
{
|
|
for(int childIndex = 0; childIndex < _ChildRedStateList.Count; childIndex++)
|
|
{
|
|
if (_ChildRedStateList[childIndex].childGuid == packet.list[index].childGuid)
|
|
{
|
|
_ChildRedStateList[childIndex] = packet.list[index];
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
for (int index = 0; index < _ChildRedStateList.Count; index++)
|
|
{
|
|
if (_ChildRedStateList[index].redPointList.Count > 0)
|
|
{
|
|
_IsShowIconRedState = true;
|
|
return;
|
|
}
|
|
}
|
|
_IsShowIconRedState = false;
|
|
}
|
|
|
|
public static List<int> GetChildRedStateByIndex(int index)
|
|
{
|
|
var childGuid = GetChildByIndex(index).guid;
|
|
return GetChildRedStateByGuid(childGuid);
|
|
}
|
|
|
|
public static List<int> GetChildRedStateByGuid(long guid)
|
|
{
|
|
if (_ChildRedStateList == null)
|
|
return null;
|
|
|
|
for(int index = 0; index < _ChildRedStateList.Count; index++)
|
|
{
|
|
if (_ChildRedStateList[index].childGuid == guid)
|
|
return _ChildRedStateList[index].redPointList;
|
|
}
|
|
|
|
return null;
|
|
}
|
|
} |