| Core/GameEngine/Model/Config/TalentConfig.cs | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 | |
| Core/GameEngine/Model/Config/TalentConfig.cs.meta | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 | |
| System/Skill/TalentModel.cs | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 | |
| System/Skill/TalentSkillBehaviour.cs | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 | |
| System/Skill/TalentTreeScriptable.cs | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 | |
| System/Skill/TalentWin.cs | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 |
Core/GameEngine/Model/Config/TalentConfig.cs
@@ -1,6 +1,6 @@ //-------------------------------------------------------- // [Author]: 第二世界 // [ Date ]: Tuesday, August 21, 2018 // [ Date ]: Tuesday, September 25, 2018 //-------------------------------------------------------- using UnityEngine; @@ -11,38 +11,32 @@ public partial class TalentConfig : ConfigBase { public int SkillId { get ; private set ; } public int skillId { get ; private set ; } public int type { get ; private set ; } public int series { get ; private set ; } public int talentType { get ; private set ; } public int SkillLv { get ; private set ; } public int property { get ; private set ; } public int propertyValue { get ; private set ; } public int seriesCondition { get ; private set ; } public int point { get ; private set ; } public int level { get ; private set ; } public int requireSeries { get ; private set ; } public int requireSeriesPoint { get ; private set ; } public override string getKey() { return SkillId.ToString(); return skillId.ToString(); } public override void Parse() { try { SkillId=IsNumeric(rawContents[0]) ? int.Parse(rawContents[0]):0; skillId=IsNumeric(rawContents[0]) ? int.Parse(rawContents[0]):0; series=IsNumeric(rawContents[1]) ? int.Parse(rawContents[1]):0; type=IsNumeric(rawContents[1]) ? int.Parse(rawContents[1]):0; talentType=IsNumeric(rawContents[2]) ? int.Parse(rawContents[2]):0; series=IsNumeric(rawContents[2]) ? int.Parse(rawContents[2]):0; SkillLv=IsNumeric(rawContents[3]) ? int.Parse(rawContents[3]):0; level=IsNumeric(rawContents[3]) ? int.Parse(rawContents[3]):0; property=IsNumeric(rawContents[4]) ? int.Parse(rawContents[4]):0; requireSeries=IsNumeric(rawContents[4]) ? int.Parse(rawContents[4]):0; propertyValue=IsNumeric(rawContents[5]) ? int.Parse(rawContents[5]):0; seriesCondition=IsNumeric(rawContents[6]) ? int.Parse(rawContents[6]):0; point=IsNumeric(rawContents[7]) ? int.Parse(rawContents[7]):0; requireSeriesPoint=IsNumeric(rawContents[5]) ? int.Parse(rawContents[5]):0; } catch (Exception ex) { Core/GameEngine/Model/Config/TalentConfig.cs.meta
@@ -1,6 +1,6 @@ fileFormatVersion: 2 guid: 86eb4a564c7dcb047bb4509cf2e2758a timeCreated: 1534837559 timeCreated: 1537873567 licenseType: Pro MonoImporter: serializedVersion: 2 System/Skill/TalentModel.cs
@@ -8,8 +8,8 @@ { public class TalentModel : Model, IPlayerLoginOk, IBeforePlayerDataInitialize { Dictionary<int, TalentSkill> talentSkillDict = new Dictionary<int, TalentSkill>(); Dictionary<int, Dictionary<int, List<int>>> talentSkills = new Dictionary<int, Dictionary<int, List<int>>>(); Dictionary<int, TalentSkill> talentSkills = new Dictionary<int, TalentSkill>(); Dictionary<int, TalentTree> talentTreeDict = new Dictionary<int, TalentTree>(); int m_SelectSeries; public int selectSeries @@ -68,7 +68,7 @@ public void OnBeforePlayerDataInitialize() { foreach (var talent in talentSkillDict.Values) foreach (var talent in talentSkills.Values) { talent.level = 0; } @@ -96,49 +96,42 @@ var configs = Config.Instance.GetAllValues<TalentConfig>(); for (int i = 0; i < configs.Count; i++) { var skillId = configs[i].SkillId; var skillId = configs[i].skillId; var skillConfig = Config.Instance.Get<SkillConfig>(skillId); TalentSkill talent; if (!TryGetTalent(skillConfig.SkillTypeID, out talent)) { talent = new TalentSkill(skillConfig.SkillTypeID, skillConfig.SkillMaxLV); talent.level = 0; talentSkillDict.Add(skillConfig.SkillTypeID, talent); talentSkills.Add(skillConfig.SkillTypeID, talent); Dictionary<int, List<int>> dict = null; if (!talentSkills.TryGetValue(skillConfig.UseType, out dict)) TalentTree talentTree; if (!talentTreeDict.TryGetValue(skillConfig.UseType, out talentTree)) { dict = new Dictionary<int, List<int>>(); talentSkills.Add(skillConfig.UseType, dict); talentTree = new TalentTree(); talentTreeDict.Add(skillConfig.UseType, talentTree); } List<int> list = null; var type = configs[i].series * 10 + configs[i].talentType; if (!dict.TryGetValue(type, out list)) { list = new List<int>(); dict.Add(type, list); } list.Add(skillConfig.SkillTypeID); talentTree.Add(configs[i], skillConfig.SkillTypeID); } } } public bool TryGetTalents(int job, int series, int talentType, out List<int> talents) public bool TryGetTalents(int job, int talentType, int talentSeries, out List<int> talents) { talents = null; Dictionary<int, List<int>> dict = null; TalentTree talentTree = null; var _job = (int)Math.Pow(2, job); talentSkills.TryGetValue(_job, out dict); if (null != dict) talentTreeDict.TryGetValue(_job, out talentTree); if (null != talentTree) { return dict.TryGetValue(series * 10 + talentType, out talents); return talentTree.TryGetTalents(talentType, talentSeries, out talents); } return false; } public bool TryGetTalent(int talentId,out TalentSkill talent) public bool TryGetTalent(int talentId, out TalentSkill talent) { return talentSkillDict.TryGetValue(talentId, out talent); return talentSkills.TryGetValue(talentId, out talent); } public int GetTalentTypeTotalPoint(int series, int talentType) @@ -166,7 +159,7 @@ TalentSkill talent; if (TryGetTalent(talentId, out talent)) { if (talent.level >= talent.max) if (talent.level >= talent.maxLevel) { error = 1; return false; @@ -177,17 +170,9 @@ return false; } var talentConfig = Config.Instance.Get<TalentConfig>(talent.skillId + talent.level); if (talentConfig.property != 0) if (talentConfig.requireSeriesPoint != 0) { if (UIHelper.GetPropertyMapPlayerData((AttrEnum)talentConfig.property) < talentConfig.propertyValue) { error = 3; return false; } } if (talentConfig.seriesCondition != 0) { if (GetTalentTypeTotalPoint(talentConfig.series, talentConfig.seriesCondition) < talentConfig.point) if (GetTalentTypeTotalPoint(talentConfig.requireSeries, talentConfig.type) < talentConfig.requireSeriesPoint) { error = 4; return false; @@ -246,12 +231,76 @@ { public int skillId { get; private set; } public int level { get; set; } public int max { get; private set; } public int maxLevel { get; private set; } public TalentSkill(int id, int maxLevel) public TalentSkill(int skillId, int maxLevel) { skillId = id; max = maxLevel; this.skillId = skillId; this.maxLevel = maxLevel; } } public class TalentSeries { public int series { get; private set; } public List<int> talentSkills { get; private set; } public TalentSeries(int series) { this.series = series; talentSkills = new List<int>(); } public void Add(int skillId) { if (talentSkills.Contains(skillId)) { return; } talentSkills.Add(skillId); } } public class TalentTree { Dictionary<int, List<TalentSeries>> talentSeriesDict = new Dictionary<int, List<TalentSeries>>(); public void Add(TalentConfig config, int skillId) { List<TalentSeries> list = null; if (!talentSeriesDict.TryGetValue(config.type, out list)) { list = new List<TalentSeries>(); talentSeriesDict.Add(config.type, list); } TalentSeries talentSeries = list.Find((x) => { return x.series == config.series; }); if (talentSeries == null) { talentSeries = new TalentSeries(config.series); list.Add(talentSeries); } talentSeries.Add(skillId); } public bool TryGetTalents(int type, int series, out List<int> list) { list = null; if (talentSeriesDict.ContainsKey(type)) { var talentSeries = talentSeriesDict[type].Find((x) => { return x.series == series; }); if (talentSeries != null) { list = talentSeries.talentSkills; return true; } } return false; } } } System/Skill/TalentSkillBehaviour.cs
@@ -12,6 +12,7 @@ [SerializeField] Image m_Icon; [SerializeField] Text m_Level; [SerializeField] Button m_Button; [SerializeField] RectTransform m_ContainerSelect; int skillId = 0; @@ -40,7 +41,7 @@ { m_Icon.SetSprite(config.IconName); } m_Level.text = StringUtility.Contact(talent.level, "/", talent.max); m_Level.text = StringUtility.Contact(talent.level, "/", talent.maxLevel); m_Icon.material = talent.level > 0 ? MaterialUtility.GetUIDefaultGraphicMaterial() : MaterialUtility.GetDefaultSpriteGrayMaterial(); } } System/Skill/TalentTreeScriptable.cs
@@ -10,7 +10,23 @@ public class TalentTreeScriptable : ScriptableObject { [SerializeField] TalentTree[] talentTrees; [SerializeField] TalentElement[] talentElements; [SerializeField] Vector2 m_ContentSizeDelta; [SerializeField] TalentElement[] skillElements; [SerializeField] ArrowElement[] arrowElements; public Vector2 contentSizeDelta { get { return m_ContentSizeDelta; } } public TalentElement GetTalentElement(int index) { if (index < skillElements.Length) { return skillElements[index]; } return default(TalentElement); } public bool Belong(int job, int talentType, int talentSeries) { @@ -40,9 +56,15 @@ [Serializable] public struct TalentElement { public int type; public Vector3 position; } [Serializable] public struct ArrowElement { public Vector3 position; public Vector3 rotation; public Vector2 sizeDelta; } } System/Skill/TalentWin.cs
@@ -20,6 +20,7 @@ [SerializeField] Button m_TalentTypeSelect; [SerializeField] Text m_TalentType; [SerializeField] ScrollRect m_Scroller; [SerializeField] TalentSkillBehaviour[] m_TalentSkills; [SerializeField] Image[] m_Arrows; @@ -38,6 +39,10 @@ [SerializeField] Button m_AddPoint; [SerializeField] Text m_AddPointBtnText; [SerializeField] Text m_SurplusPoint; #if UNITY_EDITOR [SerializeField] TalentTreeScriptable m_EditorScriptable; #endif TalentModel model { get { return ModelCenter.Instance.GetModel<TalentModel>(); } } #region Built-in @@ -79,12 +84,30 @@ { m_TalentSeries[i].Dispose(); } #if UNITY_EDITOR if (m_EditorScriptable != null) { m_EditorScriptable = null; } #endif } protected override void OnAfterClose() { } #endregion protected override void LateUpdate() { base.LateUpdate(); #if UNITY_EDITOR if (m_EditorScriptable != null) { DisplayTalentLayout(m_EditorScriptable); } #endif } void Display() { @@ -132,21 +155,10 @@ var skillConfig = Config.Instance.Get<SkillConfig>(talent.skillId + talent.level); if (talentConfig != null) { if (talentConfig.property != 0 && index < m_SelectConditions.Length) { var propertyConfig = Config.Instance.Get<PlayerPropertyConfig>(talentConfig.property); m_SelectConditions[index].gameObject.SetActive(true); m_SelectConditions[index].text = StringUtility.Contact( string.Format("需要{0}点:", propertyConfig.Name), UIHelper.GetPropertyMapPlayerData((AttrEnum)talentConfig.property), "/", talentConfig.propertyValue ); index++; } if (talentConfig.seriesCondition != 0 && index < m_SelectConditions.Length) if (talentConfig.requireSeriesPoint != 0 && index < m_SelectConditions.Length) { m_SelectConditions[index].gameObject.SetActive(true); m_SelectConditions[index].text = StringUtility.Contact(0, "/", talentConfig.point); m_SelectConditions[index].text = StringUtility.Contact(0, "/", talentConfig.requireSeriesPoint); index++; } } @@ -180,7 +192,7 @@ m_ContainerSelectSkill.gameObject.SetActive(true); var config = Config.Instance.Get<SkillConfig>(talent.skillId + talent.level); m_SelectSkillIcon.SetSprite(config.IconName); m_SelectSkillLevel.text = StringUtility.Contact(talent.level, "/", talent.max); m_SelectSkillLevel.text = StringUtility.Contact(talent.level, "/", talent.maxLevel); m_SelectSkillName.text = config.SkillName; } } @@ -192,8 +204,8 @@ { var config = Config.Instance.Get<SkillConfig>(talent.skillId + talent.level); m_SelectSkillEffect.text = config.Description; m_ContainerNextEffect.gameObject.SetActive(talent.level < talent.max); if (talent.level < talent.max) m_ContainerNextEffect.gameObject.SetActive(talent.level < talent.maxLevel); if (talent.level < talent.maxLevel) { var nextConfig = Config.Instance.Get<SkillConfig>(talent.skillId + talent.level + 1); m_SelectNextEffect.text = nextConfig.Description; @@ -274,6 +286,16 @@ { } void DisplayTalentLayout(TalentTreeScriptable config) { m_Scroller.content.sizeDelta = config.contentSizeDelta; for (int i = 0; i < m_TalentSkills.Length; i++) { var element = config.GetTalentElement(i); m_TalentSkills[i].transform.localPosition = element.position; } } } }