net.dreditor.minigames.nsd 0.1.6 → 0.1.7
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/DREditor.Minigames.NSD.asmdef +37 -37
- package/DREditor.Minigames.NSD.asmdef.meta +7 -7
- package/Editor/DREditor.Minigames.NSD.Editor.asmdef +23 -23
- package/Editor/DREditor.Minigames.NSD.Editor.asmdef.meta +7 -7
- package/Editor/MenuItemNSDUtility.cs +127 -127
- package/Editor/MenuItemNSDUtility.cs.meta +11 -11
- package/Editor/NSDBuilderEditor.cs +184 -184
- package/Editor/NSDBuilderEditor.cs.meta +11 -11
- package/Editor.meta +8 -8
- package/Managers/ManuallyRenderCamera.cs +39 -39
- package/Managers/ManuallyRenderCamera.cs.meta +11 -11
- package/Managers/NSDBuilder.cs +56 -56
- package/Managers/NSDBuilder.cs.meta +11 -11
- package/Managers/NSDBulletLoadAnimation.cs +339 -339
- package/Managers/NSDBulletLoadAnimation.cs.meta +11 -11
- package/Managers/NSDIntro.cs +257 -257
- package/Managers/NSDIntro.cs.meta +11 -11
- package/Managers/NSDManager.cs +121 -121
- package/Managers/NSDManager.cs.meta +11 -11
- package/Managers/NSDReticle.cs +233 -233
- package/Managers/NSDReticle.cs.meta +11 -11
- package/Managers/OverlayBlend.shader +55 -55
- package/Managers/OverlayBlend.shader.meta +10 -10
- package/Managers.meta +8 -8
- package/{Samples → Samples~}/Absorb_Bullet_Mode_Mechanic_Template.prefab +939 -939
- package/{Samples → Samples~}/Absorb_Bullet_Mode_Mechanic_Template.prefab.meta +7 -7
- package/{Samples → Samples~}/Animations/NSD_Reticle/NSDReticleHover.anim +179 -179
- package/{Samples → Samples~}/Animations/NSD_Reticle/NSDReticleHover.anim.meta +8 -8
- package/{Samples → Samples~}/Animations/NSD_Reticle/NSDReticleShow.anim +116 -116
- package/{Samples → Samples~}/Animations/NSD_Reticle/NSDReticleShow.anim.meta +8 -8
- package/{Samples → Samples~}/Animations/NSD_Reticle/NSDReticleSpin.anim +199 -199
- package/{Samples → Samples~}/Animations/NSD_Reticle/NSDReticleSpin.anim.meta +8 -8
- package/{Samples → Samples~}/Animations/NSD_Reticle/NSDUIRingLoop.anim +345 -345
- package/{Samples → Samples~}/Animations/NSD_Reticle/NSDUIRingLoop.anim.meta +8 -8
- package/{Samples → Samples~}/Animations/NSD_Reticle/Reticle.controller +835 -835
- package/{Samples → Samples~}/Animations/NSD_Reticle/Reticle.controller.meta +8 -8
- package/{Samples → Samples~}/Animations/NSD_Reticle.meta +8 -8
- package/{Samples → Samples~}/Animations/NSD_Selection/NSDSelectionPieces.anim +791 -791
- package/{Samples → Samples~}/Animations/NSD_Selection/NSDSelectionPieces.anim.meta +8 -8
- package/{Samples → Samples~}/Animations/NSD_Selection/Selection UI.controller +130 -130
- package/{Samples → Samples~}/Animations/NSD_Selection/Selection UI.controller.meta +8 -8
- package/{Samples → Samples~}/Animations/NSD_Selection.meta +8 -8
- package/{Samples → Samples~}/Animations.meta +8 -8
- package/{Samples → Samples~}/Bullet_Canvas_Shell.prefab +193 -193
- package/{Samples → Samples~}/Bullet_Canvas_Shell.prefab.meta +7 -7
- package/{Samples → Samples~}/Bullet_Canvas_Template.prefab +348 -348
- package/{Samples → Samples~}/Bullet_Canvas_Template.prefab.meta +7 -7
- package/{Samples → Samples~}/Bullet_Chamber_Shell.prefab +178 -178
- package/{Samples → Samples~}/Bullet_Chamber_Shell.prefab.meta +7 -7
- package/{Samples → Samples~}/Bullet_Chamber_Template.prefab +280 -280
- package/{Samples → Samples~}/Bullet_Chamber_Template.prefab.meta +7 -7
- package/{Samples → Samples~}/Bullet_UI_Parent_Shell.prefab +38 -38
- package/{Samples → Samples~}/Bullet_UI_Parent_Shell.prefab.meta +7 -7
- package/{Samples → Samples~}/Bullet_UI_Parent_Template.prefab +510 -510
- package/{Samples → Samples~}/Bullet_UI_Parent_Template.prefab.meta +7 -7
- package/{Samples → Samples~}/Can_Absorb_Condition.prefab +61 -61
- package/{Samples → Samples~}/Can_Absorb_Condition.prefab.meta +7 -7
- package/{Samples → Samples~}/Debate_Controls_UI_Condition.prefab +56 -56
- package/{Samples → Samples~}/Debate_Controls_UI_Condition.prefab.meta +7 -7
- package/{Samples → Samples~}/Debate_Text_Camera.prefab +125 -125
- package/{Samples → Samples~}/Debate_Text_Camera.prefab.meta +7 -7
- package/{Samples → Samples~}/Debate_Text_Texture.prefab +119 -119
- package/{Samples → Samples~}/Debate_Text_Texture.prefab.meta +7 -7
- package/{Samples → Samples~}/Firing_Bullet_Texture.prefab +75 -75
- package/{Samples → Samples~}/Firing_Bullet_Texture.prefab.meta +7 -7
- package/{Samples → Samples~}/Load_Bullet_ETemplate.prefab +343 -343
- package/{Samples → Samples~}/Load_Bullet_ETemplate.prefab.meta +7 -7
- package/{Samples → Samples~}/Loading_Bullet_Canvas_ETemplate.prefab +405 -405
- package/{Samples → Samples~}/Loading_Bullet_Canvas_ETemplate.prefab.meta +7 -7
- package/{Samples → Samples~}/NSDUICameraEnabled.asset +21 -21
- package/{Samples → Samples~}/NSDUICameraEnabled.asset.meta +8 -8
- package/{Samples → Samples~}/NSD_Controls_UI_Handler.prefab +168 -168
- package/{Samples → Samples~}/NSD_Controls_UI_Handler.prefab.meta +7 -7
- package/{Samples → Samples~}/NSD_Intro_Canvas_ETemplate.prefab +272 -272
- package/{Samples → Samples~}/NSD_Intro_Canvas_ETemplate.prefab.meta +7 -7
- package/{Samples → Samples~}/NSD_Intro_Shell.prefab +60 -60
- package/{Samples → Samples~}/NSD_Intro_Shell.prefab.meta +7 -7
- package/{Samples → Samples~}/NSD_Intro_Template.prefab +248 -248
- package/{Samples → Samples~}/NSD_Intro_Template.prefab.meta +7 -7
- package/{Samples → Samples~}/NSD_Line_Manager.prefab +271 -271
- package/{Samples → Samples~}/NSD_Line_Manager.prefab.meta +7 -7
- package/{Samples → Samples~}/NSD_Manager_Shell.prefab +313 -313
- package/{Samples → Samples~}/NSD_Manager_Shell.prefab.meta +7 -7
- package/{Samples → Samples~}/NSD_Manager_Template.prefab +2078 -2078
- package/{Samples → Samples~}/NSD_Manager_Template.prefab.meta +7 -7
- package/{Samples → Samples~}/NSD_Reticle_ETemplate.prefab +314 -314
- package/{Samples → Samples~}/NSD_Reticle_ETemplate.prefab.meta +7 -7
- package/{Samples → Samples~}/NSD_UI_Camera.prefab +158 -158
- package/{Samples → Samples~}/NSD_UI_Camera.prefab.meta +7 -7
- package/{Samples → Samples~}/NSD_UI_Canvas_Shell.prefab +481 -481
- package/{Samples → Samples~}/NSD_UI_Canvas_Shell.prefab.meta +7 -7
- package/{Samples → Samples~}/NSD_UI_Canvas_Template.prefab +603 -603
- package/{Samples → Samples~}/NSD_UI_Canvas_Template.prefab.meta +7 -7
- package/{Samples → Samples~}/NSD_UI_Texture.prefab +75 -75
- package/{Samples → Samples~}/NSD_UI_Texture.prefab.meta +7 -7
- package/{Samples → Samples~}/White Noise Triangle Shatter.asset +31 -31
- package/{Samples → Samples~}/White Noise Triangle Shatter.asset.meta +8 -8
- package/package.json +57 -52
- package/package.json.meta +7 -7
- package/Samples.meta +0 -8
|
@@ -1,340 +1,340 @@
|
|
|
1
|
-
//Author: Benjamin "Sweden" Jillson : Discord: sweden_gaming For Project Eden's Garden
|
|
2
|
-
#if DOTWEEN
|
|
3
|
-
using DG.Tweening;
|
|
4
|
-
#endif
|
|
5
|
-
using DREditor.Minigames.Debates;
|
|
6
|
-
using DREditor.Minigames.Debates.Cycling;
|
|
7
|
-
using DREditor.Investigations;
|
|
8
|
-
using DREditor.UIHandling;
|
|
9
|
-
using System.Collections;
|
|
10
|
-
using System.Collections.Generic;
|
|
11
|
-
using UnityEngine;
|
|
12
|
-
using UnityEngine.Events;
|
|
13
|
-
using UnityEngine.UI;
|
|
14
|
-
|
|
15
|
-
namespace DREditor.Minigames.NSD.Managers
|
|
16
|
-
{
|
|
17
|
-
/// <summary>
|
|
18
|
-
///
|
|
19
|
-
/// </summary>
|
|
20
|
-
[ClassHeader(nameof(UIVisibilityComponent) + ", " + nameof(IUIVisibility) + ", " + nameof(IBulletSendable) +
|
|
21
|
-
"\n\n")]
|
|
22
|
-
public class NSDBulletLoadAnimation : UIVisibilityComponent, IBulletSendable
|
|
23
|
-
{
|
|
24
|
-
/// <summary>
|
|
25
|
-
///
|
|
26
|
-
/// </summary>
|
|
27
|
-
[Tooltip("")]
|
|
28
|
-
[SerializeField] protected UIVisibilityComponent uiParent = null;
|
|
29
|
-
|
|
30
|
-
/// <summary>
|
|
31
|
-
///
|
|
32
|
-
/// </summary>
|
|
33
|
-
[Tooltip("")]
|
|
34
|
-
[SerializeField] protected float resolveBufferDuration = 0.3f;
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
/// <summary>
|
|
38
|
-
///
|
|
39
|
-
/// </summary>
|
|
40
|
-
[Header("")]
|
|
41
|
-
[Divider]
|
|
42
|
-
[Tooltip("")]
|
|
43
|
-
[SerializeField] protected Transform loadBulletParent = null;
|
|
44
|
-
|
|
45
|
-
/// <summary>
|
|
46
|
-
///
|
|
47
|
-
/// </summary>
|
|
48
|
-
[Tooltip("")]
|
|
49
|
-
[SerializeField] protected GameObject loadBulletPrefab = null;
|
|
50
|
-
|
|
51
|
-
/// <summary>
|
|
52
|
-
///
|
|
53
|
-
/// </summary>
|
|
54
|
-
[Tooltip("")]
|
|
55
|
-
[SerializeField] protected float bulletLoadSpeed = 0.3f;
|
|
56
|
-
|
|
57
|
-
/// <summary>
|
|
58
|
-
///
|
|
59
|
-
/// </summary>
|
|
60
|
-
[Tooltip("")]
|
|
61
|
-
[SerializeField] protected float bulletLoadSpeedMultiplier = 1.25f;
|
|
62
|
-
|
|
63
|
-
/// <summary>
|
|
64
|
-
///
|
|
65
|
-
/// </summary>
|
|
66
|
-
[Tooltip("")]
|
|
67
|
-
[SerializeField] protected Vector3 loadBulletParentPosition = Vector3.zero;
|
|
68
|
-
|
|
69
|
-
/// <summary>
|
|
70
|
-
///
|
|
71
|
-
/// </summary>
|
|
72
|
-
[Tooltip("")]
|
|
73
|
-
[SerializeField] protected Vector3 bulletObjectOffset = new(97, 8, 0);
|
|
74
|
-
|
|
75
|
-
/// <summary>
|
|
76
|
-
///
|
|
77
|
-
/// </summary>
|
|
78
|
-
[Tooltip("")]
|
|
79
|
-
[SerializeField] protected float doubleSpaceBetweenBullets = 66.7f;
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
/// <summary>
|
|
83
|
-
///
|
|
84
|
-
/// </summary>
|
|
85
|
-
[Header("")]
|
|
86
|
-
[Divider]
|
|
87
|
-
[Tooltip("")]
|
|
88
|
-
[SerializeField] protected Image chamberParent = null;
|
|
89
|
-
|
|
90
|
-
/// <summary>
|
|
91
|
-
///
|
|
92
|
-
/// </summary>
|
|
93
|
-
[Tooltip("")]
|
|
94
|
-
[SerializeField] protected float loadChamberZ = 66.1f;
|
|
95
|
-
|
|
96
|
-
/// <summary>
|
|
97
|
-
///
|
|
98
|
-
/// </summary>
|
|
99
|
-
[Tooltip("")]
|
|
100
|
-
[SerializeField] protected float postChamberZ = 80;
|
|
101
|
-
|
|
102
|
-
/// <summary>
|
|
103
|
-
///
|
|
104
|
-
/// </summary>
|
|
105
|
-
[Tooltip("")]
|
|
106
|
-
[SerializeField] protected float chamberRotateDuration = 2;
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
[Header("")]
|
|
110
|
-
[SerializeField] protected UnityEvent onBulletLoaded;
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
/// <summary>
|
|
114
|
-
///
|
|
115
|
-
/// </summary>
|
|
116
|
-
protected List<GameObject> bulletObjects = new();
|
|
117
|
-
|
|
118
|
-
/// <summary>
|
|
119
|
-
///
|
|
120
|
-
/// </summary>
|
|
121
|
-
protected List<TruthBullet> truthBullets = new();
|
|
122
|
-
|
|
123
|
-
/// <summary>
|
|
124
|
-
///
|
|
125
|
-
/// </summary>
|
|
126
|
-
protected Vector3[] bulletOGPos;
|
|
127
|
-
|
|
128
|
-
/// <summary>
|
|
129
|
-
///
|
|
130
|
-
/// </summary>
|
|
131
|
-
protected Vector3 originalChamberRotation;
|
|
132
|
-
|
|
133
|
-
/// <summary>
|
|
134
|
-
///
|
|
135
|
-
/// </summary>
|
|
136
|
-
protected bool finished = false;
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
/// <inheritdoc/>
|
|
140
|
-
public virtual void OnSentBullets(List<TruthBullet> bullets)
|
|
141
|
-
{
|
|
142
|
-
truthBullets = bullets;
|
|
143
|
-
|
|
144
|
-
Restart();
|
|
145
|
-
|
|
146
|
-
SetBulletParentPosition();
|
|
147
|
-
|
|
148
|
-
SpawnBullets();
|
|
149
|
-
}
|
|
150
|
-
|
|
151
|
-
/// <summary>
|
|
152
|
-
///
|
|
153
|
-
/// </summary>
|
|
154
|
-
protected virtual void Restart()
|
|
155
|
-
{
|
|
156
|
-
foreach (var bullet in bulletObjects)
|
|
157
|
-
Destroy(bullet);
|
|
158
|
-
|
|
159
|
-
bulletObjects.Clear();
|
|
160
|
-
}
|
|
161
|
-
|
|
162
|
-
/// <summary>
|
|
163
|
-
///
|
|
164
|
-
/// </summary>
|
|
165
|
-
protected virtual void SetBulletParentPosition()
|
|
166
|
-
{
|
|
167
|
-
loadBulletParent.transform.localPosition = loadBulletParentPosition;
|
|
168
|
-
|
|
169
|
-
if (truthBullets.Count == 1)
|
|
170
|
-
return;
|
|
171
|
-
|
|
172
|
-
Vector3 position = loadBulletParent.transform.localPosition;
|
|
173
|
-
|
|
174
|
-
float total = 0;
|
|
175
|
-
|
|
176
|
-
for (int i = 0; i < truthBullets.Count; i++)
|
|
177
|
-
if (i < truthBullets.Count - 1)
|
|
178
|
-
total += doubleSpaceBetweenBullets / 2;
|
|
179
|
-
|
|
180
|
-
position.y += total;
|
|
181
|
-
|
|
182
|
-
loadBulletParent.transform.localPosition = position;
|
|
183
|
-
}
|
|
184
|
-
|
|
185
|
-
/// <summary>
|
|
186
|
-
///
|
|
187
|
-
/// </summary>
|
|
188
|
-
protected virtual void SpawnBullets()
|
|
189
|
-
{
|
|
190
|
-
for (int i = 0; i < truthBullets.Count; i++)
|
|
191
|
-
bulletObjects.Add(Instantiate(loadBulletPrefab, loadBulletParent));
|
|
192
|
-
}
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
/// <inheritdoc/>
|
|
196
|
-
protected override void ShowUI() => StartCoroutine(LoadBulletAnimation());
|
|
197
|
-
|
|
198
|
-
/// <inheritdoc/>
|
|
199
|
-
protected override void HideUI() => StartCoroutine(LoadBulletAnimation());
|
|
200
|
-
|
|
201
|
-
/// <inheritdoc/>
|
|
202
|
-
protected override IEnumerator WaitForUIToComplete()
|
|
203
|
-
{
|
|
204
|
-
yield return new WaitUntil(() => finished);
|
|
205
|
-
|
|
206
|
-
Destroy(gameObject);
|
|
207
|
-
}
|
|
208
|
-
|
|
209
|
-
/// <summary>
|
|
210
|
-
///
|
|
211
|
-
/// </summary>
|
|
212
|
-
protected virtual IEnumerator LoadBulletAnimation()
|
|
213
|
-
{
|
|
214
|
-
ShowBulletTrails();
|
|
215
|
-
|
|
216
|
-
yield return uiParent.ShowTillComplete();
|
|
217
|
-
|
|
218
|
-
yield return ShowChamber();
|
|
219
|
-
|
|
220
|
-
yield return LoadBullets();
|
|
221
|
-
|
|
222
|
-
yield return PostChamberRotate();
|
|
223
|
-
|
|
224
|
-
yield return uiParent.HideTillComplete();
|
|
225
|
-
|
|
226
|
-
yield return new WaitForSeconds(resolveBufferDuration);
|
|
227
|
-
|
|
228
|
-
finished = true;
|
|
229
|
-
}
|
|
230
|
-
|
|
231
|
-
/// <summary>
|
|
232
|
-
///
|
|
233
|
-
/// </summary>
|
|
234
|
-
protected virtual IEnumerator ShowChamber()
|
|
235
|
-
{
|
|
236
|
-
originalChamberRotation = chamberParent.rectTransform.rotation.eulerAngles;
|
|
237
|
-
|
|
238
|
-
if (chamberParent.TryGetComponent<UIVisibilityComponent>(out var visibility))
|
|
239
|
-
yield return visibility.ShowTillComplete();
|
|
240
|
-
}
|
|
241
|
-
|
|
242
|
-
/// <summary>
|
|
243
|
-
///
|
|
244
|
-
/// </summary>
|
|
245
|
-
protected virtual void ShowBulletTrails()
|
|
246
|
-
{
|
|
247
|
-
for (int i = 0; i < truthBullets.Count; i++)
|
|
248
|
-
DisplayBulletTrails(i, true);
|
|
249
|
-
}
|
|
250
|
-
|
|
251
|
-
/// <summary>
|
|
252
|
-
///
|
|
253
|
-
/// </summary>
|
|
254
|
-
/// <param name="i"></param>
|
|
255
|
-
/// <param name="visible"></param>
|
|
256
|
-
protected virtual void DisplayBulletTrails(int i, bool visible)
|
|
257
|
-
{
|
|
258
|
-
if (bulletObjects[i].GetComponentInChildren<UIVisibilityComponent>() is UIVisibilityComponent bulletTrail)
|
|
259
|
-
if (visible)
|
|
260
|
-
bulletTrail.Show();
|
|
261
|
-
else
|
|
262
|
-
bulletTrail.Hide();
|
|
263
|
-
}
|
|
264
|
-
|
|
265
|
-
/// <summary>
|
|
266
|
-
///
|
|
267
|
-
/// </summary>
|
|
268
|
-
protected virtual IEnumerator LoadBullets()
|
|
269
|
-
{
|
|
270
|
-
bulletOGPos = new Vector3[truthBullets.Count];
|
|
271
|
-
|
|
272
|
-
for (int i = 0; i < truthBullets.Count; i++)
|
|
273
|
-
{
|
|
274
|
-
LoadBulletText(i);
|
|
275
|
-
|
|
276
|
-
LoadBulletTransform(i);
|
|
277
|
-
|
|
278
|
-
RotateChambers(loadChamberZ, bulletLoadSpeed);
|
|
279
|
-
|
|
280
|
-
DisplayBulletTrails(i, false);
|
|
281
|
-
|
|
282
|
-
onBulletLoaded?.Invoke();
|
|
283
|
-
|
|
284
|
-
yield return new WaitForSeconds(bulletLoadSpeed * bulletLoadSpeedMultiplier);
|
|
285
|
-
}
|
|
286
|
-
}
|
|
287
|
-
|
|
288
|
-
/// <summary>
|
|
289
|
-
///
|
|
290
|
-
/// </summary>
|
|
291
|
-
/// <param name="i"></param>
|
|
292
|
-
protected virtual void LoadBulletText(int i)
|
|
293
|
-
{
|
|
294
|
-
ICycleUITextComponent loadBullet = bulletObjects[i].GetComponentInChildren<ICycleUITextComponent>();
|
|
295
|
-
|
|
296
|
-
loadBullet?.UpdateBulletText(truthBullets[i].DisplayName);
|
|
297
|
-
}
|
|
298
|
-
|
|
299
|
-
/// <summary>
|
|
300
|
-
///
|
|
301
|
-
/// </summary>
|
|
302
|
-
/// <param name="i"></param>
|
|
303
|
-
protected virtual void LoadBulletTransform(int i)
|
|
304
|
-
{
|
|
305
|
-
bulletOGPos[i] = bulletObjects[i].GetComponent<RectTransform>().position;
|
|
306
|
-
#if DOTWEEN
|
|
307
|
-
bulletObjects[i].transform.DOMove(bulletOGPos[i] + bulletObjectOffset, bulletLoadSpeed);
|
|
308
|
-
#else
|
|
309
|
-
bulletObjects[i].transform.Translate(bulletOGPos[i] + bulletObjectOffset);
|
|
310
|
-
#endif
|
|
311
|
-
}
|
|
312
|
-
|
|
313
|
-
/// <summary>
|
|
314
|
-
///
|
|
315
|
-
/// </summary>
|
|
316
|
-
/// <param name="initialZMove"></param>
|
|
317
|
-
/// <param name="duration"></param>
|
|
318
|
-
protected virtual void RotateChambers(float initialZMove, float duration)
|
|
319
|
-
{
|
|
320
|
-
originalChamberRotation.z += initialZMove;
|
|
321
|
-
|
|
322
|
-
var originalQuaternion = Quaternion.Euler(originalChamberRotation);
|
|
323
|
-
#if DOTWEEN
|
|
324
|
-
chamberParent.transform.DORotateQuaternion(originalQuaternion, duration);
|
|
325
|
-
#else
|
|
326
|
-
chamberParent.transform.Rotate(originalQuaternion.eulerAngles);
|
|
327
|
-
#endif
|
|
328
|
-
}
|
|
329
|
-
|
|
330
|
-
/// <summary>
|
|
331
|
-
///
|
|
332
|
-
/// </summary>
|
|
333
|
-
protected virtual IEnumerator PostChamberRotate()
|
|
334
|
-
{
|
|
335
|
-
RotateChambers(postChamberZ, chamberRotateDuration);
|
|
336
|
-
|
|
337
|
-
yield return new WaitForSeconds(chamberRotateDuration);
|
|
338
|
-
}
|
|
339
|
-
}
|
|
1
|
+
//Author: Benjamin "Sweden" Jillson : Discord: sweden_gaming For Project Eden's Garden
|
|
2
|
+
#if DOTWEEN
|
|
3
|
+
using DG.Tweening;
|
|
4
|
+
#endif
|
|
5
|
+
using DREditor.Minigames.Debates;
|
|
6
|
+
using DREditor.Minigames.Debates.Cycling;
|
|
7
|
+
using DREditor.Investigations;
|
|
8
|
+
using DREditor.UIHandling;
|
|
9
|
+
using System.Collections;
|
|
10
|
+
using System.Collections.Generic;
|
|
11
|
+
using UnityEngine;
|
|
12
|
+
using UnityEngine.Events;
|
|
13
|
+
using UnityEngine.UI;
|
|
14
|
+
|
|
15
|
+
namespace DREditor.Minigames.NSD.Managers
|
|
16
|
+
{
|
|
17
|
+
/// <summary>
|
|
18
|
+
///
|
|
19
|
+
/// </summary>
|
|
20
|
+
[ClassHeader(nameof(UIVisibilityComponent) + ", " + nameof(IUIVisibility) + ", " + nameof(IBulletSendable) +
|
|
21
|
+
"\n\n")]
|
|
22
|
+
public class NSDBulletLoadAnimation : UIVisibilityComponent, IBulletSendable
|
|
23
|
+
{
|
|
24
|
+
/// <summary>
|
|
25
|
+
///
|
|
26
|
+
/// </summary>
|
|
27
|
+
[Tooltip("")]
|
|
28
|
+
[SerializeField] protected UIVisibilityComponent uiParent = null;
|
|
29
|
+
|
|
30
|
+
/// <summary>
|
|
31
|
+
///
|
|
32
|
+
/// </summary>
|
|
33
|
+
[Tooltip("")]
|
|
34
|
+
[SerializeField] protected float resolveBufferDuration = 0.3f;
|
|
35
|
+
|
|
36
|
+
|
|
37
|
+
/// <summary>
|
|
38
|
+
///
|
|
39
|
+
/// </summary>
|
|
40
|
+
[Header("")]
|
|
41
|
+
[Divider]
|
|
42
|
+
[Tooltip("")]
|
|
43
|
+
[SerializeField] protected Transform loadBulletParent = null;
|
|
44
|
+
|
|
45
|
+
/// <summary>
|
|
46
|
+
///
|
|
47
|
+
/// </summary>
|
|
48
|
+
[Tooltip("")]
|
|
49
|
+
[SerializeField] protected GameObject loadBulletPrefab = null;
|
|
50
|
+
|
|
51
|
+
/// <summary>
|
|
52
|
+
///
|
|
53
|
+
/// </summary>
|
|
54
|
+
[Tooltip("")]
|
|
55
|
+
[SerializeField] protected float bulletLoadSpeed = 0.3f;
|
|
56
|
+
|
|
57
|
+
/// <summary>
|
|
58
|
+
///
|
|
59
|
+
/// </summary>
|
|
60
|
+
[Tooltip("")]
|
|
61
|
+
[SerializeField] protected float bulletLoadSpeedMultiplier = 1.25f;
|
|
62
|
+
|
|
63
|
+
/// <summary>
|
|
64
|
+
///
|
|
65
|
+
/// </summary>
|
|
66
|
+
[Tooltip("")]
|
|
67
|
+
[SerializeField] protected Vector3 loadBulletParentPosition = Vector3.zero;
|
|
68
|
+
|
|
69
|
+
/// <summary>
|
|
70
|
+
///
|
|
71
|
+
/// </summary>
|
|
72
|
+
[Tooltip("")]
|
|
73
|
+
[SerializeField] protected Vector3 bulletObjectOffset = new(97, 8, 0);
|
|
74
|
+
|
|
75
|
+
/// <summary>
|
|
76
|
+
///
|
|
77
|
+
/// </summary>
|
|
78
|
+
[Tooltip("")]
|
|
79
|
+
[SerializeField] protected float doubleSpaceBetweenBullets = 66.7f;
|
|
80
|
+
|
|
81
|
+
|
|
82
|
+
/// <summary>
|
|
83
|
+
///
|
|
84
|
+
/// </summary>
|
|
85
|
+
[Header("")]
|
|
86
|
+
[Divider]
|
|
87
|
+
[Tooltip("")]
|
|
88
|
+
[SerializeField] protected Image chamberParent = null;
|
|
89
|
+
|
|
90
|
+
/// <summary>
|
|
91
|
+
///
|
|
92
|
+
/// </summary>
|
|
93
|
+
[Tooltip("")]
|
|
94
|
+
[SerializeField] protected float loadChamberZ = 66.1f;
|
|
95
|
+
|
|
96
|
+
/// <summary>
|
|
97
|
+
///
|
|
98
|
+
/// </summary>
|
|
99
|
+
[Tooltip("")]
|
|
100
|
+
[SerializeField] protected float postChamberZ = 80;
|
|
101
|
+
|
|
102
|
+
/// <summary>
|
|
103
|
+
///
|
|
104
|
+
/// </summary>
|
|
105
|
+
[Tooltip("")]
|
|
106
|
+
[SerializeField] protected float chamberRotateDuration = 2;
|
|
107
|
+
|
|
108
|
+
|
|
109
|
+
[Header("")]
|
|
110
|
+
[SerializeField] protected UnityEvent onBulletLoaded;
|
|
111
|
+
|
|
112
|
+
|
|
113
|
+
/// <summary>
|
|
114
|
+
///
|
|
115
|
+
/// </summary>
|
|
116
|
+
protected List<GameObject> bulletObjects = new();
|
|
117
|
+
|
|
118
|
+
/// <summary>
|
|
119
|
+
///
|
|
120
|
+
/// </summary>
|
|
121
|
+
protected List<TruthBullet> truthBullets = new();
|
|
122
|
+
|
|
123
|
+
/// <summary>
|
|
124
|
+
///
|
|
125
|
+
/// </summary>
|
|
126
|
+
protected Vector3[] bulletOGPos;
|
|
127
|
+
|
|
128
|
+
/// <summary>
|
|
129
|
+
///
|
|
130
|
+
/// </summary>
|
|
131
|
+
protected Vector3 originalChamberRotation;
|
|
132
|
+
|
|
133
|
+
/// <summary>
|
|
134
|
+
///
|
|
135
|
+
/// </summary>
|
|
136
|
+
protected bool finished = false;
|
|
137
|
+
|
|
138
|
+
|
|
139
|
+
/// <inheritdoc/>
|
|
140
|
+
public virtual void OnSentBullets(List<TruthBullet> bullets)
|
|
141
|
+
{
|
|
142
|
+
truthBullets = bullets;
|
|
143
|
+
|
|
144
|
+
Restart();
|
|
145
|
+
|
|
146
|
+
SetBulletParentPosition();
|
|
147
|
+
|
|
148
|
+
SpawnBullets();
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
/// <summary>
|
|
152
|
+
///
|
|
153
|
+
/// </summary>
|
|
154
|
+
protected virtual void Restart()
|
|
155
|
+
{
|
|
156
|
+
foreach (var bullet in bulletObjects)
|
|
157
|
+
Destroy(bullet);
|
|
158
|
+
|
|
159
|
+
bulletObjects.Clear();
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
/// <summary>
|
|
163
|
+
///
|
|
164
|
+
/// </summary>
|
|
165
|
+
protected virtual void SetBulletParentPosition()
|
|
166
|
+
{
|
|
167
|
+
loadBulletParent.transform.localPosition = loadBulletParentPosition;
|
|
168
|
+
|
|
169
|
+
if (truthBullets.Count == 1)
|
|
170
|
+
return;
|
|
171
|
+
|
|
172
|
+
Vector3 position = loadBulletParent.transform.localPosition;
|
|
173
|
+
|
|
174
|
+
float total = 0;
|
|
175
|
+
|
|
176
|
+
for (int i = 0; i < truthBullets.Count; i++)
|
|
177
|
+
if (i < truthBullets.Count - 1)
|
|
178
|
+
total += doubleSpaceBetweenBullets / 2;
|
|
179
|
+
|
|
180
|
+
position.y += total;
|
|
181
|
+
|
|
182
|
+
loadBulletParent.transform.localPosition = position;
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
/// <summary>
|
|
186
|
+
///
|
|
187
|
+
/// </summary>
|
|
188
|
+
protected virtual void SpawnBullets()
|
|
189
|
+
{
|
|
190
|
+
for (int i = 0; i < truthBullets.Count; i++)
|
|
191
|
+
bulletObjects.Add(Instantiate(loadBulletPrefab, loadBulletParent));
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
|
|
195
|
+
/// <inheritdoc/>
|
|
196
|
+
protected override void ShowUI() => StartCoroutine(LoadBulletAnimation());
|
|
197
|
+
|
|
198
|
+
/// <inheritdoc/>
|
|
199
|
+
protected override void HideUI() => StartCoroutine(LoadBulletAnimation());
|
|
200
|
+
|
|
201
|
+
/// <inheritdoc/>
|
|
202
|
+
protected override IEnumerator WaitForUIToComplete()
|
|
203
|
+
{
|
|
204
|
+
yield return new WaitUntil(() => finished);
|
|
205
|
+
|
|
206
|
+
Destroy(gameObject);
|
|
207
|
+
}
|
|
208
|
+
|
|
209
|
+
/// <summary>
|
|
210
|
+
///
|
|
211
|
+
/// </summary>
|
|
212
|
+
protected virtual IEnumerator LoadBulletAnimation()
|
|
213
|
+
{
|
|
214
|
+
ShowBulletTrails();
|
|
215
|
+
|
|
216
|
+
yield return uiParent.ShowTillComplete();
|
|
217
|
+
|
|
218
|
+
yield return ShowChamber();
|
|
219
|
+
|
|
220
|
+
yield return LoadBullets();
|
|
221
|
+
|
|
222
|
+
yield return PostChamberRotate();
|
|
223
|
+
|
|
224
|
+
yield return uiParent.HideTillComplete();
|
|
225
|
+
|
|
226
|
+
yield return new WaitForSeconds(resolveBufferDuration);
|
|
227
|
+
|
|
228
|
+
finished = true;
|
|
229
|
+
}
|
|
230
|
+
|
|
231
|
+
/// <summary>
|
|
232
|
+
///
|
|
233
|
+
/// </summary>
|
|
234
|
+
protected virtual IEnumerator ShowChamber()
|
|
235
|
+
{
|
|
236
|
+
originalChamberRotation = chamberParent.rectTransform.rotation.eulerAngles;
|
|
237
|
+
|
|
238
|
+
if (chamberParent.TryGetComponent<UIVisibilityComponent>(out var visibility))
|
|
239
|
+
yield return visibility.ShowTillComplete();
|
|
240
|
+
}
|
|
241
|
+
|
|
242
|
+
/// <summary>
|
|
243
|
+
///
|
|
244
|
+
/// </summary>
|
|
245
|
+
protected virtual void ShowBulletTrails()
|
|
246
|
+
{
|
|
247
|
+
for (int i = 0; i < truthBullets.Count; i++)
|
|
248
|
+
DisplayBulletTrails(i, true);
|
|
249
|
+
}
|
|
250
|
+
|
|
251
|
+
/// <summary>
|
|
252
|
+
///
|
|
253
|
+
/// </summary>
|
|
254
|
+
/// <param name="i"></param>
|
|
255
|
+
/// <param name="visible"></param>
|
|
256
|
+
protected virtual void DisplayBulletTrails(int i, bool visible)
|
|
257
|
+
{
|
|
258
|
+
if (bulletObjects[i].GetComponentInChildren<UIVisibilityComponent>() is UIVisibilityComponent bulletTrail)
|
|
259
|
+
if (visible)
|
|
260
|
+
bulletTrail.Show();
|
|
261
|
+
else
|
|
262
|
+
bulletTrail.Hide();
|
|
263
|
+
}
|
|
264
|
+
|
|
265
|
+
/// <summary>
|
|
266
|
+
///
|
|
267
|
+
/// </summary>
|
|
268
|
+
protected virtual IEnumerator LoadBullets()
|
|
269
|
+
{
|
|
270
|
+
bulletOGPos = new Vector3[truthBullets.Count];
|
|
271
|
+
|
|
272
|
+
for (int i = 0; i < truthBullets.Count; i++)
|
|
273
|
+
{
|
|
274
|
+
LoadBulletText(i);
|
|
275
|
+
|
|
276
|
+
LoadBulletTransform(i);
|
|
277
|
+
|
|
278
|
+
RotateChambers(loadChamberZ, bulletLoadSpeed);
|
|
279
|
+
|
|
280
|
+
DisplayBulletTrails(i, false);
|
|
281
|
+
|
|
282
|
+
onBulletLoaded?.Invoke();
|
|
283
|
+
|
|
284
|
+
yield return new WaitForSeconds(bulletLoadSpeed * bulletLoadSpeedMultiplier);
|
|
285
|
+
}
|
|
286
|
+
}
|
|
287
|
+
|
|
288
|
+
/// <summary>
|
|
289
|
+
///
|
|
290
|
+
/// </summary>
|
|
291
|
+
/// <param name="i"></param>
|
|
292
|
+
protected virtual void LoadBulletText(int i)
|
|
293
|
+
{
|
|
294
|
+
ICycleUITextComponent loadBullet = bulletObjects[i].GetComponentInChildren<ICycleUITextComponent>();
|
|
295
|
+
|
|
296
|
+
loadBullet?.UpdateBulletText(truthBullets[i].DisplayName);
|
|
297
|
+
}
|
|
298
|
+
|
|
299
|
+
/// <summary>
|
|
300
|
+
///
|
|
301
|
+
/// </summary>
|
|
302
|
+
/// <param name="i"></param>
|
|
303
|
+
protected virtual void LoadBulletTransform(int i)
|
|
304
|
+
{
|
|
305
|
+
bulletOGPos[i] = bulletObjects[i].GetComponent<RectTransform>().position;
|
|
306
|
+
#if DOTWEEN
|
|
307
|
+
bulletObjects[i].transform.DOMove(bulletOGPos[i] + bulletObjectOffset, bulletLoadSpeed);
|
|
308
|
+
#else
|
|
309
|
+
bulletObjects[i].transform.Translate(bulletOGPos[i] + bulletObjectOffset);
|
|
310
|
+
#endif
|
|
311
|
+
}
|
|
312
|
+
|
|
313
|
+
/// <summary>
|
|
314
|
+
///
|
|
315
|
+
/// </summary>
|
|
316
|
+
/// <param name="initialZMove"></param>
|
|
317
|
+
/// <param name="duration"></param>
|
|
318
|
+
protected virtual void RotateChambers(float initialZMove, float duration)
|
|
319
|
+
{
|
|
320
|
+
originalChamberRotation.z += initialZMove;
|
|
321
|
+
|
|
322
|
+
var originalQuaternion = Quaternion.Euler(originalChamberRotation);
|
|
323
|
+
#if DOTWEEN
|
|
324
|
+
chamberParent.transform.DORotateQuaternion(originalQuaternion, duration);
|
|
325
|
+
#else
|
|
326
|
+
chamberParent.transform.Rotate(originalQuaternion.eulerAngles);
|
|
327
|
+
#endif
|
|
328
|
+
}
|
|
329
|
+
|
|
330
|
+
/// <summary>
|
|
331
|
+
///
|
|
332
|
+
/// </summary>
|
|
333
|
+
protected virtual IEnumerator PostChamberRotate()
|
|
334
|
+
{
|
|
335
|
+
RotateChambers(postChamberZ, chamberRotateDuration);
|
|
336
|
+
|
|
337
|
+
yield return new WaitForSeconds(chamberRotateDuration);
|
|
338
|
+
}
|
|
339
|
+
}
|
|
340
340
|
}
|