net.dreditor.minigames 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.
Files changed (167) hide show
  1. package/.attestation.p7m +0 -0
  2. package/BulletDifficulty.cs +36 -36
  3. package/BulletDifficulty.cs.meta +11 -11
  4. package/BulletDifficultyEditor.cs +380 -380
  5. package/BulletDifficultyEditor.cs.meta +11 -11
  6. package/DREditor.Minigames.asmdef +36 -36
  7. package/DREditor.Minigames.asmdef.meta +7 -7
  8. package/DifficultyEditorBase.cs +60 -60
  9. package/DifficultyEditorBase.cs.meta +11 -11
  10. package/IShatterGraphic.cs +32 -32
  11. package/IShatterGraphic.cs.meta +11 -11
  12. package/IShatterText.cs +33 -33
  13. package/IShatterText.cs.meta +11 -11
  14. package/InitializeTrialOffsets.cs +51 -51
  15. package/InitializeTrialOffsets.cs.meta +11 -11
  16. package/MinigameBuilderBase.cs +28 -28
  17. package/MinigameBuilderBase.cs.meta +11 -11
  18. package/MinigameControlsUIHandler.cs +94 -94
  19. package/MinigameControlsUIHandler.cs.meta +11 -11
  20. package/MinigameManagerBase.cs +197 -197
  21. package/MinigameManagerBase.cs.meta +11 -11
  22. package/QuestionToggle.cs +154 -154
  23. package/QuestionToggle.cs.meta +11 -11
  24. package/RestoreControlsUIPostDialogue.cs +100 -100
  25. package/RestoreControlsUIPostDialogue.cs.meta +1 -1
  26. package/{Samples → Samples~}/Bullet Shatter Mesh Generator.asset +23 -23
  27. package/{Samples → Samples~}/Bullet Shatter Mesh Generator.asset.meta +8 -8
  28. package/{Samples → Samples~}/HasStamina.asset +21 -21
  29. package/{Samples → Samples~}/HasStamina.asset.meta +8 -8
  30. package/{Samples → Samples~}/IsDrainingStamina.asset +21 -21
  31. package/{Samples → Samples~}/IsDrainingStamina.asset.meta +8 -8
  32. package/{Samples → Samples~}/MinigameInputAllowed.asset +21 -21
  33. package/{Samples → Samples~}/MinigameInputAllowed.asset.meta +8 -8
  34. package/{Samples → Samples~}/Minigame_Controls_UI_Handler.prefab +53 -53
  35. package/{Samples → Samples~}/Minigame_Controls_UI_Handler.prefab.meta +7 -7
  36. package/{Samples → Samples~}/Quad Shatter.asset +31 -31
  37. package/{Samples → Samples~}/Quad Shatter.asset.meta +8 -8
  38. package/{Samples → Samples~}/ShatterCameraEnabled.asset +21 -21
  39. package/{Samples → Samples~}/ShatterCameraEnabled.asset.meta +8 -8
  40. package/{Samples → Samples~}/Shatter_Graphic.prefab +98 -98
  41. package/{Samples → Samples~}/Shatter_Graphic.prefab.meta +7 -7
  42. package/{Samples → Samples~}/Stamina_Handler.prefab +59 -59
  43. package/{Samples → Samples~}/Stamina_Handler.prefab.meta +7 -7
  44. package/{Samples → Samples~}/TBS_Manager_Shell.prefab +60 -60
  45. package/{Samples → Samples~}/TBS_Manager_Shell.prefab.meta +7 -7
  46. package/{Samples → Samples~}/TBS_Manager_Template.prefab +504 -504
  47. package/{Samples → Samples~}/TBS_Manager_Template.prefab.meta +7 -7
  48. package/{Samples → Samples~}/Trial_UI_Shatter_Canvas_Shell.prefab +289 -289
  49. package/{Samples → Samples~}/Trial_UI_Shatter_Canvas_Shell.prefab.meta +7 -7
  50. package/{Samples → Samples~}/Trial_UI_Shatter_Canvas_Template.prefab +449 -449
  51. package/{Samples → Samples~}/Trial_UI_Shatter_Canvas_Template.prefab.meta +7 -7
  52. package/{Samples → Samples~}/Triangle Shatter.asset +31 -31
  53. package/{Samples → Samples~}/Triangle Shatter.asset.meta +8 -8
  54. package/{Samples → Samples~}/Truth_Bullet_Menu_Canvas_Shell.prefab +221 -221
  55. package/{Samples → Samples~}/Truth_Bullet_Menu_Canvas_Shell.prefab.meta +7 -7
  56. package/{Samples → Samples~}/Truth_Bullet_Menu_Canvas_Template.prefab +525 -525
  57. package/{Samples → Samples~}/Truth_Bullet_Menu_Canvas_Template.prefab.meta +7 -7
  58. package/{Samples → Samples~}/Truth_Bullet_Menu_Holder_Shell.prefab +38 -38
  59. package/{Samples → Samples~}/Truth_Bullet_Menu_Holder_Shell.prefab.meta +7 -7
  60. package/{Samples → Samples~}/Truth_Bullet_Menu_Holder_Template.prefab +1159 -1159
  61. package/{Samples → Samples~}/Truth_Bullet_Menu_Holder_Template.prefab.meta +7 -7
  62. package/{Samples → Samples~}/Truth_Bullet_Minigame_Canvas_Template.prefab +494 -494
  63. package/{Samples → Samples~}/Truth_Bullet_Minigame_Canvas_Template.prefab.meta +7 -7
  64. package/{Samples → Samples~}/Truth_Bullet_Option_ETemplate.prefab +294 -294
  65. package/{Samples → Samples~}/Truth_Bullet_Option_ETemplate.prefab.meta +7 -7
  66. package/Shattering/BreakTex.renderTexture +39 -39
  67. package/Shattering/BreakTex.renderTexture.meta +8 -8
  68. package/Shattering/BulletShatter.cs +176 -176
  69. package/Shattering/BulletShatter.cs.meta +11 -11
  70. package/Shattering/IShatterableCanvas.cs +20 -20
  71. package/Shattering/IShatterableCanvas.cs.meta +11 -11
  72. package/Shattering/MeshGenerator.cs +178 -178
  73. package/Shattering/MeshGenerator.cs.meta +11 -11
  74. package/Shattering/RenderCanvasOnShatter.cs +47 -47
  75. package/Shattering/RenderCanvasOnShatter.cs.meta +11 -11
  76. package/Shattering/ShatterCameraRender.cs +79 -79
  77. package/Shattering/ShatterCameraRender.cs.meta +11 -11
  78. package/Shattering/ShatterGraphic.cs +135 -135
  79. package/Shattering/ShatterGraphic.cs.meta +11 -11
  80. package/Shattering/ShatterMeshGraphic.cs +304 -304
  81. package/Shattering/ShatterMeshGraphic.cs.meta +11 -11
  82. package/Shattering/ShatterProcess.cs +282 -282
  83. package/Shattering/ShatterProcess.cs.meta +11 -11
  84. package/Shattering/ShatterProcessBase.cs +51 -51
  85. package/Shattering/ShatterProcessBase.cs.meta +11 -11
  86. package/Shattering/ShatterQuad.cs +56 -56
  87. package/Shattering/ShatterQuad.cs.meta +11 -11
  88. package/Shattering/ShatterQuadProcess.cs +65 -65
  89. package/Shattering/ShatterQuadProcess.cs.meta +11 -11
  90. package/Shattering/ShatterShape.cs +84 -84
  91. package/Shattering/ShatterShape.cs.meta +11 -11
  92. package/Shattering/ShatterTri.cs +27 -27
  93. package/Shattering/ShatterTri.cs.meta +11 -11
  94. package/Shattering/ShatterTriProcess.cs +179 -179
  95. package/Shattering/ShatterTriProcess.cs.meta +11 -11
  96. package/Shattering/ShatterWithUI.cs +68 -68
  97. package/Shattering/ShatterWithUI.cs.meta +11 -11
  98. package/Shattering/SplitShatter.cs +114 -114
  99. package/Shattering/SplitShatter.cs.meta +11 -11
  100. package/Shattering/TMPTextShatter.cs +243 -243
  101. package/Shattering/TMPTextShatter.cs.meta +11 -11
  102. package/Shattering/UIBreakVisibility.cs +172 -172
  103. package/Shattering/UIBreakVisibility.cs.meta +11 -11
  104. package/Shattering.meta +8 -8
  105. package/ShuffleUtility.cs +32 -32
  106. package/ShuffleUtility.cs.meta +11 -11
  107. package/SimpleRandom.cs +32 -32
  108. package/SimpleRandom.cs.meta +11 -11
  109. package/Stats/ColorHealthBar.cs +56 -56
  110. package/Stats/ColorHealthBar.cs.meta +11 -11
  111. package/Stats/ColorHealthModifier.cs +138 -138
  112. package/Stats/ColorHealthModifier.cs.meta +11 -11
  113. package/Stats/GaugeHandler.cs +72 -72
  114. package/Stats/GaugeHandler.cs.meta +1 -1
  115. package/Stats/HealthBarModifier.cs +89 -89
  116. package/Stats/HealthBarModifier.cs.meta +11 -11
  117. package/Stats/HealthStat.cs +77 -77
  118. package/Stats/HealthStat.cs.meta +11 -11
  119. package/Stats/HealthStatBase.cs +26 -26
  120. package/Stats/HealthStatBase.cs.meta +11 -11
  121. package/Stats/IGauge.cs +36 -36
  122. package/Stats/IGauge.cs.meta +1 -1
  123. package/Stats/InfluenceGauge.cs +107 -107
  124. package/Stats/InfluenceGauge.cs.meta +11 -11
  125. package/Stats/InfluenceGaugeBase.cs +42 -42
  126. package/Stats/InfluenceGaugeBase.cs.meta +11 -11
  127. package/Stats/SimpleGauge.cs +46 -46
  128. package/Stats/SimpleGauge.cs.meta +1 -1
  129. package/Stats/StaminaHandler.cs +153 -153
  130. package/Stats/StaminaHandler.cs.meta +11 -11
  131. package/Stats/TrialStats.cs +140 -140
  132. package/Stats/TrialStats.cs.meta +11 -11
  133. package/Stats/TrialStatsBase.cs +36 -36
  134. package/Stats/TrialStatsBase.cs.meta +11 -11
  135. package/Stats.meta +8 -8
  136. package/TBS/TBSelectBuilder.cs +59 -59
  137. package/TBS/TBSelectBuilder.cs.meta +11 -11
  138. package/TBS/TBSelectBuilderEditor.cs +166 -166
  139. package/TBS/TBSelectBuilderEditor.cs.meta +11 -11
  140. package/TBS/TBSelectManager.cs +315 -315
  141. package/TBS/TBSelectManager.cs.meta +11 -11
  142. package/TBS/TBSelection.cs +46 -46
  143. package/TBS/TBSelection.cs.meta +11 -11
  144. package/TBS/TrialTruthBulletMenu.cs +24 -24
  145. package/TBS/TrialTruthBulletMenu.cs.meta +11 -11
  146. package/TBS.meta +8 -8
  147. package/ThreadSafeSimpleRandom.cs +29 -29
  148. package/ThreadSafeSimpleRandom.cs.meta +11 -11
  149. package/TimedDifficultyEditor.cs +56 -56
  150. package/TimedDifficultyEditor.cs.meta +11 -11
  151. package/TimedMinigameEditor.cs +31 -31
  152. package/TimedMinigameEditor.cs.meta +11 -11
  153. package/TimerBase.cs +189 -189
  154. package/TimerBase.cs.meta +11 -11
  155. package/TimerDifficulty.cs +45 -45
  156. package/TimerDifficulty.cs.meta +11 -11
  157. package/TrialDialogueMinigame.cs +276 -276
  158. package/TrialDialogueMinigame.cs.meta +11 -11
  159. package/TrialDiscussion.cs +68 -68
  160. package/TrialDiscussion.cs.meta +11 -11
  161. package/TrialTimer.cs +113 -113
  162. package/TrialTimer.cs.meta +11 -11
  163. package/TrialTimerBase.cs +129 -129
  164. package/TrialTimerBase.cs.meta +11 -11
  165. package/package.json +56 -51
  166. package/package.json.meta +7 -7
  167. package/Samples.meta +0 -8
@@ -1,305 +1,305 @@
1
- //Author: Benjamin "Sweden" Jillson : Discord: sweden_gaming For Project Eden's Garden
2
- // Leothedev also helped out a lot
3
- using System.Collections;
4
- using System.Collections.Generic;
5
- using UnityEngine;
6
- using UnityEngine.UI;
7
-
8
- namespace DREditor.Minigames.Shattering
9
- {
10
- /// <summary>
11
- ///
12
- /// </summary>
13
- [ClassHeader(nameof(ShatterGraphic) + ", " + nameof(Graphic) + ", " + nameof(IShatterGraphic) +
14
- "\n\n")]
15
- public partial class ShatterMeshGraphic : ShatterGraphic
16
- {
17
- /// <summary>
18
- ///
19
- /// </summary>
20
- [Tooltip("")]
21
- [SerializeField] protected MeshFilter targetMeshFilter;
22
-
23
- /// <summary>
24
- ///
25
- /// </summary>
26
- [Tooltip("")]
27
- [SerializeField] protected Mesh resetMesh = null;
28
-
29
-
30
- /// <summary>
31
- ///
32
- /// </summary>
33
- [Header("")]
34
- [Divider]
35
- [Tooltip("")]
36
- [SerializeField] protected bool debugMode = false;
37
-
38
- /// <summary>
39
- ///
40
- /// </summary>
41
- [Tooltip("")]
42
- [SerializeField] protected float explosionTime = 7f;
43
-
44
- /// <summary>
45
- ///
46
- /// </summary>
47
- [Tooltip("")]
48
- [SerializeField] protected MeshGenerator meshGenerator = null;
49
-
50
-
51
- /// <summary>
52
- ///
53
- /// </summary>
54
- protected List<UIVertex> uiVertices = new();
55
-
56
- /// <summary>
57
- ///
58
- /// </summary>
59
- protected Vector3[] triangleVelocity;
60
-
61
-
62
- /// <inheritdoc/>
63
- protected override void Start()
64
- {
65
- base.Start();
66
-
67
- if (debugMode)
68
- DebugShatter();
69
- }
70
-
71
-
72
- /// <inheritdoc/>
73
- protected override void PostShatter()
74
- {
75
- base.PostShatter();
76
-
77
- uiVertices.Clear();
78
- }
79
-
80
- /// <inheritdoc/>
81
- protected override void ShatterMesh()
82
- {
83
- meshGenerator.GenerateMesh(targetMeshFilter, uiVertices);
84
-
85
- base.ShatterMesh();
86
- }
87
-
88
- /// <inheritdoc/>
89
- protected override IEnumerator ShatterMeshProcess()
90
- {
91
- triangleVelocity = meshGenerator.InitializeVelocity(uiVertices);
92
-
93
- yield return ShatteringMesh();
94
- }
95
-
96
- /// <summary>
97
- ///
98
- /// </summary>
99
- protected virtual IEnumerator ShatteringMesh()
100
- {
101
- float time = 0;
102
-
103
- while (time <= explosionTime)
104
- {
105
- time += Time.deltaTime;
106
-
107
- UpdateShatter();
108
-
109
- yield return null;
110
-
111
- SetVerticesDirty();
112
-
113
- if (!Application.isPlaying)
114
- ResetProcess();
115
- }
116
- }
117
-
118
- /// <summary>
119
- ///
120
- /// </summary>
121
- protected virtual void UpdateShatter()
122
- {
123
- for (int i = 0; i < uiVertices.Count / 3; i++)
124
- {
125
- CalculateUpdatedVertex(i, 0);
126
-
127
- CalculateUpdatedVertex(i, 1);
128
-
129
- CalculateUpdatedVertex(i, 2);
130
-
131
- DecayVelocity(i);
132
- }
133
- }
134
-
135
- /// <summary>
136
- ///
137
- /// </summary>
138
- /// <param name="i"></param>
139
- /// <param name="offset"></param>
140
- protected virtual void CalculateUpdatedVertex(int i, int offset)
141
- {
142
- Vector3 position = uiVertices[i * 3 + offset].position;
143
-
144
- position += triangleVelocity[i] * Time.deltaTime;
145
-
146
- UIVertex uiVertex = uiVertices[i * 3 + offset];
147
-
148
- uiVertex.position = position;
149
-
150
- uiVertices[i * 3 + offset] = uiVertex;
151
- }
152
-
153
- /// <summary>
154
- ///
155
- /// </summary>
156
- /// <param name="i"></param>
157
- protected virtual void DecayVelocity(int i) =>
158
- triangleVelocity[i] -= Time.deltaTime * triangleVelocity[i] / explosionTime;
159
-
160
-
161
- /// <summary>
162
- ///
163
- /// </summary>
164
- [BehaviourButton]
165
- public void DebugShatter()
166
- {
167
- ResetProcess();
168
-
169
- StartCoroutine(ShatterTheGraphic());
170
- }
171
-
172
- /// <inheritdoc/>
173
- protected override void ResetProcess()
174
- {
175
- if (resetMesh != null)
176
- targetMeshFilter.mesh = resetMesh;
177
- }
178
-
179
-
180
- /// <inheritdoc/>
181
- protected override void OnPopulateMesh(VertexHelper vertexHelper)
182
- {
183
- if (finished)
184
- return;
185
-
186
- vertexHelper.Clear();
187
-
188
- foreach (UIVertex uiVertex in uiVertices)
189
- vertexHelper.AddVert(uiVertex);
190
-
191
- for (int i = 0; (i + 6) <= uiVertices.Count; i += 6)
192
- {
193
- vertexHelper.AddTriangle(i, i + 1, i + 2);
194
-
195
- vertexHelper.AddTriangle(i + 3, i + 4, i + 5);
196
- }
197
- }
198
- }
199
-
200
- // Gizmo Section
201
- public partial class ShatterMeshGraphic
202
- {
203
- /// <summary>
204
- ///
205
- /// </summary>
206
- [Header("")]
207
- [Divider]
208
- [Tooltip("")]
209
- [SerializeField] protected Vector3 sphereOffset = new(960, 540, 0);
210
-
211
- /// <summary>
212
- ///
213
- /// </summary>
214
- [Tooltip("")]
215
- [SerializeField] protected float sphereRadius = 50;
216
-
217
- /// <summary>
218
- ///
219
- /// </summary>
220
- [Tooltip("")]
221
- [SerializeField] protected int spheresPerColor = 2;
222
-
223
- /// <summary>
224
- ///
225
- /// </summary>
226
- [Tooltip("")]
227
- [SerializeField] protected Color startingColor = Color.red;
228
-
229
- /// <summary>
230
- ///
231
- /// </summary>
232
- [Tooltip("")]
233
- [SerializeField] protected List<Color> gizmoColors = new() { Color.red, Color.green, Color.blue };
234
-
235
-
236
- /// <summary>
237
- ///
238
- /// </summary>
239
- protected Color vColor;
240
-
241
- /// <summary>
242
- ///
243
- /// </summary>
244
- protected int counter = 0;
245
-
246
-
247
- protected virtual void OnDrawGizmos()
248
- {
249
- if (Application.isPlaying && uiVertices != null)
250
- StartDrawingGizmos();
251
- }
252
-
253
- /// <summary>
254
- ///
255
- /// </summary>
256
- protected virtual void StartDrawingGizmos()
257
- {
258
- SetGizmoColor(startingColor);
259
-
260
- foreach (var uiVertex in uiVertices)
261
- DrawGizmoSphere(uiVertex);
262
- }
263
-
264
- /// <summary>
265
- ///
266
- /// </summary>
267
- /// <param name="vColor"></param>
268
- protected virtual void SetGizmoColor(Color vColor)
269
- {
270
- this.vColor = vColor;
271
-
272
- Gizmos.color = vColor;
273
-
274
- counter = 0;
275
- }
276
-
277
- /// <summary>
278
- ///
279
- /// </summary>
280
- /// <param name="uiVertex"></param>
281
- protected virtual void DrawGizmoSphere(UIVertex uiVertex)
282
- {
283
- Gizmos.DrawSphere(uiVertex.position + sphereOffset, sphereRadius);
284
-
285
- if (counter == spheresPerColor)
286
- SetGizmoColor(GetNextColor());
287
- else
288
- counter++;
289
- }
290
-
291
- /// <summary>
292
- ///
293
- /// </summary>
294
- /// <returns></returns>
295
- protected virtual Color GetNextColor()
296
- {
297
- int gizmoColorIndex = gizmoColors.IndexOf(vColor) + 1;
298
-
299
- if (gizmoColorIndex >= gizmoColors.Count)
300
- gizmoColorIndex = 0;
301
-
302
- return gizmoColors[gizmoColorIndex];
303
- }
304
- }
1
+ //Author: Benjamin "Sweden" Jillson : Discord: sweden_gaming For Project Eden's Garden
2
+ // Leothedev also helped out a lot
3
+ using System.Collections;
4
+ using System.Collections.Generic;
5
+ using UnityEngine;
6
+ using UnityEngine.UI;
7
+
8
+ namespace DREditor.Minigames.Shattering
9
+ {
10
+ /// <summary>
11
+ ///
12
+ /// </summary>
13
+ [ClassHeader(nameof(ShatterGraphic) + ", " + nameof(Graphic) + ", " + nameof(IShatterGraphic) +
14
+ "\n\n")]
15
+ public partial class ShatterMeshGraphic : ShatterGraphic
16
+ {
17
+ /// <summary>
18
+ ///
19
+ /// </summary>
20
+ [Tooltip("")]
21
+ [SerializeField] protected MeshFilter targetMeshFilter;
22
+
23
+ /// <summary>
24
+ ///
25
+ /// </summary>
26
+ [Tooltip("")]
27
+ [SerializeField] protected Mesh resetMesh = null;
28
+
29
+
30
+ /// <summary>
31
+ ///
32
+ /// </summary>
33
+ [Header("")]
34
+ [Divider]
35
+ [Tooltip("")]
36
+ [SerializeField] protected bool debugMode = false;
37
+
38
+ /// <summary>
39
+ ///
40
+ /// </summary>
41
+ [Tooltip("")]
42
+ [SerializeField] protected float explosionTime = 7f;
43
+
44
+ /// <summary>
45
+ ///
46
+ /// </summary>
47
+ [Tooltip("")]
48
+ [SerializeField] protected MeshGenerator meshGenerator = null;
49
+
50
+
51
+ /// <summary>
52
+ ///
53
+ /// </summary>
54
+ protected List<UIVertex> uiVertices = new();
55
+
56
+ /// <summary>
57
+ ///
58
+ /// </summary>
59
+ protected Vector3[] triangleVelocity;
60
+
61
+
62
+ /// <inheritdoc/>
63
+ protected override void Start()
64
+ {
65
+ base.Start();
66
+
67
+ if (debugMode)
68
+ DebugShatter();
69
+ }
70
+
71
+
72
+ /// <inheritdoc/>
73
+ protected override void PostShatter()
74
+ {
75
+ base.PostShatter();
76
+
77
+ uiVertices.Clear();
78
+ }
79
+
80
+ /// <inheritdoc/>
81
+ protected override void ShatterMesh()
82
+ {
83
+ meshGenerator.GenerateMesh(targetMeshFilter, uiVertices);
84
+
85
+ base.ShatterMesh();
86
+ }
87
+
88
+ /// <inheritdoc/>
89
+ protected override IEnumerator ShatterMeshProcess()
90
+ {
91
+ triangleVelocity = meshGenerator.InitializeVelocity(uiVertices);
92
+
93
+ yield return ShatteringMesh();
94
+ }
95
+
96
+ /// <summary>
97
+ ///
98
+ /// </summary>
99
+ protected virtual IEnumerator ShatteringMesh()
100
+ {
101
+ float time = 0;
102
+
103
+ while (time <= explosionTime)
104
+ {
105
+ time += Time.deltaTime;
106
+
107
+ UpdateShatter();
108
+
109
+ yield return null;
110
+
111
+ SetVerticesDirty();
112
+
113
+ if (!Application.isPlaying)
114
+ ResetProcess();
115
+ }
116
+ }
117
+
118
+ /// <summary>
119
+ ///
120
+ /// </summary>
121
+ protected virtual void UpdateShatter()
122
+ {
123
+ for (int i = 0; i < uiVertices.Count / 3; i++)
124
+ {
125
+ CalculateUpdatedVertex(i, 0);
126
+
127
+ CalculateUpdatedVertex(i, 1);
128
+
129
+ CalculateUpdatedVertex(i, 2);
130
+
131
+ DecayVelocity(i);
132
+ }
133
+ }
134
+
135
+ /// <summary>
136
+ ///
137
+ /// </summary>
138
+ /// <param name="i"></param>
139
+ /// <param name="offset"></param>
140
+ protected virtual void CalculateUpdatedVertex(int i, int offset)
141
+ {
142
+ Vector3 position = uiVertices[i * 3 + offset].position;
143
+
144
+ position += triangleVelocity[i] * Time.deltaTime;
145
+
146
+ UIVertex uiVertex = uiVertices[i * 3 + offset];
147
+
148
+ uiVertex.position = position;
149
+
150
+ uiVertices[i * 3 + offset] = uiVertex;
151
+ }
152
+
153
+ /// <summary>
154
+ ///
155
+ /// </summary>
156
+ /// <param name="i"></param>
157
+ protected virtual void DecayVelocity(int i) =>
158
+ triangleVelocity[i] -= Time.deltaTime * triangleVelocity[i] / explosionTime;
159
+
160
+
161
+ /// <summary>
162
+ ///
163
+ /// </summary>
164
+ [BehaviourButton]
165
+ public void DebugShatter()
166
+ {
167
+ ResetProcess();
168
+
169
+ StartCoroutine(ShatterTheGraphic());
170
+ }
171
+
172
+ /// <inheritdoc/>
173
+ protected override void ResetProcess()
174
+ {
175
+ if (resetMesh != null)
176
+ targetMeshFilter.mesh = resetMesh;
177
+ }
178
+
179
+
180
+ /// <inheritdoc/>
181
+ protected override void OnPopulateMesh(VertexHelper vertexHelper)
182
+ {
183
+ if (finished)
184
+ return;
185
+
186
+ vertexHelper.Clear();
187
+
188
+ foreach (UIVertex uiVertex in uiVertices)
189
+ vertexHelper.AddVert(uiVertex);
190
+
191
+ for (int i = 0; (i + 6) <= uiVertices.Count; i += 6)
192
+ {
193
+ vertexHelper.AddTriangle(i, i + 1, i + 2);
194
+
195
+ vertexHelper.AddTriangle(i + 3, i + 4, i + 5);
196
+ }
197
+ }
198
+ }
199
+
200
+ // Gizmo Section
201
+ public partial class ShatterMeshGraphic
202
+ {
203
+ /// <summary>
204
+ ///
205
+ /// </summary>
206
+ [Header("")]
207
+ [Divider]
208
+ [Tooltip("")]
209
+ [SerializeField] protected Vector3 sphereOffset = new(960, 540, 0);
210
+
211
+ /// <summary>
212
+ ///
213
+ /// </summary>
214
+ [Tooltip("")]
215
+ [SerializeField] protected float sphereRadius = 50;
216
+
217
+ /// <summary>
218
+ ///
219
+ /// </summary>
220
+ [Tooltip("")]
221
+ [SerializeField] protected int spheresPerColor = 2;
222
+
223
+ /// <summary>
224
+ ///
225
+ /// </summary>
226
+ [Tooltip("")]
227
+ [SerializeField] protected Color startingColor = Color.red;
228
+
229
+ /// <summary>
230
+ ///
231
+ /// </summary>
232
+ [Tooltip("")]
233
+ [SerializeField] protected List<Color> gizmoColors = new() { Color.red, Color.green, Color.blue };
234
+
235
+
236
+ /// <summary>
237
+ ///
238
+ /// </summary>
239
+ protected Color vColor;
240
+
241
+ /// <summary>
242
+ ///
243
+ /// </summary>
244
+ protected int counter = 0;
245
+
246
+
247
+ protected virtual void OnDrawGizmos()
248
+ {
249
+ if (Application.isPlaying && uiVertices != null)
250
+ StartDrawingGizmos();
251
+ }
252
+
253
+ /// <summary>
254
+ ///
255
+ /// </summary>
256
+ protected virtual void StartDrawingGizmos()
257
+ {
258
+ SetGizmoColor(startingColor);
259
+
260
+ foreach (var uiVertex in uiVertices)
261
+ DrawGizmoSphere(uiVertex);
262
+ }
263
+
264
+ /// <summary>
265
+ ///
266
+ /// </summary>
267
+ /// <param name="vColor"></param>
268
+ protected virtual void SetGizmoColor(Color vColor)
269
+ {
270
+ this.vColor = vColor;
271
+
272
+ Gizmos.color = vColor;
273
+
274
+ counter = 0;
275
+ }
276
+
277
+ /// <summary>
278
+ ///
279
+ /// </summary>
280
+ /// <param name="uiVertex"></param>
281
+ protected virtual void DrawGizmoSphere(UIVertex uiVertex)
282
+ {
283
+ Gizmos.DrawSphere(uiVertex.position + sphereOffset, sphereRadius);
284
+
285
+ if (counter == spheresPerColor)
286
+ SetGizmoColor(GetNextColor());
287
+ else
288
+ counter++;
289
+ }
290
+
291
+ /// <summary>
292
+ ///
293
+ /// </summary>
294
+ /// <returns></returns>
295
+ protected virtual Color GetNextColor()
296
+ {
297
+ int gizmoColorIndex = gizmoColors.IndexOf(vColor) + 1;
298
+
299
+ if (gizmoColorIndex >= gizmoColors.Count)
300
+ gizmoColorIndex = 0;
301
+
302
+ return gizmoColors[gizmoColorIndex];
303
+ }
304
+ }
305
305
  }
@@ -1,11 +1,11 @@
1
- fileFormatVersion: 2
2
- guid: b857da65edc3879419ed01255ba2ff27
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: b857da65edc3879419ed01255ba2ff27
3
+ MonoImporter:
4
+ externalObjects: {}
5
+ serializedVersion: 2
6
+ defaultReferences: []
7
+ executionOrder: 0
8
+ icon: {instanceID: 0}
9
+ userData:
10
+ assetBundleName:
11
+ assetBundleVariant: