Elin Decompiled Documentation EA 23.102 Nightly
Loading...
Searching...
No Matches
LayerGachaResult.cs
Go to the documentation of this file.
1using System.Collections.Generic;
2using UnityEngine.UI;
3
4public class LayerGachaResult : ELayer
5{
6 public enum Mode
7 {
9 }
10
11 public class Data
12 {
14
15 public int weight;
16 }
17
19
20 public LayoutGroup layout;
21
23
25
26 public Mode mode;
27
28 public List<ItemGachaResult> items = new List<ItemGachaResult>();
29
30 public void PlayGacha(int n, string id)
31 {
32 layout.DestroyChildren();
33 items.Clear();
34 for (int j = 0; j < n; j++)
35 {
36 Chara c = Draw(id.Split('_').LastItem());
37 ItemGachaResult itemGachaResult = Util.Instantiate(moldItem, layout);
38 itemGachaResult.SetChara(c, this);
39 items.Add(itemGachaResult);
40 }
42 Msg.Say("playedGacha", n.ToString() ?? "");
43 buttonGetAll.onClick.AddListener(delegate
44 {
45 ELayer.Sound.Play("good");
46 items.ForeachReverse(delegate(ItemGachaResult i)
47 {
48 i.Confirm(add: true);
49 });
50 });
51 buttonDumpAll.onClick.AddListener(delegate
52 {
53 ELayer.Sound.Play("pay");
54 items.ForeachReverse(delegate(ItemGachaResult i)
55 {
56 i.Confirm(add: false);
57 });
58 });
59 Refresh();
60 }
61
62 public static Chara Draw(string id = "citizen")
63 {
64 List<Data> list = new List<Data>();
65 int num = 0;
66 foreach (SourceChara.Row row in ELayer.sources.charas.rows)
67 {
68 switch (id)
69 {
70 case "citizen":
71 if (!row.gachaFilter.Contains("resident"))
72 {
73 continue;
74 }
75 break;
76 case "livestock":
77 if (!row.gachaFilter.Contains("livestock"))
78 {
79 continue;
80 }
81 break;
82 case "unique":
83 if (!row.gachaFilter.Contains("resident") || row.quality != 4)
84 {
85 continue;
86 }
87 break;
88 default:
89 if (!row.gachaFilter.Contains("resident") && !row.gachaFilter.Contains("livestock"))
90 {
91 continue;
92 }
93 break;
94 }
95 int num2 = ((row.chance <= 0) ? 1 : row.chance);
96 if (row.LV < 10)
97 {
98 num2 = num2 * 300 / 100;
99 }
100 else if (row.LV < 20)
101 {
102 num2 = num2 * 250 / 100;
103 }
104 else if (row.LV < 30)
105 {
106 num2 = num2 * 200 / 100;
107 }
108 else if (row.LV < 50)
109 {
110 num2 = num2 * 150 / 100;
111 }
112 list.Add(new Data
113 {
114 row = row,
115 weight = num2
116 });
117 num += num2;
118 }
119 int num3 = ELayer.rnd(num);
120 int num4 = 0;
121 Data data = list[0];
122 foreach (Data item in list)
123 {
124 num4 += item.weight;
125 if (num3 < num4)
126 {
127 data = item;
128 break;
129 }
130 }
131 return CharaGen.Create(data.row.id);
132 }
133
134 public void Refresh()
135 {
136 int num = 0;
137 foreach (ItemGachaResult item in items)
138 {
139 num += item.GetMedal();
140 }
141 buttonDumpAll.mainText.text = "dumpAll".lang(num.ToString() ?? "");
142 }
143}
ThingContainer things
Definition: Card.cs:34
static Chara Create(string id, int lv=-1)
Definition: CharaGen.cs:17
Definition: Chara.cs:10
Definition: ELayer.cs:4
static Chara pc
Definition: ELayer.cs:15
static SourceManager sources
Definition: ELayer.cs:37
static int rnd(int a)
Definition: ELayer.cs:49
static SoundManager Sound
Definition: ELayer.cs:41
void SetChara(Chara c, LayerGachaResult _layer)
void Confirm(bool add)
LayoutGroup layout
List< ItemGachaResult > items
static Chara Draw(string id="citizen")
void PlayGacha(int n, string id)
ItemGachaResult moldItem
Definition: Msg.cs:5
static string Say(string idLang, string ref1, string ref2=null, string ref3=null, string ref4=null)
Definition: Msg.cs:58
SourceChara charas
void AddCurrency(Card owner, string id, int a, SourceMaterial.Row mat=null)