NLDClient-yudde/ProjectNLD/Assets/Code/Scripts/Gameplay/Level/LevelManager.Settle.cs

82 lines
2.3 KiB
C#

using System.Collections.Generic;
using Gameplay.Net;
using NLDPB;
namespace Gameplay.Level
{
public struct LvExp
{
public uint Lv;
public uint Exp;
public LvExp(uint exp, uint lv)
{
Lv = lv;
Exp = exp;
}
}
public class LevelSettleData
{
private readonly int _levelID;
private readonly Team _team;
private readonly Dictionary<uint, LvExp> _favorDic; //角色好感度缓存
private readonly Dictionary<uint, LvExp> _expDic; //角色经验值缓存
private LvExp _playerLvEXp; //玩家经验值缓存
public int LevelID => _levelID;
public Team Team => _team;
public Dictionary<uint, LvExp> FavorDic => _favorDic;
public Dictionary<uint, LvExp> ExpDic => _expDic;
public LvExp PlayerLvExp => _playerLvEXp;
public LevelSettleData(int levelId, Team team)
{
_levelID = levelId;
_team = team;
_favorDic = new Dictionary<uint, LvExp>();
_expDic = new Dictionary<uint, LvExp>();
SetCharacterExp();
SetPlayerExp();
}
private void SetCharacterExp()
{
var charIDs = _team.GetCharacterIDs();
for (int i = 0; i < charIDs.Length; i++)
{
var id = charIDs[i];
if (id != Team.NONE_ID)
{
if (!CharacterDataInfoManager.Instance.DataDic.TryGetValue(id, out var charDataInfo))
{
continue;
}
var favorData = new LvExp(charDataInfo.LikelyExp, charDataInfo.LikelyLevel);
var expData = new LvExp(charDataInfo.Exp, charDataInfo.Level);
_favorDic.Add(id, favorData);
_expDic.Add(id, expData);
}
}
}
private void SetPlayerExp()
{
var exp = Actor.Instance.Base.GetProp(ActorProp.Exp);
var lv = Actor.Instance.Base.GetProp(ActorProp.Level);
_playerLvEXp = new LvExp(exp, lv);
}
}
public partial class LevelManager
{
private LevelSettleData _cacheSettleData;
public LevelSettleData SettleData => _cacheSettleData;
}
}