| | |
| | | public int exp; //当前阶等级经验,每级从0开始
|
| | | public event Action OnHorseUpdateEvent;
|
| | |
|
| | | public Dictionary<int, HorseSkin> skinDic = new Dictionary<int, HorseSkin>();
|
| | | public int lastClassLV; //皮肤界面点击后红点刷新
|
| | |
|
| | | Dictionary<int, HorseSkin> skinDic = new Dictionary<int, HorseSkin>();
|
| | | public event Action OnSkinUpdateEvent;
|
| | |
|
| | | //升级/升阶属性
|
| | | public Dictionary<int, long> specialAttrDic = new Dictionary<int, long>();
|
| | | public Dictionary<int, long> attrDic = new Dictionary<int, long>();
|
| | | public Dictionary<int, long> skinAttrDic = new Dictionary<int, long>();
|
| | |
|
| | | int m_selectSkinID;
|
| | | public event Action OnSelectEvent;
|
| | | public int selectSkinID
|
| | | {
|
| | | get { return m_selectSkinID; }
|
| | | set
|
| | | {
|
| | | m_selectSkinID = value;
|
| | | OnSelectEvent?.Invoke();
|
| | | }
|
| | | }
|
| | | //配置
|
| | | public int lvUPItemID;
|
| | | public int rankUPItemID;
|
| | |
| | | {
|
| | | DTC0102_tagCDBPlayer.beforePlayerDataInitializeEventOnRelogin += OnBeforePlayerDataInitialize;
|
| | | PackManager.Instance.RefreshItemEvent += OnRefreshItemEvent;
|
| | | DTC0403_tagPlayerLoginLoadOK.playerLoginOkEvent += OnPlayerLoginOk;
|
| | |
|
| | | ParseConfig();
|
| | | }
|
| | |
| | | {
|
| | | DTC0102_tagCDBPlayer.beforePlayerDataInitializeEventOnRelogin -= OnBeforePlayerDataInitialize;
|
| | | PackManager.Instance.RefreshItemEvent -= OnRefreshItemEvent;
|
| | | DTC0403_tagPlayerLoginLoadOK.playerLoginOkEvent -= OnPlayerLoginOk;
|
| | | }
|
| | |
|
| | | void ParseConfig()
|
| | |
| | | horseLV = 0;
|
| | | exp = 0;
|
| | | skinDic.Clear();
|
| | | lastClassLV = 0;
|
| | | }
|
| | |
|
| | | void OnPlayerLoginOk()
|
| | | {
|
| | | UpdateSkinRedpoint();
|
| | | }
|
| | |
|
| | | void OnRefreshItemEvent(PackType type, int index, int itemID)
|
| | |
| | | {
|
| | | UpdateRedpoint();
|
| | | }
|
| | |
|
| | | if (HorseSkinConfig.itemsList.Contains(itemID))
|
| | | {
|
| | | UpdateSkinRedpoint();
|
| | | }
|
| | | }
|
| | | }
|
| | |
|
| | | public int GetHorseSkinID()
|
| | | //获取当前使用坐骑皮肤ID
|
| | | public int GetUsingHorseSkinID(bool useDefault = false)
|
| | | {
|
| | | var id = (int)PlayerDatas.Instance.baseData.equipShowSwitch % 1000;
|
| | | if (id == 0)
|
| | | {
|
| | | id = 1;
|
| | | if (useDefault)
|
| | | {
|
| | | return 1;
|
| | | }
|
| | | }
|
| | | return id;
|
| | | }
|
| | |
|
| | | //获取其他玩家使用坐骑皮肤ID
|
| | | public int GetOtherPlayerHorseSkinID(int value)
|
| | | {
|
| | | return value % 1000;
|
| | | }
|
| | |
|
| | |
|
| | | public void UpdateHorseInfo(HA303_tagSCHorseClassInfo netPack)
|
| | | {
|
| | |
| | | horseLV = netPack.HorseLV;
|
| | | exp = netPack.Exp;
|
| | | UpdateRedpoint();
|
| | | UpdateSkinRedpoint();
|
| | | RefreshAttr();
|
| | | OnHorseUpdateEvent?.Invoke();
|
| | | if (isOpenSuccess)
|
| | | {
|
| | | UIManager.Instance.OpenWindow<HorseSuccessWin>();
|
| | | }
|
| | |
|
| | | if (!DTC0403_tagPlayerLoginLoadOK.finishedLogin)
|
| | | {
|
| | | lastClassLV = classLV;
|
| | | }
|
| | | }
|
| | |
|
| | |
| | | }
|
| | |
|
| | | RefreshSkinAttr();
|
| | | UpdateRedpoint();
|
| | | OnHorseUpdateEvent?.Invoke();
|
| | | UpdateSkinRedpoint();
|
| | | OnSkinUpdateEvent?.Invoke();
|
| | | }
|
| | |
|
| | | Redpoint redpoint = new Redpoint(MainRedDot.RedPoint_HorseKey);
|
| | | #region 红点
|
| | | Redpoint redpoint = new Redpoint(MainRedDot.RedPoint_HorseKey, MainRedDot.RedPoint_HorseKey * 10 + 1);
|
| | | Redpoint skinRedpoint = new Redpoint(MainRedDot.RedPoint_HorseKey, MainRedDot.RedPoint_HorseKey * 10 + 2);
|
| | |
|
| | |
|
| | | void UpdateRedpoint()
|
| | | {
|
| | | redpoint.state = RedPointState.None;
|
| | | if (!FuncOpen.Instance.IsFuncOpen((int)FuncOpenEnum.Horse))
|
| | | {
|
| | | return;
|
| | | }
|
| | |
|
| | | redpoint.state = RedPointState.None;
|
| | | var state = GetHorseState();
|
| | | if (state == 0)
|
| | | {
|
| | |
| | | }
|
| | | }
|
| | | }
|
| | |
|
| | | //皮肤红点
|
| | | public void UpdateSkinRedpoint()
|
| | | {
|
| | | skinRedpoint.state = RedPointState.None;
|
| | | if (!FuncOpen.Instance.IsFuncOpen((int)FuncOpenEnum.Horse))
|
| | | {
|
| | | return;
|
| | | }
|
| | |
|
| | | if (!DTC0403_tagPlayerLoginLoadOK.finishedLogin)
|
| | | {
|
| | | return;
|
| | | }
|
| | |
|
| | | //升阶解锁红点
|
| | | foreach (var lv in HorseSkinConfig.rankLVList)
|
| | | {
|
| | | if (classLV >= lv && lastClassLV < lv)
|
| | | {
|
| | | skinRedpoint.state = RedPointState.Simple;
|
| | | return;
|
| | | }
|
| | | }
|
| | |
|
| | | //升星解锁红点
|
| | | foreach (var skin in HorseSkinConfig.GetValues())
|
| | | {
|
| | | if (skin.UnlockWay != 2)
|
| | | continue;
|
| | |
|
| | | if (IsSkinActive(skin.SkinID))
|
| | | {
|
| | | if (skin.StarMax > 0)
|
| | | {
|
| | | //皮肤升星红点
|
| | | int itemID = skin.UnlockValue;
|
| | | var count = PackManager.Instance.GetItemCountByID(PackType.Item, itemID);
|
| | | if (count >= skin.UpNeedCnt && skinDic[skin.SkinID].Star < skin.StarMax)
|
| | | {
|
| | | skinRedpoint.state = RedPointState.Simple;
|
| | | return;
|
| | | }
|
| | | }
|
| | | }
|
| | | else
|
| | | {
|
| | | //皮肤解锁红点
|
| | | int itemID = skin.UnlockValue;
|
| | | var count = PackManager.Instance.GetItemCountByID(PackType.Item, itemID);
|
| | | if (count >= skin.UnlockNeedCnt)
|
| | | {
|
| | | skinRedpoint.state = RedPointState.Simple;
|
| | | return;
|
| | | }
|
| | | }
|
| | |
|
| | | }
|
| | | }
|
| | |
|
| | | public bool IsSkinActive(int id)
|
| | | {
|
| | | if (skinDic.TryGetValue(id, out var skin))
|
| | | {
|
| | | if (skin.State == 1 && skin.EndTime == 0)
|
| | | {
|
| | | return true;
|
| | | }
|
| | | else if (skin.State == 1 && skin.EndTime > 0 && skin.EndTime > TimeUtility.AllSeconds)
|
| | | {
|
| | | return true;
|
| | | }
|
| | | }
|
| | | var skinConfig = HorseSkinConfig.Get(id);
|
| | | if (skinConfig.UnlockWay == 1)
|
| | | {
|
| | | return classLV >= skinConfig.UnlockValue;
|
| | | }
|
| | | return false;
|
| | | }
|
| | |
|
| | | public bool IsShowTheHorseRedImg(int skinID)
|
| | | {
|
| | | var skin = HorseSkinConfig.Get(skinID);
|
| | | int lv = skin.UnlockWay == 1 ? skin.UnlockValue : 0;
|
| | | //升阶解锁红点
|
| | | if (classLV >= lv && lastClassLV < lv)
|
| | | {
|
| | | return true;
|
| | | }
|
| | |
|
| | | //升星解锁红点
|
| | | if (skin.UnlockWay != 2)
|
| | | return false;
|
| | |
|
| | | if (IsSkinActive(skin.SkinID))
|
| | | {
|
| | | if (skin.StarMax > 0)
|
| | | {
|
| | | //皮肤升星红点
|
| | | int itemID = skin.UnlockValue;
|
| | | var count = PackManager.Instance.GetItemCountByID(PackType.Item, itemID);
|
| | | if (count >= skin.UpNeedCnt && skinDic[skinID].Star < skin.StarMax)
|
| | | {
|
| | | return true;
|
| | | }
|
| | | }
|
| | | }
|
| | | else
|
| | | {
|
| | | //皮肤解锁红点
|
| | | int itemID = skin.UnlockValue;
|
| | | var count = PackManager.Instance.GetItemCountByID(PackType.Item, itemID);
|
| | | if (count >= skin.UnlockNeedCnt)
|
| | | {
|
| | | return true;
|
| | | }
|
| | | }
|
| | | return false;
|
| | | }
|
| | |
|
| | |
|
| | |
|
| | | //0 升级 1 升阶 2 满级
|
| | | public int GetHorseState()
|
| | |
| | | return 2;
|
| | |
|
| | | }
|
| | | #endregion
|
| | |
|
| | |
|
| | | #region 属性
|
| | | public void RefreshAttr()
|
| | | {
|
| | | specialAttrDic.Clear();
|
| | |
| | | specialAttrDic[config.ClassSpecAttrIDList[i]] += config.ClassSpecAttrValueList[i];
|
| | | }
|
| | | }
|
| | | |
| | |
|
| | | if (!config.ClassAttrValueList.IsNullOrEmpty())
|
| | | {
|
| | | for (int i = 0; i < config.AttrIDList.Length; i++)
|
| | |
| | | {
|
| | | attrDic[config.AttrIDList[i]] = 0;
|
| | | }
|
| | | var tmpHorseLV = lv != classLV ? config.MaxLV :horseLV;
|
| | | var tmpHorseLV = lv != classLV ? config.MaxLV : horseLV;
|
| | |
|
| | | attrDic[config.AttrIDList[i]] += config.PerLVAttrValueList[i]*tmpHorseLV;
|
| | | attrDic[config.AttrIDList[i]] += config.PerLVAttrValueList[i] * tmpHorseLV;
|
| | | }
|
| | | }
|
| | | }
|
| | |
| | | void RefreshSkinAttr()
|
| | | {
|
| | | skinAttrDic.Clear();
|
| | | foreach(var skinID in skinDic.Keys)
|
| | | foreach (var skinID in skinDic.Keys)
|
| | | {
|
| | | var skin = skinDic[skinID];
|
| | | if (skin.State != 1)
|
| | | {
|
| | | continue;
|
| | | }
|
| | | |
| | |
|
| | | var config = HorseSkinConfig.Get(skinID);
|
| | | |
| | |
|
| | | if (config.AttrIDList.IsNullOrEmpty())
|
| | | {
|
| | | continue;
|
| | |
| | | skinAttrDic[config.AttrIDList[i]] += config.InitAttrValueList[i];
|
| | | }
|
| | | }
|
| | | |
| | |
|
| | | if (!config.AttrPerStarAddList.IsNullOrEmpty())
|
| | | {
|
| | | for (int i = 0; i < config.AttrIDList.Length; i++)
|
| | |
| | | {
|
| | | skinAttrDic[config.AttrIDList[i]] = 0;
|
| | | }
|
| | | skinAttrDic[config.AttrIDList[i]] += config.AttrPerStarAddList[i]*skin.Star;
|
| | | skinAttrDic[config.AttrIDList[i]] += config.AttrPerStarAddList[i] * skin.Star;
|
| | | }
|
| | | }
|
| | | }
|
| | |
| | |
|
| | | return 0;
|
| | | }
|
| | | #endregion
|
| | |
|
| | | public List<int> sortSkinList = new List<int>();
|
| | | public void SortHorseSkinList()
|
| | | {
|
| | | sortSkinList = HorseSkinConfig.GetKeys();
|
| | | sortSkinList.Sort((a, b) =>
|
| | | {
|
| | | var isActiveA = IsSkinActive(a);
|
| | | var isActiveB = IsSkinActive(b);
|
| | | if (isActiveA != isActiveB)
|
| | | {
|
| | | return isActiveA ? -1 : 1;
|
| | | }
|
| | | var skinA = HorseSkinConfig.Get(a);
|
| | | var skinB = HorseSkinConfig.Get(b);
|
| | | return skinA.SkinID - skinB.SkinID;
|
| | | });
|
| | | }
|
| | |
|
| | | public Dictionary<int, long> GetAttrBySkinID(HorseSkinConfig config)
|
| | | {
|
| | | skinAttrDic.Clear();
|
| | |
|
| | | if (!config.InitAttrValueList.IsNullOrEmpty())
|
| | | {
|
| | | for (int i = 0; i < config.AttrIDList.Length; i++)
|
| | | {
|
| | | if (!skinAttrDic.ContainsKey(config.AttrIDList[i]))
|
| | | {
|
| | | skinAttrDic[config.AttrIDList[i]] = 0;
|
| | | }
|
| | | skinAttrDic[config.AttrIDList[i]] += config.InitAttrValueList[i];
|
| | | }
|
| | | }
|
| | |
|
| | | if (!config.AttrPerStarAddList.IsNullOrEmpty())
|
| | | {
|
| | | var star = 0;
|
| | | if (skinDic.TryGetValue(config.SkinID, out var skin))
|
| | | {
|
| | | star = skin.Star;
|
| | | }
|
| | | for (int i = 0; i < config.AttrIDList.Length; i++)
|
| | | {
|
| | | if (!skinAttrDic.ContainsKey(config.AttrIDList[i]))
|
| | | {
|
| | | skinAttrDic[config.AttrIDList[i]] = 0;
|
| | | }
|
| | | skinAttrDic[config.AttrIDList[i]] += config.AttrPerStarAddList[i] * star;
|
| | | }
|
| | | }
|
| | | return skinAttrDic;
|
| | | }
|
| | |
|
| | | public HorseSkin GetSkinData(int skinID)
|
| | | {
|
| | | skinDic.TryGetValue(skinID, out var skin);
|
| | | return skin;
|
| | | }
|
| | |
|
| | | //// 操作 1-激活;2-佩戴;3-升星
|
| | | public void SendSkinOP(int opType, int skinID)
|
| | | {
|
| | | var pack = new CB203_tagCSHorseSkinOP();
|
| | | pack.OPType = (byte)opType;
|
| | | pack.SkinID = (ushort)skinID;
|
| | | GameNetSystem.Instance.SendInfo(pack);
|
| | | }
|
| | | }
|
| | |
|
| | | public class HorseSkin {
|