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.
- package/.attestation.p7m +0 -0
- package/BulletDifficulty.cs +36 -36
- package/BulletDifficulty.cs.meta +11 -11
- package/BulletDifficultyEditor.cs +380 -380
- package/BulletDifficultyEditor.cs.meta +11 -11
- package/DREditor.Minigames.asmdef +36 -36
- package/DREditor.Minigames.asmdef.meta +7 -7
- package/DifficultyEditorBase.cs +60 -60
- package/DifficultyEditorBase.cs.meta +11 -11
- package/IShatterGraphic.cs +32 -32
- package/IShatterGraphic.cs.meta +11 -11
- package/IShatterText.cs +33 -33
- package/IShatterText.cs.meta +11 -11
- package/InitializeTrialOffsets.cs +51 -51
- package/InitializeTrialOffsets.cs.meta +11 -11
- package/MinigameBuilderBase.cs +28 -28
- package/MinigameBuilderBase.cs.meta +11 -11
- package/MinigameControlsUIHandler.cs +94 -94
- package/MinigameControlsUIHandler.cs.meta +11 -11
- package/MinigameManagerBase.cs +197 -197
- package/MinigameManagerBase.cs.meta +11 -11
- package/QuestionToggle.cs +154 -154
- package/QuestionToggle.cs.meta +11 -11
- package/RestoreControlsUIPostDialogue.cs +100 -100
- package/RestoreControlsUIPostDialogue.cs.meta +1 -1
- package/{Samples → Samples~}/Bullet Shatter Mesh Generator.asset +23 -23
- package/{Samples → Samples~}/Bullet Shatter Mesh Generator.asset.meta +8 -8
- package/{Samples → Samples~}/HasStamina.asset +21 -21
- package/{Samples → Samples~}/HasStamina.asset.meta +8 -8
- package/{Samples → Samples~}/IsDrainingStamina.asset +21 -21
- package/{Samples → Samples~}/IsDrainingStamina.asset.meta +8 -8
- package/{Samples → Samples~}/MinigameInputAllowed.asset +21 -21
- package/{Samples → Samples~}/MinigameInputAllowed.asset.meta +8 -8
- package/{Samples → Samples~}/Minigame_Controls_UI_Handler.prefab +53 -53
- package/{Samples → Samples~}/Minigame_Controls_UI_Handler.prefab.meta +7 -7
- package/{Samples → Samples~}/Quad Shatter.asset +31 -31
- package/{Samples → Samples~}/Quad Shatter.asset.meta +8 -8
- package/{Samples → Samples~}/ShatterCameraEnabled.asset +21 -21
- package/{Samples → Samples~}/ShatterCameraEnabled.asset.meta +8 -8
- package/{Samples → Samples~}/Shatter_Graphic.prefab +98 -98
- package/{Samples → Samples~}/Shatter_Graphic.prefab.meta +7 -7
- package/{Samples → Samples~}/Stamina_Handler.prefab +59 -59
- package/{Samples → Samples~}/Stamina_Handler.prefab.meta +7 -7
- package/{Samples → Samples~}/TBS_Manager_Shell.prefab +60 -60
- package/{Samples → Samples~}/TBS_Manager_Shell.prefab.meta +7 -7
- package/{Samples → Samples~}/TBS_Manager_Template.prefab +504 -504
- package/{Samples → Samples~}/TBS_Manager_Template.prefab.meta +7 -7
- package/{Samples → Samples~}/Trial_UI_Shatter_Canvas_Shell.prefab +289 -289
- package/{Samples → Samples~}/Trial_UI_Shatter_Canvas_Shell.prefab.meta +7 -7
- package/{Samples → Samples~}/Trial_UI_Shatter_Canvas_Template.prefab +449 -449
- package/{Samples → Samples~}/Trial_UI_Shatter_Canvas_Template.prefab.meta +7 -7
- package/{Samples → Samples~}/Triangle Shatter.asset +31 -31
- package/{Samples → Samples~}/Triangle Shatter.asset.meta +8 -8
- package/{Samples → Samples~}/Truth_Bullet_Menu_Canvas_Shell.prefab +221 -221
- package/{Samples → Samples~}/Truth_Bullet_Menu_Canvas_Shell.prefab.meta +7 -7
- package/{Samples → Samples~}/Truth_Bullet_Menu_Canvas_Template.prefab +525 -525
- package/{Samples → Samples~}/Truth_Bullet_Menu_Canvas_Template.prefab.meta +7 -7
- package/{Samples → Samples~}/Truth_Bullet_Menu_Holder_Shell.prefab +38 -38
- package/{Samples → Samples~}/Truth_Bullet_Menu_Holder_Shell.prefab.meta +7 -7
- package/{Samples → Samples~}/Truth_Bullet_Menu_Holder_Template.prefab +1159 -1159
- package/{Samples → Samples~}/Truth_Bullet_Menu_Holder_Template.prefab.meta +7 -7
- package/{Samples → Samples~}/Truth_Bullet_Minigame_Canvas_Template.prefab +494 -494
- package/{Samples → Samples~}/Truth_Bullet_Minigame_Canvas_Template.prefab.meta +7 -7
- package/{Samples → Samples~}/Truth_Bullet_Option_ETemplate.prefab +294 -294
- package/{Samples → Samples~}/Truth_Bullet_Option_ETemplate.prefab.meta +7 -7
- package/Shattering/BreakTex.renderTexture +39 -39
- package/Shattering/BreakTex.renderTexture.meta +8 -8
- package/Shattering/BulletShatter.cs +176 -176
- package/Shattering/BulletShatter.cs.meta +11 -11
- package/Shattering/IShatterableCanvas.cs +20 -20
- package/Shattering/IShatterableCanvas.cs.meta +11 -11
- package/Shattering/MeshGenerator.cs +178 -178
- package/Shattering/MeshGenerator.cs.meta +11 -11
- package/Shattering/RenderCanvasOnShatter.cs +47 -47
- package/Shattering/RenderCanvasOnShatter.cs.meta +11 -11
- package/Shattering/ShatterCameraRender.cs +79 -79
- package/Shattering/ShatterCameraRender.cs.meta +11 -11
- package/Shattering/ShatterGraphic.cs +135 -135
- package/Shattering/ShatterGraphic.cs.meta +11 -11
- package/Shattering/ShatterMeshGraphic.cs +304 -304
- package/Shattering/ShatterMeshGraphic.cs.meta +11 -11
- package/Shattering/ShatterProcess.cs +282 -282
- package/Shattering/ShatterProcess.cs.meta +11 -11
- package/Shattering/ShatterProcessBase.cs +51 -51
- package/Shattering/ShatterProcessBase.cs.meta +11 -11
- package/Shattering/ShatterQuad.cs +56 -56
- package/Shattering/ShatterQuad.cs.meta +11 -11
- package/Shattering/ShatterQuadProcess.cs +65 -65
- package/Shattering/ShatterQuadProcess.cs.meta +11 -11
- package/Shattering/ShatterShape.cs +84 -84
- package/Shattering/ShatterShape.cs.meta +11 -11
- package/Shattering/ShatterTri.cs +27 -27
- package/Shattering/ShatterTri.cs.meta +11 -11
- package/Shattering/ShatterTriProcess.cs +179 -179
- package/Shattering/ShatterTriProcess.cs.meta +11 -11
- package/Shattering/ShatterWithUI.cs +68 -68
- package/Shattering/ShatterWithUI.cs.meta +11 -11
- package/Shattering/SplitShatter.cs +114 -114
- package/Shattering/SplitShatter.cs.meta +11 -11
- package/Shattering/TMPTextShatter.cs +243 -243
- package/Shattering/TMPTextShatter.cs.meta +11 -11
- package/Shattering/UIBreakVisibility.cs +172 -172
- package/Shattering/UIBreakVisibility.cs.meta +11 -11
- package/Shattering.meta +8 -8
- package/ShuffleUtility.cs +32 -32
- package/ShuffleUtility.cs.meta +11 -11
- package/SimpleRandom.cs +32 -32
- package/SimpleRandom.cs.meta +11 -11
- package/Stats/ColorHealthBar.cs +56 -56
- package/Stats/ColorHealthBar.cs.meta +11 -11
- package/Stats/ColorHealthModifier.cs +138 -138
- package/Stats/ColorHealthModifier.cs.meta +11 -11
- package/Stats/GaugeHandler.cs +72 -72
- package/Stats/GaugeHandler.cs.meta +1 -1
- package/Stats/HealthBarModifier.cs +89 -89
- package/Stats/HealthBarModifier.cs.meta +11 -11
- package/Stats/HealthStat.cs +77 -77
- package/Stats/HealthStat.cs.meta +11 -11
- package/Stats/HealthStatBase.cs +26 -26
- package/Stats/HealthStatBase.cs.meta +11 -11
- package/Stats/IGauge.cs +36 -36
- package/Stats/IGauge.cs.meta +1 -1
- package/Stats/InfluenceGauge.cs +107 -107
- package/Stats/InfluenceGauge.cs.meta +11 -11
- package/Stats/InfluenceGaugeBase.cs +42 -42
- package/Stats/InfluenceGaugeBase.cs.meta +11 -11
- package/Stats/SimpleGauge.cs +46 -46
- package/Stats/SimpleGauge.cs.meta +1 -1
- package/Stats/StaminaHandler.cs +153 -153
- package/Stats/StaminaHandler.cs.meta +11 -11
- package/Stats/TrialStats.cs +140 -140
- package/Stats/TrialStats.cs.meta +11 -11
- package/Stats/TrialStatsBase.cs +36 -36
- package/Stats/TrialStatsBase.cs.meta +11 -11
- package/Stats.meta +8 -8
- package/TBS/TBSelectBuilder.cs +59 -59
- package/TBS/TBSelectBuilder.cs.meta +11 -11
- package/TBS/TBSelectBuilderEditor.cs +166 -166
- package/TBS/TBSelectBuilderEditor.cs.meta +11 -11
- package/TBS/TBSelectManager.cs +315 -315
- package/TBS/TBSelectManager.cs.meta +11 -11
- package/TBS/TBSelection.cs +46 -46
- package/TBS/TBSelection.cs.meta +11 -11
- package/TBS/TrialTruthBulletMenu.cs +24 -24
- package/TBS/TrialTruthBulletMenu.cs.meta +11 -11
- package/TBS.meta +8 -8
- package/ThreadSafeSimpleRandom.cs +29 -29
- package/ThreadSafeSimpleRandom.cs.meta +11 -11
- package/TimedDifficultyEditor.cs +56 -56
- package/TimedDifficultyEditor.cs.meta +11 -11
- package/TimedMinigameEditor.cs +31 -31
- package/TimedMinigameEditor.cs.meta +11 -11
- package/TimerBase.cs +189 -189
- package/TimerBase.cs.meta +11 -11
- package/TimerDifficulty.cs +45 -45
- package/TimerDifficulty.cs.meta +11 -11
- package/TrialDialogueMinigame.cs +276 -276
- package/TrialDialogueMinigame.cs.meta +11 -11
- package/TrialDiscussion.cs +68 -68
- package/TrialDiscussion.cs.meta +11 -11
- package/TrialTimer.cs +113 -113
- package/TrialTimer.cs.meta +11 -11
- package/TrialTimerBase.cs +129 -129
- package/TrialTimerBase.cs.meta +11 -11
- package/package.json +56 -51
- package/package.json.meta +7 -7
- package/Samples.meta +0 -8
|
@@ -1,283 +1,283 @@
|
|
|
1
|
-
// Completely Reworked Author: Benjamin "Sweden" Jillson : Discord: sweden_gaming For Project Eden's Garden
|
|
2
|
-
// Original Author: LeoTheDev
|
|
3
|
-
using System;
|
|
4
|
-
using System.Collections;
|
|
5
|
-
using UnityEngine;
|
|
6
|
-
|
|
7
|
-
namespace DREditor.Minigames.Shattering
|
|
8
|
-
{
|
|
9
|
-
/// <summary>
|
|
10
|
-
///
|
|
11
|
-
/// </summary>
|
|
12
|
-
/// <typeparam name="T"></typeparam>
|
|
13
|
-
public abstract class ShatterProcess<T> : ShatterProcessBase where T : ShatterShape
|
|
14
|
-
{
|
|
15
|
-
/// <summary>
|
|
16
|
-
///
|
|
17
|
-
/// </summary>
|
|
18
|
-
[Header("")]
|
|
19
|
-
[Divider]
|
|
20
|
-
[Range(0, 1)]
|
|
21
|
-
[Tooltip("")]
|
|
22
|
-
[SerializeField] protected float maxAlpha = 1;
|
|
23
|
-
|
|
24
|
-
/// <summary>
|
|
25
|
-
///
|
|
26
|
-
/// </summary>
|
|
27
|
-
[Range(0, 1)]
|
|
28
|
-
[Tooltip("")]
|
|
29
|
-
[SerializeField] protected float minAlpha = 0;
|
|
30
|
-
|
|
31
|
-
/// <summary>
|
|
32
|
-
///
|
|
33
|
-
/// </summary>
|
|
34
|
-
[Range(0, 1)]
|
|
35
|
-
[Tooltip("")]
|
|
36
|
-
[SerializeField] protected float airResistince = 0.8f;
|
|
37
|
-
|
|
38
|
-
/// <summary>
|
|
39
|
-
///
|
|
40
|
-
/// </summary>
|
|
41
|
-
[Tooltip("")]
|
|
42
|
-
[SerializeField] protected float hitForce = .025f;// 0.125
|
|
43
|
-
|
|
44
|
-
/// <summary>
|
|
45
|
-
///
|
|
46
|
-
/// </summary>
|
|
47
|
-
[Tooltip("")]
|
|
48
|
-
[SerializeField] protected float maxHitArea = 3f;// 10
|
|
49
|
-
|
|
50
|
-
/// <summary>
|
|
51
|
-
///
|
|
52
|
-
/// </summary>
|
|
53
|
-
[Tooltip("")]
|
|
54
|
-
[SerializeField] protected float angularVelocityMultiplier = 100;
|
|
55
|
-
|
|
56
|
-
/// <summary>
|
|
57
|
-
///
|
|
58
|
-
/// </summary>
|
|
59
|
-
[Tooltip("")]
|
|
60
|
-
[SerializeField] protected Vector3 hitPointOffset;
|
|
61
|
-
|
|
62
|
-
/// <summary>
|
|
63
|
-
///
|
|
64
|
-
/// </summary>
|
|
65
|
-
[Tooltip("")]
|
|
66
|
-
[SerializeField] protected bool fades = false; // true
|
|
67
|
-
|
|
68
|
-
/// <summary>
|
|
69
|
-
///
|
|
70
|
-
/// </summary>
|
|
71
|
-
[Tooltip("")]
|
|
72
|
-
[SerializeField] protected float fadeTime = 1f;
|
|
73
|
-
|
|
74
|
-
/// <summary>
|
|
75
|
-
///
|
|
76
|
-
/// </summary>
|
|
77
|
-
[Tooltip("")]
|
|
78
|
-
[SerializeField] protected float fadeDelay = 0;
|
|
79
|
-
|
|
80
|
-
/// <summary>
|
|
81
|
-
///
|
|
82
|
-
/// </summary>
|
|
83
|
-
[Tooltip("")]
|
|
84
|
-
[SerializeField] protected bool freezeXYRot = false;
|
|
85
|
-
|
|
86
|
-
/// <summary>
|
|
87
|
-
///
|
|
88
|
-
/// </summary>
|
|
89
|
-
[Tooltip("")]
|
|
90
|
-
[SerializeField] protected bool freezeZPos = false;
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
/// <summary>
|
|
94
|
-
///
|
|
95
|
-
/// </summary>
|
|
96
|
-
[Header("")]
|
|
97
|
-
[Divider]
|
|
98
|
-
[Tooltip("")]
|
|
99
|
-
[SerializeField] protected Vector3[] newVertices;
|
|
100
|
-
|
|
101
|
-
/// <summary>
|
|
102
|
-
///
|
|
103
|
-
/// </summary>
|
|
104
|
-
[Tooltip("")]
|
|
105
|
-
[SerializeField] protected int[] newTriangles;
|
|
106
|
-
|
|
107
|
-
/// <summary>
|
|
108
|
-
///
|
|
109
|
-
/// </summary>
|
|
110
|
-
[Tooltip("")]
|
|
111
|
-
[SerializeField] protected Vector2[][] newUVs;
|
|
112
|
-
|
|
113
|
-
/// <summary>
|
|
114
|
-
///
|
|
115
|
-
/// </summary>
|
|
116
|
-
[Tooltip("")]
|
|
117
|
-
[SerializeField] protected Color[] vertexColors;
|
|
118
|
-
|
|
119
|
-
/// <summary>
|
|
120
|
-
///
|
|
121
|
-
/// </summary>
|
|
122
|
-
[Tooltip("")]
|
|
123
|
-
[SerializeField] protected Vector3[] triangleVelocity;
|
|
124
|
-
|
|
125
|
-
/// <summary>
|
|
126
|
-
///
|
|
127
|
-
/// </summary>
|
|
128
|
-
[Tooltip("")]
|
|
129
|
-
[SerializeField] protected Vector3[] rotationVelocity;
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
/// <summary>
|
|
133
|
-
///
|
|
134
|
-
/// </summary>
|
|
135
|
-
protected T[] shapes;
|
|
136
|
-
|
|
137
|
-
/// <summary>
|
|
138
|
-
///
|
|
139
|
-
/// </summary>
|
|
140
|
-
protected MonoBehaviour runner;
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
/// <summary>
|
|
144
|
-
///
|
|
145
|
-
/// </summary>
|
|
146
|
-
/// <param name="mesh"></param>
|
|
147
|
-
protected virtual void InitializeArrays(Mesh mesh)
|
|
148
|
-
{
|
|
149
|
-
int triCount = mesh.triangles.Length / 3 - 2;
|
|
150
|
-
|
|
151
|
-
int newVertexCount = triCount * 3;
|
|
152
|
-
|
|
153
|
-
triangleVelocity = new Vector3[triCount];
|
|
154
|
-
|
|
155
|
-
rotationVelocity = new Vector3[triCount];
|
|
156
|
-
|
|
157
|
-
newTriangles = new int[newVertexCount];
|
|
158
|
-
|
|
159
|
-
newUVs = new Vector2[2][];
|
|
160
|
-
|
|
161
|
-
newUVs[0] = new Vector2[newVertexCount];
|
|
162
|
-
|
|
163
|
-
newUVs[1] = new Vector2[newVertexCount];
|
|
164
|
-
}
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
public override void Shatter(MonoBehaviour runner, Vector3 hitPoint, Mesh mesh)
|
|
168
|
-
{
|
|
169
|
-
this.runner = runner;
|
|
170
|
-
|
|
171
|
-
ShapeAngulate(mesh);
|
|
172
|
-
|
|
173
|
-
ShatterShapes(hitPoint);
|
|
174
|
-
|
|
175
|
-
FadeShapes();
|
|
176
|
-
}
|
|
177
|
-
|
|
178
|
-
/// <summary>
|
|
179
|
-
///
|
|
180
|
-
/// </summary>
|
|
181
|
-
/// <param name="mesh"></param>
|
|
182
|
-
protected abstract void ShapeAngulate(Mesh mesh);
|
|
183
|
-
|
|
184
|
-
/// <summary>
|
|
185
|
-
///
|
|
186
|
-
/// </summary>
|
|
187
|
-
/// <param name="hitPoint"></param>
|
|
188
|
-
protected virtual void ShatterShapes(Vector3 hitPoint)
|
|
189
|
-
{
|
|
190
|
-
hitPoint += hitPointOffset;
|
|
191
|
-
|
|
192
|
-
for (int i = 0; i < shapes.Length; i++)
|
|
193
|
-
{
|
|
194
|
-
Vector3 direction = (shapes[i].Center - hitPoint).normalized;
|
|
195
|
-
|
|
196
|
-
float dist = Vector3.Distance(shapes[i].Center, hitPoint);
|
|
197
|
-
|
|
198
|
-
float force = Mathf.Lerp(hitForce, 0, dist / maxHitArea);
|
|
199
|
-
|
|
200
|
-
triangleVelocity[i] = direction * force;
|
|
201
|
-
|
|
202
|
-
if (freezeXYRot)
|
|
203
|
-
rotationVelocity[i] = angularVelocityMultiplier * force * new Vector3(0, 0, UnityEngine.Random.Range(0, 1f));
|
|
204
|
-
else
|
|
205
|
-
rotationVelocity[i] =
|
|
206
|
-
angularVelocityMultiplier *
|
|
207
|
-
force *
|
|
208
|
-
new Vector3(
|
|
209
|
-
UnityEngine.Random.Range(0f, 1f),
|
|
210
|
-
UnityEngine.Random.Range(0f, 1f),
|
|
211
|
-
UnityEngine.Random.Range(0f, 1f));
|
|
212
|
-
}
|
|
213
|
-
}
|
|
214
|
-
|
|
215
|
-
/// <summary>
|
|
216
|
-
///
|
|
217
|
-
/// </summary>
|
|
218
|
-
protected virtual void FadeShapes()
|
|
219
|
-
{
|
|
220
|
-
if (fades)
|
|
221
|
-
runner.StartCoroutine(FadeShape());
|
|
222
|
-
}
|
|
223
|
-
|
|
224
|
-
/// <summary>
|
|
225
|
-
///
|
|
226
|
-
/// </summary>
|
|
227
|
-
protected virtual IEnumerator FadeShape()
|
|
228
|
-
{
|
|
229
|
-
yield return new WaitForSeconds(fadeDelay);
|
|
230
|
-
|
|
231
|
-
float initial = vertexColors[0].a;
|
|
232
|
-
|
|
233
|
-
float counter = 0;
|
|
234
|
-
|
|
235
|
-
while (counter <= fadeTime)
|
|
236
|
-
{
|
|
237
|
-
for (int i = 0; i < vertexColors.Length; i++)
|
|
238
|
-
vertexColors[i].a = Mathf.Lerp(initial, 0, counter / fadeTime);
|
|
239
|
-
|
|
240
|
-
counter += Time.deltaTime;
|
|
241
|
-
|
|
242
|
-
yield return null;
|
|
243
|
-
}
|
|
244
|
-
|
|
245
|
-
yield break;
|
|
246
|
-
}
|
|
247
|
-
|
|
248
|
-
public override ShatterShape[] GetShapes() => shapes;
|
|
249
|
-
|
|
250
|
-
public override IEnumerator UpdateShatter(Action<Vector3[], Color[]> updateCallback)
|
|
251
|
-
{
|
|
252
|
-
Ready();
|
|
253
|
-
|
|
254
|
-
while (ready)
|
|
255
|
-
{
|
|
256
|
-
UpdateShape();
|
|
257
|
-
|
|
258
|
-
updateCallback(newVertices, vertexColors);
|
|
259
|
-
|
|
260
|
-
yield return null;
|
|
261
|
-
}
|
|
262
|
-
|
|
263
|
-
yield break;
|
|
264
|
-
}
|
|
265
|
-
|
|
266
|
-
/// <summary>
|
|
267
|
-
///
|
|
268
|
-
/// </summary>
|
|
269
|
-
protected virtual void UpdateShape()
|
|
270
|
-
{
|
|
271
|
-
for (int i = 0; i < shapes.Length; i++)
|
|
272
|
-
{
|
|
273
|
-
shapes[i].Rotate(rotationVelocity[i], newVertices);
|
|
274
|
-
|
|
275
|
-
shapes[i].Move(triangleVelocity[i], newVertices, freezeZPos);
|
|
276
|
-
|
|
277
|
-
rotationVelocity[i] *= (1 - (airResistince * Time.deltaTime));
|
|
278
|
-
|
|
279
|
-
triangleVelocity[i] *= (1 - (airResistince * Time.deltaTime));
|
|
280
|
-
}
|
|
281
|
-
}
|
|
282
|
-
}
|
|
1
|
+
// Completely Reworked Author: Benjamin "Sweden" Jillson : Discord: sweden_gaming For Project Eden's Garden
|
|
2
|
+
// Original Author: LeoTheDev
|
|
3
|
+
using System;
|
|
4
|
+
using System.Collections;
|
|
5
|
+
using UnityEngine;
|
|
6
|
+
|
|
7
|
+
namespace DREditor.Minigames.Shattering
|
|
8
|
+
{
|
|
9
|
+
/// <summary>
|
|
10
|
+
///
|
|
11
|
+
/// </summary>
|
|
12
|
+
/// <typeparam name="T"></typeparam>
|
|
13
|
+
public abstract class ShatterProcess<T> : ShatterProcessBase where T : ShatterShape
|
|
14
|
+
{
|
|
15
|
+
/// <summary>
|
|
16
|
+
///
|
|
17
|
+
/// </summary>
|
|
18
|
+
[Header("")]
|
|
19
|
+
[Divider]
|
|
20
|
+
[Range(0, 1)]
|
|
21
|
+
[Tooltip("")]
|
|
22
|
+
[SerializeField] protected float maxAlpha = 1;
|
|
23
|
+
|
|
24
|
+
/// <summary>
|
|
25
|
+
///
|
|
26
|
+
/// </summary>
|
|
27
|
+
[Range(0, 1)]
|
|
28
|
+
[Tooltip("")]
|
|
29
|
+
[SerializeField] protected float minAlpha = 0;
|
|
30
|
+
|
|
31
|
+
/// <summary>
|
|
32
|
+
///
|
|
33
|
+
/// </summary>
|
|
34
|
+
[Range(0, 1)]
|
|
35
|
+
[Tooltip("")]
|
|
36
|
+
[SerializeField] protected float airResistince = 0.8f;
|
|
37
|
+
|
|
38
|
+
/// <summary>
|
|
39
|
+
///
|
|
40
|
+
/// </summary>
|
|
41
|
+
[Tooltip("")]
|
|
42
|
+
[SerializeField] protected float hitForce = .025f;// 0.125
|
|
43
|
+
|
|
44
|
+
/// <summary>
|
|
45
|
+
///
|
|
46
|
+
/// </summary>
|
|
47
|
+
[Tooltip("")]
|
|
48
|
+
[SerializeField] protected float maxHitArea = 3f;// 10
|
|
49
|
+
|
|
50
|
+
/// <summary>
|
|
51
|
+
///
|
|
52
|
+
/// </summary>
|
|
53
|
+
[Tooltip("")]
|
|
54
|
+
[SerializeField] protected float angularVelocityMultiplier = 100;
|
|
55
|
+
|
|
56
|
+
/// <summary>
|
|
57
|
+
///
|
|
58
|
+
/// </summary>
|
|
59
|
+
[Tooltip("")]
|
|
60
|
+
[SerializeField] protected Vector3 hitPointOffset;
|
|
61
|
+
|
|
62
|
+
/// <summary>
|
|
63
|
+
///
|
|
64
|
+
/// </summary>
|
|
65
|
+
[Tooltip("")]
|
|
66
|
+
[SerializeField] protected bool fades = false; // true
|
|
67
|
+
|
|
68
|
+
/// <summary>
|
|
69
|
+
///
|
|
70
|
+
/// </summary>
|
|
71
|
+
[Tooltip("")]
|
|
72
|
+
[SerializeField] protected float fadeTime = 1f;
|
|
73
|
+
|
|
74
|
+
/// <summary>
|
|
75
|
+
///
|
|
76
|
+
/// </summary>
|
|
77
|
+
[Tooltip("")]
|
|
78
|
+
[SerializeField] protected float fadeDelay = 0;
|
|
79
|
+
|
|
80
|
+
/// <summary>
|
|
81
|
+
///
|
|
82
|
+
/// </summary>
|
|
83
|
+
[Tooltip("")]
|
|
84
|
+
[SerializeField] protected bool freezeXYRot = false;
|
|
85
|
+
|
|
86
|
+
/// <summary>
|
|
87
|
+
///
|
|
88
|
+
/// </summary>
|
|
89
|
+
[Tooltip("")]
|
|
90
|
+
[SerializeField] protected bool freezeZPos = false;
|
|
91
|
+
|
|
92
|
+
|
|
93
|
+
/// <summary>
|
|
94
|
+
///
|
|
95
|
+
/// </summary>
|
|
96
|
+
[Header("")]
|
|
97
|
+
[Divider]
|
|
98
|
+
[Tooltip("")]
|
|
99
|
+
[SerializeField] protected Vector3[] newVertices;
|
|
100
|
+
|
|
101
|
+
/// <summary>
|
|
102
|
+
///
|
|
103
|
+
/// </summary>
|
|
104
|
+
[Tooltip("")]
|
|
105
|
+
[SerializeField] protected int[] newTriangles;
|
|
106
|
+
|
|
107
|
+
/// <summary>
|
|
108
|
+
///
|
|
109
|
+
/// </summary>
|
|
110
|
+
[Tooltip("")]
|
|
111
|
+
[SerializeField] protected Vector2[][] newUVs;
|
|
112
|
+
|
|
113
|
+
/// <summary>
|
|
114
|
+
///
|
|
115
|
+
/// </summary>
|
|
116
|
+
[Tooltip("")]
|
|
117
|
+
[SerializeField] protected Color[] vertexColors;
|
|
118
|
+
|
|
119
|
+
/// <summary>
|
|
120
|
+
///
|
|
121
|
+
/// </summary>
|
|
122
|
+
[Tooltip("")]
|
|
123
|
+
[SerializeField] protected Vector3[] triangleVelocity;
|
|
124
|
+
|
|
125
|
+
/// <summary>
|
|
126
|
+
///
|
|
127
|
+
/// </summary>
|
|
128
|
+
[Tooltip("")]
|
|
129
|
+
[SerializeField] protected Vector3[] rotationVelocity;
|
|
130
|
+
|
|
131
|
+
|
|
132
|
+
/// <summary>
|
|
133
|
+
///
|
|
134
|
+
/// </summary>
|
|
135
|
+
protected T[] shapes;
|
|
136
|
+
|
|
137
|
+
/// <summary>
|
|
138
|
+
///
|
|
139
|
+
/// </summary>
|
|
140
|
+
protected MonoBehaviour runner;
|
|
141
|
+
|
|
142
|
+
|
|
143
|
+
/// <summary>
|
|
144
|
+
///
|
|
145
|
+
/// </summary>
|
|
146
|
+
/// <param name="mesh"></param>
|
|
147
|
+
protected virtual void InitializeArrays(Mesh mesh)
|
|
148
|
+
{
|
|
149
|
+
int triCount = mesh.triangles.Length / 3 - 2;
|
|
150
|
+
|
|
151
|
+
int newVertexCount = triCount * 3;
|
|
152
|
+
|
|
153
|
+
triangleVelocity = new Vector3[triCount];
|
|
154
|
+
|
|
155
|
+
rotationVelocity = new Vector3[triCount];
|
|
156
|
+
|
|
157
|
+
newTriangles = new int[newVertexCount];
|
|
158
|
+
|
|
159
|
+
newUVs = new Vector2[2][];
|
|
160
|
+
|
|
161
|
+
newUVs[0] = new Vector2[newVertexCount];
|
|
162
|
+
|
|
163
|
+
newUVs[1] = new Vector2[newVertexCount];
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
|
|
167
|
+
public override void Shatter(MonoBehaviour runner, Vector3 hitPoint, Mesh mesh)
|
|
168
|
+
{
|
|
169
|
+
this.runner = runner;
|
|
170
|
+
|
|
171
|
+
ShapeAngulate(mesh);
|
|
172
|
+
|
|
173
|
+
ShatterShapes(hitPoint);
|
|
174
|
+
|
|
175
|
+
FadeShapes();
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
/// <summary>
|
|
179
|
+
///
|
|
180
|
+
/// </summary>
|
|
181
|
+
/// <param name="mesh"></param>
|
|
182
|
+
protected abstract void ShapeAngulate(Mesh mesh);
|
|
183
|
+
|
|
184
|
+
/// <summary>
|
|
185
|
+
///
|
|
186
|
+
/// </summary>
|
|
187
|
+
/// <param name="hitPoint"></param>
|
|
188
|
+
protected virtual void ShatterShapes(Vector3 hitPoint)
|
|
189
|
+
{
|
|
190
|
+
hitPoint += hitPointOffset;
|
|
191
|
+
|
|
192
|
+
for (int i = 0; i < shapes.Length; i++)
|
|
193
|
+
{
|
|
194
|
+
Vector3 direction = (shapes[i].Center - hitPoint).normalized;
|
|
195
|
+
|
|
196
|
+
float dist = Vector3.Distance(shapes[i].Center, hitPoint);
|
|
197
|
+
|
|
198
|
+
float force = Mathf.Lerp(hitForce, 0, dist / maxHitArea);
|
|
199
|
+
|
|
200
|
+
triangleVelocity[i] = direction * force;
|
|
201
|
+
|
|
202
|
+
if (freezeXYRot)
|
|
203
|
+
rotationVelocity[i] = angularVelocityMultiplier * force * new Vector3(0, 0, UnityEngine.Random.Range(0, 1f));
|
|
204
|
+
else
|
|
205
|
+
rotationVelocity[i] =
|
|
206
|
+
angularVelocityMultiplier *
|
|
207
|
+
force *
|
|
208
|
+
new Vector3(
|
|
209
|
+
UnityEngine.Random.Range(0f, 1f),
|
|
210
|
+
UnityEngine.Random.Range(0f, 1f),
|
|
211
|
+
UnityEngine.Random.Range(0f, 1f));
|
|
212
|
+
}
|
|
213
|
+
}
|
|
214
|
+
|
|
215
|
+
/// <summary>
|
|
216
|
+
///
|
|
217
|
+
/// </summary>
|
|
218
|
+
protected virtual void FadeShapes()
|
|
219
|
+
{
|
|
220
|
+
if (fades)
|
|
221
|
+
runner.StartCoroutine(FadeShape());
|
|
222
|
+
}
|
|
223
|
+
|
|
224
|
+
/// <summary>
|
|
225
|
+
///
|
|
226
|
+
/// </summary>
|
|
227
|
+
protected virtual IEnumerator FadeShape()
|
|
228
|
+
{
|
|
229
|
+
yield return new WaitForSeconds(fadeDelay);
|
|
230
|
+
|
|
231
|
+
float initial = vertexColors[0].a;
|
|
232
|
+
|
|
233
|
+
float counter = 0;
|
|
234
|
+
|
|
235
|
+
while (counter <= fadeTime)
|
|
236
|
+
{
|
|
237
|
+
for (int i = 0; i < vertexColors.Length; i++)
|
|
238
|
+
vertexColors[i].a = Mathf.Lerp(initial, 0, counter / fadeTime);
|
|
239
|
+
|
|
240
|
+
counter += Time.deltaTime;
|
|
241
|
+
|
|
242
|
+
yield return null;
|
|
243
|
+
}
|
|
244
|
+
|
|
245
|
+
yield break;
|
|
246
|
+
}
|
|
247
|
+
|
|
248
|
+
public override ShatterShape[] GetShapes() => shapes;
|
|
249
|
+
|
|
250
|
+
public override IEnumerator UpdateShatter(Action<Vector3[], Color[]> updateCallback)
|
|
251
|
+
{
|
|
252
|
+
Ready();
|
|
253
|
+
|
|
254
|
+
while (ready)
|
|
255
|
+
{
|
|
256
|
+
UpdateShape();
|
|
257
|
+
|
|
258
|
+
updateCallback(newVertices, vertexColors);
|
|
259
|
+
|
|
260
|
+
yield return null;
|
|
261
|
+
}
|
|
262
|
+
|
|
263
|
+
yield break;
|
|
264
|
+
}
|
|
265
|
+
|
|
266
|
+
/// <summary>
|
|
267
|
+
///
|
|
268
|
+
/// </summary>
|
|
269
|
+
protected virtual void UpdateShape()
|
|
270
|
+
{
|
|
271
|
+
for (int i = 0; i < shapes.Length; i++)
|
|
272
|
+
{
|
|
273
|
+
shapes[i].Rotate(rotationVelocity[i], newVertices);
|
|
274
|
+
|
|
275
|
+
shapes[i].Move(triangleVelocity[i], newVertices, freezeZPos);
|
|
276
|
+
|
|
277
|
+
rotationVelocity[i] *= (1 - (airResistince * Time.deltaTime));
|
|
278
|
+
|
|
279
|
+
triangleVelocity[i] *= (1 - (airResistince * Time.deltaTime));
|
|
280
|
+
}
|
|
281
|
+
}
|
|
282
|
+
}
|
|
283
283
|
}
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
fileFormatVersion: 2
|
|
2
|
-
guid: 39961e135dd49d942a33c225366e7e0b
|
|
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: 39961e135dd49d942a33c225366e7e0b
|
|
3
|
+
MonoImporter:
|
|
4
|
+
externalObjects: {}
|
|
5
|
+
serializedVersion: 2
|
|
6
|
+
defaultReferences: []
|
|
7
|
+
executionOrder: 0
|
|
8
|
+
icon: {instanceID: 0}
|
|
9
|
+
userData:
|
|
10
|
+
assetBundleName:
|
|
11
|
+
assetBundleVariant:
|