From 36a67fa54ddfa8638c3488d00bbcd2d87a076041 Mon Sep 17 00:00:00 2001
From: client_linchunjie <461730578@qq.com>
Date: 星期四, 20 九月 2018 17:29:16 +0800
Subject: [PATCH] 1871天赋功能

---
 System/Skill/TalentTreeBehaviour.cs |   92 +++++++++++++++++++++++++++++++++++++++-------
 1 files changed, 78 insertions(+), 14 deletions(-)

diff --git a/System/Skill/TalentTreeBehaviour.cs b/System/Skill/TalentTreeBehaviour.cs
index 857aca8..7d624ba 100644
--- a/System/Skill/TalentTreeBehaviour.cs
+++ b/System/Skill/TalentTreeBehaviour.cs
@@ -2,33 +2,97 @@
 using System.Collections.Generic;
 using UnityEngine;
 using System;
+using TableConfig;
+using UnityEngine.UI;
+
 namespace Snxxz.UI
 {
     public class TalentTreeBehaviour : MonoBehaviour
     {
-        [SerializeField] TalentTree[] talentTrees;
+        [SerializeField] TalentTree m_TalentTree;
+        [SerializeField] TalentSkillBehaviour[] m_TalentSkills;
+        [SerializeField] ScrollRect m_Scroller;
+        TalentModel model
+        {
+            get { return ModelCenter.Instance.GetModel<TalentModel>(); }
+        }
+
+        public int series { get; private set; }
+        public int talentType { get; private set; }
+
+        public virtual void Display(int series, int type)
+        {
+            this.series = series;
+            talentType = type;
+            DisplaySkills();
+            m_Scroller.verticalNormalizedPosition = 1;
+        }
+
+        void DisplaySkills()
+        {
+            var job = PlayerDatas.Instance.baseData.Job;
+            List<int> talentSkills;
+            model.TryGetTalents(job, series, talentType, out talentSkills);
+            for (int i = 0; i < m_TalentSkills.Length; i++)
+            {
+                m_TalentSkills[i].Dispose();
+                if (talentSkills != null && i < talentSkills.Count)
+                {
+                    m_TalentSkills[i].gameObject.SetActive(true);
+                    m_TalentSkills[i].Display(talentSkills[i]);
+                }
+                else
+                {
+                    m_TalentSkills[i].gameObject.SetActive(false);
+                }
+            }
+
+            model.selectSkill = talentSkills != null ? talentSkills[0] : 0;
+        }
+
+        public virtual void Dispose()
+        {
+
+        }
 
         public bool BelongToTalentTree(int job, int series, int type)
         {
-            for (int i = 0; i < talentTrees.Length; i++)
-            {
-                var talentTree = talentTrees[i];
-                if (talentTree.job == job && talentTree.series == series
-                    && talentTree.type == type)
-                {
-                    return true;
-                }
-            }
-            return false;
+            return m_TalentTree.BelongToTalentTree(job, series, type);
         }
     }
 
     [Serializable]
     public struct TalentTree
     {
-        public int job;
-        public int series;
-        public int type;
+        public int[] jobs;
+        public int[] series;
+        public int[] types;
+
+        public bool BelongToTalentTree(int job, int series, int type)
+        {
+            for (int i = 0; i < jobs.Length; i++)
+            {
+                if (jobs[i] != job)
+                {
+                    continue;
+                }
+                for (int k = 0; k < this.series.Length; k++)
+                {
+                    if (this.series[k] != series)
+                    {
+                        continue;
+                    }
+                    for (int q = 0; q < types.Length; q++)
+                    {
+                        if (types[q] == type)
+                        {
+                            return true;
+                        }
+                    }
+                }
+            }
+            return false;
+        }
     }
 }
 

--
Gitblit v1.8.0