using System.Collections.Generic; using Gameplay.Common; 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 _favorDic; //角色好感度缓存 private readonly Dictionary _expDic; //角色经验值缓存 private LvExp _playerLvEXp; //玩家经验值缓存 public int _commonExpCount; //通用经验道具拥有数量 public int LevelID => _levelID; public Team Team => _team; public Dictionary FavorDic => _favorDic; public Dictionary ExpDic => _expDic; public LvExp PlayerLvExp => _playerLvEXp; public int CommonExp => _commonExpCount; public LevelSettleData(int levelId, Team team) { _levelID = levelId; _team = team; _favorDic = new Dictionary(); _expDic = new Dictionary(); SetCharacterExp(); SetPlayerExp(); _commonExpCount = GetCommonExp(); } 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); } private int GetCommonExp() { int count = (int)CommonUtils.GetItemCount(GLConfig.Inst.data.HeroExpItem); return count; } } public partial class LevelManager { private LevelSettleData _cacheSettleData; public LevelSettleData SettleData => _cacheSettleData; } }