Elin Decompiled Documentation EA 23.102 Nightly
Loading...
Searching...
No Matches
LayerGacha.cs
Go to the documentation of this file.
1using DG.Tweening;
2using UnityEngine;
3
4public class LayerGacha : ELayer
5{
6 public static GameObject slot;
7
8 public GameObject goFree;
9
10 public Color colorC;
11
12 public Color colorR;
13
14 public Color colorSR;
15
17
18 public Color colorLE;
19
20 public DOTweenAnimation[] randomAnimes;
21
22 public bool alt;
23
25
26 public override void OnAfterInit()
27 {
28 Msg.TalkHomeMemeber("layerGacha");
29 if (alt)
30 {
32 }
34 InvokeRepeating("RandomAnime", 2f, 2f);
35 }
36
37 private void RandomAnime()
38 {
39 randomAnimes.RandomItem().DORestart();
40 }
41
42 public void OnClickGoldGacha(int num)
43 {
44 PlayGacha(gold: true, num);
45 }
46
47 public void OnClickSilverGacha(int num)
48 {
49 PlayGacha(gold: false, num);
50 }
51
52 public void PlayGacha(bool gold, int num)
53 {
54 Thing thing = null;
55 if (ELayer.player.dailyGacha && !gold && num == 1)
56 {
57 ELayer.player.dailyGacha = false;
58 }
59 else
60 {
61 thing = ELayer.pc.things.Find("gacha_coin", gold ? "gold" : "silver");
62 if (thing == null || thing.Num < num)
63 {
64 SE.Beep();
65 return;
66 }
67 thing.ModNum(-num);
68 }
70 Dialog d = Layer.Create("DialogGacha") as Dialog;
71 d.windows[0].setting.textCaption = "confirm".lang();
72 d.note.AddPrefab("Media/Graphics/Image/IllustGacha");
73 d.note.Space();
74 bool lose = true;
75 for (int i = 0; i < num; i++)
76 {
77 int num2 = 1;
78 if (ELayer.rnd(6) == 0)
79 {
80 num2 = 2;
81 }
82 if (ELayer.rnd(30) == 0)
83 {
84 num2 = 3;
85 }
86 if (ELayer.rnd(100) == 0)
87 {
88 num2 = 4;
89 }
90 if (ELayer.rnd(1000) == 0)
91 {
92 num2 = 5;
93 }
94 if (gold)
95 {
96 num2++;
97 }
98 if (i == 9)
99 {
100 if (gold)
101 {
102 if (num2 < 4)
103 {
104 num2 = 4;
105 }
106 }
107 else if (num2 < 3)
108 {
109 num2 = 3;
110 }
111 }
112 if (num2 > 5)
113 {
114 num2 = 5;
115 }
117 int rarity = item.Source.rarity;
118 if (rarity == 4 || rarity == 5)
119 {
120 lose = false;
121 }
122 d.note.AddText(null, item.Name(1), ELayer.Colors.GetRarityColor(rarity));
123 }
124 d.note.Space();
125 if (thing == null)
126 {
127 d.note.AddText("dailyGacha".lang() + " 1 > 0");
128 }
129 else
130 {
131 d.note.AddText(thing.NameSimple + " " + (thing.Num + num) + " > " + thing.Num);
132 }
133 d.note.Build();
134 d.windows[0].Find<Transform>("GachaAnime").SetActive(enable: true);
135 d.list.AddButton(null, Lang.Get("ok"), delegate
136 {
137 d.Close();
138 });
139 ELayer.ui.AddLayer(d);
140 ELayer.Sound.Play("gacha");
141 TweenUtil.Delay(0.5f, delegate
142 {
143 ELayer.Sound.Play(lose ? "gacha_lose" : "gacha_win");
144 });
145 d.SetOnKill(delegate
146 {
147 if (!lose)
148 {
149 Msg.TalkHomeMemeber("ding_other");
150 }
151 });
152 }
153
154 public void RefreshCoin()
155 {
156 goFree.SetActive(ELayer.player.dailyGacha);
157 listCoin.Clear();
158 listCoin.callbacks = new UIList.Callback<Thing, ButtonGrid>
159 {
160 onInstantiate = delegate(Thing a, ButtonGrid b)
161 {
162 b.SetCard(a);
163 },
164 onClick = delegate(Thing a, ButtonGrid b)
165 {
166 ELayer.ui.AddLayer<LayerInfo>().Set(a);
167 }
168 };
170 }
171
172 public void OnClickBuyCoin()
173 {
174 SE.Beep();
175 }
176
177 public override void OnKill()
178 {
179 if (alt)
180 {
182 }
183 }
184}
static ActionMode DefaultMode
Definition: ActionMode.cs:7
void Activate(bool toggle=true, bool forceActivate=false)
Definition: ActionMode.cs:339
static AM_NoMap NoMap
Definition: ActionMode.cs:25
void SetCard(Card c, Mode mode=Mode.Default, Action< UINote > onWriteNote=null)
Definition: ButtonGrid.cs:184
ThingContainer things
Definition: Card.cs:34
string NameSimple
Definition: Card.cs:2015
int Num
Definition: Card.cs:154
void ModNum(int a, bool notify=true)
Definition: Card.cs:3262
Color GetRarityColor(int r, bool light=false)
Definition: Dialog.cs:7
UINote note
Definition: Dialog.cs:23
UIButtonList list
Definition: Dialog.cs:25
Definition: ELayer.cs:4
static Chara pc
Definition: ELayer.cs:15
static Player player
Definition: ELayer.cs:13
static int rnd(int a)
Definition: ELayer.cs:49
static ColorProfile Colors
Definition: ELayer.cs:35
static UI ui
Definition: ELayer.cs:21
static SoundManager Sound
Definition: ELayer.cs:41
Item AddRandom(int r, bool msg=true)
Definition: Hoard.cs:149
Definition: Lang.cs:6
static string Get(string id)
Definition: Lang.cs:91
GameObject goFree
Definition: LayerGacha.cs:8
Color colorR
Definition: LayerGacha.cs:12
override void OnAfterInit()
Definition: LayerGacha.cs:26
static GameObject slot
Definition: LayerGacha.cs:6
Color colorC
Definition: LayerGacha.cs:10
Color colorLE
Definition: LayerGacha.cs:18
void OnClickBuyCoin()
Definition: LayerGacha.cs:172
void RandomAnime()
Definition: LayerGacha.cs:37
void RefreshCoin()
Definition: LayerGacha.cs:154
void OnClickSilverGacha(int num)
Definition: LayerGacha.cs:47
DOTweenAnimation[] randomAnimes
Definition: LayerGacha.cs:20
Color colorSR
Definition: LayerGacha.cs:14
override void OnKill()
Definition: LayerGacha.cs:177
Color colorSSR
Definition: LayerGacha.cs:16
UIList listCoin
Definition: LayerGacha.cs:24
void PlayGacha(bool gold, int num)
Definition: LayerGacha.cs:52
bool alt
Definition: LayerGacha.cs:22
void OnClickGoldGacha(int num)
Definition: LayerGacha.cs:42
Definition: Layer.cs:9
List< Window > windows
Definition: Layer.cs:116
static Layer Create(string path)
Definition: Layer.cs:299
Layer SetOnKill(Action action)
Definition: Layer.cs:579
Definition: Msg.cs:5
static PopItem TalkHomeMemeber(string id)
Definition: Msg.cs:219
bool dailyGacha
Definition: Player.cs:778
Hoard hoard
Definition: Player.cs:892
Thing Find(int uid)
Definition: Thing.cs:8
void AddButton(object obj, string text, Action onClick, Action< UIButton > onInstantiate=null)
Definition: UIButtonList.cs:11
Definition: UIList.cs:9
override void Clear()
Definition: UIList.cs:349
virtual void Refresh(bool highlightLast=false)
Definition: UIList.cs:424
Transform AddPrefab(string path)
Definition: UINote.cs:218
UIItem AddText(string text, FontColor color=FontColor.DontChange)
Definition: UINote.cs:113
void Space(int sizeY=0, int sizeX=1)
Definition: UINote.cs:62
void Build()
Definition: UINote.cs:49