using JetBrains.Annotations; using System; using System.Collections.Generic; using XGame.Database; using XGame.Framework.Data; namespace FL { public class MountData : DataSingleton, IDisposable { /// /// 每个星级(黄|紫|红)最多拥有5个星星数量 /// public const int MaxStarNum = 5; #region 通用坐骑数据 /// /// 通用坐骑的星阶对应的zuoqiInfo表的id /// public int UniversalId { get; set; } /// /// 通用坐骑升星进度条 /// public int UniversalExp { set; get; } /// /// 坐骑部位驯养经验条 /// public int MountPartExp { set; get; } /// /// 通用坐骑部位驯养等级数据 /// private Dictionary _mountsPartsMap; public Dictionary MountsPartsMap => _mountsPartsMap ??= new Dictionary(); /// /// 通用坐骑基础信息 /// private mountBaseTable _universalMountConfig; /// /// 获取通用坐骑的基础信息 /// /// public mountBaseTable GetUniversalMountBaseInfo() { if (_universalMountConfig == null) { var mountBaseConfigList = mountBaseTableRepo.GetAll(); for ( int i = 0; i < mountBaseConfigList.Length; i++) { if (mountBaseConfigList[i].Type == 1) //普通坐骑类型 { _universalMountConfig = mountBaseConfigList[i]; break; } } } return _universalMountConfig; } /// /// 获取基础坐骑的升级信息:序号ID(10000 + 阶级 * 100 + 阶段等级) /// /// 阶级 /// 阶段等级 /// public mountLevelTable GetMountLevelTable(int step, int level) { return mountLevelTableRepo.Get(10000 + step * 100 + level); } #endregion #region 高级坐骑数据 /// /// 启用的高级坐骑的技能的坐骑id /// public int UseSkillMountId { set; get; } /// /// 已解锁的坐骑星级数据 /// key:zuoqiBase.id /// value:star(星级) /// private Dictionary _advancedMountsMap; public Dictionary AdvancedMountsMap => _advancedMountsMap ??= new Dictionary(); /// /// 获取高级坐骑升星表格信息(id:100*坐骑id+星级) /// /// 坐骑id /// 星级 /// public mountStarTable GetMountStarTable(int mountId, int starLevel) { return mountStarTableRepo.Get(mountId * 100 + starLevel); } /// /// 高级坐骑是否已解锁状态 /// /// /// public bool IsUnLock(int advancedMountId) { return _advancedMountsMap.ContainsKey(advancedMountId); } /// /// 获取高级坐骑的星级 /// /// public int GetAdvancedMountLv(int mountId) { return _advancedMountsMap.ContainsKey(mountId) ? _advancedMountsMap[mountId] : 0; } #endregion /// /// 当前使用的骑乘坐骑外观模型id(通用坐骑用的是zuoqiInfo表格,高级坐骑对应的是zuoqiBase表格) /// 此字段只在坐骑内部使用,如果外部需要使用坐骑骑乘外观,GetRidingAppearance() /// public int MountModelId { set; get; } /// /// 获取当前骑乘的坐骑外观 /// /// public string GetRidingAppearance() { if (MountModelId == 0) return string.Empty; var mountBaseInfo = mountBaseTableRepo.Get(MountModelId); if (mountBaseInfo != null) return mountBaseInfo.Spine; var mountInfo = mountLevelTableRepo.Get(MountModelId); return mountInfo == null ? string.Empty : mountInfo.Spine; } void IDisposable.Dispose() { _mountsPartsMap?.Clear(); _advancedMountsMap?.Clear(); } } }