少年修仙传客户端代码仓库
client_linchunjie
2018-09-25 46cc37e769add056423f5fc77ab650db83f453bb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using System;
using TableConfig;
using UnityEngine.UI;
 
namespace Snxxz.UI
{
    public class TalentTreeBehaviour : MonoBehaviour
    {
        [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)
        {
            return m_TalentTree.BelongToTalentTree(job, series, type);
        }
    }
 
    [Serializable]
    public struct TalentTree
    {
        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;
        }
    }
}