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
package/Stats/ColorHealthBar.cs
CHANGED
|
@@ -1,57 +1,57 @@
|
|
|
1
|
-
//Author: Benjamin "Sweden" Jillson : Discord: sweden_gaming For Project Eden's Garden
|
|
2
|
-
#if DOTWEEN
|
|
3
|
-
using DG.Tweening;
|
|
4
|
-
#endif
|
|
5
|
-
using UnityEngine;
|
|
6
|
-
using UnityEngine.UI;
|
|
7
|
-
|
|
8
|
-
namespace DREditor.Minigames.Stats
|
|
9
|
-
{
|
|
10
|
-
/// <summary>
|
|
11
|
-
///
|
|
12
|
-
/// </summary>
|
|
13
|
-
[ClassHeader(nameof(HealthStatBase) + ", " + nameof(ColorHealthModifier) +
|
|
14
|
-
"\n\n")]
|
|
15
|
-
public class ColorHealthBar : ColorHealthModifier
|
|
16
|
-
{
|
|
17
|
-
/// <summary>
|
|
18
|
-
///
|
|
19
|
-
/// </summary>
|
|
20
|
-
[Header("")]
|
|
21
|
-
[Divider]
|
|
22
|
-
[Tooltip("")]
|
|
23
|
-
[SerializeField] protected Image fillImage = null;
|
|
24
|
-
|
|
25
|
-
/// <summary>
|
|
26
|
-
///
|
|
27
|
-
/// </summary>
|
|
28
|
-
[Tooltip("")]
|
|
29
|
-
[SerializeField] protected float regenHealthFillDuration = 1;
|
|
30
|
-
|
|
31
|
-
/// <summary>
|
|
32
|
-
///
|
|
33
|
-
/// </summary>
|
|
34
|
-
[Tooltip("")]
|
|
35
|
-
[SerializeField] protected float colorDuration = 1;
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
/// <inheritdoc/>
|
|
39
|
-
public override void ResetHealth()
|
|
40
|
-
{
|
|
41
|
-
#if DOTWEEN
|
|
42
|
-
fillImage.DOColor(regenColor, 0);
|
|
43
|
-
|
|
44
|
-
fillImage.DOColor(colorRange[0], regenHealthFillDuration)
|
|
45
|
-
.SetDelay(regenHealthFillDuration);
|
|
46
|
-
#endif
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
/// <inheritdoc/>
|
|
50
|
-
protected override void ApplyColor() =>
|
|
51
|
-
#if DOTWEEN
|
|
52
|
-
fillImage.DOColor(currentColor, colorDuration);
|
|
53
|
-
#else
|
|
54
|
-
fillImage.color = currentColor;
|
|
55
|
-
#endif
|
|
56
|
-
}
|
|
1
|
+
//Author: Benjamin "Sweden" Jillson : Discord: sweden_gaming For Project Eden's Garden
|
|
2
|
+
#if DOTWEEN
|
|
3
|
+
using DG.Tweening;
|
|
4
|
+
#endif
|
|
5
|
+
using UnityEngine;
|
|
6
|
+
using UnityEngine.UI;
|
|
7
|
+
|
|
8
|
+
namespace DREditor.Minigames.Stats
|
|
9
|
+
{
|
|
10
|
+
/// <summary>
|
|
11
|
+
///
|
|
12
|
+
/// </summary>
|
|
13
|
+
[ClassHeader(nameof(HealthStatBase) + ", " + nameof(ColorHealthModifier) +
|
|
14
|
+
"\n\n")]
|
|
15
|
+
public class ColorHealthBar : ColorHealthModifier
|
|
16
|
+
{
|
|
17
|
+
/// <summary>
|
|
18
|
+
///
|
|
19
|
+
/// </summary>
|
|
20
|
+
[Header("")]
|
|
21
|
+
[Divider]
|
|
22
|
+
[Tooltip("")]
|
|
23
|
+
[SerializeField] protected Image fillImage = null;
|
|
24
|
+
|
|
25
|
+
/// <summary>
|
|
26
|
+
///
|
|
27
|
+
/// </summary>
|
|
28
|
+
[Tooltip("")]
|
|
29
|
+
[SerializeField] protected float regenHealthFillDuration = 1;
|
|
30
|
+
|
|
31
|
+
/// <summary>
|
|
32
|
+
///
|
|
33
|
+
/// </summary>
|
|
34
|
+
[Tooltip("")]
|
|
35
|
+
[SerializeField] protected float colorDuration = 1;
|
|
36
|
+
|
|
37
|
+
|
|
38
|
+
/// <inheritdoc/>
|
|
39
|
+
public override void ResetHealth()
|
|
40
|
+
{
|
|
41
|
+
#if DOTWEEN
|
|
42
|
+
fillImage.DOColor(regenColor, 0);
|
|
43
|
+
|
|
44
|
+
fillImage.DOColor(colorRange[0], regenHealthFillDuration)
|
|
45
|
+
.SetDelay(regenHealthFillDuration);
|
|
46
|
+
#endif
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
/// <inheritdoc/>
|
|
50
|
+
protected override void ApplyColor() =>
|
|
51
|
+
#if DOTWEEN
|
|
52
|
+
fillImage.DOColor(currentColor, colorDuration);
|
|
53
|
+
#else
|
|
54
|
+
fillImage.color = currentColor;
|
|
55
|
+
#endif
|
|
56
|
+
}
|
|
57
57
|
}
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
fileFormatVersion: 2
|
|
2
|
-
guid: b9001133a7dabb2458a03da064bf7484
|
|
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: b9001133a7dabb2458a03da064bf7484
|
|
3
|
+
MonoImporter:
|
|
4
|
+
externalObjects: {}
|
|
5
|
+
serializedVersion: 2
|
|
6
|
+
defaultReferences: []
|
|
7
|
+
executionOrder: 0
|
|
8
|
+
icon: {instanceID: 0}
|
|
9
|
+
userData:
|
|
10
|
+
assetBundleName:
|
|
11
|
+
assetBundleVariant:
|
|
@@ -1,139 +1,139 @@
|
|
|
1
|
-
//Author: Benjamin "Sweden" Jillson : Discord: sweden_gaming For Project Eden's Garden
|
|
2
|
-
using DREditor.Saving.Handlers;
|
|
3
|
-
using System.Linq;
|
|
4
|
-
using UnityEngine;
|
|
5
|
-
|
|
6
|
-
namespace DREditor.Minigames.Stats
|
|
7
|
-
{
|
|
8
|
-
/// <summary>
|
|
9
|
-
///
|
|
10
|
-
/// </summary>
|
|
11
|
-
public abstract class ColorHealthModifier : HealthStatBase
|
|
12
|
-
{
|
|
13
|
-
/// <summary>
|
|
14
|
-
///
|
|
15
|
-
/// </summary>
|
|
16
|
-
[Header("")]
|
|
17
|
-
[Divider]
|
|
18
|
-
[Tooltip("")]
|
|
19
|
-
[SerializeField] protected Color[] colorRange = new Color[3]
|
|
20
|
-
{
|
|
21
|
-
new Color32(32, 133, 47, 255), new Color32(255, 116, 1, 255), new(255, 0, 0, 255)
|
|
22
|
-
};
|
|
23
|
-
|
|
24
|
-
/// <summary>
|
|
25
|
-
///
|
|
26
|
-
/// </summary>
|
|
27
|
-
[Tooltip("")]
|
|
28
|
-
[SerializeField] protected Color regenColor = new Color32(144, 247, 198, 255);
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
/// <summary>
|
|
32
|
-
///
|
|
33
|
-
/// </summary>
|
|
34
|
-
protected Color[] colorSteps;
|
|
35
|
-
|
|
36
|
-
/// <summary>
|
|
37
|
-
///
|
|
38
|
-
/// </summary>
|
|
39
|
-
protected Color currentColor;
|
|
40
|
-
|
|
41
|
-
/// <summary>
|
|
42
|
-
///
|
|
43
|
-
/// </summary>
|
|
44
|
-
protected HealthDataHandler<int> healthDataHandler = null;
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
protected virtual void Start()
|
|
48
|
-
{
|
|
49
|
-
healthDataHandler = transform.root.GetComponentInChildren<HealthDataHandler<int>>();
|
|
50
|
-
|
|
51
|
-
colorSteps = GenerateColorSteps(colorRange, healthDataHandler.GetMaxHealth());
|
|
52
|
-
|
|
53
|
-
SetCurrentColor(colorSteps[0]);
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
/// <summary>
|
|
57
|
-
///
|
|
58
|
-
/// </summary>
|
|
59
|
-
/// <param name="anchorColors"></param>
|
|
60
|
-
/// <param name="totalSteps"></param>
|
|
61
|
-
protected virtual Color[] GenerateColorSteps(Color[] anchorColors, int totalSteps)
|
|
62
|
-
{
|
|
63
|
-
if (anchorColors == null || anchorColors.Length == 0)
|
|
64
|
-
return new Color[totalSteps];
|
|
65
|
-
|
|
66
|
-
if (anchorColors.Length == 1)
|
|
67
|
-
return Enumerable.Repeat(anchorColors[0], totalSteps).ToArray();
|
|
68
|
-
|
|
69
|
-
if (totalSteps < anchorColors.Length)
|
|
70
|
-
totalSteps = anchorColors.Length;
|
|
71
|
-
|
|
72
|
-
Color[] steps = new Color[totalSteps];
|
|
73
|
-
|
|
74
|
-
int segmentsCount = anchorColors.Length - 1;
|
|
75
|
-
|
|
76
|
-
float stepsPerSegment = (float)(totalSteps - 1) / segmentsCount;
|
|
77
|
-
|
|
78
|
-
for (int i = 0; i < totalSteps; i++)
|
|
79
|
-
{
|
|
80
|
-
float globalPosition = i / stepsPerSegment;
|
|
81
|
-
|
|
82
|
-
int currentAnchorIndex = Mathf.FloorToInt(globalPosition);
|
|
83
|
-
|
|
84
|
-
if (currentAnchorIndex >= segmentsCount)
|
|
85
|
-
{
|
|
86
|
-
steps[i] = anchorColors[^1];
|
|
87
|
-
|
|
88
|
-
continue;
|
|
89
|
-
}
|
|
90
|
-
|
|
91
|
-
int nextAnchorIndex = currentAnchorIndex + 1;
|
|
92
|
-
|
|
93
|
-
float localT = globalPosition - currentAnchorIndex;
|
|
94
|
-
|
|
95
|
-
steps[i] = Color.Lerp(anchorColors[currentAnchorIndex], anchorColors[nextAnchorIndex], localT);
|
|
96
|
-
}
|
|
97
|
-
|
|
98
|
-
return steps.Reverse().ToArray();
|
|
99
|
-
}
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
/// <inheritdoc/>
|
|
103
|
-
public override void Refresh() => CalculateColor();
|
|
104
|
-
|
|
105
|
-
/// <inheritdoc/>
|
|
106
|
-
public override void TakeDamage(float damage) => CalculateColor();
|
|
107
|
-
|
|
108
|
-
/// <summary>
|
|
109
|
-
///
|
|
110
|
-
/// </summary>
|
|
111
|
-
protected virtual void CalculateColor()
|
|
112
|
-
{
|
|
113
|
-
UpdateColor();
|
|
114
|
-
|
|
115
|
-
ApplyColor();
|
|
116
|
-
}
|
|
117
|
-
|
|
118
|
-
/// <summary>
|
|
119
|
-
///
|
|
120
|
-
/// </summary>
|
|
121
|
-
protected virtual void UpdateColor()
|
|
122
|
-
{
|
|
123
|
-
if (healthDataHandler.GetHealth() - 1 >= 0 && healthDataHandler.GetHealth() - 1 < colorSteps.Length)
|
|
124
|
-
SetCurrentColor(colorSteps[healthDataHandler.GetHealth() - 1]);
|
|
125
|
-
else
|
|
126
|
-
SetCurrentColor(colorRange[^1]);
|
|
127
|
-
}
|
|
128
|
-
|
|
129
|
-
/// <summary>
|
|
130
|
-
///
|
|
131
|
-
/// </summary>
|
|
132
|
-
protected abstract void ApplyColor();
|
|
133
|
-
|
|
134
|
-
/// <summary>
|
|
135
|
-
///
|
|
136
|
-
/// </summary>
|
|
137
|
-
protected virtual void SetCurrentColor(Color color) => currentColor = color;
|
|
138
|
-
}
|
|
1
|
+
//Author: Benjamin "Sweden" Jillson : Discord: sweden_gaming For Project Eden's Garden
|
|
2
|
+
using DREditor.Saving.Handlers;
|
|
3
|
+
using System.Linq;
|
|
4
|
+
using UnityEngine;
|
|
5
|
+
|
|
6
|
+
namespace DREditor.Minigames.Stats
|
|
7
|
+
{
|
|
8
|
+
/// <summary>
|
|
9
|
+
///
|
|
10
|
+
/// </summary>
|
|
11
|
+
public abstract class ColorHealthModifier : HealthStatBase
|
|
12
|
+
{
|
|
13
|
+
/// <summary>
|
|
14
|
+
///
|
|
15
|
+
/// </summary>
|
|
16
|
+
[Header("")]
|
|
17
|
+
[Divider]
|
|
18
|
+
[Tooltip("")]
|
|
19
|
+
[SerializeField] protected Color[] colorRange = new Color[3]
|
|
20
|
+
{
|
|
21
|
+
new Color32(32, 133, 47, 255), new Color32(255, 116, 1, 255), new(255, 0, 0, 255)
|
|
22
|
+
};
|
|
23
|
+
|
|
24
|
+
/// <summary>
|
|
25
|
+
///
|
|
26
|
+
/// </summary>
|
|
27
|
+
[Tooltip("")]
|
|
28
|
+
[SerializeField] protected Color regenColor = new Color32(144, 247, 198, 255);
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
/// <summary>
|
|
32
|
+
///
|
|
33
|
+
/// </summary>
|
|
34
|
+
protected Color[] colorSteps;
|
|
35
|
+
|
|
36
|
+
/// <summary>
|
|
37
|
+
///
|
|
38
|
+
/// </summary>
|
|
39
|
+
protected Color currentColor;
|
|
40
|
+
|
|
41
|
+
/// <summary>
|
|
42
|
+
///
|
|
43
|
+
/// </summary>
|
|
44
|
+
protected HealthDataHandler<int> healthDataHandler = null;
|
|
45
|
+
|
|
46
|
+
|
|
47
|
+
protected virtual void Start()
|
|
48
|
+
{
|
|
49
|
+
healthDataHandler = transform.root.GetComponentInChildren<HealthDataHandler<int>>();
|
|
50
|
+
|
|
51
|
+
colorSteps = GenerateColorSteps(colorRange, healthDataHandler.GetMaxHealth());
|
|
52
|
+
|
|
53
|
+
SetCurrentColor(colorSteps[0]);
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
/// <summary>
|
|
57
|
+
///
|
|
58
|
+
/// </summary>
|
|
59
|
+
/// <param name="anchorColors"></param>
|
|
60
|
+
/// <param name="totalSteps"></param>
|
|
61
|
+
protected virtual Color[] GenerateColorSteps(Color[] anchorColors, int totalSteps)
|
|
62
|
+
{
|
|
63
|
+
if (anchorColors == null || anchorColors.Length == 0)
|
|
64
|
+
return new Color[totalSteps];
|
|
65
|
+
|
|
66
|
+
if (anchorColors.Length == 1)
|
|
67
|
+
return Enumerable.Repeat(anchorColors[0], totalSteps).ToArray();
|
|
68
|
+
|
|
69
|
+
if (totalSteps < anchorColors.Length)
|
|
70
|
+
totalSteps = anchorColors.Length;
|
|
71
|
+
|
|
72
|
+
Color[] steps = new Color[totalSteps];
|
|
73
|
+
|
|
74
|
+
int segmentsCount = anchorColors.Length - 1;
|
|
75
|
+
|
|
76
|
+
float stepsPerSegment = (float)(totalSteps - 1) / segmentsCount;
|
|
77
|
+
|
|
78
|
+
for (int i = 0; i < totalSteps; i++)
|
|
79
|
+
{
|
|
80
|
+
float globalPosition = i / stepsPerSegment;
|
|
81
|
+
|
|
82
|
+
int currentAnchorIndex = Mathf.FloorToInt(globalPosition);
|
|
83
|
+
|
|
84
|
+
if (currentAnchorIndex >= segmentsCount)
|
|
85
|
+
{
|
|
86
|
+
steps[i] = anchorColors[^1];
|
|
87
|
+
|
|
88
|
+
continue;
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
int nextAnchorIndex = currentAnchorIndex + 1;
|
|
92
|
+
|
|
93
|
+
float localT = globalPosition - currentAnchorIndex;
|
|
94
|
+
|
|
95
|
+
steps[i] = Color.Lerp(anchorColors[currentAnchorIndex], anchorColors[nextAnchorIndex], localT);
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
return steps.Reverse().ToArray();
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
|
|
102
|
+
/// <inheritdoc/>
|
|
103
|
+
public override void Refresh() => CalculateColor();
|
|
104
|
+
|
|
105
|
+
/// <inheritdoc/>
|
|
106
|
+
public override void TakeDamage(float damage) => CalculateColor();
|
|
107
|
+
|
|
108
|
+
/// <summary>
|
|
109
|
+
///
|
|
110
|
+
/// </summary>
|
|
111
|
+
protected virtual void CalculateColor()
|
|
112
|
+
{
|
|
113
|
+
UpdateColor();
|
|
114
|
+
|
|
115
|
+
ApplyColor();
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
/// <summary>
|
|
119
|
+
///
|
|
120
|
+
/// </summary>
|
|
121
|
+
protected virtual void UpdateColor()
|
|
122
|
+
{
|
|
123
|
+
if (healthDataHandler.GetHealth() - 1 >= 0 && healthDataHandler.GetHealth() - 1 < colorSteps.Length)
|
|
124
|
+
SetCurrentColor(colorSteps[healthDataHandler.GetHealth() - 1]);
|
|
125
|
+
else
|
|
126
|
+
SetCurrentColor(colorRange[^1]);
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
/// <summary>
|
|
130
|
+
///
|
|
131
|
+
/// </summary>
|
|
132
|
+
protected abstract void ApplyColor();
|
|
133
|
+
|
|
134
|
+
/// <summary>
|
|
135
|
+
///
|
|
136
|
+
/// </summary>
|
|
137
|
+
protected virtual void SetCurrentColor(Color color) => currentColor = color;
|
|
138
|
+
}
|
|
139
139
|
}
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
fileFormatVersion: 2
|
|
2
|
-
guid: df34f5df4828a904886efd4a7efb399a
|
|
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: df34f5df4828a904886efd4a7efb399a
|
|
3
|
+
MonoImporter:
|
|
4
|
+
externalObjects: {}
|
|
5
|
+
serializedVersion: 2
|
|
6
|
+
defaultReferences: []
|
|
7
|
+
executionOrder: 0
|
|
8
|
+
icon: {instanceID: 0}
|
|
9
|
+
userData:
|
|
10
|
+
assetBundleName:
|
|
11
|
+
assetBundleVariant:
|
package/Stats/GaugeHandler.cs
CHANGED
|
@@ -1,73 +1,73 @@
|
|
|
1
|
-
//Author: Benjamin "Sweden" Jillson : Discord: sweden_gaming For Project Eden's Garden
|
|
2
|
-
using DREditor.EventObjects;
|
|
3
|
-
using UnityEngine;
|
|
4
|
-
|
|
5
|
-
namespace DREditor.Minigames.Stats
|
|
6
|
-
{
|
|
7
|
-
/// <summary>
|
|
8
|
-
///
|
|
9
|
-
/// </summary>
|
|
10
|
-
public abstract class GaugeHandler : MonoBehaviour
|
|
11
|
-
{
|
|
12
|
-
/// <summary>
|
|
13
|
-
///
|
|
14
|
-
/// </summary>
|
|
15
|
-
[Tooltip("")]
|
|
16
|
-
[SerializeField] protected BoolWithEvent gaugeState = null;
|
|
17
|
-
|
|
18
|
-
/// <summary>
|
|
19
|
-
///
|
|
20
|
-
/// </summary>
|
|
21
|
-
[SelectType]
|
|
22
|
-
[Tooltip("")]
|
|
23
|
-
[SerializeReference] protected IGauge gauge = null;
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
protected virtual void Awake() => Validate();
|
|
27
|
-
|
|
28
|
-
/// <summary>
|
|
29
|
-
///
|
|
30
|
-
/// </summary>
|
|
31
|
-
protected virtual void Validate()
|
|
32
|
-
{
|
|
33
|
-
if (gauge == null)
|
|
34
|
-
UnityEngine.Debug.LogError($"ALERT: {nameof(gauge)} cannot be null!");
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
protected virtual void Update()
|
|
39
|
-
{
|
|
40
|
-
if (GaugeShouldTick())
|
|
41
|
-
OnGaugeTick();
|
|
42
|
-
else
|
|
43
|
-
OnFailedTick();
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
/// <summary>
|
|
47
|
-
///
|
|
48
|
-
/// </summary>
|
|
49
|
-
/// <returns></returns>
|
|
50
|
-
protected virtual bool GaugeShouldTick() => gaugeState.Value;
|
|
51
|
-
|
|
52
|
-
/// <summary>
|
|
53
|
-
///
|
|
54
|
-
/// </summary>
|
|
55
|
-
protected abstract void OnGaugeTick();
|
|
56
|
-
|
|
57
|
-
/// <summary>
|
|
58
|
-
///
|
|
59
|
-
/// </summary>
|
|
60
|
-
protected abstract void OnFailedTick();
|
|
61
|
-
|
|
62
|
-
/// <summary>
|
|
63
|
-
///
|
|
64
|
-
/// </summary>
|
|
65
|
-
protected virtual void TickGauge() => gauge.Tick(GetTickAmount());
|
|
66
|
-
|
|
67
|
-
/// <summary>
|
|
68
|
-
///
|
|
69
|
-
/// </summary>
|
|
70
|
-
/// <returns></returns>
|
|
71
|
-
protected abstract float GetTickAmount();
|
|
72
|
-
}
|
|
1
|
+
//Author: Benjamin "Sweden" Jillson : Discord: sweden_gaming For Project Eden's Garden
|
|
2
|
+
using DREditor.EventObjects;
|
|
3
|
+
using UnityEngine;
|
|
4
|
+
|
|
5
|
+
namespace DREditor.Minigames.Stats
|
|
6
|
+
{
|
|
7
|
+
/// <summary>
|
|
8
|
+
///
|
|
9
|
+
/// </summary>
|
|
10
|
+
public abstract class GaugeHandler : MonoBehaviour
|
|
11
|
+
{
|
|
12
|
+
/// <summary>
|
|
13
|
+
///
|
|
14
|
+
/// </summary>
|
|
15
|
+
[Tooltip("")]
|
|
16
|
+
[SerializeField] protected BoolWithEvent gaugeState = null;
|
|
17
|
+
|
|
18
|
+
/// <summary>
|
|
19
|
+
///
|
|
20
|
+
/// </summary>
|
|
21
|
+
[SelectType]
|
|
22
|
+
[Tooltip("")]
|
|
23
|
+
[SerializeReference] protected IGauge gauge = null;
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
protected virtual void Awake() => Validate();
|
|
27
|
+
|
|
28
|
+
/// <summary>
|
|
29
|
+
///
|
|
30
|
+
/// </summary>
|
|
31
|
+
protected virtual void Validate()
|
|
32
|
+
{
|
|
33
|
+
if (gauge == null)
|
|
34
|
+
UnityEngine.Debug.LogError($"ALERT: {nameof(gauge)} cannot be null!");
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
|
|
38
|
+
protected virtual void Update()
|
|
39
|
+
{
|
|
40
|
+
if (GaugeShouldTick())
|
|
41
|
+
OnGaugeTick();
|
|
42
|
+
else
|
|
43
|
+
OnFailedTick();
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
/// <summary>
|
|
47
|
+
///
|
|
48
|
+
/// </summary>
|
|
49
|
+
/// <returns></returns>
|
|
50
|
+
protected virtual bool GaugeShouldTick() => gaugeState.Value;
|
|
51
|
+
|
|
52
|
+
/// <summary>
|
|
53
|
+
///
|
|
54
|
+
/// </summary>
|
|
55
|
+
protected abstract void OnGaugeTick();
|
|
56
|
+
|
|
57
|
+
/// <summary>
|
|
58
|
+
///
|
|
59
|
+
/// </summary>
|
|
60
|
+
protected abstract void OnFailedTick();
|
|
61
|
+
|
|
62
|
+
/// <summary>
|
|
63
|
+
///
|
|
64
|
+
/// </summary>
|
|
65
|
+
protected virtual void TickGauge() => gauge.Tick(GetTickAmount());
|
|
66
|
+
|
|
67
|
+
/// <summary>
|
|
68
|
+
///
|
|
69
|
+
/// </summary>
|
|
70
|
+
/// <returns></returns>
|
|
71
|
+
protected abstract float GetTickAmount();
|
|
72
|
+
}
|
|
73
73
|
}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
fileFormatVersion: 2
|
|
1
|
+
fileFormatVersion: 2
|
|
2
2
|
guid: 3a366f78ace1d974e8b147c2076f0e24
|