using System;
|
using System.Collections.Generic;
|
// 默认ID相关
|
public partial class PhantasmPavilionManager : GameSystemManager<PhantasmPavilionManager>
|
{
|
//<类型,<job,id>>
|
public Dictionary<PhantasmPavilionType, Dictionary<int, int>> defaultIDDict = new Dictionary<PhantasmPavilionType, Dictionary<int, int>>();
|
//<类型,id>
|
public Dictionary<PhantasmPavilionType, int> nowIDDict = new Dictionary<PhantasmPavilionType, int>();
|
void InitTable()
|
{
|
var tabValues = Enum.GetValues(typeof(PhantasmPavilionType));
|
for (int i = 0; i < tabValues.Length; i++)
|
{
|
PhantasmPavilionType tab = (PhantasmPavilionType)tabValues.GetValue(i);
|
if (!defaultIDDict.ContainsKey(tab))
|
{
|
defaultIDDict[tab] = new Dictionary<int, int>();
|
}
|
}
|
var config = FuncConfigConfig.Get("PhantasmPavilion");
|
defaultIDDict[PhantasmPavilionType.Face] = ConfigParse.ParseIntDict(config.Numerical1);
|
defaultIDDict[PhantasmPavilionType.FacePic] = ConfigParse.ParseIntDict(config.Numerical2);
|
defaultIDDict[PhantasmPavilionType.ChatBox] = ConfigParse.ParseIntDict(config.Numerical3);
|
defaultIDDict[PhantasmPavilionType.Model] = ConfigParse.ParseIntDict(config.Numerical4);
|
//PhantasmPavilionType.Title 支持卸下,不需要保底的默认值
|
}
|
|
void InitNowIDDict()
|
{
|
nowIDDict[PhantasmPavilionType.Face] = PlayerDatas.Instance.baseData.face;
|
nowIDDict[PhantasmPavilionType.FacePic] = PlayerDatas.Instance.baseData.facePic;
|
nowIDDict[PhantasmPavilionType.ChatBox] = (int)PlayerDatas.Instance.baseData.chatBox;
|
nowIDDict[PhantasmPavilionType.Model] = PlayerDatas.Instance.baseData.modelMark;
|
nowIDDict[PhantasmPavilionType.Title] = PlayerDatas.Instance.baseData.TitleID;
|
}
|
|
void UpdateNowIDDict(PlayerDataType type)
|
{
|
bool isUpdate = true;
|
PhantasmPavilionType phantasmPavilionType = PhantasmPavilionType.Face;
|
switch (type)
|
{
|
case PlayerDataType.Face:
|
phantasmPavilionType = PhantasmPavilionType.Face;
|
nowIDDict[phantasmPavilionType] = (int)PlayerDatas.Instance.GetPlayerDataByType(PlayerDataType.Face);
|
break;
|
case PlayerDataType.FacePic:
|
phantasmPavilionType = PhantasmPavilionType.FacePic;
|
nowIDDict[phantasmPavilionType] = (int)PlayerDatas.Instance.GetPlayerDataByType(PlayerDataType.FacePic);
|
break;
|
case PlayerDataType.ExAttr10:
|
phantasmPavilionType = PhantasmPavilionType.ChatBox;
|
nowIDDict[phantasmPavilionType] = (int)PlayerDatas.Instance.GetPlayerDataByType(PlayerDataType.ExAttr10);
|
break;
|
case PlayerDataType.ModelMark:
|
phantasmPavilionType = PhantasmPavilionType.Model;
|
nowIDDict[phantasmPavilionType] = (int)PlayerDatas.Instance.GetPlayerDataByType(PlayerDataType.ModelMark);
|
break;
|
case PlayerDataType.ExAttr3:
|
phantasmPavilionType = PhantasmPavilionType.Title;
|
nowIDDict[phantasmPavilionType] = (int)PlayerDatas.Instance.GetPlayerDataByType(PlayerDataType.ExAttr3);
|
break;
|
default:
|
isUpdate = false;
|
break;
|
}
|
|
if (isUpdate)
|
{
|
if (nowType == phantasmPavilionType)
|
{
|
if (TryGetNowShowID(phantasmPavilionType, out int showID))
|
{
|
selectId = showID;
|
}
|
|
}
|
UpdateRedPoint();
|
}
|
}
|
|
//获取不同职业对应的ID默认值
|
public bool TryGetDefaultID(PhantasmPavilionType type, int job, out int defaultID)
|
{
|
defaultID = 0;
|
if (defaultIDDict == null || !defaultIDDict.TryGetValue(type, out var dict) || dict == null)
|
return false;
|
return dict.TryGetValue(job, out defaultID) || dict.TryGetValue(0, out defaultID);
|
}
|
|
// 获取当前应该显示的ID
|
public bool TryGetNowShowID(PhantasmPavilionType type, out int showID)
|
{
|
showID = 0;
|
int job = PlayerDatas.Instance.baseData.Job;
|
|
if (type != PhantasmPavilionType.Title)
|
{
|
if (!TryGetDefaultID(type, job, out int defaultID))
|
return false;
|
|
// 尝试获取玩家当前佩戴的ID
|
bool hasEquippedID = nowIDDict.TryGetValue(type, out int equippedID);
|
// 检查当前佩戴的ID是否有效
|
bool isEquippedIDValid = hasEquippedID && IsUnlock(type, equippedID);
|
// 如果佩戴的ID有效,则使用它;否则,回退到之前获取的默认ID
|
showID = isEquippedIDValid ? equippedID : defaultID;
|
return true;
|
}
|
else
|
{
|
// 尝试获取玩家当前佩戴的ID
|
bool hasEquippedID = nowIDDict.TryGetValue(type, out int equippedID);
|
// 检查当前佩戴的ID是否有效
|
bool isEquippedIDValid = hasEquippedID && IsUnlock(type, equippedID);
|
// 如果佩戴的ID有效,则使用它;否则,返回0
|
showID = isEquippedIDValid ? equippedID : 0;
|
return true;
|
}
|
}
|
|
//获得形象外观ID
|
public int GetModelSkinID(int id)
|
{
|
var config = ModelConfig.Get(id);
|
if (config == null)
|
{
|
TryGetDefaultID(PhantasmPavilionType.Model, PlayerDatas.Instance.baseData.Job, out int defaultID);
|
return ModelConfig.Get(defaultID).SkinID;
|
}
|
return config.SkinID;
|
}
|
|
public int GetMyModelSkinID()
|
{
|
return GetModelSkinID(PlayerDatas.Instance.baseData.modelMark);
|
}
|
}
|