using System.Collections;
|
using System.Collections.Generic;
|
using UnityEngine;
|
using System;
|
using System.Linq;
|
using LitJson;
|
|
|
public partial class BeautyMMManager : GameSystemManager<BeautyMMManager>
|
{
|
|
public List<int> beautyMMIDSortList = new List<int>();
|
public Dictionary<int, BeautyMMData> beautyMMDataDict = new Dictionary<int, BeautyMMData>(); //MMID 对应 数据
|
public Dictionary<int, BeautyMMSkinData> beautyMMSkinDataDict = new Dictionary<int, BeautyMMSkinData>(); //皮肤ID 对应 数据
|
public event Action OnBeautyMMDataUpdate;
|
|
public int selectLoveItemID = 0;
|
|
int m_SelectSkinID;
|
public event Action OnSelectSkinIDChange;
|
public int selectSkinID
|
{
|
get { return m_SelectSkinID; }
|
set
|
{
|
m_SelectSkinID = value;
|
OnSelectSkinIDChange?.Invoke();
|
}
|
}
|
//配置
|
|
//道具ID 对应 好感度
|
public Dictionary<int, int> giftIDToLoveDict = new Dictionary<int, int>();
|
public int[] loveItemIDs;
|
public int specialGiftLove = 0; // 数值3:专属信物道具好感度
|
public int needLVForTalent = 0; // 数值4:每x级好感度提升一级天赋效果
|
public int baseTravelEnergy = 0; // 数值1:基础体力上限
|
public int recoverTravelEnergyTime = 0; // 数值2:恢复1点体力所需时间,分钟
|
public int[] travelRowCol = new int[2]; // 数值3:游历行列数 行|列
|
|
public Dictionary<int, long> allMMTalentAttr = new Dictionary<int, long>();
|
public Dictionary<int, int> allMMTalentEffect = new Dictionary<int, int>();
|
|
|
public override void Init()
|
{
|
DTC0102_tagCDBPlayer.beforePlayerDataInitializeEventOnRelogin += OnBeforePlayerDataInitialize;
|
GlobalTimeEvent.Instance.fiveSecondEvent += UpdateRedpoint;
|
ParseConfig();
|
}
|
|
public override void Release()
|
{
|
DTC0102_tagCDBPlayer.beforePlayerDataInitializeEventOnRelogin -= OnBeforePlayerDataInitialize;
|
GlobalTimeEvent.Instance.fiveSecondEvent -= UpdateRedpoint;
|
}
|
|
void OnBeforePlayerDataInitialize()
|
{
|
beautyMMIDSortList.Clear();
|
beautyMMDataDict.Clear();
|
beautyMMSkinDataDict.Clear();
|
m_GridDict.Clear();
|
allMMTalentAttr.Clear();
|
allMMTalentEffect.Clear();
|
}
|
|
void ParseConfig()
|
{
|
var config = FuncConfigConfig.Get("BeautyLVUP");
|
loveItemIDs = JsonMapper.ToObject<int[]>(config.Numerical1);
|
var _list2 = JsonMapper.ToObject<int[]>(config.Numerical2);
|
for (int i = 0; i < loveItemIDs.Length; i++)
|
{
|
giftIDToLoveDict[loveItemIDs[i]] = _list2[i];
|
}
|
specialGiftLove = int.Parse(config.Numerical3);
|
needLVForTalent = int.Parse(config.Numerical4);
|
|
|
config = FuncConfigConfig.Get("TravelSet");
|
baseTravelEnergy = int.Parse(config.Numerical1);
|
recoverTravelEnergyTime = int.Parse(config.Numerical2);
|
travelRowCol = ConfigParse.GetMultipleStr<int>(config.Numerical3);
|
maxGirds = travelRowCol[0] * travelRowCol[1];
|
addEnergyItemID = int.Parse(config.Numerical4);
|
addEnergyValue = int.Parse(config.Numerical5);
|
|
}
|
|
|
public void UpdateBeautyMMData(HB130_tagSCBeautyInfo data)
|
{
|
int activeMMID = 0;
|
int activeSkinID = 0;
|
foreach (var beauty in data.BeautyList)
|
{
|
if (data.Count == 1)
|
{
|
//data.Count == 1 可以理解为解锁回报
|
if (beautyMMDataDict.ContainsKey(beauty.BeautyID))
|
{
|
if (beautyMMDataDict[beauty.BeautyID].State != beauty.State)
|
{
|
activeMMID = beauty.BeautyID;
|
}
|
}
|
else if (beauty.State != 0)
|
{
|
activeMMID = beauty.BeautyID;
|
}
|
|
}
|
beautyMMDataDict[beauty.BeautyID] = new BeautyMMData()
|
{
|
State = beauty.State,
|
LV = beauty.LV,
|
Exp = beauty.Exp,
|
AwardLV = beauty.AwardLV,
|
};
|
|
foreach (var skin in beauty.SkinList)
|
{
|
if (data.Count == 1)
|
{
|
//data.Count == 1 可以理解为解锁回报
|
if (beautyMMSkinDataDict.ContainsKey(skin.SkinID))
|
{
|
if (beautyMMSkinDataDict[skin.SkinID].State != skin.State)
|
{
|
activeSkinID = skin.SkinID;
|
}
|
}
|
else if (skin.State != 0)
|
{
|
activeSkinID = skin.SkinID;
|
}
|
}
|
|
beautyMMSkinDataDict[skin.SkinID] = new BeautyMMSkinData()
|
{
|
State = skin.State,
|
Used = skin.Used,
|
Star = skin.Star,
|
};
|
}
|
}
|
UpdateRedpoint();
|
RefreshAllTalen();
|
OnBeautyMMDataUpdate?.Invoke();
|
|
if (activeMMID > 0)
|
{
|
UIManager.Instance.OpenWindow<BeautyMMActiveWin>(activeMMID);
|
}
|
else if (activeSkinID > 0)
|
{
|
UIManager.Instance.OpenWindow<BeautyMMSkinActiveWin>(activeSkinID);
|
}
|
}
|
|
//0 全部 1 已激活 2 未激活
|
public void SortMMList(int type)
|
{
|
var _list = BeautyConfig.GetKeys();
|
beautyMMIDSortList.Clear();
|
if (type == 0)
|
{
|
beautyMMIDSortList = _list;
|
}
|
else if (type == 1)
|
{
|
foreach (var mmID in _list)
|
{
|
if (beautyMMDataDict.ContainsKey(mmID) && beautyMMDataDict[mmID].State == 1)
|
{
|
beautyMMIDSortList.Add(mmID);
|
}
|
}
|
}
|
else if (type == 2)
|
{
|
foreach (var mmID in _list)
|
{
|
if (!beautyMMDataDict.ContainsKey(mmID) || beautyMMDataDict[mmID].State == 0)
|
{
|
beautyMMIDSortList.Add(mmID);
|
}
|
}
|
}
|
beautyMMIDSortList.Sort(CmpMM);
|
}
|
|
int CmpMM(int mmIDA, int mmIDB)
|
{
|
bool isActiveA = false;
|
if (beautyMMDataDict.ContainsKey(mmIDA))
|
{
|
isActiveA = beautyMMDataDict[mmIDA].State == 1;
|
}
|
bool isActiveB = false;
|
if (beautyMMDataDict.ContainsKey(mmIDB))
|
{
|
isActiveB = beautyMMDataDict[mmIDB].State == 1;
|
}
|
if (isActiveA != isActiveB)
|
{
|
return isActiveA ? -1 : 1;
|
}
|
var qualityA = BeautyConfig.Get(mmIDA).BeautyQuality;
|
var qualityB = BeautyConfig.Get(mmIDB).BeautyQuality;
|
if (qualityA != qualityB)
|
{
|
return qualityB - qualityA;
|
}
|
return mmIDA - mmIDB;
|
}
|
|
|
public BeautyMMData GetBeautyMMData(int mmID)
|
{
|
if (beautyMMDataDict.ContainsKey(mmID))
|
{
|
return beautyMMDataDict[mmID];
|
}
|
return null;
|
}
|
|
public int GetMMLV(int mmID)
|
{
|
if (beautyMMDataDict.ContainsKey(mmID))
|
{
|
return beautyMMDataDict[mmID].LV;
|
}
|
return 0;
|
}
|
|
public int GetUsedSkinID(int mmID)
|
{
|
if (beautyMMDataDict.ContainsKey(mmID))
|
{
|
var _beauty = beautyMMDataDict[mmID];
|
if (_beauty.State == 1)
|
{
|
foreach (var skin in beautyMMSkinDataDict)
|
{
|
if (skin.Value.Used == 1)
|
{
|
return skin.Key;
|
}
|
}
|
}
|
}
|
//默认第一个
|
var _list = BeautySkinConfig.GetSkinListByMMID(mmID);
|
if (_list.Count > 0)
|
{
|
return _list[0].SkinID;
|
}
|
|
return 0;
|
}
|
|
public bool isActiveMM(int mmID)
|
{
|
if (beautyMMDataDict.ContainsKey(mmID))
|
{
|
return beautyMMDataDict[mmID].State == 1;
|
}
|
return false;
|
}
|
|
// 获取MM天赋属性属性, defaultAttr 是否使用默认属性
|
public Dictionary<int, long> GetMMTalentAttrForUI(int mmID, bool defaultAttr = false)
|
{
|
var _dict = new Dictionary<int, long>();
|
if (beautyMMDataDict.ContainsKey(mmID))
|
{
|
var _beauty = beautyMMDataDict[mmID];
|
if (_beauty.State == 1)
|
{
|
var config = BeautyConfig.Get(mmID);
|
if (config != null)
|
{
|
//初始天赋属性
|
for (int i = 0; i < config.TalentAttrIDList.Length; i++)
|
{
|
_dict[config.TalentAttrIDList[i]] = config.TalentAttrValueList[i];
|
}
|
|
//按x级好感度提升一级天赋效果
|
var _lv = _beauty.LV;
|
var _addLV = _lv / needLVForTalent;
|
if (_addLV > 0)
|
{
|
for (int i = 0; i < config.TalentAttrIDList.Length; i++)
|
{
|
_dict[config.TalentAttrIDList[i]] += _addLV * config.TalentPerLVAddList[i];
|
}
|
}
|
}
|
return _dict;
|
}
|
}
|
|
if (defaultAttr)
|
{
|
var config = BeautyConfig.Get(mmID);
|
if (config != null)
|
{
|
//初始天赋属性
|
for (int i = 0; i < config.TalentAttrIDList.Length; i++)
|
{
|
_dict[config.TalentAttrIDList[i]] = config.TalentAttrValueList[i];
|
}
|
}
|
}
|
return _dict;
|
}
|
|
|
public int GetTalentEffectByType(TalentEffectType type)
|
{
|
var value = allMMTalentEffect.ContainsKey((int)type) ? allMMTalentEffect[(int)type] : 0;
|
return value;
|
}
|
|
|
// 真实天赋属性
|
public Dictionary<int, long> GetMMTalentAttr(int mmID)
|
{
|
var _dict = new Dictionary<int, long>();
|
if (beautyMMDataDict.ContainsKey(mmID))
|
{
|
var _beauty = beautyMMDataDict[mmID];
|
if (_beauty.State == 1)
|
{
|
var config = BeautyConfig.Get(mmID);
|
if (config != null)
|
{
|
//初始天赋属性
|
for (int i = 0; i < config.TalentAttrIDList.Length; i++)
|
{
|
_dict[config.TalentAttrIDList[i]] = config.TalentAttrValueList[i];
|
}
|
|
//按x级好感度提升一级天赋效果
|
var _lv = _beauty.LV;
|
var _addLV = _lv / needLVForTalent;
|
if (_addLV > 0)
|
{
|
for (int i = 0; i < config.TalentAttrIDList.Length; i++)
|
{
|
_dict[config.TalentAttrIDList[i]] += _addLV * config.TalentPerLVAddList[i];
|
}
|
}
|
}
|
return _dict;
|
}
|
}
|
|
return _dict;
|
}
|
|
|
public int GetMMTalentEffectForUI(int mmID, bool defaultAttr = true)
|
{
|
int _effect = 0;
|
if (beautyMMDataDict.ContainsKey(mmID))
|
{
|
var _beauty = beautyMMDataDict[mmID];
|
if (_beauty.State == 1)
|
{
|
var config = BeautyConfig.Get(mmID);
|
if (config != null)
|
{
|
//初始天赋效果
|
_effect = config.EffValue;
|
//按x级好感度提升一级天赋效果
|
var _lv = _beauty.LV;
|
var _addLV = _lv / needLVForTalent;
|
if (_addLV > 0)
|
{
|
_effect += _addLV * config.EffPerLVAdd;
|
}
|
}
|
return _effect;
|
}
|
}
|
|
if (defaultAttr)
|
{
|
var config = BeautyConfig.Get(mmID);
|
if (config != null)
|
{
|
//初始天赋效果
|
_effect = config.EffValue;
|
}
|
}
|
return _effect;
|
}
|
|
// 获取MM天赋效果
|
public Dictionary<int, int> GetMMTalentEffect(int mmID)
|
{
|
int _effect = 0;
|
if (beautyMMDataDict.ContainsKey(mmID))
|
{
|
var _beauty = beautyMMDataDict[mmID];
|
if (_beauty.State == 1)
|
{
|
var config = BeautyConfig.Get(mmID);
|
if (config != null)
|
{
|
//初始天赋效果
|
_effect = config.EffValue;
|
//按x级好感度提升一级天赋效果
|
var _lv = _beauty.LV;
|
var _addLV = _lv / needLVForTalent;
|
if (_addLV > 0)
|
{
|
_effect += _addLV * config.EffPerLVAdd;
|
}
|
}
|
return new Dictionary<int, int>()
|
{
|
{config.EffType, _effect}
|
} ;
|
}
|
}
|
return new Dictionary<int, int>();
|
}
|
|
Dictionary<int, long> GetMMLVUPAttr(int mmID)
|
{
|
var mmConfig = BeautyConfig.Get(mmID);
|
//升级获得的属性
|
var _dict = new Dictionary<int, long>();
|
var lv = GetMMLV(mmID);
|
BeautyQualityLVConfig config;
|
for (int i = 1; i <= lv; i++)
|
{
|
BeautyQualityLVConfig.TryGetBeautyQualityLVConfig(mmConfig.BeautyQuality, i, out config);
|
if (config != null)
|
{
|
for (int j = 0; j < config.AttrIDList.Length; j++)
|
{
|
if (_dict.ContainsKey(config.AttrIDList[j]))
|
{
|
_dict[config.AttrIDList[j]] += config.AttrValueList[j];
|
}
|
else
|
{
|
_dict.Add(config.AttrIDList[j], config.AttrValueList[j]);
|
}
|
}
|
}
|
}
|
|
|
return _dict;
|
|
}
|
|
void RefreshAllTalen()
|
{
|
allMMTalentAttr.Clear();
|
allMMTalentEffect.Clear();
|
foreach (var key in beautyMMDataDict.Keys)
|
{
|
var _dict = GetMMTalentAttr(key);
|
//加到allMMTalentAttr
|
foreach (var _key in _dict.Keys)
|
{
|
if (allMMTalentAttr.ContainsKey(_key))
|
{
|
allMMTalentAttr[_key] += _dict[_key];
|
}
|
else
|
{
|
allMMTalentAttr.Add(_key, _dict[_key]);
|
}
|
}
|
|
//升级属性
|
var _dict1 = GetMMLVUPAttr(key);
|
//加到allMMTalentAttr
|
foreach (var _key in _dict1.Keys)
|
{
|
if (allMMTalentAttr.ContainsKey(_key))
|
{
|
allMMTalentAttr[_key] += _dict1[_key];
|
}
|
else
|
{
|
allMMTalentAttr.Add(_key, _dict1[_key]);
|
}
|
}
|
|
|
var _dict2 = GetMMTalentEffect(key);
|
//加到allMMTalentEffect
|
foreach (var _key in _dict2.Keys)
|
{
|
if (allMMTalentEffect.ContainsKey(_key))
|
{
|
allMMTalentEffect[_key] += _dict2[_key];
|
}
|
else
|
{
|
allMMTalentEffect.Add(_key, _dict2[_key]);
|
}
|
}
|
}
|
|
|
}
|
|
public long GetAttrValue(int attrID)
|
{
|
allMMTalentAttr.TryGetValue(attrID, out long value);
|
return value;
|
}
|
|
public int GetAttrPer(int attrID)
|
{
|
if (PlayerPropertyConfig.baseAttr2perDict.ContainsKey(attrID))
|
{
|
var pertype = PlayerPropertyConfig.baseAttr2perDict[attrID];
|
allMMTalentAttr.TryGetValue(pertype, out long value);
|
return (int)(value);
|
}
|
|
return 0;
|
}
|
|
|
//操作 1-激活;2-佩戴;3-升星
|
public void SendSkinOP(int mmID, int skinID, int opType)
|
{
|
var pack = new CB221_tagCSBeautySkinOP();
|
pack.BeautyID = (ushort)mmID;
|
pack.SkinID = (ushort)skinID;
|
pack.OPType = (byte)opType;
|
GameNetSystem.Instance.SendInfo(pack);
|
}
|
|
|
#region 红点
|
Redpoint redpoint = new Redpoint(MainRedDot.MainAffairsRedpoint, MainRedDot.Redpoint_BeautyMM);
|
Redpoint redpointMM = new Redpoint(MainRedDot.Redpoint_BeautyMM, MainRedDot.Redpoint_BeautyMM * 10 + 1);
|
Redpoint redpointMMTotal = new Redpoint(MainRedDot.Redpoint_BeautyMM * 10 + 1, (MainRedDot.Redpoint_BeautyMM * 10 + 1) * 10);
|
Redpoint redpointMMKnown = new Redpoint((MainRedDot.Redpoint_BeautyMM * 10 + 1) * 10, (MainRedDot.Redpoint_BeautyMM * 10 + 1) * 10 + 1);
|
Redpoint redpointMMUnKnown = new Redpoint((MainRedDot.Redpoint_BeautyMM * 10 + 1) * 10, (MainRedDot.Redpoint_BeautyMM * 10 + 1) * 10 + 2);
|
|
|
|
|
|
|
|
void UpdateRedpoint()
|
{
|
redpointMMKnown.state = RedPointState.None;
|
redpointMMUnKnown.state = RedPointState.None;
|
if (!FuncOpen.Instance.IsFuncOpen((int)FuncOpenEnum.BeautyMM))
|
{
|
return;
|
}
|
var _list = BeautyConfig.GetValues();
|
foreach (var beauty in _list)
|
{
|
var state = GetMMBaseState(beauty);
|
if (state == 1)
|
{
|
redpointMMKnown.state = RedPointState.Simple;
|
}
|
else if (state >= 2)
|
{
|
redpointMMUnKnown.state = RedPointState.Simple;
|
}
|
}
|
|
// 时装MM 红点
|
if (redpointMMKnown.state == RedPointState.None)
|
{
|
foreach (var beauty in _list)
|
{
|
if (IsMMSkinRed(beauty.BeautyID))
|
{
|
redpointMMKnown.state = RedPointState.Simple;
|
break;
|
}
|
}
|
}
|
}
|
|
//MM基础状态 0 无 1 有奖励 2 可物品激活 3 可功能激活
|
public int GetMMBaseState(BeautyConfig beauty)
|
{
|
//是否可激活,是否有奖励可领取
|
if (beautyMMDataDict.ContainsKey(beauty.BeautyID))
|
{
|
var _beauty = beautyMMDataDict[beauty.BeautyID];
|
if (_beauty.State == 1)
|
{
|
if (_beauty.LV > _beauty.AwardLV)
|
{
|
//有奖励可领取
|
return 1;
|
}
|
return 0;
|
}
|
|
}
|
|
|
//功能性激活
|
switch (beauty.UnlockWay)
|
{
|
case 1:
|
if (PackManager.Instance.GetItemCountByID(PackType.Item, beauty.UnlockValue) >= beauty.UnlockNeedCnt)
|
{
|
//可激活
|
return 2;
|
}
|
break;
|
case 2:
|
if (TaskManager.Instance.mainTask.TaskID > beauty.UnlockValue)
|
{
|
//任务
|
return 3;
|
}
|
break;
|
case 3:
|
if (ArenaManager.Instance.totalWinCnt >= beauty.UnlockNeedCnt)
|
{
|
return 3;
|
}
|
break;
|
case 4:
|
if (GoldRushManager.Instance.maxWorkerCount >= beauty.UnlockNeedCnt)
|
{
|
//可激活
|
return 3;
|
}
|
break;
|
case 5:
|
int dataMapID = BoneFieldManager.Instance.DataMapID;
|
if (DungeonManager.Instance.TryGetFBInfoByMapID(dataMapID, out var fbInfo))
|
{
|
if (BoneFieldManager.Instance.GetNowPassLineID(fbInfo) > beauty.UnlockValue)
|
{
|
return 3;
|
}
|
}
|
break;
|
case 6:
|
if (PlayerDatas.Instance.baseData.realmLevel >= beauty.UnlockValue)
|
{
|
return 3;
|
}
|
break;
|
case 7:
|
if (m_TravelCnt >= beauty.UnlockNeedCnt)
|
{
|
return 3;
|
}
|
break;
|
}
|
|
|
|
return 0;
|
}
|
|
// 时装MM 状态 (前提是已激活本体的情况) 0 无 1 可激活 2 可升星;
|
public int GetMMSkinStateBySkinID(BeautySkinConfig skin)
|
{
|
if (beautyMMSkinDataDict.ContainsKey(skin.SkinID))
|
{
|
//升星判断
|
var _skin = beautyMMSkinDataDict[skin.SkinID];
|
if (_skin.State == 1)
|
{
|
if (_skin.Star < skin.StarMax && PackManager.Instance.GetItemCountByID(PackType.Item, skin.UnlockValue) >= skin.UpNeedCnt)
|
{
|
return 2;
|
}
|
return 0;
|
}
|
}
|
|
//激活
|
if (skin.UnlockWay == 2 && PackManager.Instance.GetItemCountByID(PackType.Item, skin.UnlockValue) >= skin.UnlockNeedCnt)
|
{
|
return 1;
|
}
|
return 0;
|
}
|
|
public BeautyMMSkinData GetSkinData(int skinID)
|
{
|
if (beautyMMSkinDataDict.ContainsKey(skinID))
|
{
|
return beautyMMSkinDataDict[skinID];
|
}
|
return new BeautyMMSkinData();
|
}
|
|
public bool IsMMSkinRed(int mmID)
|
{
|
var _list = BeautySkinConfig.GetSkinListByMMID(mmID);
|
if (_list == null || _list.Count == 0)
|
{
|
return false;
|
}
|
if (!beautyMMDataDict.ContainsKey(mmID))
|
{
|
return false;
|
}
|
|
var _beauty = beautyMMDataDict[mmID];
|
if (_beauty.State == 0)
|
{
|
return false;
|
}
|
foreach (var skin in _list)
|
{
|
if (GetMMSkinStateBySkinID(skin) > 0)
|
{
|
return true;
|
}
|
}
|
return false;
|
|
}
|
|
// 判断基础的养成 和 时装
|
public bool IsMMRed(int mmID)
|
{
|
var config = BeautyConfig.Get(mmID);
|
if (GetMMBaseState(config) > 0)
|
{
|
return true;
|
}
|
|
return IsMMSkinRed(mmID);
|
}
|
|
#endregion
|
|
|
|
}
|
|
|
public class BeautyMMData
|
{
|
public byte State; //是否已激活
|
public ushort LV; //红颜好感等级,激活时为0级
|
public ushort Exp; //当前等级经验
|
public ushort AwardLV; //已经领取到的奖励等级记录
|
}
|
public class BeautyMMSkinData
|
{
|
public byte State; //是否已激活
|
public byte Used; //是否已穿戴该时装,某个红颜的所有时装穿戴可能都为0,则前端取默认时装进行展示,如果有同步已穿戴的则以后端为准
|
public byte Star; //时装星级,激活时为0星
|
}
|
|
// 1.主线战利品上限提高百分比 无 百分比
|
// 2.演武场挑战胜利,概率额外获得1个物品的概率 物品ID 概率
|
// 3.游历体力上限增加 无 增加上限
|
// 4.白骨盈野扫荡额外物品奖励 物品ID 个数
|
|
public enum TalentEffectType
|
{
|
MainLine = 1,
|
Arena = 2,
|
Travel = 3,
|
BoneField = 4,
|
}
|