少年修仙传客户端代码仓库
client_linchunjie
2018-09-26 0ced6b94425308d2a672fb93e9d245906d1d4879
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
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using System;
#if UNITY_EDITOR
using UnityEditor;
#endif
namespace Snxxz.UI
{
    public class TalentTreeScriptable : ScriptableObject
    {
        [SerializeField] TalentTree talentTrees;
        [SerializeField] Vector2 m_ContentSizeDelta;
        [SerializeField] List<TalentElement> skillElements;
        [SerializeField] List<ArrowElement> arrowElements;
 
        public Vector2 contentSizeDelta
        {
            get { return m_ContentSizeDelta; }
        }
 
        public TalentElement GetTalentElement(int index)
        {
            if (skillElements != null && index < skillElements.Count)
            {
                return skillElements[index];
            }
            return default(TalentElement);
        }
 
#if UNITY_EDITOR
        public void ApplyTalentElement(int index,Vector3 _position)
        {
            if (index >= skillElements.Count)
            {
                skillElements.Add(new TalentElement()
                {
                    position = _position,
                });
            }
            else
            {
                skillElements[index] = new TalentElement()
                {
                    position = _position,
                };
            }
        }
 
        public void SyncElementsCount(int count)
        {
            if (count < skillElements.Count)
            {
                skillElements.RemoveRange(count, skillElements.Count - count);
            }
        }
#endif
 
        public bool Belong(int job, int talentType, int talentSeries)
        {
            return talentTrees.Belong(job, talentType, talentSeries);
        }
 
        [Serializable]
        public struct TalentTree
        {
            public int[] jobs;
            public int[] talentTypes;
            public int[] talentSeriess;
 
            public bool Belong(int job, int talentType, int talentSeries)
            {
                bool sameJob = false;
                for (int i = 0; i < jobs.Length; i++)
                {
                    if (jobs[i] == job)
                    {
                        sameJob = true;
                        break;
                    }
                }
                bool sameType = false;
                for (int i = 0; i < talentTypes.Length; i++)
                {
                    if (talentTypes[i] == talentType)
                    {
                        sameType = true;
                        break;
                    }
                }
                bool sameSeries = false;
                for (int i = 0; i < talentSeriess.Length; i++)
                {
                    if (talentSeriess[i] == talentSeries)
                    {
                        sameSeries = true;
                        break;
                    }
                }
                return sameJob && sameType && sameSeries;
            }
        }
 
        [Serializable]
        public struct TalentElement
        {
            public Vector3 position;
        }
 
        [Serializable]
        public struct ArrowElement
        {
            public Vector3 position;
            public Vector3 rotation;
            public Vector2 sizeDelta;
        }
    }
 
#if UNITY_EDITOR
    public class TalentTreeScriptableEditor : Editor
    {
        [MenuItem("策划工具/生成天赋配置文件")]
        static void BuildConfig()
        {
            TalentTreeScriptable config = CreateInstance<TalentTreeScriptable>();
            string _path = StringUtility.Contact("Assets/ResourcesOut/Refdata/ScriptableObject/SoTalentTree/",
                                          "SoTalentTree_",
                                          ".asset");
            AssetDatabase.CreateAsset(config, _path);
            AssetDatabase.Refresh();
            ProjectWindowUtil.ShowCreatedAsset(config);
        }
    }
#endif
}