Elin Decompiled Documentation EA 23.102 Nightly
Loading...
Searching...
No Matches
LayerFaith.cs
Go to the documentation of this file.
1using System;
2using System.Collections.Generic;
3using DG.Tweening;
4using UnityEngine;
5using UnityEngine.UI;
6
7public class LayerFaith : ELayer
8{
9 [Serializable]
10 public class Slot
11 {
12 public float scale;
13
14 public float alpha;
15
16 public Vector2 position;
17
18 public Ease ease;
19 }
20
21 public Vector2 startPos;
22
23 public float time;
24
25 public float bgAlpha;
26
27 public float startDelay;
28
29 public Slot slotVoid;
30
31 public List<Slot> slots;
32
34
35 public LayoutGroup layout;
36
37 public Action<Religion> onWorship;
38
39 [NonSerialized]
40 public bool isBranchFaith;
41
42 [NonSerialized]
43 public int index;
44
45 [NonSerialized]
46 public List<UIItem> items = new List<UIItem>();
47
48 [NonSerialized]
49 public List<UIItem> orders = new List<UIItem>();
50
51 public void Activate(Religion r, Action<Religion> _onWorship)
52 {
53 onWorship = _onWorship;
54 if (r == null)
55 {
57 {
58 if (!item.IsMinorGod)
59 {
61 }
62 }
63 isBranchFaith = true;
64 }
65 else
66 {
67 AddReligion(r);
68 }
69 TweenUtil.Tween(startDelay, RefreshSlots);
70 SE.Play("zoomIn");
71 }
72
73 private void Update()
74 {
75 if (EInput.wheel != 0)
76 {
77 Move((EInput.wheel > 0) ? 1 : (-1));
78 }
79 }
80
81 public void Move(int a)
82 {
83 index += a;
84 if (index >= items.Count)
85 {
86 index = 0;
87 }
88 else if (index < 0)
89 {
90 index = items.Count - 1;
91 }
93 SE.Play("zoomOut");
94 }
95
96 public void RefreshSlots()
97 {
98 orders.Clear();
99 int num = index;
100 for (int i = 0; i < items.Count; i++)
101 {
102 if (num >= items.Count)
103 {
104 num = 0;
105 }
106 orders.Add(items[num]);
107 num++;
108 }
109 for (int j = 0; j < items.Count; j++)
110 {
111 Slot slot = ((j >= slots.Count) ? slotVoid : slots[j]);
112 UIItem item = orders[j];
113 bool flag = j == 2;
114 if (items.Count == 1)
115 {
116 flag = true;
117 slot = slots[2];
118 }
119 item.button1.icon.raycastTarget = !flag;
120 if (j == 1)
121 {
122 item.button1.SetOnClick(delegate
123 {
124 Move(-1);
125 });
126 }
127 if (j == 3)
128 {
129 item.button1.SetOnClick(delegate
130 {
131 Move(1);
132 });
133 }
134 item.button2.SetOnClick(delegate
135 {
136 Religion religion = item.refObj as Religion;
137 if (religion.IsAvailable || !isBranchFaith)
138 {
139 Close();
141 }
142 else
143 {
144 SE.Beep();
145 }
146 });
147 item.button3.SetOnClick(delegate
148 {
149 Close();
150 });
151 item.button2.GetComponent<CanvasGroup>().DOFade(flag ? 1f : 0f, time).SetEase(slot.ease);
152 item.button3.GetComponent<CanvasGroup>().DOFade(flag ? 1f : 0f, time).SetEase(slot.ease);
153 item.text1.DOFade(flag ? 1f : 0f, time).SetEase(slot.ease);
154 item.text3.DOFade(flag ? 1f : 0f, time).SetEase(slot.ease);
155 item.image2.DOFade(flag ? bgAlpha : 0f, time).SetEase(slot.ease);
156 item.Rect().DOAnchorPos(slot.position, time).SetEase(slot.ease);
157 item.Rect().DOScale(slot.scale, time).SetEase(slot.ease);
158 item.GetComponent<CanvasGroup>().DOFade(slot.alpha, time).SetEase(slot.ease);
159 }
160 }
161
162 public void AddReligion(Religion r)
163 {
164 UIItem uIItem = Util.Instantiate(moldItem, layout);
165 uIItem.text1.SetText(r.source.GetDetail());
166 uIItem.text2.SetText(r.Name);
167 uIItem.button1.icon.sprite = Resources.Load<Sprite>("Media/Graphics/Image/Faction/" + r.source.id);
168 if (isBranchFaith && !r.IsAvailable)
169 {
170 uIItem.button2.mainText.SetText("faithUnavailable".lang());
171 }
172 uIItem.refObj = r;
173 items.Add(uIItem);
174 uIItem.Rect().anchoredPosition = startPos;
175 }
176}
Definition: EInput.cs:8
static int wheel
Definition: EInput.cs:289
Definition: ELayer.cs:4
static Game game
Definition: ELayer.cs:9
ReligionManager religions
Definition: Game.cs:158
Vector2 position
Definition: LayerFaith.cs:16
List< UIItem > orders
Definition: LayerFaith.cs:49
float time
Definition: LayerFaith.cs:23
List< UIItem > items
Definition: LayerFaith.cs:46
void RefreshSlots()
Definition: LayerFaith.cs:96
void Update()
Definition: LayerFaith.cs:73
bool isBranchFaith
Definition: LayerFaith.cs:40
float startDelay
Definition: LayerFaith.cs:27
Slot slotVoid
Definition: LayerFaith.cs:29
void Move(int a)
Definition: LayerFaith.cs:81
void AddReligion(Religion r)
Definition: LayerFaith.cs:162
LayoutGroup layout
Definition: LayerFaith.cs:35
Action< Religion > onWorship
Definition: LayerFaith.cs:37
void Activate(Religion r, Action< Religion > _onWorship)
Definition: LayerFaith.cs:51
List< Slot > slots
Definition: LayerFaith.cs:31
UIItem moldItem
Definition: LayerFaith.cs:33
float bgAlpha
Definition: LayerFaith.cs:25
Vector2 startPos
Definition: LayerFaith.cs:21
virtual void Close()
Definition: Layer.cs:463
List< Religion > list
string Name
Definition: Religion.cs:30
SourceReligion.Row source
Definition: Religion.cs:32
virtual bool IsAvailable
Definition: Religion.cs:28
UIText mainText
Definition: UIButton.cs:102
Definition: UIItem.cs:5
UIText text2
Definition: UIItem.cs:8
UIButton button2
Definition: UIItem.cs:20
UIText text1
Definition: UIItem.cs:6
void SetText(string s)
Definition: UIText.cs:159