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