| Core/GameEngine/Model/Config/AlchemyConfig.cs | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 | |
| Core/GameEngine/Model/Config/AlchemyConfig.cs.meta | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 | |
| System/Alchemy/AlchemyBriefBehaviour.cs | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 | |
| System/Alchemy/AlchemyDrugBriefBehaviour.cs | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 | |
| System/Alchemy/AlchemyDrugBriefBehaviour.cs.meta | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 | |
| System/Alchemy/AlchemyModel.cs | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 | |
| System/Alchemy/AlchemyStoveBehaviour.cs | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 | |
| System/Alchemy/AlchemyStoveBehaviour.cs.meta | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 | |
| System/BlastFurnace/DandrugCell.cs | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 | |
| System/BlastFurnace/StoveRecipeCell.cs | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 |
Core/GameEngine/Model/Config/AlchemyConfig.cs
@@ -24,7 +24,8 @@ public readonly int NeedTime; public readonly int AlchemyExp; public readonly string Material; public readonly string ICONID; public readonly int drugPromoteType; public readonly string description; public AlchemyConfig() { @@ -58,7 +59,9 @@ Material = tables[10]; ICONID = tables[11]; int.TryParse(tables[11],out drugPromoteType); description = tables[12]; } catch (Exception ex) { Core/GameEngine/Model/Config/AlchemyConfig.cs.meta
@@ -1,6 +1,6 @@ fileFormatVersion: 2 guid: 93a73d5a5e9d51c4abc2515a6180cac4 timeCreated: 1555481595 timeCreated: 1555494121 licenseType: Pro MonoImporter: serializedVersion: 2 System/Alchemy/AlchemyBriefBehaviour.cs
@@ -18,6 +18,39 @@ public void Display(int alchemyId) { this.alchemyId = alchemyId; DisplayAlchemyTime(); DisplayAlchemyCount(); DisplaySuccRate(); } void DisplayAlchemyTime() { var config = AlchemyConfig.Get(alchemyId); m_AlchemyTime.text = TimeUtility.SecondsToDHMSCHS(config.NeedTime); } void DisplayAlchemyCount() { AlchemyCount alchemyCount; if (model.TryGetAlchemyCount(alchemyId, out alchemyCount)) { if (alchemyCount.min == alchemyCount.max) { m_AlchemyCount.text = alchemyCount.min.ToString(); } else { m_AlchemyCount.text = StringUtility.Contact(alchemyCount.min, "~", alchemyCount.max); } } } void DisplaySuccRate() { var succRate = model.GetAlchemySuccRate(alchemyId); var rate = (int)(succRate / 100); m_AlchemySuccRate.text = rate + "%"; } public void Dispose() System/Alchemy/AlchemyDrugBriefBehaviour.cs
New file @@ -0,0 +1,104 @@ using System.Collections; using System.Collections.Generic; using UnityEngine; using UnityEngine.UI; namespace Snxxz.UI { public class AlchemyDrugBriefBehaviour : MonoBehaviour { [SerializeField] ItemBehaviour m_Item; [SerializeField] Transform m_ContainerProperty; [SerializeField] PropertyBehaviour[] m_Propertys; [SerializeField] Text m_Effect; int alchemyId = 0; static Dictionary<int, int> s_Propertys = new Dictionary<int, int>(); public void Display(int alchemyId) { this.alchemyId = alchemyId; DisplayItem(); DisplayProperty(); DisplayEffect(); } void DisplayItem() { var config = AlchemyConfig.Get(alchemyId); m_Item.SetItem(config.AlchemItemID, 0); } void DisplayProperty() { var config = AlchemyConfig.Get(alchemyId); m_ContainerProperty.gameObject.SetActive(config.drugPromoteType == 1); if (config.drugPromoteType == 1) { var itemConfig = ItemConfig.Get(config.AlchemItemID); GetItemPromoteProperty(itemConfig,ref s_Propertys); var index = 0; foreach (var property in s_Propertys.Keys) { if (index < m_Propertys.Length) { m_Propertys[index].gameObject.SetActive(true); m_Propertys[index].Display(property, s_Propertys[property]); index++; } } for (int i = index; i < m_Propertys.Length; i++) { m_Propertys[i].gameObject.SetActive(false); } } } void DisplayEffect() { var config = AlchemyConfig.Get(alchemyId); m_Effect.gameObject.SetActive(config.drugPromoteType == 2); if (config.drugPromoteType == 2) { m_Effect.text = config.description; } } public void Dispose() { } static void GetItemPromoteProperty(ItemConfig config, ref Dictionary<int, int> dict) { dict.Clear(); if (config == null) { return; } if (config.Effect1 != 0) { dict.Add(config.Effect1, config.EffectValueA1); } if (config.Effect2 != 0) { dict.Add(config.Effect2, config.EffectValueA2); } if (config.Effect3 != 0) { dict.Add(config.Effect3, config.EffectValueA3); } if (config.Effect4 != 0) { dict.Add(config.Effect4, config.EffectValueA4); } if (config.Effect5 != 0) { dict.Add(config.Effect5, config.EffectValueA5); } } } } System/Alchemy/AlchemyDrugBriefBehaviour.cs.meta
New file @@ -0,0 +1,12 @@ fileFormatVersion: 2 guid: 90d98004fd586034e948253625325eb4 timeCreated: 1555492947 licenseType: Pro MonoImporter: serializedVersion: 2 defaultReferences: [] executionOrder: 0 icon: {instanceID: 0} userData: assetBundleName: assetBundleVariant: System/Alchemy/AlchemyModel.cs
@@ -7,7 +7,9 @@ public class AlchemyModel : Model, IBeforePlayerDataInitialize, IPlayerLoginOk { Dictionary<int, uint> m_AlchemyTimes = new Dictionary<int, uint>(); Dictionary<int, AlchemyCount> m_AlchemyCounts = new Dictionary<int, AlchemyCount>(); Dictionary<int, AlchemyCount> m_AlchemyCounts = new Dictionary<int, AlchemyCount>(); Dictionary<int, int> m_AlchemyQualityLucks = new Dictionary<int, int>(); Dictionary<int, List<Item>> m_AlchemyMaterials = new Dictionary<int, List<Item>>(); int m_SelectQuality = 0; public int selectQuality @@ -45,6 +47,7 @@ public int stoveLevel { get; private set; } public int stoveExp { get; private set; } public string alchemySuccRate { get; private set; } public event Action selectQualityRefresh; public event Action selectAlchemyRefresh; @@ -77,7 +80,54 @@ var max = intArray[intArray.Length - 1][1]; if (m_AlchemyCounts.ContainsKey(config.AlchemyQuality)) { var alchemyCount = m_AlchemyCounts[config.AlchemyQuality]; if (min < alchemyCount.min) { alchemyCount.min = min; m_AlchemyCounts[config.AlchemyQuality] = alchemyCount; } if (max > alchemyCount.max) { alchemyCount.max = max; m_AlchemyCounts[config.AlchemyQuality] = alchemyCount; } } else { m_AlchemyCounts[config.AlchemyQuality] = new AlchemyCount() { min = min, max = max, }; } } } { var funcConfig = FuncConfigConfig.Get("alchemySuccess"); alchemySuccRate = funcConfig.Numerical3; var json = LitJson.JsonMapper.ToObject(funcConfig.Numerical2); foreach (var key in json.Keys) { var quality = int.Parse(key); m_AlchemyQualityLucks.Add(quality, int.Parse(json[key].ToString())); } } { var configs = AlchemyConfig.GetValues(); foreach (var config in configs) { m_AlchemyMaterials.Add(config.ID, new List<Item>()); var dict = ConfigParse.GetDic<int, int>(config.Material); foreach (var key in dict.Keys) { m_AlchemyMaterials[config.ID].Add(new Item() { id = key, count = dict[key], }); } } } @@ -86,6 +136,54 @@ public bool TryGetAlchemyStartTime(int alchemyId, out uint tick) { return m_AlchemyTimes.TryGetValue(alchemyId, out tick); } public bool TryGetAlchemyCount(int alchemyId, out AlchemyCount alchemyCount) { var config = AlchemyConfig.Get(alchemyId); if (config == null) { alchemyCount = default(AlchemyCount); return false; } if (config.AlchemType == (int)AlchemyType.Fairy) { alchemyCount = AlchemyCount.one; return true; } return m_AlchemyCounts.TryGetValue(config.AlchemyQuality, out alchemyCount); } public bool TryGetAlchemyMaterials(int alchemyId, out List<Item> items) { return m_AlchemyMaterials.TryGetValue(alchemyId, out items); } public float GetAlchemySuccRate(int alchemyId) { var config = AlchemyConfig.Get(alchemyId); if (config == null) { return 0f; } if (config.AlchemType == (int)AlchemyType.Fairy) { return 10000f; } var itemConfig = ItemConfig.Get(config.AlchemItemID); var luckValue = PlayerDatas.Instance.extersion.luckValue; return GetAlchemySuccRate(stoveLevel, itemConfig.LV, luckValue); } public float GetAlchemySuccRate(int stoveLevel, int itemLevel, int luck) { Equation.Instance.Clear(); Equation.Instance.AddKeyValue("alchemyLV", stoveLevel); Equation.Instance.AddKeyValue("alchemyQuality", itemLevel); Equation.Instance.AddKeyValue("curLuckValue", luck); var qualityNeedLuck = m_AlchemyQualityLucks.ContainsKey(itemLevel) ? m_AlchemyQualityLucks[itemLevel] : 0; Equation.Instance.AddKeyValue("qualityNeedLuck", qualityNeedLuck); return Equation.Instance.Eval<float>(alchemySuccRate); } public bool IsGraspRecipe(int alchemyId) @@ -129,14 +227,20 @@ public enum AlchemyType { Normal, Fairy, Normal = 1, Fairy = 2, } public struct AlchemyCount { public int min; public int max; public static readonly AlchemyCount one = new AlchemyCount() { min = 1, max = 1, }; } } System/Alchemy/AlchemyStoveBehaviour.cs
New file @@ -0,0 +1,244 @@ using System; using System.Collections; using System.Collections.Generic; using UnityEngine; using UnityEngine.UI; namespace Snxxz.UI { public class AlchemyStoveBehaviour : MonoBehaviour { [SerializeField] AlchemyMaterial[] m_AlchemyMaterials; [SerializeField] Transform m_ContainerAlcheming; [SerializeField] Text m_AlchemyTime; [SerializeField] Transform m_ContainerComplete; [SerializeField] Transform m_ContainerNormal; [SerializeField] Text m_StoveLevel; [SerializeField] Text m_StoveExp; [SerializeField] Slider m_StoveExpSlider; [SerializeField] Text m_LuckValue; [SerializeField] Transform m_ContainerGrasp; [SerializeField] Button m_Func; [SerializeField] Text m_FuncLabel; [SerializeField] Transform m_ContainerUnGrasp; int m_State = 0; //0-正常状态 1-炼丹中 2-炼丹结束 int state { get { return m_State; } set { if (m_State != value) { m_State = value; DisplayStove(); } } } AlchemyModel model { get { return ModelCenter.Instance.GetModel<AlchemyModel>(); } } private void Awake() { m_Func.SetListener(OnFunc); } public void Display() { model.selectAlchemyRefresh += SelectAlchemyRefresh; GlobalTimeEvent.Instance.secondEvent += PerSecond; model.alchemyStateRefresh += AlchemyStateRefresh; PlayerDatas.Instance.playerDataRefreshEvent += PlayerDataRefreshEvent; m_State = GetStoveState(); DisplayAlchemyMaterials(); DisplayStove(); DisplayLuckValue(); } void DisplayAlchemyMaterials() { var grasp = model.IsGraspRecipe(model.selectAlchemy); List<Item> materials; model.TryGetAlchemyMaterials(model.selectAlchemy, out materials); for (int i = 0; i < m_AlchemyMaterials.Length; i++) { if (grasp && materials != null && i < materials.Count) { m_AlchemyMaterials[i].SetLock(true); m_AlchemyMaterials[i].Display(materials[i]); } else { m_AlchemyMaterials[i].SetLock(false); } } } void DisplayStove() { switch (state) { case 0: m_StoveLevel.text = StringUtility.Contact("Lv.", model.stoveLevel); var isMax = !RefineStoveConfig.Has(model.stoveLevel + 1); var stoveConfig = RefineStoveConfig.Get(model.stoveLevel); m_StoveExp.text = StringUtility.Contact(model.stoveExp, "/", stoveConfig.Exp); var progress = Mathf.Clamp01((float)model.stoveExp / stoveConfig.Exp); m_StoveExpSlider.value = progress; break; case 1: uint tick = 0; if (model.TryGetAlchemyStartTime(model.selectAlchemy, out tick)) { var config = AlchemyConfig.Get(model.selectAlchemy); var startTime = TimeUtility.GetTime(tick); var seconds = Mathf.CeilToInt(config.NeedTime - (float)(TimeUtility.ServerNow - startTime).TotalSeconds); m_AlchemyTime.text = TimeUtility.SecondsToHMS(seconds); } break; case 2: break; } var grasp = model.IsGraspRecipe(model.selectAlchemy); m_ContainerGrasp.gameObject.SetActive(grasp); m_ContainerUnGrasp.gameObject.SetActive(!grasp); if (grasp) { switch (state) { case 0: m_FuncLabel.text = "开始炼丹"; break; case 1: m_FuncLabel.text = "停止炼丹"; break; case 2: m_FuncLabel.text = "开炉取丹"; break; } } } void DisplayLuckValue() { m_LuckValue.text = PlayerDatas.Instance.extersion.luckValue.ToString(); } int GetStoveState() { uint tick = 0; if (model.TryGetAlchemyStartTime(model.selectAlchemy, out tick) && tick > 0) { var config = AlchemyConfig.Get(model.selectAlchemy); var startTime = TimeUtility.GetTime(tick); var seconds = Mathf.CeilToInt(config.NeedTime - (float)(TimeUtility.ServerNow - startTime).TotalSeconds); return seconds > 0 ? 1 : 2; } return 0; } private void SelectAlchemyRefresh() { DisplayAlchemyMaterials(); } private void AlchemyStateRefresh() { m_State = GetStoveState(); DisplayStove(); } private void PlayerDataRefreshEvent(PlayerDataType dataType) { if (dataType == PlayerDataType.LuckValue) { DisplayLuckValue(); } } private void PerSecond() { var _state = GetStoveState(); if (_state == state) { if (state == 1) { DisplayStove(); } } else { state = _state; } } private void OnFunc() { var pak = new CA576_tagCMPlayerRefine(); pak.AlchemyID = (uint)model.selectAlchemy; switch (state) { case 0: pak.DoType = 1; break; case 1: pak.DoType = 2; break; case 2: pak.DoType = 3; break; } GameNetSystem.Instance.SendInfo(pak); } public void Dispose() { model.selectAlchemyRefresh -= SelectAlchemyRefresh; GlobalTimeEvent.Instance.secondEvent -= PerSecond; model.alchemyStateRefresh -= AlchemyStateRefresh; PlayerDatas.Instance.playerDataRefreshEvent -= PlayerDataRefreshEvent; } } public class AlchemyMaterial { [SerializeField] Transform m_ContainerItem; [SerializeField] Image m_Icon; [SerializeField] Text m_Count; [SerializeField] Transform m_ContainerLock; PackModel packModel { get { return ModelCenter.Instance.GetModel<PackModel>(); } } public void Display(Item item) { Display(item.id, item.count); } public void Display(int id, int count) { var itemConfig = ItemConfig.Get(id); m_Icon.SetSprite(itemConfig.IconKey); var packCount = packModel.GetItemCountByID(PackType.Item, id); var enough = packCount >= count; var label = UIHelper.AppendColor(enough ? TextColType.Green : TextColType.Red, packCount.ToString()); m_Count.text = StringUtility.Contact(label, "/", count); } public void SetLock(bool _lock) { m_ContainerLock.gameObject.SetActive(_lock); m_ContainerItem.gameObject.SetActive(!_lock); } } } System/Alchemy/AlchemyStoveBehaviour.cs.meta
New file @@ -0,0 +1,12 @@ fileFormatVersion: 2 guid: 318da5e8e0250734c8be86940bd2d5c4 timeCreated: 1555551888 licenseType: Pro MonoImporter: serializedVersion: 2 defaultReferences: [] executionOrder: 0 icon: {instanceID: 0} userData: assetBundleName: assetBundleVariant: System/BlastFurnace/DandrugCell.cs
@@ -41,7 +41,7 @@ { AlchemyConfig alchemyModel = FurnaceModel.alchemyModellist[index]; Redpoint.redpointId = FurnaceModel.danDrugRedPointlist[index].id; danIcon.SetSprite(alchemyModel.ICONID); //danIcon.SetSprite(alchemyModel.ICONID); danBgIcon.SetItemBackGround(alchemyModel.AlchemyQuality); nameText.text = alchemyModel.AlchemName; //if (FurnaceModel.StoveLV < alchemyModel.BlastFurnaceLV) System/BlastFurnace/StoveRecipeCell.cs
@@ -14,7 +14,7 @@ AlchemyConfig alchemy = AlchemyConfig.Get(alchemyId); if (alchemy == null) return; icon.SetSprite(alchemy.ICONID); //icon.SetSprite(alchemy.ICONID); bgIcon.SetItemBackGround(alchemy.AlchemyQuality); recipeNameText.text = alchemy.AlchemName; }