Core/GameEngine/Model/Config/HorseLVUpConfig.cs
New file @@ -0,0 +1,228 @@ //-------------------------------------------------------- // [Author]: Fish // [ Date ]: Sunday, December 29, 2019 //-------------------------------------------------------- using System.Collections.Generic; using System.IO; using System.Threading; using System; using UnityEngine; [XLua.LuaCallCSharp] public partial class HorseLVUpConfig { public readonly int HorseLV; public readonly int HorseSkinID; public readonly string name; public readonly int NeedEatCount; public readonly int[] LVAttrType; public readonly int[] LVAttrValue; public readonly int HorseID; public HorseLVUpConfig() { } public HorseLVUpConfig(string input) { try { var tables = input.Split('\t'); int.TryParse(tables[0],out HorseLV); int.TryParse(tables[1],out HorseSkinID); name = tables[2]; int.TryParse(tables[3],out NeedEatCount); string[] LVAttrTypeStringArray = tables[4].Trim().Split(StringUtility.splitSeparator,StringSplitOptions.RemoveEmptyEntries); LVAttrType = new int[LVAttrTypeStringArray.Length]; for (int i=0;i<LVAttrTypeStringArray.Length;i++) { int.TryParse(LVAttrTypeStringArray[i],out LVAttrType[i]); } string[] LVAttrValueStringArray = tables[5].Trim().Split(StringUtility.splitSeparator,StringSplitOptions.RemoveEmptyEntries); LVAttrValue = new int[LVAttrValueStringArray.Length]; for (int i=0;i<LVAttrValueStringArray.Length;i++) { int.TryParse(LVAttrValueStringArray[i],out LVAttrValue[i]); } int.TryParse(tables[6],out HorseID); } catch (Exception ex) { DebugEx.Log(ex); } } static Dictionary<string, HorseLVUpConfig> configs = new Dictionary<string, HorseLVUpConfig>(); public static HorseLVUpConfig Get(string id) { if (!inited) { Debug.Log("HorseLVUpConfig 还未完成初始化。"); return null; } if (configs.ContainsKey(id)) { return configs[id]; } HorseLVUpConfig config = null; if (rawDatas.ContainsKey(id)) { config = configs[id] = new HorseLVUpConfig(rawDatas[id]); rawDatas.Remove(id); } return config; } public static HorseLVUpConfig Get(int id) { return Get(id.ToString()); } public static List<string> GetKeys() { var keys = new List<string>(); keys.AddRange(configs.Keys); keys.AddRange(rawDatas.Keys); return keys; } public static List<HorseLVUpConfig> GetValues() { var values = new List<HorseLVUpConfig>(); values.AddRange(configs.Values); var keys = new List<string>(rawDatas.Keys); foreach (var key in keys) { values.Add(Get(key)); } return values; } public static bool Has(string id) { return configs.ContainsKey(id) || rawDatas.ContainsKey(id); } public static bool Has(int id) { return Has(id.ToString()); } public static bool inited { get; private set; } protected static Dictionary<string, string> rawDatas = new Dictionary<string, string>(); public static void Init(bool sync=false) { inited = false; var path = string.Empty; if (AssetSource.refdataFromEditor) { path = ResourcesPath.CONFIG_FODLER +"/HorseLVUp.txt"; } else { path = AssetVersionUtility.GetAssetFilePath("config/HorseLVUp.txt"); } configs.Clear(); var tempConfig = new HorseLVUpConfig(); var preParse = tempConfig is IConfigPostProcess; if (sync) { var lines = File.ReadAllLines(path); if (!preParse) { rawDatas = new Dictionary<string, string>(lines.Length - 3); } for (int i = 3; i < lines.Length; i++) { try { var line = lines[i]; var index = line.IndexOf("\t"); if (index == -1) { continue; } var id = line.Substring(0, index); if (preParse) { var config = new HorseLVUpConfig(line); configs[id] = config; (config as IConfigPostProcess).OnConfigParseCompleted(); } else { rawDatas[id] = line; } } catch (System.Exception ex) { Debug.LogError(ex); } } inited = true; } else { ThreadPool.QueueUserWorkItem((object _object) => { var lines = File.ReadAllLines(path); if (!preParse) { rawDatas = new Dictionary<string, string>(lines.Length - 3); } for (int i = 3; i < lines.Length; i++) { try { var line = lines[i]; var index = line.IndexOf("\t"); if (index == -1) { continue; } var id = line.Substring(0, index); if (preParse) { var config = new HorseLVUpConfig(line); configs[id] = config; (config as IConfigPostProcess).OnConfigParseCompleted(); } else { rawDatas[id] = line; } } catch (System.Exception ex) { Debug.LogError(ex); } } inited = true; }); } } } Core/GameEngine/Model/Config/HorseLVUpConfig.cs.meta
New file @@ -0,0 +1,12 @@ fileFormatVersion: 2 guid: 2d50dc327ea1fe941bf7f48e5aaf65dc timeCreated: 1577630948 licenseType: Pro MonoImporter: serializedVersion: 2 defaultReferences: [] executionOrder: 0 icon: {instanceID: 0} userData: assetBundleName: assetBundleVariant: Core/GameEngine/Model/Config/HorseSkinPlusConfig.cs
New file @@ -0,0 +1,237 @@ //-------------------------------------------------------- // [Author]: Fish // [ Date ]: Monday, December 30, 2019 //-------------------------------------------------------- using System.Collections.Generic; using System.IO; using System.Threading; using System; using UnityEngine; [XLua.LuaCallCSharp] public partial class HorseSkinPlusConfig { public readonly int ID; public readonly int HorseSkinID; public readonly int UnlockItemID; public readonly int UnlockItemCnt; public readonly string name; public readonly int[] AttrType; public readonly int[] AttrValue; public readonly int InitFightPower; public readonly int HorseID; public readonly int sortIndex; public HorseSkinPlusConfig() { } public HorseSkinPlusConfig(string input) { try { var tables = input.Split('\t'); int.TryParse(tables[0],out ID); int.TryParse(tables[1],out HorseSkinID); int.TryParse(tables[2],out UnlockItemID); int.TryParse(tables[3],out UnlockItemCnt); name = tables[4]; string[] AttrTypeStringArray = tables[5].Trim().Split(StringUtility.splitSeparator,StringSplitOptions.RemoveEmptyEntries); AttrType = new int[AttrTypeStringArray.Length]; for (int i=0;i<AttrTypeStringArray.Length;i++) { int.TryParse(AttrTypeStringArray[i],out AttrType[i]); } string[] AttrValueStringArray = tables[6].Trim().Split(StringUtility.splitSeparator,StringSplitOptions.RemoveEmptyEntries); AttrValue = new int[AttrValueStringArray.Length]; for (int i=0;i<AttrValueStringArray.Length;i++) { int.TryParse(AttrValueStringArray[i],out AttrValue[i]); } int.TryParse(tables[7],out InitFightPower); int.TryParse(tables[8],out HorseID); int.TryParse(tables[9],out sortIndex); } catch (Exception ex) { DebugEx.Log(ex); } } static Dictionary<string, HorseSkinPlusConfig> configs = new Dictionary<string, HorseSkinPlusConfig>(); public static HorseSkinPlusConfig Get(string id) { if (!inited) { Debug.Log("HorseSkinPlusConfig 还未完成初始化。"); return null; } if (configs.ContainsKey(id)) { return configs[id]; } HorseSkinPlusConfig config = null; if (rawDatas.ContainsKey(id)) { config = configs[id] = new HorseSkinPlusConfig(rawDatas[id]); rawDatas.Remove(id); } return config; } public static HorseSkinPlusConfig Get(int id) { return Get(id.ToString()); } public static List<string> GetKeys() { var keys = new List<string>(); keys.AddRange(configs.Keys); keys.AddRange(rawDatas.Keys); return keys; } public static List<HorseSkinPlusConfig> GetValues() { var values = new List<HorseSkinPlusConfig>(); values.AddRange(configs.Values); var keys = new List<string>(rawDatas.Keys); foreach (var key in keys) { values.Add(Get(key)); } return values; } public static bool Has(string id) { return configs.ContainsKey(id) || rawDatas.ContainsKey(id); } public static bool Has(int id) { return Has(id.ToString()); } public static bool inited { get; private set; } protected static Dictionary<string, string> rawDatas = new Dictionary<string, string>(); public static void Init(bool sync=false) { inited = false; var path = string.Empty; if (AssetSource.refdataFromEditor) { path = ResourcesPath.CONFIG_FODLER +"/HorseSkinPlus.txt"; } else { path = AssetVersionUtility.GetAssetFilePath("config/HorseSkinPlus.txt"); } configs.Clear(); var tempConfig = new HorseSkinPlusConfig(); var preParse = tempConfig is IConfigPostProcess; if (sync) { var lines = File.ReadAllLines(path); if (!preParse) { rawDatas = new Dictionary<string, string>(lines.Length - 3); } for (int i = 3; i < lines.Length; i++) { try { var line = lines[i]; var index = line.IndexOf("\t"); if (index == -1) { continue; } var id = line.Substring(0, index); if (preParse) { var config = new HorseSkinPlusConfig(line); configs[id] = config; (config as IConfigPostProcess).OnConfigParseCompleted(); } else { rawDatas[id] = line; } } catch (System.Exception ex) { Debug.LogError(ex); } } inited = true; } else { ThreadPool.QueueUserWorkItem((object _object) => { var lines = File.ReadAllLines(path); if (!preParse) { rawDatas = new Dictionary<string, string>(lines.Length - 3); } for (int i = 3; i < lines.Length; i++) { try { var line = lines[i]; var index = line.IndexOf("\t"); if (index == -1) { continue; } var id = line.Substring(0, index); if (preParse) { var config = new HorseSkinPlusConfig(line); configs[id] = config; (config as IConfigPostProcess).OnConfigParseCompleted(); } else { rawDatas[id] = line; } } catch (System.Exception ex) { Debug.LogError(ex); } } inited = true; }); } } } Core/GameEngine/Model/Config/HorseSkinPlusConfig.cs.meta
New file @@ -0,0 +1,12 @@ fileFormatVersion: 2 guid: d5644b27bab76474d96ca23e02784a63 timeCreated: 1577705237 licenseType: Pro MonoImporter: serializedVersion: 2 defaultReferences: [] executionOrder: 0 icon: {instanceID: 0} userData: assetBundleName: assetBundleVariant: Core/NetworkPackage/ClientPack/ClientToMapServer/CA5_Function/CA501_tagPlayerActivateHorse.cs
@@ -4,7 +4,7 @@ //A5 01 坐骑激活 #tagPlayerActivateHorse public class CA501_tagPlayerActivateHorse : GameNetPackBasic { public uint HorseID; //坐骑ID public uint HorseID; //坐骑幻化ID public CA501_tagPlayerActivateHorse () { combineCmd = (ushort)0x03FE; Core/NetworkPackage/ClientPack/ClientToMapServer/CA5_Function/CA502_tagPlayerChooseHorse.cs
@@ -4,7 +4,8 @@ //A5 02 坐骑选择 #tagPlayerChooseHorse public class CA502_tagPlayerChooseHorse : GameNetPackBasic { public uint Index; //选择索引 public byte ChooseType; // 1-按等阶,2-按幻化 public byte LVID; // 阶等级或幻化ID public CA502_tagPlayerChooseHorse () { combineCmd = (ushort)0x03FE; @@ -12,7 +13,8 @@ } public override void WriteToBytes () { WriteBytes (Index, NetDataType.DWORD); WriteBytes (ChooseType, NetDataType.BYTE); WriteBytes (LVID, NetDataType.BYTE); } } Core/NetworkPackage/ClientPack/ClientToMapServer/CA5_Function/CA527_tagCMHorseUp.cs
@@ -4,7 +4,6 @@ // A5 27 坐骑提升 #tagCMHorseUp public class CA527_tagCMHorseUp : GameNetPackBasic { public uint HorseID; //坐骑ID public byte UseItemCnt; //消耗材料个数 public byte IsAutoBuy; //是否自动购买 @@ -14,7 +13,6 @@ } public override void WriteToBytes () { WriteBytes (HorseID, NetDataType.DWORD); WriteBytes (UseItemCnt, NetDataType.BYTE); WriteBytes (IsAutoBuy, NetDataType.BYTE); } Core/NetworkPackage/DTCFile/ServerPack/HA3_Function/DTCA301_tagTrainHorseData.cs
@@ -1,31 +1,12 @@ using UnityEngine; using System.Collections; using Snxxz.UI; //A3 01 坐骑培养信息 #tagTrainHorseData public class DTCA301_tagTrainHorseData : DtcBasic { MountModel m_HorseModel; MountModel horsemodel { get { return m_HorseModel ?? (m_HorseModel = ModelCenter.Instance.GetModel<MountModel>()); } } public override void Done(GameNetPackBasic vNetPack) { base.Done(vNetPack); HA301_tagTrainHorseData vNetData = vNetPack as HA301_tagTrainHorseData; if (vNetData != null) { horsemodel.MountHA301(vNetData); } } //A3 01 坐骑培养信息 #tagTrainHorseData public class DTCA301_tagTrainHorseData : DtcBasic { MountModel horseModel { get { return ModelCenter.Instance.GetModel<MountModel>(); } } public override void Done(GameNetPackBasic vNetPack) { base.Done(vNetPack); HA301_tagTrainHorseData vNetData = vNetPack as HA301_tagTrainHorseData; horseModel.MountHA301(vNetData); } } Core/NetworkPackage/ServerPack/HA3_Function/HA301_tagTrainHorseData.cs
@@ -4,30 +4,18 @@ //A3 01 坐骑培养信息 #tagTrainHorseData public class HA301_tagTrainHorseData : GameNetPackBasic { public byte Multiple; //下次暴击倍数 public byte Num; //个数 public tagMCHorseInfo[] InfoList = null; // 坐骑数据列表 public byte LV; //等阶 public ushort EatItemCount; //当前阶已吃丹个数 public uint SkinPlusState; //幻化激活状态,按位存储是否激活,幻化编号ID对应位 public HA301_tagTrainHorseData () { _cmd = (ushort)0xA301; } public override void ReadFromBytes (byte[] vBytes) { TransBytes (out Multiple, vBytes, NetDataType.BYTE); TransBytes (out Num, vBytes, NetDataType.BYTE); InfoList = new tagMCHorseInfo[Num]; for (int i = 0; i < Num; i ++) { InfoList[i] = new tagMCHorseInfo(); TransBytes (out InfoList[i].HorseID, vBytes, NetDataType.DWORD); TransBytes (out InfoList[i].LV, vBytes, NetDataType.BYTE); TransBytes (out InfoList[i].Exp, vBytes, NetDataType.DWORD); } } public struct tagMCHorseInfo { public uint HorseID; //ID public byte LV; //等级 public uint Exp; //经验 TransBytes (out LV, vBytes, NetDataType.BYTE); TransBytes (out EatItemCount, vBytes, NetDataType.WORD); TransBytes (out SkinPlusState, vBytes, NetDataType.DWORD); } } System/Mount/AutoTrainTipsWin.cs
@@ -64,7 +64,7 @@ IsFairy = false; _NumKeyBoardBGM.gameObject.SetActive(false); isBool = true; horseID = moutwin.signHorseID; horseID = 1; m_NowLevelTxt.text = string.Format(Language.Get("Z1031"), mountModel._DicHorse[horseID].Lv); GetMountSkills(horseID); PropertyEntries(horseID);//默认自动选择 @@ -151,7 +151,6 @@ if (NeedFairyJade > 0 && gold >= NeedFairyJade) { IsFairy = true; moutwin.FairyJadeDomesticate(); Close(); } else System/Mount/MountModel.cs
@@ -3,7 +3,7 @@ using System.Collections; using System.Collections.Generic; using System.Text.RegularExpressions; using LitJson; using UnityEngine; //用于坐骑 [XLua.LuaCallCSharp] @@ -41,23 +41,24 @@ public static event MountHA339Update Event_MountHA339U;//坐骑魂石的刷新 public Dictionary<int, HorseSkillClass> GetMountSkillAndItem = new Dictionary<int, HorseSkillClass>();//1技能TypeID,所需的消耗物品ID public delegate void OnMountAlteration(string NowMount);//当前坐骑变更 public delegate void OnMountAlteration();//当前坐骑变更 public static event OnMountAlteration Event_MountAlteration; public static event Action OnMountUieffectUpLv;//关于坐骑升级时特效播放时的调用 public Dictionary<int, HorseClass> _DicHorse = new Dictionary<int, HorseClass>();//当前的坐骑字典 public Dictionary<int, int> _DicMountItem = new Dictionary<int, int>();//坐骑魂石的字典 public Dictionary<int, Redpoint> mountRedpoint = new Dictionary<int, Redpoint>();//坐骑外观切换红点 public Dictionary<int, Redpoint> DeblockingRedPoint = new Dictionary<int, Redpoint>();//激活按钮红点 public Dictionary<int, Redpoint> ASingleFeedRedPoint = new Dictionary<int, Redpoint>();//单次喂养红点 private List<HorseConfig> SortMount = new List<HorseConfig>();//用于红点排序 public int MountStoneItemId = 0; public bool IsOk = false; public List<int> ListEffectSkill = new List<int>(); private int HorseDanExp = 0;//坐骑丹经验 private int autoActiveHorseId = 0; private bool hasSendAutoActive = false; public int horseUpItemId { get; private set; } public int horseUpItemCost { get; private set; } public int HorseDanExp = 0;//坐骑丹经验 public int[][] horseDanAttr; public int[] HorseAttrSort; //坐骑属性面板排序,属性和添加属性为0则不显示 public int HorseTrainMoreCnt; public int horseUpItemCost = 10; PackModel _playerPack; PackModel playerPack { get { return _playerPack ?? (_playerPack = ModelCenter.Instance.GetModel<PackModel>()); } @@ -66,7 +67,7 @@ public bool Wait = true;//等待回包(使用坐骑丹) public static Action<int, bool> MultipleEvent; public static event Action PlayerLoginOKData; public event Action onHorseInfoUpdate; private Dictionary<int, int> DicDefaultMount = new Dictionary<int, int>(); Dictionary<SkillEffectGroup, int> integrationSkills = new Dictionary<SkillEffectGroup, int>(); @@ -76,9 +77,9 @@ public override void Init() { GetRankHorseIDs(); ToAddSorting(); playerPack.refreshItemCountEvent += OnItemRefreshEvent; MountWin.RedPointMountDan += RedPointMountDan; FuncOpen.Instance.OnFuncStateChangeEvent += OnFuncStateChangeEvent; MountSkillAndItem(); MountNumberPreservation(); @@ -94,16 +95,14 @@ var funcConfig = FuncConfigConfig.Get("HorseUpItem"); horseUpItemId = int.Parse(funcConfig.Numerical1); HorseDanExp = int.Parse(funcConfig.Numerical2); horseUpItemCost = 10; var shopTypes = new int[] { 2, 3 }; for (int i = 0; i < shopTypes.Length; i++) horseDanAttr = JsonMapper.ToObject<int[][]>(funcConfig.Numerical3); HorseAttrSort = JsonMapper.ToObject<int[]>(funcConfig.Numerical4); //坐骑面板属性排序 HorseTrainMoreCnt = int.Parse(funcConfig.Numerical5); var shopConfig = StoreConfig.GetStoreCfg(horseUpItemId, 1, 1); if (shopConfig != null) { var shopConfig = StoreConfig.GetStoreCfg(horseUpItemId, 1, shopTypes[i]); if (shopConfig != null) { horseUpItemCost = shopConfig.MoneyNumber; break; } horseUpItemCost = shopConfig.MoneyNumber; } funcConfig = FuncConfigConfig.Get("PetHorseSkillIntegration"); @@ -145,7 +144,6 @@ public override void UnInit() { MountWin.RedPointMountDan -= RedPointMountDan; playerPack.refreshItemCountEvent -= OnItemRefreshEvent; FuncOpen.Instance.OnFuncStateChangeEvent -= OnFuncStateChangeEvent; } @@ -161,6 +159,7 @@ _DicHorse.Clear(); HorseRidingBool = false; Wait = true; MountHA301MorePack = false; } public void OnPlayerLoginOk() @@ -178,6 +177,7 @@ { PlayerLoginOKData(); } NextTrainCount = GetTrainCount(); } private DateTime dateTimeA; @@ -199,64 +199,53 @@ List<HorseConfig> Hconfigs = new List<HorseConfig>(); List<HorseUpConfig> Uconfigs = new List<HorseUpConfig>(); int RedPoint_HuaxingID = MainRedDot.RedPoint_MountPackKey * 10; //化形红点 int RedPoint_DanID = MainRedDot.RedPoint_MountPackKey * 10 + 1; //可用坐骑丹红点 Redpoint RedPoint_Dan; private void MountNumberPreservation()//用来对坐骑个数的保存 { if (mountRedpoint.Count != 0) return; // var configs = HorseConfig.GetValues(); if (Hconfigs.Count <= 0) { Hconfigs = HorseConfig.GetValues(); } Redpoint RedPoint_Huaxing = new Redpoint(MainRedDot.RedPoint_MountPackKey, RedPoint_HuaxingID); RedPoint_Dan = new Redpoint(MainRedDot.RedPoint_MountPackKey, RedPoint_DanID); DeblockingRedPoint.Clear(); var skinConfigs = HorseSkinPlusConfig.GetValues(); int type = 0; foreach (var config in Hconfigs) foreach (var config in skinConfigs) { if (!mountRedpoint.ContainsKey(config.HorseID)) { type += 1; int mountID = config.HorseID; int RedPoint_Mountkey = MainRedDot.RedPoint_MountPackKey * 10 + mountID; Redpoint redPointMountStare = new Redpoint(Redpoint_key1, RedPoint_Mountkey); mountRedpoint.Add(mountID, redPointMountStare); type += 1; int RedPoint_Mountkey1 = RedPoint_Mountkey * 10 + type; Redpoint redPointMountStare1 = new Redpoint(RedPoint_Mountkey, RedPoint_Mountkey1); DeblockingRedPoint.Add(mountID, redPointMountStare1); int RedPoint_Mountkey2 = RedPoint_Mountkey1 * 10 + type; Redpoint redPointMountStare2 = new Redpoint(RedPoint_Mountkey, RedPoint_Mountkey2); ASingleFeedRedPoint.Add(mountID, redPointMountStare2); } int RedPoint_Mountkey1 = RedPoint_HuaxingID * 10 + type; Redpoint redPointMountStare1 = new Redpoint(RedPoint_HuaxingID, RedPoint_Mountkey1); DeblockingRedPoint.Add(config.HorseID, redPointMountStare1); } } private void MountChangeRedPoint()//坐骑激活红点 { foreach (var key in DeblockingRedPoint.Keys) { DeblockingRedPoint[key].state = RedPointState.None; } if (!FuncOpen.Instance.IsFuncOpen(8)) { return; } if (Hconfigs.Count <= 0) { Hconfigs = HorseConfig.GetValues(); } // var configs = HorseConfig.GetValues(); foreach (var config in Hconfigs) { int unlockItemID = config.UnlockItemID; int itemCount = playerPack.GetItemCountByID(PackType.Item, unlockItemID); int unlockItemCnt = config.UnlockItemCnt; if (itemCount >= unlockItemCnt && !_DicHorse.ContainsKey(config.HorseID)) { DeblockingRedPoint[config.HorseID].state = RedPointState.Simple; } } return; //foreach (var key in DeblockingRedPoint.Keys) //{ // DeblockingRedPoint[key].state = RedPointState.None; //} //if (!FuncOpen.Instance.IsFuncOpen(8)) //{ // return; //} //if (Hconfigs.Count <= 0) //{ // Hconfigs = HorseConfig.GetValues(); //} //// var configs = HorseConfig.GetValues(); //foreach (var config in Hconfigs) //{ // int unlockItemID = config.UnlockItemID; // int itemCount = playerPack.GetItemCountByID(PackType.Item, unlockItemID); // int unlockItemCnt = config.UnlockItemCnt; // if (itemCount >= unlockItemCnt && !_DicHorse.ContainsKey(config.HorseID)) // { // DeblockingRedPoint[config.HorseID].state = RedPointState.Simple; // } //} } void MountSkillAndItem()//获取坐骑技能 @@ -295,11 +284,12 @@ } } } } private const int Redpoint_key1 = 1050101; public Redpoint redPointStre1 = new Redpoint(MainRedDot.RedPoint_MountPackKey, Redpoint_key1);//坐骑外观 private const int Redpoint_key2 = 1050102; public Redpoint redPointStre2 = new Redpoint(MainRedDot.RedPoint_MountPackKey, Redpoint_key2);//坐骑兽魂 } //private const int Redpoint_key1 = 1050101; //public Redpoint redPointStre1 = new Redpoint(MainRedDot.RedPoint_MountPackKey, Redpoint_key1);//坐骑外观 //private const int Redpoint_key2 = 1050102; //public Redpoint redPointStre2 = new Redpoint(MainRedDot.RedPoint_MountPackKey, Redpoint_key2);//坐骑兽魂 public event Action HorseExpItemRefresh; private void OnItemRefreshEvent(PackType type, int index, int id) { if (type == PackType.Equip) @@ -309,12 +299,14 @@ if (type == PackType.Item) { if (_DicMountItem.ContainsKey(id)) { MountStoneRed(); } MountChangeRedPoint(); MountDanRed(); if (id == horseUpItemId) { MountDanRed(); NextTrainCount = GetTrainCount(); if (HorseExpItemRefresh != null) HorseExpItemRefresh(); } var config = HorseConfig.Get(autoActiveHorseId); if (config != null && id == config.UnlockItemID) @@ -354,35 +346,32 @@ private void MountStoneRed()//坐骑魂石红点 { redPointStre2.state = RedPointState.None; if (!FuncOpen.Instance.IsFuncOpen(8)) return; int type = 0; foreach (var key in _DicMountItem.Keys) { var AttrFruit = AttrFruitConfig.Get(key); if (AttrFruit == null) { continue; } if (_DicMountItem[key] >= AttrFruit.basicUseLimit) { continue; } type += playerPack.GetItemCountByID(PackType.Item, key); } if (type > 0) { redPointStre2.state = RedPointState.Simple; return; } //暂时关闭 return; //redPointStre2.state = RedPointState.None; //if (!FuncOpen.Instance.IsFuncOpen(8)) // return; //int type = 0; //foreach (var key in _DicMountItem.Keys) //{ // var AttrFruit = AttrFruitConfig.Get(key); // if (AttrFruit == null) // { // continue; // } // if (_DicMountItem[key] >= AttrFruit.basicUseLimit) // { // continue; // } // type += playerPack.GetItemCountByID(PackType.Item, key); //} //if (type > 0) //{ // redPointStre2.state = RedPointState.Simple; // return; //} } private void RedPointMountDan() { MountDanRed(); } private void ToAddSorting() { @@ -404,122 +393,17 @@ } private void MountDanRed()//关于坐骑丹红点 { foreach (var key in ASingleFeedRedPoint.Keys) { ASingleFeedRedPoint[key].state = RedPointState.None; } if (!FuncOpen.Instance.IsFuncOpen(8) || _DicHorse.Count == 0) if (!FuncOpen.Instance.IsFuncOpen(8)) { return; } List<int> IntList = new List<int>(); FuncConfigConfig _tagfun = FuncConfigConfig.Get("HorseUpItem"); ItemConfig _tagchine = ItemConfig.Get(int.Parse(_tagfun.Numerical1)); int number = playerPack.GetItemCountByID(PackType.Item, _tagchine.ID); for (int i = 0; i < SortMount.Count; i++) { int horseID = SortMount[i].HorseID; int MaxLv = HorseConfig.Get(horseID).MaxLV; if (_DicHorse.ContainsKey(horseID) && _DicHorse[horseID].Lv < MaxLv) { int _NeedExp = HorseUpConfig.GetHorseIDAndLV(horseID, (_DicHorse[horseID].Lv)).NeedExp; int NeedExp = _NeedExp - _DicHorse[horseID].Exp; int NeedNumber = Mathf.CeilToInt((float)NeedExp / HorseDanExp); if (number >= NeedNumber) { IntList.Add(horseID); } } } foreach (var key in _DicHorse.Keys)//因为有成就任务限制所有 第一只坐骑红点逻辑特殊写 { if (DicDefaultMount.ContainsKey(key) && DicDefaultMount[key] > _DicHorse[key].Lv && number > 0 && ASingleFeedRedPoint.ContainsKey(key)) { ASingleFeedRedPoint[key].state = RedPointState.Simple; return; } } int GetMinLV = 100; int GetMountID = 0; List<int> IntListSkill = new List<int>(); for (int j = 0; j < SortMount.Count; j++)//选取出可升级坐骑等级最低且有未激活技能的坐骑切经验最少 { int Id = SortMount[j].HorseID; int GetHorseMaxLv = GetMountSkillMaxLV(Id); if (IntList.Contains(Id) && _DicHorse.ContainsKey(Id)) { if (_DicHorse[Id].Lv < GetHorseMaxLv) { IntListSkill.Add(Id); } } } int SkillHorseId = GetRedPointMountID(IntListSkill); if (SkillHorseId != 0 && ASingleFeedRedPoint.ContainsKey(SkillHorseId)) { ASingleFeedRedPoint[SkillHorseId].state = RedPointState.Simple; return; } int number = playerPack.GetItemCountByID(PackType.Item, horseUpItemId); RedPoint_Dan.state = number == 0 ? RedPointState.None : RedPointState.Simple; for (int j = 0; j < SortMount.Count; j++)//选取出可升级坐骑等级最低 { int Id = SortMount[j].HorseID; if (IntList.Contains(Id) && _DicHorse.ContainsKey(Id)) { if (_DicHorse[Id].Lv < GetMinLV) { GetMinLV = _DicHorse[Id].Lv; GetMountID = Id; } } } if (GetMountID != 0 && ASingleFeedRedPoint.ContainsKey(GetMountID)) { ASingleFeedRedPoint[GetMountID].state = RedPointState.Simple; return; } } public int GetMinExpMount() { foreach (var key in ASingleFeedRedPoint.Keys)//当存在驯养红点时选中当有红点的那只 { if (ASingleFeedRedPoint[key].state == RedPointState.Simple) { return key; } } int GetMountID = 0; int MountLV = 999; List<int> IntListSkill = new List<int>(); foreach (var key in _DicHorse.Keys) { var mountConfig = HorseConfig.Get(key); if (_DicHorse[key].Lv < mountConfig.MaxLV) { IntListSkill.Add(key); } } int SkillHorseId = GetRedPointMountID(IntListSkill); if (SkillHorseId != 0) { GetMountID = SkillHorseId; return GetMountID; } foreach (var key in _DicHorse.Keys)//无红点时跳转选中最低阶数且未满级 { var mountConfig = HorseConfig.Get(key); if (_DicHorse[key].Lv < MountLV && _DicHorse[key].Lv < mountConfig.MaxLV) { GetMountID = key; MountLV = _DicHorse[key].Lv; } } return GetMountID; } private int GetRedPointMountID(List<int> MountList) { @@ -611,71 +495,39 @@ _HorseIDNow = config.HorseID.ToString(); if (Event_MountAlteration != null && IsOk) { Event_MountAlteration(_HorseIDNow); Event_MountAlteration(); } } } } MountDanRed(); MountStoneRed(); } public int HorseLV = 1; public int HorseEatCount = 0; //乘以每个丹的经验就是当前经验 public uint SkinPlusState = 0; public event Action onHorseInfoUpdate; public event Action onHorseLVUP; public int NextTrainCount = 0; public bool MountHA301MorePack = false; public void MountHA301(HA301_tagTrainHorseData info)//已拥有的坐骑(获得与刷新) { for (int i = 0; i < info.Num; i++) { if (_DicHorse.ContainsKey((int)info.InfoList[i].HorseID)) { if ((int)info.InfoList[i].LV > _DicHorse[(int)info.InfoList[i].HorseID].Lv) { if (OnMountUieffectUpLv != null && IsOk) { OnMountUieffectUpLv(); } } _DicHorse[(int)info.InfoList[i].HorseID].Lv = (int)info.InfoList[i].LV;//坐骑等级 _DicHorse[(int)info.InfoList[i].HorseID].Exp = (int)info.InfoList[i].Exp;//坐骑经验 if (Event_MountHA301U != null && IsOk) { Event_MountHA301U((int)info.InfoList[i].HorseID); } } else { HorseClass _horseClass = new HorseClass(); _horseClass.Lv = (int)info.InfoList[i].LV;//坐骑等级 _horseClass.Exp = (int)info.InfoList[i].Exp;//坐骑经验 _DicHorse.Add((int)info.InfoList[i].HorseID, _horseClass); if (Event_MountHA301A != null && IsOk) { Event_MountHA301A((int)info.InfoList[i].HorseID); } if (IsOk && (int)info.InfoList[i].HorseID == autoActiveHorseId) { var config = HorseConfig.Get(autoActiveHorseId); if (_horseClass.Lv >= config.UseNeedRank) { AppearanceSwitch(autoActiveHorseId); DTC0428_tagPlayerRideHorse.Send_tagPlayerRideHorse(true); } } } } if (onHorseInfoUpdate != null && IsOk) if (MountHA301MorePack && info.LV > HorseLV) { onHorseInfoUpdate(); if (onHorseLVUP != null) onHorseLVUP(); } HorseLV = info.LV; HorseEatCount = info.EatItemCount; SkinPlusState = info.SkinPlusState; MountStoneRed(); MountChangeRedPoint(); MountDanRed(); RefreshHorseAllAttr(); if (onHorseInfoUpdate != null) onHorseInfoUpdate(); MountHA301MorePack = true; } public void MountHA339(HA339_tagMCAttrFruitEatCntList info)//坐骑魂石 @@ -809,18 +661,19 @@ return true; } } public void AppearanceSwitch(int HorseID)//坐骑外观切换 //ChooseType; // 1-按等阶,2-按幻化 //LVID; // 阶等级或幻化ID public void AppearanceSwitch(byte lvID, byte ChooseType)//坐骑外观切换 { CA502_tagPlayerChooseHorse _tagCA502 = new CA502_tagPlayerChooseHorse(); _tagCA502.Index = (uint)HorseID; _tagCA502.LVID = lvID; _tagCA502.ChooseType = ChooseType; GameNetSystem.Instance.SendInfo(_tagCA502); } public void MountDanUse(int HorseID, int Number, bool IsAutoBuy = false)//是否自动购买 public void MountDanUse(int Number, bool IsAutoBuy = false)//是否自动购买 { CA527_tagCMHorseUp _tagC527 = new CA527_tagCMHorseUp();//向服务端发包坐骑经验单 _tagC527.HorseID = (uint)HorseID; _tagC527.UseItemCnt = (byte)Number; if (IsAutoBuy) { @@ -969,4 +822,152 @@ { return _DicHorse.ContainsKey(horseId); } private Dictionary<int, int> HorseAllAttr = new Dictionary<int, int>(); private int activeAllSkinAddPower = 0; //额外增加的坐骑皮肤战力 //坐骑属性:丹经验属性,升阶属性,皮肤属性 public Dictionary<int, int> RefreshHorseAllAttr() { HorseAllAttr.Clear(); activeAllSkinAddPower = 0; int allHorseEatCount = HorseEatCount; //丹经验属性 for (int i = 1; i < HorseLV; i++) { var config = HorseLVUpConfig.Get(i); allHorseEatCount += config.NeedEatCount; } foreach (var attrPair in horseDanAttr) { HorseAllAttr[attrPair[0]] = attrPair[1] * allHorseEatCount; } //升阶属性 for (int k = 1; k <= HorseLV; k++) { var horseLVConfig = HorseLVUpConfig.Get(k); for (int i = 0; i < horseLVConfig.LVAttrType.Length; i++) { if (!HorseAllAttr.ContainsKey(horseLVConfig.LVAttrType[i])) { HorseAllAttr[horseLVConfig.LVAttrType[i]] = 0; } HorseAllAttr[horseLVConfig.LVAttrType[i]] = HorseAllAttr[horseLVConfig.LVAttrType[i]] + horseLVConfig.LVAttrValue[i]; } } //皮肤属性 foreach (var byteID in HorseSkinPlusConfig.GetKeys()) { if (((int)Math.Pow(2, int.Parse(byteID) - 1) & SkinPlusState) <= 0) //未激活皮肤 continue; var config = HorseSkinPlusConfig.Get(byteID); for (int i = 0; i < config.AttrType.Length; i++) { if (!HorseAllAttr.ContainsKey(config.AttrType[i])) { HorseAllAttr[config.AttrType[i]] = 0; } HorseAllAttr[config.AttrType[i]] = HorseAllAttr[config.AttrType[i]] + config.AttrValue[i]; } activeAllSkinAddPower += config.InitFightPower; } return HorseAllAttr; } public Dictionary<int, int> GetHorseAllAttr() { if (HorseAllAttr.Keys.Count == 0) RefreshHorseAllAttr(); return HorseAllAttr; } //UIHelper.GetFightPower(FightDic) public int GetHorseFightPower() { var allAttrDict = GetHorseAllAttr(); return UIHelper.GetFightPower(allAttrDict) + activeAllSkinAddPower; } //默认驯养一颗,当数量大于X 全部驯养(不超过2阶) //MountWin114 MountPanel_UnlockBtn_2 MountPanel_AutoTrainTxt_1 public int GetTrainCount() { int trainCount = 1; var config = HorseLVUpConfig.Get(HorseLV); if (config.NeedEatCount == 0) { //已满级 return 0; } int number = playerPack.GetItemCountByID(PackType.Item, horseUpItemId); if (number > HorseTrainMoreCnt) { trainCount = number; if (HorseEatCount + number >= config.NeedEatCount) { //有升阶的情况,最多一阶 var Nextconfig = HorseLVUpConfig.Get(HorseLV + 1); if (Nextconfig.NeedEatCount == 0) { //升级后满级 trainCount = config.NeedEatCount - HorseEatCount; } else if (number >= (config.NeedEatCount - HorseEatCount + Nextconfig.NeedEatCount)) { //超过2阶的情况 trainCount = config.NeedEatCount - HorseEatCount + Nextconfig.NeedEatCount - 1; } } } return trainCount; } public Dictionary<int, int> GetNextTrainAttr() { Dictionary<int, int> nextTrainAttr = new Dictionary<int, int>(); if (NextTrainCount == 0) { return nextTrainAttr; } foreach (var attrPair in horseDanAttr) { nextTrainAttr[attrPair[0]] = attrPair[1] * NextTrainCount; } var config = HorseLVUpConfig.Get(HorseLV); if (HorseEatCount + NextTrainCount >= config.NeedEatCount) { //有升阶的情况 var Nextconfig = HorseLVUpConfig.Get(HorseLV + 1); for (int i = 0; i < Nextconfig.LVAttrType.Length; i++) { if (!nextTrainAttr.ContainsKey(Nextconfig.LVAttrType[i])) { nextTrainAttr[Nextconfig.LVAttrType[i]] = 0; } nextTrainAttr[Nextconfig.LVAttrType[i]] = nextTrainAttr[Nextconfig.LVAttrType[i]] + Nextconfig.LVAttrValue[i]; } } return nextTrainAttr; } //获取升阶的所有坐骑ID public List<int> RankHorseIDList = new List<int>(); private void GetRankHorseIDs() { RankHorseIDList.Clear(); foreach (var horseConfig in HorseLVUpConfig.GetValues()) { RankHorseIDList.Add(horseConfig.HorseID); } } } System/Mount/MountPanelAssignment.cs
@@ -15,625 +15,6 @@ public class MountPanelAssignment : MonoBehaviour { [SerializeField] RawImage m_MountRawImg; [SerializeField] Text m_HpTxt;//当前生命 [SerializeField] Text m_AtkTxt;//当前攻击 [SerializeField] Text m_SpeedTxt;//当前速度 [SerializeField] Text m_PutTxt;//战斗力 [SerializeField] RedpointBehaviour m_RedPointJH;//激活红点 [SerializeField] UIEffect m_Uieffect3;//经验条特效 [SerializeField] Transform GroupSkill; [SerializeField] FunctionUnlockFlyObjectTarget[] flyObjectTargets; [SerializeField] GameObject m_YiJieSuo;//解锁面板 [SerializeField] GameObject m_BottomOperate;//关于经验条 [SerializeField] Text m_MountLVNum; [SerializeField] Text m_ExpNum; [SerializeField] IntensifySmoothSlider m_IntensifySmoothSlider; [SerializeField] GameObject m_WeiJieSuo;//未解锁面板 [SerializeField] Button m_NotUnlockButton; [SerializeField] Image m_NotUnlockImageBG; [SerializeField] Image m_ImmageBG;//背景框品质 [SerializeField] Text m_NotUnlockTxt; [SerializeField] GameObject m_ManJie;//满阶面板 [SerializeField] GameObject m_Deblocking;//激活按钮 [SerializeField] GameObject m_TrainButtonGroup;//已激活按钮组 [SerializeField] GameObject m_TrainBtn_1;//一倍驯养 [SerializeField] RedpointBehaviour m_Redpoint_1; [SerializeField] Image IconImage1; [SerializeField] Text m_Text1; [Header("控制绳子")] [SerializeField] GameObject Skillimage1; [SerializeField] GameObject Skillimage2; [SerializeField] GameObject Skillimage3; [SerializeField] GameObject Skillimage4; [SerializeField] GameObject Skillimage5; private float timePlay = 0;//坐骑动作播放时间 List<GameObject> Skillimage = new List<GameObject>(); [SerializeField] ScrollerController allPetSkillCtrl;//所有的技能 private int mount_ID = 0;//用来标记坐骑的ID MountModel m_MountModel; MountModel mountModel { get { return m_MountModel ?? (m_MountModel = ModelCenter.Instance.GetModel<MountModel>()); } } PackModel _playerPack; PackModel playerPack { get { return _playerPack ?? (_playerPack = ModelCenter.Instance.GetModel<PackModel>()); } } RidingAndPetActivationModel ridingModel { get { return ModelCenter.Instance.GetModel<RidingAndPetActivationModel>(); } } private int pitchOnHorseID = 0; private void Start() { m_NotUnlockButton.AddListener(OnClickNotUnlockButton); } private void OnEnable() { MountModel.Event_MountHA301U += OnMountHA301Update; allPetSkillCtrl.OnRefreshCell += RefreshAllMountSkillCell; CreateAllMountSkill(); } private void OnDisable() { mount_ID = 0; MountModel.Event_MountHA301U -= OnMountHA301Update; allPetSkillCtrl.OnRefreshCell -= RefreshAllMountSkillCell; m_MountRawImg.gameObject.SetActive(false); } private void LateUpdate() { timePlay += Time.deltaTime; if (timePlay >= GeneralDefine.PetDanceInterval) { timePlay = 0; if (UI3DModelExhibition.Instance.NpcModelHorse != null) { var animator = UI3DModelExhibition.Instance.NpcModelHorse.GetComponent<Animator>(); if (animator != null) { StartCoroutine("FrameDelay"); } } } } IEnumerator FrameDelay() { yield return null; if (UI3DModelExhibition.Instance.NpcModelHorse != null) { var animator = UI3DModelExhibition.Instance.NpcModelHorse.GetComponent<Animator>(); animator.Play(GAStaticDefine.State_Dance); } } private void OnMountHA301Update(int _HorseID) { m_Uieffect3.Play(); SoundPlayer.Instance.PlayUIAudio(19); ToAddSorting(); allPetSkillCtrl.m_Scorller.RefreshActiveCellViews(); if (pitchOnHorseID != 0 && pitchOnHorseID!= _HorseID) { PanelAssignment(pitchOnHorseID); } else { PanelAssignment(_HorseID); } } private void OnClickDeblockingButton() { FuncConfigConfig _tagfun = FuncConfigConfig.Get("HorseUpItem"); ItemConfig _tagchine = ItemConfig.Get(int.Parse(_tagfun.Numerical1)); ItemTipUtility.Show(_tagchine.ID); } private void OnClickNotUnlockButton() { var _Horse = HorseConfig.Get(pitchOnHorseID); var _item = ItemConfig.Get(_Horse.UnlockItemID); ItemTipUtility.Show(_item.ID); } public void PanelAssignment(int mountID) { SetSkillimage(); pitchOnHorseID = mountID; MountAttribute(mountID); PanelClassify(mountID); ShowHorse(mountID); MountSkill(mountID); TheMountButton(); if (WindowCenter.Instance.Get<MountWin>().AchievementGuideEffect2 != null) { AchievementGuideEffectPool.Recycle(WindowCenter.Instance.Get<MountWin>().AchievementGuideEffect2); } } private void ShowHorse(int HorseID) { if (!m_MountRawImg.gameObject.activeSelf) { m_MountRawImg.gameObject.SetActive(true); } if (HorseID != mount_ID) { HorseConfig _model = HorseConfig.Get(HorseID); UI3DModelExhibition.Instance.ShowHourse(_model.Model, m_MountRawImg); mount_ID = HorseID; if (UI3DModelExhibition.Instance.NpcModelHorse != null) { var animator = UI3DModelExhibition.Instance.NpcModelHorse.GetComponent<Animator>(); if (animator != null) { if (this.gameObject.activeInHierarchy) { StartCoroutine("FrameDelay"); } else { animator.Play(GAStaticDefine.State_Dance); } } } } } private void MountAttribute(int mountID)//坐骑属性面板赋值 { //Dictionary<int, int> dicStone = Bonuses(); int _HPP = 0;//生命 int _AttT = 0;//攻击 int _SpeE = 0;//速度 Dictionary<int, float> addAttrDict510 = ridingModel.GetAllMountProperty(); Dictionary<int, float> addAttrDict511 = ridingModel.GetAllMountPropertyQuality(); if (mountModel._DicHorse.Count == 0) { m_HpTxt.text = (_HPP /*+ dicStone[6]*/).ToString(); m_AtkTxt.text = (_AttT /*+ dicStone[7]*/).ToString(); m_SpeedTxt.text = _SpeE.ToString(); m_PutTxt.text = "0"; } else { foreach (int key in mountModel._DicHorse.Keys) { HorseUpConfig tagMode = HorseUpConfig.GetHorseIDAndLV(key, mountModel._DicHorse[key].Lv); int[] intAttrValue = tagMode.AttrValue; if (intAttrValue.Length != 0) { _HPP += intAttrValue[0]; _AttT += intAttrValue[1]; if (intAttrValue[2] > _SpeE) { _SpeE = intAttrValue[2]; } } } float addHp = 0; float addAtk = 0; if (addAttrDict510.ContainsKey((int)PropertyType.HP)) { addHp += addAttrDict510[(int)PropertyType.HP]; } if (addAttrDict511.ContainsKey((int)PropertyType.HP)) { addHp += addAttrDict511[(int)PropertyType.HP]; } if (addAttrDict510.ContainsKey((int)PropertyType.ATK)) { addAtk += addAttrDict510[(int)PropertyType.ATK]; } if (addAttrDict511.ContainsKey((int)PropertyType.ATK)) { addAtk += addAttrDict511[(int)PropertyType.ATK]; } m_HpTxt.text = ((int)(_HPP /*+ dicStone[6]*/ + addHp)).ToString(); m_AtkTxt.text = ((int)(_AttT /*+ dicStone[7]*/ + addAtk)).ToString(); m_SpeedTxt.text = _SpeE.ToString(); int fightNumberA = 0; foreach (int key in mountModel.GetMountSkillAndItem.Keys) { fightNumberA += fightNumber(key); } int initialForce = 0; foreach (var key in mountModel._DicHorse.Keys) { HorseConfig horseConfig = HorseConfig.Get(key); initialForce += horseConfig.InitFightPower; } Dictionary<int, int> AddPowerDic = new Dictionary<int, int>(); AddPowerDic.Clear(); AddPowerDic.Add(6, (_HPP /*+ dicStone[6]*/)); AddPowerDic.Add(7, (_AttT /*+ dicStone[7]*/)); int AddPower = UIHelper.GetFightPower(AddPowerDic); m_PutTxt.text = (fightNumberA + AddPower + initialForce).ToString(); } } Dictionary<int, int> Bonuses()//属性加成 { Dictionary<int, int> dic = new Dictionary<int, int>(); dic.Clear(); dic.Add(6, 0);//生命 dic.Add(7, 0);//攻击 dic.Add(8, 0);//防御 foreach (int key in mountModel._DicMountItem.Keys) { if (mountModel._DicMountItem[key] != 0) { ItemConfig itemModel = ItemConfig.Get(key); if (dic.ContainsKey(itemModel.Effect1)) { dic[itemModel.Effect1] += itemModel.EffectValueA1 * mountModel._DicMountItem[key]; } if (dic.ContainsKey(itemModel.Effect2)) { dic[itemModel.Effect2] += itemModel.EffectValueA2 * mountModel._DicMountItem[key]; } if (dic.ContainsKey(itemModel.Effect3)) { dic[itemModel.Effect3] += itemModel.EffectValueA3 * mountModel._DicMountItem[key]; } if (dic.ContainsKey(itemModel.Effect4)) { dic[itemModel.Effect4] += itemModel.EffectValueA4 * mountModel._DicMountItem[key]; } if (dic.ContainsKey(itemModel.Effect5)) { dic[itemModel.Effect5] += itemModel.EffectValueA5 * mountModel._DicMountItem[key]; } } } return dic; } private void PanelClassify(int mountID)//面板分类 { if (WindowCenter.Instance.Get<MountWin>().AchievementGuideEffect1 != null) { AchievementGuideEffectPool.Recycle(WindowCenter.Instance.Get<MountWin>().AchievementGuideEffect1); } if (mountModel._DicHorse.ContainsKey(mountID)) { var configHorse = HorseConfig.Get(mountID); if (mountModel._DicHorse[mountID].Lv >= configHorse.MaxLV) { m_ManJie.SetActive(true); m_YiJieSuo.SetActive(false); m_WeiJieSuo.SetActive(false); m_Deblocking.SetActive(false); m_TrainButtonGroup.SetActive(false); //满阶 } else { IsExpSlider(mountID); m_YiJieSuo.SetActive(true); m_WeiJieSuo.SetActive(false); m_ManJie.SetActive(false); m_Deblocking.SetActive(false); m_TrainButtonGroup.SetActive(true); m_Redpoint_1.redpointId = mountModel.ASingleFeedRedPoint[mountID].id; //为满街 } } else { m_RedPointJH.redpointId = mountModel.DeblockingRedPoint[mountID].id; m_WeiJieSuo.SetActive(true); m_ManJie.SetActive(false); m_YiJieSuo.SetActive(false); m_Deblocking.SetActive(true); m_TrainButtonGroup.SetActive(false); HorseConfig _Horse = HorseConfig.Get(mountID); ItemConfig _item = ItemConfig.Get(_Horse.UnlockItemID); m_NotUnlockImageBG.SetSprite(_item.IconKey); m_ImmageBG.SetItemBackGround(_item.ItemColor); int UnlockItemID = HorseConfig.Get(mountID).UnlockItemID; int MaterialNumber = playerPack.GetItemCountByID(PackType.Item, UnlockItemID);//获取背包解锁材料的数量 int UnlockItemCnt = HorseConfig.Get(mountID).UnlockItemCnt; if (MaterialNumber >= UnlockItemCnt) { m_NotUnlockTxt.text = "<color=#fffaf0>" + MaterialNumber + "/" + UnlockItemCnt + "</color>"; } else { m_NotUnlockTxt.text = "<color=#ff2828>" + MaterialNumber + "</color>" + "<color=#fffaf0>/" + UnlockItemCnt + "</color>"; } } } private void IsExpSlider(int mountID) { if (mountModel._DicHorse.ContainsKey(mountID)) { m_BottomOperate.SetActive(true); int horseMaxLv = HorseConfig.Get(mountID).MaxLV; if (mountModel._DicHorse[mountID].Lv >= horseMaxLv) { m_ExpNum.text = Language.Get("Z1029"); m_IntensifySmoothSlider.stage = mountModel._DicHorse[mountID].Lv; m_IntensifySmoothSlider.value = 1f; m_IntensifySmoothSlider.delay = 0f; m_IntensifySmoothSlider.ResetStage(); } else { int exp = mountModel._DicHorse[mountID].Exp; HorseUpConfig horseUp = HorseUpConfig.GetHorseIDAndLV(mountID, mountModel._DicHorse[mountID].Lv); int expMax = horseUp.NeedExp; m_ExpNum.text = exp + "/" + expMax; if (mount_ID != mountID) { m_IntensifySmoothSlider.stage = mountModel._DicHorse[mountID].Lv; m_IntensifySmoothSlider.delay = 0f; m_IntensifySmoothSlider.ResetStage(); m_IntensifySmoothSlider.value = (float)Math.Round((float)exp / expMax, 2, MidpointRounding.AwayFromZero); } else { m_IntensifySmoothSlider.delay = 0.1f; m_IntensifySmoothSlider.stage = mountModel._DicHorse[mountID].Lv; m_IntensifySmoothSlider.value = (float)Math.Round((float)exp / expMax, 2, MidpointRounding.AwayFromZero); } } m_MountLVNum.text = mountModel._DicHorse[mountID].Lv + Language.Get("Z1041"); } else { m_BottomOperate.SetActive(false); } } List<HorseSkillClass> MountSkills = new List<HorseSkillClass>(); private void MountSkill(int HorseID)//关于坐骑技能 { MountSkills.Clear(); foreach (var key in mountModel.GetMountSkillAndItem.Keys) { if (mountModel.GetMountSkillAndItem[key].HorseID == HorseID) { MountSkills.Add(mountModel.GetMountSkillAndItem[key]); } } for (int i = 0; i < Skillimage.Count; i++) { Skillimage[i].SetActive(false); } for (int i = 0; i < GroupSkill.childCount; i++) { if (i < MountSkills.Count) { if (i < Skillimage.Count) { Skillimage[i].SetActive(true); } GroupSkill.GetChild(i).gameObject.SetActive(true); UIEffect uie = GroupSkill.GetChild(i).GetComponent<UIEffect>(); if (mountModel.ListEffectSkill.Contains(MountSkills[i].SkillID)) { if (!uie.IsPlaying) { uie.Play(); } } else { if (uie.IsPlaying) { uie.Stop(); } } SkillButtonPet mountSkill = GroupSkill.GetChild(i).gameObject.GetComponent<SkillButtonPet>(); int curMountLv = 0; if (mountModel._DicHorse.ContainsKey(MountSkills[i].HorseID)) { curMountLv = mountModel._DicHorse[MountSkills[i].HorseID].Lv; } if (curMountLv >= MountSkills[i].HorseLV) { mountSkill.SetModel(MountSkills[i].SkillID, MountSkills[i].HorseLV, true, HorseID, SkillType.MountSkill); } else { mountSkill.SetModel(MountSkills[i].SkillID, MountSkills[i].HorseLV, false, HorseID, SkillType.MountSkill); } if (i < flyObjectTargets.Length) { var flyObjectTarget = flyObjectTargets[i]; flyObjectTarget.IdList = new int[] { MountSkills[i].SkillID }; flyObjectTarget.Z_UnLockType = FunctionUnlockType.Skill; FunctionUnlockFlyObjectTargetCenter.Register(FunctionUnlockType.Skill, new int[] { MountSkills[i].SkillID }, flyObjectTarget); } } else { GroupSkill.GetChild(i).gameObject.SetActive(false); } } } List<int> displayTotalSkills = new List<int>(); private void CreateAllMountSkill()//所有坐骑技能 { displayTotalSkills.Clear(); var skills = mountModel.GetMountSkillAndItem.Keys; foreach (var id in skills) { var config = SkillConfig.Get(id); var skillId = 0; var effect = SkillConfig.GetSkillEffectValue(config); if (mountModel.TryGetIntegrationSkill(effect, out skillId)) { if (!displayTotalSkills.Contains(skillId)) { displayTotalSkills.Add(skillId); } continue; } displayTotalSkills.Add(id); } ToAddSorting(); allPetSkillCtrl.Refresh(); int line = Mathf.CeilToInt((float)displayTotalSkills.Count / 3); for (int i = 0; i < line; i++) { allPetSkillCtrl.AddCell(ScrollerDataType.Header, i); } allPetSkillCtrl.Restart(); } void ToAddSorting() { displayTotalSkills.Sort(Compare); } int Compare(int lhs, int rhs) { var lhs_unlock = mountModel.IsSkillUnlock(lhs); var rhs_unlock = mountModel.IsSkillUnlock(rhs); if (lhs_unlock != rhs_unlock) { return -lhs_unlock.CompareTo(rhs_unlock); } var lhs_config = SkillConfig.Get(lhs); var rhs_config = SkillConfig.Get(rhs); var lhs_Id = 0; var rhs_Id = 0; var lhs_effect = SkillConfig.GetSkillEffectValue(lhs_config); var rhs_effect = SkillConfig.GetSkillEffectValue(rhs_config); var lhs_integration = mountModel.TryGetIntegrationSkill(lhs_effect, out lhs_Id); var rhs_integration = mountModel.TryGetIntegrationSkill(rhs_effect, out rhs_Id); if (lhs_integration != rhs_integration) { return -lhs_integration.CompareTo(rhs_integration); } if (lhs_integration && rhs_integration) { if (lhs_config.Effect1 != rhs_config.Effect1) { return lhs_config.Effect1.CompareTo(rhs_config.Effect1); } return lhs.CompareTo(rhs); } var lhs_horseInfo = mountModel.GetMountSkillAndItem[lhs]; var rhs_horseInfo = mountModel.GetMountSkillAndItem[rhs]; if (lhs_horseInfo.HorseID != rhs_horseInfo.HorseID) { return lhs_horseInfo.HorseID.CompareTo(rhs_horseInfo.HorseID); } if (lhs_horseInfo.HorseLV != rhs_horseInfo.HorseLV) { return lhs_horseInfo.HorseLV.CompareTo(rhs_horseInfo.HorseLV); } return lhs.CompareTo(rhs); } private bool IsDeblocking(int SkillID)//是否解锁 { if (mountModel.GetMountSkillAndItem.ContainsKey(SkillID)) { int mountID = mountModel.GetMountSkillAndItem[SkillID].HorseID; int mountLv = mountModel.GetMountSkillAndItem[SkillID].HorseLV; if (mountModel._DicHorse.ContainsKey(mountID) && mountModel._DicHorse[mountID].Lv >= mountLv) { return true; } else { return false; } } else { return false; } } private void RefreshAllMountSkillCell(ScrollerDataType type, CellView cell) { int length = cell.transform.childCount; for (int i = 0; i < length; i++) { int index = cell.index * 3 + i; SkillButtonPet skillButton = cell.transform.GetChild(i).GetComponent<SkillButtonPet>(); if (index < displayTotalSkills.Count) { skillButton.gameObject.SetActive(true); var skillId = displayTotalSkills[index]; skillButton.SetModel(skillId, 0, mountModel.IsSkillUnlock(skillId), 0, SkillType.MountSkill, true); } else { skillButton.gameObject.SetActive(false); } } } private void TheMountButton() { FuncConfigConfig _tagfun = FuncConfigConfig.Get("HorseUpItem"); ItemConfig _tagchine = ItemConfig.Get(int.Parse(_tagfun.Numerical1)); IconImage1.SetSprite(_tagchine.IconKey); int mountDanNum = playerPack.GetItemCountByID(PackType.Item, int.Parse(_tagfun.Numerical1)); m_Text1.text = string.Format(Language.Get("Remaining_Z1"), UIHelper.ReplaceLargeNum(mountDanNum)); } private int fightNumber(int SkillID) { int fightNum = 0; if (IsDeblocking(SkillID)) { SkillConfig skillconfig = SkillConfig.Get(SkillID); fightNum = skillconfig.FightPower; } return fightNum; } private void SetSkillimage() { if (Skillimage.Count <= 0) { Skillimage.Clear(); Skillimage.Add(Skillimage1); Skillimage.Add(Skillimage2); Skillimage.Add(Skillimage3); Skillimage.Add(Skillimage4); Skillimage.Add(Skillimage5); } } } } System/Mount/MountWin.cs
@@ -16,78 +16,95 @@ public class MountWin : Window { [SerializeField] ScrollerController m_ScrollerController; [SerializeField] Button m_MountHunBtn;//坐骑兽魂按钮 [SerializeField] Button m_DeblockingBtton;//解锁按钮 [SerializeField] Button m_TrainBtn_1;//坐骑驯养1颗 [SerializeField] Button m_AutoTrainBtn;//自动驯养 [SerializeField] Button m_StopDomesticateBtn;//停止驯养 [SerializeField] Text HorseName; [SerializeField] Text HorseRank; [SerializeField] Button ChangeLookLib; [SerializeField] Text FightPower; [SerializeField] RawImage Hosrse3D; [SerializeField] Button UseModel; [SerializeField] Button CancelHorseClothe; //取消幻化并使用原阶模型 [SerializeField] Image HorseState; //骑乘中或未激活 [SerializeField] Text HorseStateText; //骑乘中或未激活 [SerializeField] Button Left; [SerializeField] Button Right; [SerializeField] MountPanelAssignment m_MountPanelAssignment; [SerializeField] UIEffect m_UieffectLVUp;//坐骑升级 [SerializeField] UIEffect m_UieffectLVUp;//坐骑升级特效 [SerializeField] PositionTween m_PositionTweenLVUp; [SerializeField] Text m_MountName;//被选中的坐骑名 [SerializeField] Button m_PropertyButton1;//坐骑属性按钮 [SerializeField] Button m_PropertyButton2;//坐骑属性按钮 List<HorseConfig> sortMountlist = new List<HorseConfig>();//坐骑顺序排列 public int signHorseID = 0;//用来标记坐骑ID private int mountDanId = 0;//消耗品坐骑丹ID private int mountDanExp = 0;//消耗品坐骑丹经验值 public bool Ismultiplicity = false;//是否多倍 public bool IsFairyJade = false; public AchievementGuideEffect AchievementGuideEffect1; public AchievementGuideEffect AchievementGuideEffect2; private int MountLv = 0; List<HorseSkillClass> MountSkills = new List<HorseSkillClass>(); [SerializeField] Vector3 m_Vector3 = new Vector3(1.8f, 1.8f, 1.8f); [SerializeField] List<Text> AttrNameList; [SerializeField] List<Text> AttrValueList; [SerializeField] List<Text> AttrAddValueList; private float LatencyTime = 0;//等待时间 [SerializeField] ItemCell UseItem; [SerializeField] Text UseItemName; [SerializeField] Button m_TrainBtn_1;//坐骑驯养1颗或多颗,消耗背包物品 [SerializeField] Text m_TrainText; [SerializeField] Button m_AutoTrainBtn;//一键升阶,会消耗仙玉 [SerializeField] UIEffect effectSlider; //进度条 [SerializeField] Text Exp; [SerializeField] IntensifySmoothSlider ExpSlider; #region Built-in PackModel _playerPack; PackModel playerPack { get { return _playerPack ?? (_playerPack = ModelCenter.Instance.GetModel<PackModel>()); } } MountModel m_MountModel; MountModel mountModel { get { return m_MountModel ?? (m_MountModel = ModelCenter.Instance.GetModel<MountModel>()); } } RidingAndPetActivationModel ridingAndPetActivationModel { get { return ModelCenter.Instance.GetModel<RidingAndPetActivationModel>(); } } PackModel playerPack { get { return ModelCenter.Instance.GetModel<PackModel>(); } } MountModel mountModel { get { return ModelCenter.Instance.GetModel<MountModel>(); } } public static event Action RedPointMountDan; static int StringToHash = Animator.StringToHash("Action"); int m_ShowHorseLV = 1; // 当前显示的马匹阶 protected override void BindController() { var config = FuncConfigConfig.Get("HorseUpItem"); mountDanId = int.Parse(config.Numerical1); mountDanExp = int.Parse(config.Numerical2); } protected override void AddListeners() { m_MountHunBtn.AddListener(OnClickMountHunButton); m_DeblockingBtton.AddListener(OnClickDeblockingBtton); m_TrainBtn_1.AddListener(OnClickTrainBtn); m_AutoTrainBtn.AddListener(OnClickAutoTrainBtn); m_StopDomesticateBtn.AddListener(OnClickStopDomesticateBtn); m_PropertyButton1.AddListener(OnClickPropertyButton); m_PropertyButton2.AddListener(OnClickPropertyButton); Left.SetListener(()=> { m_ShowHorseLV = m_ShowHorseLV - 1; ShowHorse(); }); Right.SetListener(() => { if (m_ShowHorseLV - mountModel.HorseLV > 2) { ScrollTip.ShowTip(Language.Get("HorseLVUPCanSee")); return; } m_ShowHorseLV = m_ShowHorseLV + 1; ShowHorse(); }); UseModel.SetListener(()=> { if (m_ShowHorseLV > mountModel.HorseLV) { ScrollTip.ShowTip(Language.Get("HorseLVUPCanSee")); return; } mountModel.AppearanceSwitch((byte)m_ShowHorseLV, 1); ScrollTip.ShowTip(Language.Get("Z1062")); //外观切换成功 }); CancelHorseClothe.SetListener(() => { mountModel.AppearanceSwitch((byte)m_ShowHorseLV, 1); ScrollTip.ShowTip(Language.Get("Z1062")); //外观切换成功 }); m_TrainBtn_1.SetListener(() => { mountModel.MountDanUse(mountModel.NextTrainCount); }); m_AutoTrainBtn.SetListener(()=> { //WindowCenter.Instance.Open<>(); }); } protected override void OnPreOpen() { mountModel.Wait = true; MountModel.Event_MountAlteration += OnMountAlteration; MountModel.Event_MountHA301U += OnMountUpdate; MountModel.Event_MountHA301A += OnMountAdd; MountModel.OnMountUieffectUpLv += OnMountUieffectUpLv; RidingAndPetActivationWin.FairyJadeDEvent += FairyJadeDEvent; FlySkillIconWin.FairyJadeDEvent += FairyJadeDEvent; m_ScrollerController.OnRefreshCell += OnRefreshGridCell; ToAddSorting(); DefaultOption(); SetHorseID(); OnCreateGridLineCell(m_ScrollerController); m_ScrollerController.JumpIndex(JumpIndex()); m_ShowHorseLV = mountModel.HorseLV; //默认当前阶 mountModel.onHorseInfoUpdate += HorseInfoUpdate; mountModel.onHorseLVUP += HorseLVUP; mountModel.HorseExpItemRefresh += HorseExpItemRefresh; MountModel.Event_MountAlteration += ShowHorse; ShowHorse(); DisplayHorseInfo(); } protected override void OnActived() { @@ -95,617 +112,236 @@ } protected override void OnAfterOpen() { HandleAchievement(); } protected override void OnPreClose() { AchievementGoto.achievementType = 0; MountModel.Event_MountAlteration -= OnMountAlteration; MountModel.Event_MountHA301U -= OnMountUpdate; MountModel.Event_MountHA301A -= OnMountAdd; m_ScrollerController.OnRefreshCell -= OnRefreshGridCell; MountModel.OnMountUieffectUpLv -= OnMountUieffectUpLv; RidingAndPetActivationWin.FairyJadeDEvent -= FairyJadeDEvent; FlySkillIconWin.FairyJadeDEvent -= FairyJadeDEvent; OnClickStopDomesticateBtn(); UI3DModelExhibition.Instance.StopShow(); } protected override void LateUpdate() { base.LateUpdate(); } private void FairyJadeDEvent() { FairyJadeDomesticate(); mountModel.onHorseInfoUpdate -= HorseInfoUpdate; mountModel.onHorseLVUP -= HorseLVUP; MountModel.Event_MountAlteration -= ShowHorse; mountModel.HorseExpItemRefresh -= HorseExpItemRefresh; } protected override void OnAfterClose() { if (PlayerDatas.Instance.baseData.LV >= 1500 && RedPointMountDan != null) { RedPointMountDan(); } if (ItemOperateUtility.Instance.useItemModel != null)//跳轉選中 { ItemOperateUtility.Instance.useItemModel = null; } } #endregion private void RefreshLeftRightBtn() { } public void SetHorseID() private void HorseInfoUpdate() { if (ItemOperateUtility.Instance.useItemModel != null)//坐骑单 { int ItemId = ItemOperateUtility.Instance.useItemModel.itemId; if (ItemId == 181) { int MountID= mountModel.GetMinExpMount(); if (MountID != 0) { signHorseID = MountID; return; } } } if (ItemOperateUtility.Instance.useItemModel != null)//跳轉選中(碎片) { int ItemId = ItemOperateUtility.Instance.useItemModel.itemId; for (int i = 0; i < sortMountlist.Count; i++) { if (sortMountlist[i].UnlockItemID == ItemId) { signHorseID = sortMountlist[i].HorseID; return; } } } for (int i = 0; i < sortMountlist.Count; i++)//未解鎖選中 { if (!mountModel._DicHorse.ContainsKey(sortMountlist[i].HorseID)) { int MaterialNumber = playerPack.GetItemCountByID(PackType.Item, sortMountlist[i].UnlockItemID);//获取背包解锁材料的数量 if (MaterialNumber != 0) { signHorseID = sortMountlist[i].HorseID; return; } } } foreach (var key in mountModel.mountRedpoint.Keys) { if (mountModel.mountRedpoint[key].state == RedPointState.Simple) { signHorseID = key; return; } } for (int i = 0; i < sortMountlist.Count; i++) { if (sortMountlist[i].HorseID == mountModel.HorseIDNow) { signHorseID = sortMountlist[i].HorseID; return; } } signHorseID = sortMountlist[0].HorseID; effectSlider.Play(); DisplayHorseInfo(); } private int JumpIndex(int HorseID = 0) private void DisplayHorseInfo() { int Index = 0; Index = sortMountlist.FindIndex((x) => { return x.HorseID == signHorseID; }); if (Index == -1) { Index = 0; } return JumpSelect(Index); ShowAttrText(); HorseExpItemRefresh(); ShowButton(); DisplayExpSlider(); } void OnCreateGridLineCell(ScrollerController gridCtrl) private void HorseExpItemRefresh() { gridCtrl.Refresh(); for (int i = 0; i < sortMountlist.Count; i++) { gridCtrl.AddCell(ScrollerDataType.Header, sortMountlist[i].HorseID); } gridCtrl.Restart(); ShowItem(); ShowButton(); } private void OnRefreshGridCell(ScrollerDataType type, CellView cell) { SelectThemount selectThemount = cell.GetComponent<SelectThemount>(); int horseID = cell.index; var horseConfig = HorseConfig.Get(horseID); selectThemount.QualityTxt1.text = ProductOrder(horseConfig.Quality.ToString()); selectThemount.MountNameTxt.text = horseConfig.Name; selectThemount.HidingTipstext.text = Language.Get("Petwin8"); selectThemount.HidingTipstext_A.text = Language.Get("Petwin8"); if (mountModel._DicHorse.ContainsKey(horseID)) { selectThemount.MountLvText.gameObject.SetActive(true); selectThemount.MountLvActivation.SetActive(false); if (mountModel._DicHorse[horseID].Lv >= horseConfig.MaxLV) { selectThemount.MountLvText.text = string.Format(Language.Get("Horse_MaxLv"), mountModel._DicHorse[horseID].Lv); } else { selectThemount.MountLvText.text = string.Format(Language.Get("Horse_lv"), mountModel._DicHorse[horseID].Lv); } } else private void ShowItem() { int number = playerPack.GetItemCountByID(PackType.Item, mountModel.horseUpItemId); ItemCellModel cellModel = new ItemCellModel(mountModel.horseUpItemId, false, (ulong)number); UseItem.Init(cellModel); UseItem.countText.gameObject.SetActive(true); UseItem.countText.text = number.ToString(); UseItemName.text = ItemConfig.Get(mountModel.horseUpItemId).ItemName; UseItem.button.AddListener(() => { selectThemount.MountLvText.gameObject.SetActive(false); selectThemount.MountLvActivation.SetActive(true); selectThemount.MountLvActivation.GetComponent<Text>().text = Language.Get("Petwin6"); } if (horseID == signHorseID) { if (mountModel._DicHorse.ContainsKey(signHorseID)) { MountLv = mountModel._DicHorse[signHorseID].Lv; } else { MountLv = 0; } selectThemount.ChoosenImg.SetActive(false); selectThemount.DarkImage.SetActive(true); if (MountLv > 0 && mountModel.HorseIDNow != horseID) { var config = HorseConfig.Get(signHorseID); if (MountLv >= config.UseNeedRank) { selectThemount.PlayedEquipText.text = Language.Get("MountText2"); } else { selectThemount.PlayedEquipText.text = string.Format(Language.Get("MountText1"), config.UseNeedRank); } selectThemount.PlayedEquipBtn.gameObject.SetActive(true); selectThemount.PlayedEquipBtn.RemoveAllListeners(); selectThemount.PlayedEquipBtn.AddListener(() => { int useNeedRank = config.UseNeedRank; if (mountModel._DicHorse[signHorseID].Lv < useNeedRank) { ScrollTip.ShowTip(Language.Get("AppearanceMount_Z"));//未达到外观切换条件 return; } OnClickStopDomesticateBtn(); mountModel.AppearanceSwitch(signHorseID); ScrollTip.ShowTip(Language.Get("Z1062"));//外观切换成功 }); } else { selectThemount.PlayedEquipBtn.gameObject.SetActive(false); } m_MountName.text = horseConfig.Name; if (mountModel._HorseIDNow != string.Empty && int.Parse(mountModel._HorseIDNow) == horseID) { selectThemount.HidingTips.SetActive(true); } else { selectThemount.HidingTips.SetActive(false); } } else { selectThemount.ChoosenImg.SetActive(true); selectThemount.DarkImage.SetActive(false); selectThemount.PlayedEquipBtn.gameObject.SetActive(false); if (mountModel._HorseIDNow != string.Empty && int.Parse(mountModel._HorseIDNow) == horseID) { selectThemount.HidingTips_A.SetActive(true); } else { selectThemount.HidingTips_A.SetActive(false); } } selectThemount.RedPoint.redpointId = mountModel.mountRedpoint[horseID].id; if (selectThemount.DarkImage.activeSelf) { m_MountPanelAssignment.PanelAssignment(horseID); } selectThemount.MountButton.RemoveAllListeners(); selectThemount.MountButton.AddListener(() => { if (horseID != signHorseID) { OnClickStopDomesticateBtn(); StartCoroutine(SwitchDelay(horseID)); } ItemTipUtility.Show(mountModel.horseUpItemId); }); } IEnumerator SwitchDelay( int horseId) { yield return new WaitForSeconds(0.2f); signHorseID = horseId; m_ScrollerController.m_Scorller.RefreshActiveCellViews();//刷新可见 } private void DefaultOption()//默认选择 { if (mountModel._HorseIDNow == string.Empty) { signHorseID = sortMountlist[0].HorseID; } else { signHorseID = int.Parse(mountModel._HorseIDNow); } } private void OnClickMountHunButton() { OnClickStopDomesticateBtn(); WindowCenter.Instance.Open<MountStoneTipsWin>(); } private void OnClickDeblockingBtton()//解锁按钮 { HorseConfig horsefig = HorseConfig.Get(signHorseID); int MaterialNumber = playerPack.GetItemCountByID(PackType.Item, horsefig.UnlockItemID);//获取背包解锁材料的数量 if (MaterialNumber >= horsefig.UnlockItemCnt) { CA501_tagPlayerActivateHorse _tagA501 = new CA501_tagPlayerActivateHorse(); _tagA501.HorseID = (uint)signHorseID; GameNetSystem.Instance.SendInfo(_tagA501); } else { ScrollTip.ShowTip(Language.Get("Z1063"));//所需材料不足 } } private void OnClickTrainBtn()//驯养1颗 { OnClickStopDomesticateBtn(); if (ExecuteJudgment(signHorseID)) { if (playerPack.GetItemCountByID(PackType.Item, mountDanId) <= 0)//如果背包中没有坐骑丹结束方法 { FuncConfigConfig _tagfun = FuncConfigConfig.Get("HorseUpItem"); ItemConfig _tagchine = ItemConfig.Get(int.Parse(_tagfun.Numerical1)); if (!WindowCenter.Instance.IsOpen<RidingAndPetActivationWin>()) { ItemTipUtility.Show(_tagchine.ID); } return; } SingleUseMountDan(1); } else { ServerTipDetails.DisplayNormalTip(Language.Get("Z1028"));//当前坐骑升阶满级 } } private void SingleUseMountDan(int MountDanNumber)//单次使用坐骑丹 { mountModel.MountDanUse(signHorseID, MountDanNumber);//向服务端发包坐骑经验单 } public void OnClickAutoTrainBtn()//自动驯养 { OnClickStopDomesticateBtn(); if (ExecuteJudgment(signHorseID)) { if (playerPack.GetItemCountByID(PackType.Item, mountDanId) <= 0)//仙玉驯养面板 { WindowCenter.Instance.Open<AutoTrainTipsWin>(); } else { m_AutoTrainBtn.gameObject.SetActive(false); m_StopDomesticateBtn.gameObject.SetActive(true); StartCoroutine("AutomaticDomesticated"); } } else { ServerTipDetails.DisplayNormalTip(Language.Get("Z1028"));//当前坐骑升阶满级 } } IEnumerator AutomaticDomesticated()//自动驯养 private void ShowButton() { while (ExecuteJudgment(signHorseID)) { if (playerPack.GetItemCountByID(PackType.Item, mountDanId) <= 0)//如果背包中没有坐骑丹结束方法 { m_AutoTrainBtn.gameObject.SetActive(true); m_StopDomesticateBtn.gameObject.SetActive(false); //ScrollTip.ShowTip(Language.Get("HorseDan5_text")); yield break; } else if (WindowCenter.Instance.IsOpen<RidingAndPetActivationWin>())//打开骑宠激活界面结束方法 { m_AutoTrainBtn.gameObject.SetActive(true); m_StopDomesticateBtn.gameObject.SetActive(false); yield break; } else { if (mountModel.Wait) { if (mountModel._DicHorse.ContainsKey(signHorseID)) { int exp=HorseUpConfig.GetHorseIDAndLV(signHorseID, mountModel._DicHorse[signHorseID].Lv).NeedExp; int NeedNum= ridingAndPetActivationModel.PetAndHorseNeedDanNum(exp); int NumNow = playerPack.GetItemCountByID(PackType.Item, mountDanId); if (NumNow >= NeedNum) { mountModel.MountDanUse(signHorseID, NeedNum);//向服务端发包坐骑经验单 mountModel.Wait = false; } else { mountModel.MountDanUse(signHorseID, NumNow);//向服务端发包坐骑经验单 mountModel.Wait = false; } } } yield return null; } } m_TrainBtn_1.gameObject.SetActive(true); m_AutoTrainBtn.gameObject.SetActive(true); m_StopDomesticateBtn.gameObject.SetActive(false); ServerTipDetails.DisplayNormalTip(Language.Get("Z1028"));//当前坐骑升阶满级; yield break; if (mountModel.NextTrainCount <= 1) { m_TrainText.text = Language.Get("MountWin114"); } else { m_TrainText.text = Language.Get("MountPanel_UnlockBtn_2"); } if (mountModel.NextTrainCount == 0) { m_TrainBtn_1.gameObject.SetActive(false); m_AutoTrainBtn.gameObject.SetActive(false); } } public void FairyJadeDomesticate() // 幻化模型替换当前阶模型,左右按钮改变m_ShowHorseLV private void ShowHorse() { int NumberLv = AutoTrainTipsWin._Lvnumber;//等级所需的等级 if (NumberLv > mountModel._DicHorse[signHorseID].Lv && !WindowCenter.Instance.IsOpen<RidingAndPetActivationWin>() && AutoTrainTipsWin.IsFairy) var horseInfo = HorseLVUpConfig.Get(m_ShowHorseLV); if (horseInfo == null) { m_AutoTrainBtn.gameObject.SetActive(false); m_StopDomesticateBtn.gameObject.SetActive(true); StartCoroutine("FairyJadeD"); //防止意外情况,正常不会出现 m_ShowHorseLV = mountModel.HorseLV; horseInfo = HorseLVUpConfig.Get(m_ShowHorseLV); } } IEnumerator FairyJadeD()//仙玉驯养 { int number = AutoTrainTipsWin.DomesticateNumber;//所需的颗数 int NumberLv = AutoTrainTipsWin._Lvnumber;//等级所需的等级 while (NumberLv > mountModel._DicHorse[signHorseID].Lv) int curShowHorseID = horseInfo.HorseID; HorseName.text = horseInfo.name; HorseRank.text = Language.Get("FuncRankName", m_ShowHorseLV); if (!Hosrse3D.gameObject.activeSelf) { if (WindowCenter.Instance.IsOpen<RidingAndPetActivationWin>()) Hosrse3D.gameObject.SetActive(true); } int model3D = horseInfo.HorseID; if (mountModel.HorseLV == m_ShowHorseLV && !mountModel.RankHorseIDList.Contains(mountModel.HorseIDNow)) { //当前阶有幻化情况下替换幻化模型 model3D = mountModel.HorseIDNow; } HorseConfig _model = HorseConfig.Get(horseInfo.HorseID); UI3DModelExhibition.Instance.ShowHourse(_model.Model, Hosrse3D); if (UI3DModelExhibition.Instance.NpcModelHorse != null) { var animator = UI3DModelExhibition.Instance.NpcModelHorse.GetComponent<Animator>(); if (animator != null) { m_AutoTrainBtn.gameObject.SetActive(true); m_StopDomesticateBtn.gameObject.SetActive(false); StopCoroutine("FairyJadeD"); yield break; animator.Play(GAStaticDefine.State_Dance); } if (mountModel.Wait) } Left.gameObject.SetActive(true); Right.gameObject.SetActive(true); if (m_ShowHorseLV == 1) { Left.gameObject.SetActive(false); } if (HorseLVUpConfig.Get(m_ShowHorseLV + 1) == null) { Right.gameObject.SetActive(false); } UseModel.gameObject.SetActive(false); CancelHorseClothe.gameObject.SetActive(false); HorseState.gameObject.SetActive(false); if (mountModel.RankHorseIDList.Contains(mountModel.HorseIDNow)) { if (curShowHorseID == mountModel.HorseIDNow) { int exp = HorseUpConfig.GetHorseIDAndLV(signHorseID, mountModel._DicHorse[signHorseID].Lv).NeedExp; int NeedNum = ridingAndPetActivationModel.PetAndHorseNeedDanNum(exp); mountModel.MountDanUse(signHorseID, NeedNum, true);//向服务端发包坐骑经验单 mountModel.Wait = false; HorseState.gameObject.SetActive(true); HorseStateText.text = UIHelper.AppendColor(TextColType.NavyBrown, Language.Get("Petwin8")); } yield return null; else { UseModel.gameObject.SetActive(true); } } if (!m_AutoTrainBtn.gameObject.activeSelf) else { AutoTrainTipsWin.IsFairy = false; m_AutoTrainBtn.gameObject.SetActive(true); m_StopDomesticateBtn.gameObject.SetActive(false); StopCoroutine("FairyJadeD"); yield break; //幻化情况 if (mountModel.HorseLV == m_ShowHorseLV) { CancelHorseClothe.gameObject.SetActive(true); } else { UseModel.gameObject.SetActive(true); } } yield break; if (m_ShowHorseLV > mountModel.HorseLV) { UseModel.gameObject.SetActive(false); HorseState.gameObject.SetActive(true); HorseStateText.text = UIHelper.AppendColor(TextColType.Red, Language.Get("MountWin113")); } } public void OnClickStopDomesticateBtn() private void ShowAttrText() { if (!m_AutoTrainBtn.gameObject.activeSelf) ClearAttrText(); Dictionary<int, int> allAttr = mountModel.GetHorseAllAttr(); Dictionary<int, int> nextAttr = mountModel.GetNextTrainAttr(); int showIndex = 0; foreach (var attrID in mountModel.HorseAttrSort) { m_AutoTrainBtn.gameObject.SetActive(true); m_StopDomesticateBtn.gameObject.SetActive(false); StopCoroutine("AutomaticDomesticated"); StopCoroutine("FairyJadeD"); if (!allAttr.ContainsKey(attrID) && !nextAttr.ContainsKey(attrID)) { continue; } AttrNameList[showIndex].text = PlayerPropertyConfig.Get(attrID).Name; AttrValueList[showIndex].text = allAttr.ContainsKey(attrID) ? allAttr[attrID].ToString() : "0"; AttrAddValueList[showIndex].text = nextAttr.ContainsKey(attrID) ? "+" + nextAttr[attrID].ToString() : (mountModel.NextTrainCount == 0 ? string.Empty : "+0"); showIndex++; } FightPower.text = UIHelper.GetFightPower(allAttr).ToString(); } private void OnMountUieffectUpLv() private void ClearAttrText() { for (int i = 0; i < AttrNameList.Count; i++) { AttrNameList[i].text = string.Empty; AttrValueList[i].text = string.Empty; AttrAddValueList[i].text = string.Empty; } } private void HorseLVUP() { if (!m_UieffectLVUp.IsPlaying) { m_UieffectLVUp.Play(); m_PositionTweenLVUp.Play(); } ShowHorse(); } private void OnMountAdd(int _HorseID)//坐骑添加 { m_ScrollerController.m_Scorller.RefreshActiveCellViews();//刷新可见 ridingAndPetActivationModel.RidingAndPetActivationSet(RidingAndPetActivation.MountActivation, _HorseID); } private void OnMountUpdate(int _HorseID)//坐骑刷新 { mountModel.Wait = true; MountSkills.Clear(); foreach (var key in mountModel.GetMountSkillAndItem.Keys) { if (mountModel.GetMountSkillAndItem[key].HorseID == _HorseID) { MountSkills.Add(mountModel.GetMountSkillAndItem[key]); } } if (m_MountModel._DicHorse[_HorseID].Lv > MountLv) { for (int i = 0; i < MountSkills.Count; i++) { if (MountSkills[i].HorseLV == m_MountModel._DicHorse[_HorseID].Lv) { ridingAndPetActivationModel.RidingAndPetActivationSet(RidingAndPetActivation.MountSkillActivates, _HorseID, MountSkills[i].SkillID, MountSkills[i].HorseLV); } } } m_ScrollerController.m_Scorller.RefreshActiveCellViews();//刷新可见 } private void OnMountAlteration(string NowMount)//坐骑外观变化时调用 { m_ScrollerController.m_Scorller.RefreshActiveCellViews();//刷新可见 } #endregion bool ExecuteJudgment(int horeseID)//判断是否满阶可否继续使用的执行判断条件 { bool _bool = false; int _NoweLv = mountModel._DicHorse[horeseID].Lv; int _MaxLv = HorseConfig.Get(horeseID).MaxLV; if (_MaxLv > _NoweLv) private void DisplayExpSlider() { var config = HorseLVUpConfig.Get(mountModel.HorseLV); if (config.NeedEatCount == 0) { _bool = true; return _bool; Exp.text = Language.Get("Z1029"); ExpSlider.stage = mountModel.HorseLV; ExpSlider.value = 1f; ExpSlider.delay = 0f; ExpSlider.ResetStage(); } else { _bool = false; return _bool; int exp = mountModel.HorseEatCount * mountModel.HorseDanExp; int expMax = config.NeedEatCount * mountModel.HorseDanExp; Exp.text = exp + "/" + expMax; ExpSlider.delay = 0.1f; ExpSlider.stage = mountModel.HorseLV; ExpSlider.value = (float)Math.Round((float)exp / expMax, 2, MidpointRounding.AwayFromZero); } } void ToAddSorting()//坐骑的列表排序 { // sortMountlist.Clear(); if (sortMountlist.Count <= 0) { sortMountlist = HorseConfig.GetValues(); } sortMountlist.Sort(Compare); } int Compare(HorseConfig x, HorseConfig y)//数组排列 { int havex = NoFullLv(x.HorseID); int havey = NoFullLv(y.HorseID); bool have_x = IsFullLv(x.HorseID); bool have_y = IsFullLv(y.HorseID); if (havex.CompareTo(havey) != 0) { return -havex.CompareTo(havey); } if (have_x.CompareTo(have_y) != 0) { return -have_x.CompareTo(have_y); } if (x.Sort.CompareTo(y.Sort) != 0) { return x.Sort.CompareTo(y.Sort); } return 1; } private int NoFullLv(int mountID)//未满街 { HorseConfig HorseConfig = HorseConfig.Get(mountID); int MaterialNumber = playerPack.GetItemCountByID(PackType.Item, HorseConfig.UnlockItemID);//获取背包解锁材料的数量 if (MaterialNumber != 0) { return 3; } if (mountModel.HorseIDNow == mountID) return 2; if (mountModel._DicHorse.ContainsKey(mountID)) { if (HorseConfig.MaxLV > mountModel._DicHorse[mountID].Lv) { return 1; } else { return 0; } } return 0; } private bool IsFullLv(int mountID)//满阶 { HorseConfig HorseConfig = HorseConfig.Get(mountID); if (mountModel._DicHorse.ContainsKey(mountID)) { if (HorseConfig.MaxLV <= mountModel._DicHorse[mountID].Lv) { return true; } else { return false; } } return false; } private void HandleAchievement() { if (AchievementGoto.achievementType == AchievementGoto.MountDomesticated)//坐骑培养 { AchievementGoto.achievementType = 0; SuccessConfig successConfig = SuccessConfig.Get(AchievementGoto.guideAchievementId); int[] HorseId = successConfig.Condition; signHorseID = HorseId[0]; m_ScrollerController.m_Scorller.RefreshActiveCellViews();//刷新可见 m_ScrollerController.JumpIndex(JumpIndex()); int MaterialNumber = playerPack.GetItemCountByID(PackType.Item, 181); if (mountModel._DicHorse.ContainsKey(signHorseID)) { if (MaterialNumber > 0) { AchievementGuideEffect2 = AchievementGuideEffectPool.Require(1); AchievementGuideEffect2.transform.SetParentEx(m_TrainBtn_1.transform, Vector3.zero, Vector3.zero, Vector3.one); } else { SysNotifyMgr.Instance.ShowTip("HorseShowTipAchievement2"); } } else { SysNotifyMgr.Instance.ShowTip("HorseShowTipAchievement1"); } AchievementGoto.achievementType = 0; } } private void OnClickPropertyButton() { ridingAndPetActivationModel.property = PropertyTip.Mount; ridingAndPetActivationModel.RidingId = signHorseID; WindowCenter.Instance.Open<TargetPetAttrWin>(); } string ProductOrder(string _petProductOrder)//坐骑品质 { FuncConfigConfig _PetQuality = FuncConfigConfig.Get("PetQuality"); string[] _productlist = _PetQuality.Numerical1.Split('|'); for (int i = 0; i < _productlist.Length; i++) { if (_petProductOrder == _productlist[i]) { string[] _productText = _PetQuality.Numerical2.Split('|'); string str = _productText[i]; return str; } } return null; } private int JumpSelect(int Index) { if (Index <= 4) { return 0; } return Index; } } } Utility/ConfigInitiator.cs
@@ -305,6 +305,8 @@ normalTasks.Add(new ConfigInitTask("EquipShenEvolveConfig", () => { EquipShenEvolveConfig.Init(); }, () => { return EquipShenEvolveConfig.inited; })); normalTasks.Add(new ConfigInitTask("ItemPlusMasterConfig", () => { ItemPlusMasterConfig.Init(); }, () => { return ItemPlusMasterConfig.inited; })); normalTasks.Add(new ConfigInitTask("AssistThanksGiftConfig", () => { AssistThanksGiftConfig.Init(); }, () => { return AssistThanksGiftConfig.inited; })); normalTasks.Add(new ConfigInitTask("HorseLVUpConfig", () => { HorseLVUpConfig.Init(); }, () => { return HorseLVUpConfig.inited; })); normalTasks.Add(new ConfigInitTask("HorseSkinPlusConfig", () => { HorseSkinPlusConfig.Init(); }, () => { return HorseSkinPlusConfig.inited; })); } static List<ConfigInitTask> doingTasks = new List<ConfigInitTask>();