Elin Modding Docs Doc
Loading...
Searching...
No Matches
LayerFaith.cs
1using System;
2using System.Collections.Generic;
3using DG.Tweening;
4using DG.Tweening.Core;
5using DG.Tweening.Plugins.Options;
6using UnityEngine;
7using UnityEngine.UI;
8
9// Token: 0x02000545 RID: 1349
10public class LayerFaith : ELayer
11{
12 // Token: 0x060024A6 RID: 9382 RVA: 0x000CE8BC File Offset: 0x000CCABC
13 public void Activate(Religion r, Action<Religion> _onWorship)
14 {
15 this.onWorship = _onWorship;
16 if (r == null)
17 {
18 foreach (Religion religion in ELayer.game.religions.list)
19 {
20 if (!religion.IsMinorGod)
21 {
22 this.AddReligion(religion);
23 }
24 }
25 this.isBranchFaith = true;
26 }
27 else
28 {
29 this.AddReligion(r);
30 }
31 TweenUtil.Tween(this.startDelay, new Action(this.RefreshSlots), null);
32 SE.Play("zoomIn");
33 }
34
35 // Token: 0x060024A7 RID: 9383 RVA: 0x000CE960 File Offset: 0x000CCB60
36 private void Update()
37 {
38 if (EInput.wheel != 0)
39 {
40 this.Move((EInput.wheel > 0) ? 1 : -1);
41 }
42 }
43
44 // Token: 0x060024A8 RID: 9384 RVA: 0x000CE97C File Offset: 0x000CCB7C
45 public void Move(int a)
46 {
47 this.index += a;
48 if (this.index >= this.items.Count)
49 {
50 this.index = 0;
51 }
52 else if (this.index < 0)
53 {
54 this.index = this.items.Count - 1;
55 }
56 this.RefreshSlots();
57 SE.Play("zoomOut");
58 }
59
60 // Token: 0x060024A9 RID: 9385 RVA: 0x000CE9E0 File Offset: 0x000CCBE0
61 public void RefreshSlots()
62 {
63 this.orders.Clear();
64 int num = this.index;
65 for (int i = 0; i < this.items.Count; i++)
66 {
67 if (num >= this.items.Count)
68 {
69 num = 0;
70 }
71 this.orders.Add(this.items[num]);
72 num++;
73 }
74 for (int j = 0; j < this.items.Count; j++)
75 {
76 LayerFaith.Slot slot = (j >= this.slots.Count) ? this.slotVoid : this.slots[j];
77 UIItem item = this.orders[j];
78 bool flag = j == 2;
79 if (this.items.Count == 1)
80 {
81 flag = true;
82 slot = this.slots[2];
83 }
84 item.button1.icon.raycastTarget = !flag;
85 if (j == 1)
86 {
87 item.button1.SetOnClick(delegate
88 {
89 this.Move(-1);
90 });
91 }
92 if (j == 3)
93 {
94 item.button1.SetOnClick(delegate
95 {
96 this.Move(1);
97 });
98 }
99 item.button2.SetOnClick(delegate
100 {
101 Religion religion = item.refObj as Religion;
102 if (religion.IsAvailable || !this.isBranchFaith)
103 {
104 this.Close();
105 this.onWorship(religion);
106 return;
107 }
108 SE.Beep();
109 });
110 item.button3.SetOnClick(delegate
111 {
112 this.Close();
113 });
114 item.button2.GetComponent<CanvasGroup>().DOFade(flag ? 1f : 0f, this.time).SetEase(slot.ease);
115 item.button3.GetComponent<CanvasGroup>().DOFade(flag ? 1f : 0f, this.time).SetEase(slot.ease);
116 item.text1.DOFade(flag ? 1f : 0f, this.time).SetEase(slot.ease);
117 item.text3.DOFade(flag ? 1f : 0f, this.time).SetEase(slot.ease);
118 item.image2.DOFade(flag ? this.bgAlpha : 0f, this.time).SetEase(slot.ease);
119 item.Rect().DOAnchorPos(slot.position, this.time, false).SetEase(slot.ease);
120 item.Rect().DOScale(slot.scale, this.time).SetEase(slot.ease);
121 item.GetComponent<CanvasGroup>().DOFade(slot.alpha, this.time).SetEase(slot.ease);
122 }
123 }
124
125 // Token: 0x060024AA RID: 9386 RVA: 0x000CECE0 File Offset: 0x000CCEE0
126 public void AddReligion(Religion r)
127 {
128 UIItem uiitem = Util.Instantiate<UIItem>(this.moldItem, this.layout);
129 uiitem.text1.SetText(r.source.GetDetail());
130 uiitem.text2.SetText(r.Name);
131 uiitem.button1.icon.sprite = Resources.Load<Sprite>("Media/Graphics/Image/Faction/" + r.source.id);
132 if (this.isBranchFaith && !r.IsAvailable)
133 {
134 uiitem.button2.mainText.SetText("faithUnavailable".lang());
135 }
136 uiitem.refObj = r;
137 this.items.Add(uiitem);
138 uiitem.Rect().anchoredPosition = this.startPos;
139 }
140
141 // Token: 0x04001419 RID: 5145
142 public Vector2 startPos;
143
144 // Token: 0x0400141A RID: 5146
145 public float time;
146
147 // Token: 0x0400141B RID: 5147
148 public float bgAlpha;
149
150 // Token: 0x0400141C RID: 5148
151 public float startDelay;
152
153 // Token: 0x0400141D RID: 5149
154 public LayerFaith.Slot slotVoid;
155
156 // Token: 0x0400141E RID: 5150
157 public List<LayerFaith.Slot> slots;
158
159 // Token: 0x0400141F RID: 5151
160 public UIItem moldItem;
161
162 // Token: 0x04001420 RID: 5152
163 public LayoutGroup layout;
164
165 // Token: 0x04001421 RID: 5153
166 public Action<Religion> onWorship;
167
168 // Token: 0x04001422 RID: 5154
169 [NonSerialized]
170 public bool isBranchFaith;
171
172 // Token: 0x04001423 RID: 5155
173 [NonSerialized]
174 public int index;
175
176 // Token: 0x04001424 RID: 5156
177 [NonSerialized]
178 public List<UIItem> items = new List<UIItem>();
179
180 // Token: 0x04001425 RID: 5157
181 [NonSerialized]
182 public List<UIItem> orders = new List<UIItem>();
183
184 // Token: 0x02000A63 RID: 2659
185 [Serializable]
186 public class Slot
187 {
188 // Token: 0x04002A93 RID: 10899
189 public float scale;
190
191 // Token: 0x04002A94 RID: 10900
192 public float alpha;
193
194 // Token: 0x04002A95 RID: 10901
195 public Vector2 position;
196
197 // Token: 0x04002A96 RID: 10902
198 public Ease ease;
199 }
200}