| | |
| | | using UnityEngine; |
| | | using TableConfig; |
| | | using System;
|
| | | using System.Linq;
|
| | |
|
| | | namespace Snxxz.UI
|
| | | {
|
| | |
| | | {
|
| | | ParseConfig();
|
| | | FuncOpen.Instance.OnFuncStateChangeEvent += OnFuncStateChangeEvent;
|
| | | PlayerDatas.Instance.PlayerDataRefreshInfoEvent += PlayerDataRefreshInfoEvent;
|
| | | }
|
| | |
|
| | | public void OnBeforePlayerDataInitialize()
|
| | |
| | | public void OnPlayerLoginOk()
|
| | | {
|
| | | serverInited = true;
|
| | | if (WindowCenter.Instance.IsOpen<TalentWin>())
|
| | | {
|
| | | foreach (var talent in talentSkills.Values)
|
| | | {
|
| | | if (talentSkillUpdate != null)
|
| | | {
|
| | | talentSkillUpdate(talent.skillId);
|
| | | }
|
| | | }
|
| | | }
|
| | | UpdateRedpoint();
|
| | | }
|
| | |
|
| | | public override void UnInit()
|
| | | {
|
| | | FuncOpen.Instance.OnFuncStateChangeEvent -= OnFuncStateChangeEvent;
|
| | | PlayerDatas.Instance.PlayerDataRefreshInfoEvent -= PlayerDataRefreshInfoEvent;
|
| | | }
|
| | |
|
| | | private void OnFuncStateChangeEvent(int _id)
|
| | |
| | | }
|
| | |
|
| | | public int talentResetBook { get; private set; }
|
| | | public int storeId { get; private set; }
|
| | | public int talentResetBookCost { get; private set; }
|
| | | Dictionary<int, List<int>> jobTalentTypeDict = new Dictionary<int, List<int>>();
|
| | | void ParseConfig()
|
| | | {
|
| | | var configs = Config.Instance.GetAllValues<TalentConfig>();
|
| | |
| | | talentTreeDict.Add(skillConfig.UseType, talentTree);
|
| | | }
|
| | | talentTree.Add(configs[i], skillConfig.SkillTypeID);
|
| | |
|
| | | List<int> list = null;
|
| | | if (!jobTalentTypeDict.TryGetValue(skillConfig.UseType, out list))
|
| | | {
|
| | | list = new List<int>();
|
| | | jobTalentTypeDict.Add(skillConfig.UseType, list);
|
| | | }
|
| | | if (!list.Contains(configs[i].type))
|
| | | {
|
| | | list.Add(configs[i].type);
|
| | | }
|
| | | }
|
| | | }
|
| | | var config = Config.Instance.Get<FuncConfigConfig>("");
|
| | | if (config != null)
|
| | | var jobs = jobTalentTypeDict.Keys.ToList();
|
| | | for (int i = 0; i < jobs.Count; i++)
|
| | | {
|
| | | talentResetBook = int.Parse(config.Numerical1);
|
| | | }
|
| | | var storeConfigs = Config.Instance.GetAllValues<StoreConfig>();
|
| | | for (int i = 0; i < storeConfigs.Count; i++)
|
| | | {
|
| | | if (storeConfigs[i].ItemID == talentResetBook)
|
| | | var list = jobTalentTypeDict[jobs[i]];
|
| | | list.Sort((x, y) =>
|
| | | {
|
| | | storeId = storeConfigs[i].ID;
|
| | | break;
|
| | | return x.CompareTo(y);
|
| | | });
|
| | | }
|
| | |
|
| | |
|
| | | var config = Config.Instance.Get<FuncConfigConfig>("TalentResetBook");
|
| | | talentResetBook = int.Parse(config.Numerical1);
|
| | | talentResetBookCost = int.Parse(config.Numerical2);
|
| | | }
|
| | |
|
| | | public int GetTalentType(int index)
|
| | | {
|
| | | var job = (int)Math.Pow(2, PlayerDatas.Instance.baseData.Job);
|
| | | if (jobTalentTypeDict.ContainsKey(job))
|
| | | {
|
| | | var list = jobTalentTypeDict[job];
|
| | | return index < list.Count ? list[index] : list[0];
|
| | | }
|
| | | return 1;
|
| | | }
|
| | |
|
| | | public int talentTypeCount
|
| | | {
|
| | | get
|
| | | {
|
| | | var job = (int)Math.Pow(2, PlayerDatas.Instance.baseData.Job);
|
| | | if (jobTalentTypeDict.ContainsKey(job))
|
| | | {
|
| | | var list = jobTalentTypeDict[job];
|
| | | return list.Count;
|
| | | }
|
| | | return 0;
|
| | | }
|
| | | }
|
| | |
|
| | |
| | |
|
| | | public int GetSeriesPoint(int talentType,int talentSeries)
|
| | | {
|
| | | var job = (int)Math.Pow(PlayerDatas.Instance.baseData.Job, 2);
|
| | | var job = PlayerDatas.Instance.baseData.Job;
|
| | | List<int> list;
|
| | | var point = 0;
|
| | | if (TryGetTalents(job, talentType, talentSeries, out list))
|
| | |
| | | }
|
| | | var talentConfig = talent.GetTalentConfig(talent.level + 1);
|
| | | var skillConfig = talent.GetSkillConfig(talent.level + 1);
|
| | | var requireSeriesPoint = skillConfig.RequireSeriesPoint();
|
| | | var requireSeriesPoint = skillConfig.RequireTalentSeriesPoint();
|
| | | if (requireSeriesPoint != 0)
|
| | | {
|
| | | var requireSeries = skillConfig.RequireSeries();
|
| | | var requireSeries = skillConfig.RequireTalentSeries();
|
| | | if (GetSeriesPoint(talentConfig.type, requireSeries) < requireSeriesPoint)
|
| | | {
|
| | | error = 3;
|
| | |
| | | return true;
|
| | | }
|
| | |
|
| | | public void ProcessLevelUpError(int error)
|
| | | public void ProcessLevelUpError(int talentId, int error)
|
| | | {
|
| | | switch (error)
|
| | | {
|
| | | case 1:
|
| | | SysNotifyMgr.Instance.ShowTip("TalentHighestLevel");
|
| | | break;
|
| | | case 2:
|
| | | SysNotifyMgr.Instance.ShowTip("LackTalentPoint");
|
| | | break;
|
| | | case 3:
|
| | | SysNotifyMgr.Instance.ShowTip("LackTalentSeriesPoint");
|
| | | break;
|
| | | case 4:
|
| | | SysNotifyMgr.Instance.ShowTip("PreTalentLevelLimit");
|
| | | break;
|
| | | }
|
| | | }
|
| | |
|
| | | #region 服务端数据
|
| | | public int talentPoint { get; private set; }
|
| | | public int talentPoint { get { return PlayerDatas.Instance.extersion.talentPoint; } }
|
| | |
|
| | | public void UpdateTalent()
|
| | | private void PlayerDataRefreshInfoEvent(PlayerDataRefresh refreshType)
|
| | | {
|
| | |
|
| | | UpdateRedpoint();
|
| | | if (refreshType == PlayerDataRefresh.CDBPlayerRefresh_TalentPoint)
|
| | | {
|
| | | if (talentPointUpdate != null)
|
| | | {
|
| | | talentPointUpdate();
|
| | | }
|
| | | UpdateRedpoint();
|
| | | }
|
| | | }
|
| | |
|
| | | public void UpdateTalentSkill(int _oldSkillId, int _newSkillId)
|
| | | {
|
| | | var config = Config.Instance.Get<SkillConfig>(_newSkillId);
|
| | | if (config == null)
|
| | | {
|
| | | return;
|
| | | }
|
| | | if (talentSkills.ContainsKey(config.SkillTypeID))
|
| | | {
|
| | | var talentSkill = talentSkills[config.SkillTypeID];
|
| | | talentSkill.level = config.SkillLV;
|
| | | if (talentSkillUpdate != null)
|
| | | {
|
| | | talentSkillUpdate(config.SkillTypeID);
|
| | | }
|
| | | }
|
| | | }
|
| | |
|
| | | public void DeleteTalentSkill(int _skillId)
|
| | | {
|
| | | var config = Config.Instance.Get<SkillConfig>(_skillId);
|
| | | if (config == null)
|
| | | {
|
| | | return;
|
| | | }
|
| | | if (talentSkills.ContainsKey(config.SkillTypeID))
|
| | | {
|
| | | var talentSkill = talentSkills[config.SkillTypeID];
|
| | | talentSkill.level = 0;
|
| | | if (talentSkillUpdate != null)
|
| | | {
|
| | | talentSkillUpdate(config.SkillTypeID);
|
| | |
| | |
|
| | | public static class TalentHelper
|
| | | {
|
| | | public static int RequireSeries(this SkillConfig config)
|
| | | public static int RequireTalentSeries(this SkillConfig config)
|
| | | {
|
| | | if (config == null)
|
| | | {
|
| | |
| | | return config.LearnSkillPointReq / 10000;
|
| | | }
|
| | |
|
| | | public static int RequireSeriesPoint(this SkillConfig config)
|
| | | public static int RequireTalentSeriesPoint(this SkillConfig config)
|
| | | {
|
| | | if (config == null)
|
| | | {
|