Elin Modding Docs Doc
Loading...
Searching...
No Matches
LayerTravel.cs
1using System;
2using System.Collections.Generic;
3using CreativeSpore.SuperTilemapEditor;
4using DG.Tweening;
5using DG.Tweening.Core;
6using DG.Tweening.Plugins.Options;
7using UnityEngine;
8using UnityEngine.UI;
9
10// Token: 0x020005C5 RID: 1477
11public class LayerTravel : ELayer
12{
13 // Token: 0x17000BCA RID: 3018
14 // (get) Token: 0x0600287E RID: 10366 RVA: 0x000E5113 File Offset: 0x000E3313
15 public override bool blockWidgetClick
16 {
17 get
18 {
19 return false;
20 }
21 }
22
23 // Token: 0x0600287F RID: 10367 RVA: 0x000E5118 File Offset: 0x000E3318
24 public override void OnInit()
25 {
26 if (this.useZoom)
27 {
28 ELayer.screen.SetZoom(ELayer.screen.TargetZoom);
29 DOTween.To(() => ELayer.scene.screenElona.zoom, delegate(float x)
30 {
31 ELayer.scene.screenElona.zoom = x;
32 }, this.endZoom, this.timeZoom).SetEase(this.easeZoom);
33 }
34 if (this.useBG)
35 {
36 this.bg.DOFade(this.fadeAlpha, this.fadeTime).SetEase(this.easeFade);
37 ELayer.ui.layerFloat.SetActive(false);
38 }
39 }
40
41 // Token: 0x06002880 RID: 10368 RVA: 0x000E51D7 File Offset: 0x000E33D7
42 public override void OnKill()
43 {
44 if (this.useBG)
45 {
46 ELayer.ui.layerFloat.SetActive(true);
47 }
48 if (this.useZoom)
49 {
50 ELayer.screen.SetZoom(ELayer.screen.TargetZoom);
51 }
52 }
53
54 // Token: 0x06002881 RID: 10369 RVA: 0x000E520D File Offset: 0x000E340D
55 public override void OnSwitchContent(Window window)
56 {
57 this.Refresh();
58 }
59
60 // Token: 0x06002882 RID: 10370 RVA: 0x000E5215 File Offset: 0x000E3415
61 public int GetTravelFood(Zone z)
62 {
63 if (z.tempDist == 0)
64 {
65 return 0;
66 }
67 return 1 + this.GetTravelHours(z) / (12 + ELayer.pc.Evalue(407) / 2) / 2;
68 }
69
70 // Token: 0x06002883 RID: 10371 RVA: 0x000E5241 File Offset: 0x000E3441
71 public int GetTravelHours(Zone z)
72 {
73 return z.tempDist * 3;
74 }
75
76 // Token: 0x06002884 RID: 10372 RVA: 0x000E524B File Offset: 0x000E344B
77 public int GetSortVal(Zone z)
78 {
79 if (ELayer.pc.homeZone == z)
80 {
81 return -1;
82 }
83 return this.GetTravelHours(z);
84 }
85
86 // Token: 0x06002885 RID: 10373 RVA: 0x000E5264 File Offset: 0x000E3464
87 public void Refresh()
88 {
89 this.currentZone = ELayer.scene.elomap.GetZone(ELayer.pc.pos);
90 if (this.currentZone != null && !this.currentZone.isKnown)
91 {
92 this.currentZone = null;
93 }
94 this.list.callbacks = new UIList.Callback<Zone, UIButton>
95 {
96 onInstantiate = delegate(Zone a, UIButton b)
97 {
98 string text = "travelZone".lang(a.Name, a.tempDist.ToString() ?? "", null, null, null);
99 if (a == ELayer.pc.homeZone)
100 {
101 text = "travelHome".lang() + text;
102 }
103 if (a.isRandomSite)
104 {
105 text += string.Concat(new string[]
106 {
107 " (",
108 "days1".lang(),
109 (ELayer.world.date.GetRemainingHours(a.dateExpire) / 24 + 1).ToString(),
110 "days2".lang(),
111 ")"
112 }).TagSize(13);
113 }
114 b.mainText.SetText(text);
115 b.icon.sprite = (TilemapUtils.GetOrCreateTileSprite(ELayer.scene.elomap.actor.tileset, a.icon, 0f) ?? b.icon.sprite);
116 b.icon.SetNativeSize();
117 b.refObj = a;
118 int travelFood = this.GetTravelFood(a);
119 int currency = ELayer.pc.GetCurrency("ration");
120 b.subText.SetText(travelFood.ToString() ?? "", (currency >= travelFood) ? FontColor.Good : FontColor.Bad);
121 b.subText2.SetText(Date.GetText2(this.GetTravelHours(a)));
122 },
123 onClick = delegate(Zone a, UIButton b)
124 {
125 if (a == this.currentZone)
126 {
127 this.Close();
128 ELayer.player.EnterLocalZone(false);
129 return;
130 }
131 if (!ELayer.pc.TryPay(this.GetTravelFood(a), "ration"))
132 {
133 return;
134 }
135 if (ELayer.pc.burden.GetPhase() >= 3)
136 {
137 Msg.Say("errorOverweightTravel");
138 this.Close();
139 return;
140 }
141 ELayer.player.distanceTravel = a.tempDist;
142 ELayer.player.dateTravel = ELayer.world.date.GetRaw(0);
143 foreach (UIList.ButtonPair buttonPair in this.list.buttons)
144 {
145 UIButton uibutton = buttonPair.component as UIButton;
146 if (uibutton && uibutton != b)
147 {
148 uibutton.GetComponent<CanvasGroup>().alpha = 0.5f;
149 }
150 }
151 float time = 0f;
152 int h = 0;
153 int maxHours = this.GetTravelHours(a);
154 ELayer.ui.AddLayer<LayerCover>().SetCondition(delegate(float delta)
155 {
156 time += delta;
157 if (time >= 0.035f)
158 {
159 time = 0f;
160 int h = h;
161 h++;
162 ELayer.world.date.AdvanceHour();
163 if (h >= maxHours)
164 {
165 this.Close();
166 ELayer.pc.MoveImmediate(a.RegionPos, true, true);
167 ELayer.player.lastZonePos = null;
168 ZoneTransition.EnterState state = (a.RegionEnterState == ZoneTransition.EnterState.Dir) ? ZoneTransition.DirToState(ELayer.pc.GetCurrentDir()) : a.RegionEnterState;
169 if (a is Zone_Lumiest)
170 {
171 state = ZoneTransition.EnterState.Right;
172 }
173 ELayer.pc.MoveZone(a, state);
174 return true;
175 }
176 }
177 return false;
178 });
179 },
180 onList = delegate(UIList.SortMode m)
181 {
182 List<Zone> list = ELayer.game.activeZone.Region.ListTravelZones(100);
183 list.Sort((Zone a, Zone b) => this.GetSortVal(a) - this.GetSortVal(b));
184 foreach (Zone o in list)
185 {
186 if (this.windows[0].idTab != 1)
187 {
188 this.list.Add(o);
189 }
190 }
191 }
192 };
193 this.list.List(false);
194 }
195
196 // Token: 0x040016B3 RID: 5811
197 public UIList list;
198
199 // Token: 0x040016B4 RID: 5812
200 public Zone currentZone;
201
202 // Token: 0x040016B5 RID: 5813
203 public Image bg;
204
205 // Token: 0x040016B6 RID: 5814
206 public float fadeAlpha;
207
208 // Token: 0x040016B7 RID: 5815
209 public float fadeTime;
210
211 // Token: 0x040016B8 RID: 5816
212 public Ease easeFade;
213
214 // Token: 0x040016B9 RID: 5817
215 public Ease easeZoom;
216
217 // Token: 0x040016BA RID: 5818
218 public float startZoom;
219
220 // Token: 0x040016BB RID: 5819
221 public float endZoom;
222
223 // Token: 0x040016BC RID: 5820
224 public float timeZoom;
225
226 // Token: 0x040016BD RID: 5821
227 public bool highlightZone;
228
229 // Token: 0x040016BE RID: 5822
230 public bool useBG;
231
232 // Token: 0x040016BF RID: 5823
233 public bool useZoom;
234
235 // Token: 0x040016C0 RID: 5824
236 private Point posHighlight = new Point();
237}
Definition Date.cs:6
Definition Msg.cs:7
Definition Point.cs:11
Definition Zone.cs:14