net.dreditor.maps 0.1.6 → 0.1.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.attestation.p7m +0 -0
- package/CharacterMapMarkerUI.cs +94 -94
- package/CharacterMapMarkerUI.cs.meta +11 -11
- package/CharacterMapUITab.cs +171 -171
- package/CharacterMapUITab.cs.meta +11 -11
- package/ClearMapAreaData.cs +22 -22
- package/ClearMapAreaData.cs.meta +11 -11
- package/ClearMapInstanceData.cs +35 -35
- package/ClearMapInstanceData.cs.meta +11 -11
- package/ControlFastTravel.cs +56 -56
- package/ControlFastTravel.cs.meta +11 -11
- package/DREditor.Maps.asmdef +23 -23
- package/DREditor.Maps.asmdef.meta +7 -7
- package/DiscoverData.cs +22 -22
- package/DiscoverData.cs.meta +11 -11
- package/DiscoverableBase.cs +23 -23
- package/DiscoverableBase.cs.meta +11 -11
- package/FastTravelController.cs +35 -35
- package/FastTravelController.cs.meta +11 -11
- package/FastTravelData.cs +24 -24
- package/FastTravelData.cs.meta +11 -11
- package/FastTravelMarker.cs +106 -106
- package/FastTravelMarker.cs.meta +13 -13
- package/IDHolder.cs +46 -46
- package/IDHolder.cs.meta +11 -11
- package/IEntryLoader.cs +18 -18
- package/IEntryLoader.cs.meta +11 -11
- package/IMapManager.cs +26 -26
- package/IMapManager.cs.meta +11 -11
- package/IPlaceMarker.cs +25 -25
- package/IPlaceMarker.cs.meta +11 -11
- package/IPlaceOptionHolder.cs +52 -52
- package/IPlaceOptionHolder.cs.meta +11 -11
- package/MapAreaData.cs +52 -52
- package/MapAreaData.cs.meta +11 -11
- package/MapAreaEntry.cs +54 -54
- package/MapAreaEntry.cs.meta +11 -11
- package/MapAreaManager.cs +193 -193
- package/MapAreaManager.cs.meta +11 -11
- package/MapBaseData.cs +65 -65
- package/MapBaseData.cs.meta +11 -11
- package/MapData.cs +34 -34
- package/MapData.cs.meta +11 -11
- package/MapDatabase.cs +132 -132
- package/MapDatabase.cs.meta +11 -11
- package/MapEntry.cs +76 -76
- package/MapEntry.cs.meta +11 -11
- package/MapEntryChange.cs +320 -320
- package/MapEntryChange.cs.meta +11 -11
- package/MapEntryChanger.cs +44 -44
- package/MapEntryChanger.cs.meta +11 -11
- package/MapHoverSelector.cs +160 -160
- package/MapHoverSelector.cs.meta +11 -11
- package/MapManager.cs +287 -287
- package/MapManager.cs.meta +11 -11
- package/MapManagerBase.cs +259 -259
- package/MapManagerBase.cs.meta +11 -11
- package/MapMarkerSelectable.cs +70 -70
- package/MapMarkerSelectable.cs.meta +11 -11
- package/MapObjectiveData.cs +27 -27
- package/MapObjectiveData.cs.meta +11 -11
- package/MapSaveManager.cs +62 -62
- package/MapSaveManager.cs.meta +11 -11
- package/MapTabUIHandler.cs +97 -97
- package/MapTabUIHandler.cs.meta +11 -11
- package/MapUITab.cs +25 -25
- package/MapUITab.cs.meta +11 -11
- package/MapUtility.cs +182 -182
- package/MapUtility.cs.meta +11 -11
- package/MarkerData.cs +24 -24
- package/MarkerData.cs.meta +11 -11
- package/MarkerDatabase.cs +56 -56
- package/MarkerDatabase.cs.meta +11 -11
- package/MarkerUtility.cs +47 -47
- package/MarkerUtility.cs.meta +11 -11
- package/MarkerVessel.cs +37 -37
- package/MarkerVessel.cs.meta +11 -11
- package/PlaceData.cs +26 -26
- package/PlaceData.cs.meta +11 -11
- package/PlaceEntry.cs +82 -82
- package/PlaceEntry.cs.meta +11 -11
- package/PlaceManager.cs +292 -292
- package/PlaceManager.cs.meta +11 -11
- package/PlaceMapUITab.cs +202 -202
- package/PlaceMapUITab.cs.meta +11 -11
- package/{Samples → Samples~}/Clear_Map_Area_Data_Event.prefab +52 -52
- package/{Samples → Samples~}/Clear_Map_Area_Data_Event.prefab.meta +7 -7
- package/{Samples → Samples~}/Clear_Map_Instance_Data.prefab +56 -56
- package/{Samples → Samples~}/Clear_Map_Instance_Data.prefab.meta +7 -7
- package/{Samples → Samples~}/DRE_Map_UI.unity +461 -461
- package/{Samples → Samples~}/DRE_Map_UI.unity.meta +7 -7
- package/{Samples → Samples~}/Map_Entry_Changer.prefab +52 -52
- package/{Samples → Samples~}/Map_Entry_Changer.prefab.meta +7 -7
- package/{Samples → Samples~}/Map_Marker_Selectable_ETemplate.prefab +126 -126
- package/{Samples → Samples~}/Map_Marker_Selectable_ETemplate.prefab.meta +7 -7
- package/{Samples → Samples~}/Map_Tab_UI_Handler_Shell.prefab +134 -134
- package/{Samples → Samples~}/Map_Tab_UI_Handler_Shell.prefab.meta +7 -7
- package/{Samples → Samples~}/Map_Tab_UI_Handler_Template.prefab +404 -404
- package/{Samples → Samples~}/Map_Tab_UI_Handler_Template.prefab.meta +7 -7
- package/{Samples → Samples~}/Map_UI_Canvas_Shell.prefab +842 -842
- package/{Samples → Samples~}/Map_UI_Canvas_Shell.prefab.meta +7 -7
- package/{Samples → Samples~}/Map_UI_Canvas_Template.prefab +996 -996
- package/{Samples → Samples~}/Map_UI_Canvas_Template.prefab.meta +7 -7
- package/{Samples → Samples~}/Map_UI_Controls_ETemplate.prefab +538 -538
- package/{Samples → Samples~}/Map_UI_Controls_ETemplate.prefab.meta +7 -7
- package/{Samples → Samples~}/Map_UI_GO_FT_ETemplate.prefab +78 -78
- package/{Samples → Samples~}/Map_UI_GO_FT_ETemplate.prefab.meta +7 -7
- package/{Samples → Samples~}/Map_UI_Place_Place_Name_ETemplate.prefab +181 -181
- package/{Samples → Samples~}/Map_UI_Place_Place_Name_ETemplate.prefab.meta +7 -7
- package/{Samples → Samples~}/Map_UI_Place_Tab_Shell.prefab +57 -57
- package/{Samples → Samples~}/Map_UI_Place_Tab_Shell.prefab.meta +7 -7
- package/{Samples → Samples~}/Map_UI_Place_Tab_Template.prefab +806 -806
- package/{Samples → Samples~}/Map_UI_Place_Tab_Template.prefab.meta +7 -7
- package/{Samples → Samples~}/Map_UI_Place_Tab_UI_ETemplate.prefab +1265 -1265
- package/{Samples → Samples~}/Map_UI_Place_Tab_UI_ETemplate.prefab.meta +7 -7
- package/{Samples → Samples~}/Map_UI_Reticle_ETemplate.prefab +78 -78
- package/{Samples → Samples~}/Map_UI_Reticle_ETemplate.prefab.meta +7 -7
- package/{Samples → Samples~}/Map_UI_Student_Tab_Shell.prefab +267 -267
- package/{Samples → Samples~}/Map_UI_Student_Tab_Shell.prefab.meta +7 -7
- package/{Samples → Samples~}/Map_UI_Student_Tab_Template.prefab +544 -544
- package/{Samples → Samples~}/Map_UI_Student_Tab_Template.prefab.meta +7 -7
- package/{Samples → Samples~}/Map_UI_Student_Tab_UI_Shell.prefab +90 -90
- package/{Samples → Samples~}/Map_UI_Student_Tab_UI_Shell.prefab.meta +7 -7
- package/{Samples → Samples~}/Map_UI_Student_Tab_UI_Template.prefab +2031 -2031
- package/{Samples → Samples~}/Map_UI_Student_Tab_UI_Template.prefab.meta +7 -7
- package/{Samples → Samples~}/Map_UI_Title_ETemplate.prefab +672 -672
- package/{Samples → Samples~}/Map_UI_Title_ETemplate.prefab.meta +7 -7
- package/{Samples → Samples~}/Place_Template.prefab +200 -200
- package/{Samples → Samples~}/Place_Template.prefab.meta +7 -7
- package/package.json +45 -40
- package/package.json.meta +7 -7
- package/Samples.meta +0 -8
package/MapManagerBase.cs
CHANGED
|
@@ -1,260 +1,260 @@
|
|
|
1
|
-
//Author: Benjamin "Sweden" Jillson : Discord: sweden_gaming For Project Eden's Garden
|
|
2
|
-
using DREditor.Services;
|
|
3
|
-
using System.Collections;
|
|
4
|
-
using TMPro;
|
|
5
|
-
using UnityEngine;
|
|
6
|
-
using UnityEngine.Events;
|
|
7
|
-
using UnityEngine.EventSystems;
|
|
8
|
-
using static UnityEngine.InputSystem.InputAction;
|
|
9
|
-
|
|
10
|
-
namespace DREditor.Maps
|
|
11
|
-
{
|
|
12
|
-
/// <summary>
|
|
13
|
-
///
|
|
14
|
-
/// </summary>
|
|
15
|
-
public abstract class MapManagerBase : ServiceHolder<IMapManager>, IMapManager
|
|
16
|
-
{
|
|
17
|
-
/// <summary>
|
|
18
|
-
///
|
|
19
|
-
/// </summary>
|
|
20
|
-
[Header("")]
|
|
21
|
-
[Divider]
|
|
22
|
-
[Tooltip("")]
|
|
23
|
-
[SerializeField] protected MapEntry InstanceData = null;
|
|
24
|
-
|
|
25
|
-
/// <summary>
|
|
26
|
-
///
|
|
27
|
-
/// </summary>
|
|
28
|
-
[Tooltip("")]
|
|
29
|
-
[SerializeField] protected GameObject areaGameObject = null;
|
|
30
|
-
|
|
31
|
-
/// <summary>
|
|
32
|
-
///
|
|
33
|
-
/// </summary>
|
|
34
|
-
[Tooltip("")]
|
|
35
|
-
[SerializeField] protected MapAreaManager currentAreaManager = null;
|
|
36
|
-
|
|
37
|
-
/// <summary>
|
|
38
|
-
///
|
|
39
|
-
/// </summary>
|
|
40
|
-
[Tooltip("")]
|
|
41
|
-
[SerializeField] protected int currentAreaIndex = 0;
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
/// <summary>
|
|
45
|
-
///
|
|
46
|
-
/// </summary>
|
|
47
|
-
[Header("")]
|
|
48
|
-
[Divider]
|
|
49
|
-
[Tooltip("")]
|
|
50
|
-
[SerializeField] protected MapDatabase mapDatabase = null;
|
|
51
|
-
|
|
52
|
-
/// <summary>
|
|
53
|
-
///
|
|
54
|
-
/// </summary>
|
|
55
|
-
[Tooltip("")]
|
|
56
|
-
[SerializeField] protected GameObject root = null;
|
|
57
|
-
|
|
58
|
-
/// <summary>
|
|
59
|
-
///
|
|
60
|
-
/// </summary>
|
|
61
|
-
[Tooltip("")]
|
|
62
|
-
[SerializeField] protected TextMeshProUGUI areaText = null;
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
[Header("")]
|
|
66
|
-
[SerializeField] protected UnityEvent onMapChanging = null;
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
/// <summary>
|
|
70
|
-
///
|
|
71
|
-
/// </summary>
|
|
72
|
-
protected int shiftNumber = 0;
|
|
73
|
-
|
|
74
|
-
/// <summary>
|
|
75
|
-
///
|
|
76
|
-
/// </summary>
|
|
77
|
-
protected IPlaceOptionHolder placeOptionHolder;
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
protected virtual void Start() => placeOptionHolder = GetComponentInChildren<IPlaceOptionHolder>();
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
/// <summary>
|
|
84
|
-
///
|
|
85
|
-
/// </summary>
|
|
86
|
-
protected virtual void UpdateMapUI()
|
|
87
|
-
{
|
|
88
|
-
shiftNumber = 0;
|
|
89
|
-
|
|
90
|
-
if (currentAreaManager != null &&
|
|
91
|
-
currentAreaManager.Data.name == mapDatabase.ValidFloorList(InstanceData.UnlockedAreas)[currentAreaIndex].name)
|
|
92
|
-
return;
|
|
93
|
-
|
|
94
|
-
StopAllCoroutines();
|
|
95
|
-
|
|
96
|
-
onMapChanging?.Invoke();
|
|
97
|
-
|
|
98
|
-
StartCoroutine(UpdateMapArea());
|
|
99
|
-
}
|
|
100
|
-
|
|
101
|
-
/// <summary>
|
|
102
|
-
///
|
|
103
|
-
/// </summary>
|
|
104
|
-
protected virtual IEnumerator UpdateMapArea()
|
|
105
|
-
{
|
|
106
|
-
DestroyAreaUI();
|
|
107
|
-
|
|
108
|
-
yield return null;
|
|
109
|
-
|
|
110
|
-
SpawnLoadAreaUI();
|
|
111
|
-
|
|
112
|
-
yield return null;
|
|
113
|
-
|
|
114
|
-
PopulateMapUIText(0);
|
|
115
|
-
|
|
116
|
-
ServiceLocator.GetService<MapTabUIHandler>().InitializeTab();
|
|
117
|
-
|
|
118
|
-
if (ServiceLocator.GetService<MapTabUIHandler>().IsOnDefaultTab())
|
|
119
|
-
NavigateSelectVisual(new CallbackContext());
|
|
120
|
-
|
|
121
|
-
AnimateToHoveredPlace();
|
|
122
|
-
}
|
|
123
|
-
|
|
124
|
-
/// <summary>
|
|
125
|
-
///
|
|
126
|
-
/// </summary>
|
|
127
|
-
protected virtual void DestroyAreaUI()
|
|
128
|
-
{
|
|
129
|
-
if (areaGameObject != null)
|
|
130
|
-
Destroy(areaGameObject);
|
|
131
|
-
}
|
|
132
|
-
|
|
133
|
-
/// <summary>
|
|
134
|
-
///
|
|
135
|
-
/// </summary>
|
|
136
|
-
protected virtual void SpawnLoadAreaUI()
|
|
137
|
-
{
|
|
138
|
-
areaGameObject = Instantiate(mapDatabase.ValidFloorList(InstanceData.UnlockedAreas)[currentAreaIndex].prefab, root.transform);
|
|
139
|
-
|
|
140
|
-
if (areaGameObject == null)
|
|
141
|
-
return;
|
|
142
|
-
|
|
143
|
-
currentAreaManager = areaGameObject.GetComponent<MapAreaManager>();
|
|
144
|
-
|
|
145
|
-
currentAreaManager
|
|
146
|
-
.LoadEntry(InstanceData.GetAreaEntry(currentAreaManager.Data.name), InstanceData.UnlockedAreas);
|
|
147
|
-
}
|
|
148
|
-
|
|
149
|
-
/// <summary>
|
|
150
|
-
///
|
|
151
|
-
/// </summary>
|
|
152
|
-
/// <param name="shiftNum"></param>
|
|
153
|
-
protected virtual void PopulateMapUIText(int shiftNum)
|
|
154
|
-
{
|
|
155
|
-
areaText.text = currentAreaManager.Data.name;
|
|
156
|
-
|
|
157
|
-
var placeNames = currentAreaManager.GetNamesOfUnlockedPlaces(InstanceData.UnlockedAreas);
|
|
158
|
-
|
|
159
|
-
placeOptionHolder.PopulatePlaceUIText(shiftNum, placeNames);
|
|
160
|
-
}
|
|
161
|
-
|
|
162
|
-
/// <summary>
|
|
163
|
-
///
|
|
164
|
-
/// </summary>
|
|
165
|
-
/// <param name="ctx"></param>
|
|
166
|
-
protected void NavigateSelectVisual(CallbackContext ctx)
|
|
167
|
-
{
|
|
168
|
-
float vertical = ctx.ReadValue<Vector2>().y;
|
|
169
|
-
|
|
170
|
-
bool movingUp = IsMovingUp(vertical);
|
|
171
|
-
|
|
172
|
-
if (vertical == 0 && !movingUp)
|
|
173
|
-
return;
|
|
174
|
-
|
|
175
|
-
bool movingDown = IsMovingDown(vertical);
|
|
176
|
-
|
|
177
|
-
if (movingUp || movingDown)
|
|
178
|
-
ShiftThenHover(movingUp);
|
|
179
|
-
|
|
180
|
-
if (ServiceLocator.GetService<MapTabUIHandler>().IsOnDefaultTab())
|
|
181
|
-
AnimateToHoveredPlace();
|
|
182
|
-
}
|
|
183
|
-
|
|
184
|
-
/// <summary>
|
|
185
|
-
///
|
|
186
|
-
/// </summary>
|
|
187
|
-
/// <param name="vertical"></param>
|
|
188
|
-
/// <returns></returns>
|
|
189
|
-
protected virtual bool IsMovingUp(float vertical) =>
|
|
190
|
-
vertical > 0 &&
|
|
191
|
-
shiftNumber > 0 &&
|
|
192
|
-
EventSystem.current.currentSelectedGameObject == placeOptionHolder.GetTopOption();
|
|
193
|
-
|
|
194
|
-
/// <summary>
|
|
195
|
-
///
|
|
196
|
-
/// </summary>
|
|
197
|
-
/// <param name="vertical"></param>
|
|
198
|
-
/// <returns></returns>
|
|
199
|
-
protected virtual bool IsMovingDown(float vertical) =>
|
|
200
|
-
vertical < 0 &&
|
|
201
|
-
shiftNumber < placeOptionHolder.GetMaxShiftIndex() &&
|
|
202
|
-
EventSystem.current.currentSelectedGameObject == placeOptionHolder.GetBottomOption();
|
|
203
|
-
|
|
204
|
-
/// <summary>
|
|
205
|
-
///
|
|
206
|
-
/// </summary>
|
|
207
|
-
/// <param name="movingUp"></param>
|
|
208
|
-
protected virtual void ShiftThenHover(bool movingUp)
|
|
209
|
-
{
|
|
210
|
-
if (movingUp)
|
|
211
|
-
shiftNumber--;
|
|
212
|
-
else
|
|
213
|
-
shiftNumber++;
|
|
214
|
-
|
|
215
|
-
PopulateMapUIText(shiftNumber);
|
|
216
|
-
|
|
217
|
-
AnimateToHoveredPlace();
|
|
218
|
-
}
|
|
219
|
-
|
|
220
|
-
/// <summary>
|
|
221
|
-
///
|
|
222
|
-
/// </summary>
|
|
223
|
-
protected virtual void AnimateToHoveredPlace() => StartCoroutine(WaitForAreaLoaded());
|
|
224
|
-
|
|
225
|
-
/// <summary>
|
|
226
|
-
///
|
|
227
|
-
/// </summary>
|
|
228
|
-
protected virtual IEnumerator WaitForAreaLoaded()
|
|
229
|
-
{
|
|
230
|
-
yield return new WaitUntil(() => ServiceLocator.HasService<MapAreaManager>());
|
|
231
|
-
|
|
232
|
-
if (!ServiceLocator.HasService(out currentAreaManager))
|
|
233
|
-
yield break;
|
|
234
|
-
|
|
235
|
-
ServiceLocator.GetService<MapHoverSelector>().AnimateToHoveredPlace(placeOptionHolder.GetCurrentlyHoveredPlace());
|
|
236
|
-
}
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
/// <inheritdoc/>
|
|
240
|
-
public virtual MapEntry GetInstanceData() => InstanceData;
|
|
241
|
-
|
|
242
|
-
/// <inheritdoc/>
|
|
243
|
-
public virtual void SetInstanceData(MapEntry InstanceData) => this.InstanceData = InstanceData;
|
|
244
|
-
|
|
245
|
-
/// <inheritdoc/>
|
|
246
|
-
public virtual void AddUnlockedArea(string areaName)
|
|
247
|
-
{
|
|
248
|
-
MapAreaData areaData = mapDatabase.GetArea(areaName);
|
|
249
|
-
|
|
250
|
-
PlaceData placeData = mapDatabase.GetPlace(areaName);
|
|
251
|
-
|
|
252
|
-
if (areaData != null)
|
|
253
|
-
InstanceData.UnlockedAreas.Add(areaData.GetID());
|
|
254
|
-
else if (placeData != null)
|
|
255
|
-
InstanceData.UnlockedAreas.Add(placeData.GetID());
|
|
256
|
-
else
|
|
257
|
-
UnityEngine.Debug.LogWarning($"ALERT: {ToString()}: Couldn't find the area/place to unlock: " + areaName);
|
|
258
|
-
}
|
|
259
|
-
}
|
|
1
|
+
//Author: Benjamin "Sweden" Jillson : Discord: sweden_gaming For Project Eden's Garden
|
|
2
|
+
using DREditor.Services;
|
|
3
|
+
using System.Collections;
|
|
4
|
+
using TMPro;
|
|
5
|
+
using UnityEngine;
|
|
6
|
+
using UnityEngine.Events;
|
|
7
|
+
using UnityEngine.EventSystems;
|
|
8
|
+
using static UnityEngine.InputSystem.InputAction;
|
|
9
|
+
|
|
10
|
+
namespace DREditor.Maps
|
|
11
|
+
{
|
|
12
|
+
/// <summary>
|
|
13
|
+
///
|
|
14
|
+
/// </summary>
|
|
15
|
+
public abstract class MapManagerBase : ServiceHolder<IMapManager>, IMapManager
|
|
16
|
+
{
|
|
17
|
+
/// <summary>
|
|
18
|
+
///
|
|
19
|
+
/// </summary>
|
|
20
|
+
[Header("")]
|
|
21
|
+
[Divider]
|
|
22
|
+
[Tooltip("")]
|
|
23
|
+
[SerializeField] protected MapEntry InstanceData = null;
|
|
24
|
+
|
|
25
|
+
/// <summary>
|
|
26
|
+
///
|
|
27
|
+
/// </summary>
|
|
28
|
+
[Tooltip("")]
|
|
29
|
+
[SerializeField] protected GameObject areaGameObject = null;
|
|
30
|
+
|
|
31
|
+
/// <summary>
|
|
32
|
+
///
|
|
33
|
+
/// </summary>
|
|
34
|
+
[Tooltip("")]
|
|
35
|
+
[SerializeField] protected MapAreaManager currentAreaManager = null;
|
|
36
|
+
|
|
37
|
+
/// <summary>
|
|
38
|
+
///
|
|
39
|
+
/// </summary>
|
|
40
|
+
[Tooltip("")]
|
|
41
|
+
[SerializeField] protected int currentAreaIndex = 0;
|
|
42
|
+
|
|
43
|
+
|
|
44
|
+
/// <summary>
|
|
45
|
+
///
|
|
46
|
+
/// </summary>
|
|
47
|
+
[Header("")]
|
|
48
|
+
[Divider]
|
|
49
|
+
[Tooltip("")]
|
|
50
|
+
[SerializeField] protected MapDatabase mapDatabase = null;
|
|
51
|
+
|
|
52
|
+
/// <summary>
|
|
53
|
+
///
|
|
54
|
+
/// </summary>
|
|
55
|
+
[Tooltip("")]
|
|
56
|
+
[SerializeField] protected GameObject root = null;
|
|
57
|
+
|
|
58
|
+
/// <summary>
|
|
59
|
+
///
|
|
60
|
+
/// </summary>
|
|
61
|
+
[Tooltip("")]
|
|
62
|
+
[SerializeField] protected TextMeshProUGUI areaText = null;
|
|
63
|
+
|
|
64
|
+
|
|
65
|
+
[Header("")]
|
|
66
|
+
[SerializeField] protected UnityEvent onMapChanging = null;
|
|
67
|
+
|
|
68
|
+
|
|
69
|
+
/// <summary>
|
|
70
|
+
///
|
|
71
|
+
/// </summary>
|
|
72
|
+
protected int shiftNumber = 0;
|
|
73
|
+
|
|
74
|
+
/// <summary>
|
|
75
|
+
///
|
|
76
|
+
/// </summary>
|
|
77
|
+
protected IPlaceOptionHolder placeOptionHolder;
|
|
78
|
+
|
|
79
|
+
|
|
80
|
+
protected virtual void Start() => placeOptionHolder = GetComponentInChildren<IPlaceOptionHolder>();
|
|
81
|
+
|
|
82
|
+
|
|
83
|
+
/// <summary>
|
|
84
|
+
///
|
|
85
|
+
/// </summary>
|
|
86
|
+
protected virtual void UpdateMapUI()
|
|
87
|
+
{
|
|
88
|
+
shiftNumber = 0;
|
|
89
|
+
|
|
90
|
+
if (currentAreaManager != null &&
|
|
91
|
+
currentAreaManager.Data.name == mapDatabase.ValidFloorList(InstanceData.UnlockedAreas)[currentAreaIndex].name)
|
|
92
|
+
return;
|
|
93
|
+
|
|
94
|
+
StopAllCoroutines();
|
|
95
|
+
|
|
96
|
+
onMapChanging?.Invoke();
|
|
97
|
+
|
|
98
|
+
StartCoroutine(UpdateMapArea());
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
/// <summary>
|
|
102
|
+
///
|
|
103
|
+
/// </summary>
|
|
104
|
+
protected virtual IEnumerator UpdateMapArea()
|
|
105
|
+
{
|
|
106
|
+
DestroyAreaUI();
|
|
107
|
+
|
|
108
|
+
yield return null;
|
|
109
|
+
|
|
110
|
+
SpawnLoadAreaUI();
|
|
111
|
+
|
|
112
|
+
yield return null;
|
|
113
|
+
|
|
114
|
+
PopulateMapUIText(0);
|
|
115
|
+
|
|
116
|
+
ServiceLocator.GetService<MapTabUIHandler>().InitializeTab();
|
|
117
|
+
|
|
118
|
+
if (ServiceLocator.GetService<MapTabUIHandler>().IsOnDefaultTab())
|
|
119
|
+
NavigateSelectVisual(new CallbackContext());
|
|
120
|
+
|
|
121
|
+
AnimateToHoveredPlace();
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
/// <summary>
|
|
125
|
+
///
|
|
126
|
+
/// </summary>
|
|
127
|
+
protected virtual void DestroyAreaUI()
|
|
128
|
+
{
|
|
129
|
+
if (areaGameObject != null)
|
|
130
|
+
Destroy(areaGameObject);
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
/// <summary>
|
|
134
|
+
///
|
|
135
|
+
/// </summary>
|
|
136
|
+
protected virtual void SpawnLoadAreaUI()
|
|
137
|
+
{
|
|
138
|
+
areaGameObject = Instantiate(mapDatabase.ValidFloorList(InstanceData.UnlockedAreas)[currentAreaIndex].prefab, root.transform);
|
|
139
|
+
|
|
140
|
+
if (areaGameObject == null)
|
|
141
|
+
return;
|
|
142
|
+
|
|
143
|
+
currentAreaManager = areaGameObject.GetComponent<MapAreaManager>();
|
|
144
|
+
|
|
145
|
+
currentAreaManager
|
|
146
|
+
.LoadEntry(InstanceData.GetAreaEntry(currentAreaManager.Data.name), InstanceData.UnlockedAreas);
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
/// <summary>
|
|
150
|
+
///
|
|
151
|
+
/// </summary>
|
|
152
|
+
/// <param name="shiftNum"></param>
|
|
153
|
+
protected virtual void PopulateMapUIText(int shiftNum)
|
|
154
|
+
{
|
|
155
|
+
areaText.text = currentAreaManager.Data.name;
|
|
156
|
+
|
|
157
|
+
var placeNames = currentAreaManager.GetNamesOfUnlockedPlaces(InstanceData.UnlockedAreas);
|
|
158
|
+
|
|
159
|
+
placeOptionHolder.PopulatePlaceUIText(shiftNum, placeNames);
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
/// <summary>
|
|
163
|
+
///
|
|
164
|
+
/// </summary>
|
|
165
|
+
/// <param name="ctx"></param>
|
|
166
|
+
protected void NavigateSelectVisual(CallbackContext ctx)
|
|
167
|
+
{
|
|
168
|
+
float vertical = ctx.ReadValue<Vector2>().y;
|
|
169
|
+
|
|
170
|
+
bool movingUp = IsMovingUp(vertical);
|
|
171
|
+
|
|
172
|
+
if (vertical == 0 && !movingUp)
|
|
173
|
+
return;
|
|
174
|
+
|
|
175
|
+
bool movingDown = IsMovingDown(vertical);
|
|
176
|
+
|
|
177
|
+
if (movingUp || movingDown)
|
|
178
|
+
ShiftThenHover(movingUp);
|
|
179
|
+
|
|
180
|
+
if (ServiceLocator.GetService<MapTabUIHandler>().IsOnDefaultTab())
|
|
181
|
+
AnimateToHoveredPlace();
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
/// <summary>
|
|
185
|
+
///
|
|
186
|
+
/// </summary>
|
|
187
|
+
/// <param name="vertical"></param>
|
|
188
|
+
/// <returns></returns>
|
|
189
|
+
protected virtual bool IsMovingUp(float vertical) =>
|
|
190
|
+
vertical > 0 &&
|
|
191
|
+
shiftNumber > 0 &&
|
|
192
|
+
EventSystem.current.currentSelectedGameObject == placeOptionHolder.GetTopOption();
|
|
193
|
+
|
|
194
|
+
/// <summary>
|
|
195
|
+
///
|
|
196
|
+
/// </summary>
|
|
197
|
+
/// <param name="vertical"></param>
|
|
198
|
+
/// <returns></returns>
|
|
199
|
+
protected virtual bool IsMovingDown(float vertical) =>
|
|
200
|
+
vertical < 0 &&
|
|
201
|
+
shiftNumber < placeOptionHolder.GetMaxShiftIndex() &&
|
|
202
|
+
EventSystem.current.currentSelectedGameObject == placeOptionHolder.GetBottomOption();
|
|
203
|
+
|
|
204
|
+
/// <summary>
|
|
205
|
+
///
|
|
206
|
+
/// </summary>
|
|
207
|
+
/// <param name="movingUp"></param>
|
|
208
|
+
protected virtual void ShiftThenHover(bool movingUp)
|
|
209
|
+
{
|
|
210
|
+
if (movingUp)
|
|
211
|
+
shiftNumber--;
|
|
212
|
+
else
|
|
213
|
+
shiftNumber++;
|
|
214
|
+
|
|
215
|
+
PopulateMapUIText(shiftNumber);
|
|
216
|
+
|
|
217
|
+
AnimateToHoveredPlace();
|
|
218
|
+
}
|
|
219
|
+
|
|
220
|
+
/// <summary>
|
|
221
|
+
///
|
|
222
|
+
/// </summary>
|
|
223
|
+
protected virtual void AnimateToHoveredPlace() => StartCoroutine(WaitForAreaLoaded());
|
|
224
|
+
|
|
225
|
+
/// <summary>
|
|
226
|
+
///
|
|
227
|
+
/// </summary>
|
|
228
|
+
protected virtual IEnumerator WaitForAreaLoaded()
|
|
229
|
+
{
|
|
230
|
+
yield return new WaitUntil(() => ServiceLocator.HasService<MapAreaManager>());
|
|
231
|
+
|
|
232
|
+
if (!ServiceLocator.HasService(out currentAreaManager))
|
|
233
|
+
yield break;
|
|
234
|
+
|
|
235
|
+
ServiceLocator.GetService<MapHoverSelector>().AnimateToHoveredPlace(placeOptionHolder.GetCurrentlyHoveredPlace());
|
|
236
|
+
}
|
|
237
|
+
|
|
238
|
+
|
|
239
|
+
/// <inheritdoc/>
|
|
240
|
+
public virtual MapEntry GetInstanceData() => InstanceData;
|
|
241
|
+
|
|
242
|
+
/// <inheritdoc/>
|
|
243
|
+
public virtual void SetInstanceData(MapEntry InstanceData) => this.InstanceData = InstanceData;
|
|
244
|
+
|
|
245
|
+
/// <inheritdoc/>
|
|
246
|
+
public virtual void AddUnlockedArea(string areaName)
|
|
247
|
+
{
|
|
248
|
+
MapAreaData areaData = mapDatabase.GetArea(areaName);
|
|
249
|
+
|
|
250
|
+
PlaceData placeData = mapDatabase.GetPlace(areaName);
|
|
251
|
+
|
|
252
|
+
if (areaData != null)
|
|
253
|
+
InstanceData.UnlockedAreas.Add(areaData.GetID());
|
|
254
|
+
else if (placeData != null)
|
|
255
|
+
InstanceData.UnlockedAreas.Add(placeData.GetID());
|
|
256
|
+
else
|
|
257
|
+
UnityEngine.Debug.LogWarning($"ALERT: {ToString()}: Couldn't find the area/place to unlock: " + areaName);
|
|
258
|
+
}
|
|
259
|
+
}
|
|
260
260
|
}
|
package/MapManagerBase.cs.meta
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
fileFormatVersion: 2
|
|
2
|
-
guid: 7c5121726acf5974fba9c41771146992
|
|
3
|
-
MonoImporter:
|
|
4
|
-
externalObjects: {}
|
|
5
|
-
serializedVersion: 2
|
|
6
|
-
defaultReferences: []
|
|
7
|
-
executionOrder: 0
|
|
8
|
-
icon: {instanceID: 0}
|
|
9
|
-
userData:
|
|
10
|
-
assetBundleName:
|
|
11
|
-
assetBundleVariant:
|
|
1
|
+
fileFormatVersion: 2
|
|
2
|
+
guid: 7c5121726acf5974fba9c41771146992
|
|
3
|
+
MonoImporter:
|
|
4
|
+
externalObjects: {}
|
|
5
|
+
serializedVersion: 2
|
|
6
|
+
defaultReferences: []
|
|
7
|
+
executionOrder: 0
|
|
8
|
+
icon: {instanceID: 0}
|
|
9
|
+
userData:
|
|
10
|
+
assetBundleName:
|
|
11
|
+
assetBundleVariant:
|