net.dreditor.minigames.rs 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/CrossSwordsMechanic.cs +329 -329
- package/CrossSwordsMechanic.cs.meta +11 -11
- package/CutHandler.cs +286 -286
- package/CutHandler.cs.meta +11 -11
- package/CutLimitMechanic.cs +58 -58
- package/CutLimitMechanic.cs.meta +11 -11
- package/DREditor.Minigames.RS.asmdef +37 -37
- package/DREditor.Minigames.RS.asmdef.meta +7 -7
- package/DamagePhraseOnSwordHit.cs +149 -149
- package/DamagePhraseOnSwordHit.cs.meta +11 -11
- package/Editor/DREditor.Minigames.RS.Editor.asmdef +23 -23
- package/Editor/DREditor.Minigames.RS.Editor.asmdef.meta +7 -7
- package/Editor/RSBuilderEditor.cs +395 -395
- package/Editor/RSBuilderEditor.cs.meta +11 -11
- package/Editor/RSDebugToolEditor.cs +98 -98
- package/Editor/RSDebugToolEditor.cs.meta +11 -11
- package/Editor/RSEditorBase.cs +189 -189
- package/Editor/RSEditorBase.cs.meta +11 -11
- package/Editor/RSPhraseEditor.cs +43 -43
- package/Editor/RSPhraseEditor.cs.meta +11 -11
- package/Editor.meta +8 -8
- package/FollowRectSizeDelta.cs +81 -81
- package/FollowRectSizeDelta.cs.meta +11 -11
- package/FollowableRect.cs +28 -28
- package/FollowableRect.cs.meta +11 -11
- package/IPhraseHealth.cs +35 -35
- package/IPhraseHealth.cs.meta +11 -11
- package/ISplitScreen.cs +48 -48
- package/ISplitScreen.cs.meta +11 -11
- package/ISwipeListener.cs +17 -17
- package/ISwipeListener.cs.meta +11 -11
- package/ISword.cs +44 -44
- package/ISword.cs.meta +11 -11
- package/ISwordHitListener.cs +17 -17
- package/ISwordHitListener.cs.meta +11 -11
- package/ITieBreaker.cs +17 -17
- package/ITieBreaker.cs.meta +11 -11
- package/Managers/FireSliceAnimation.cs +292 -292
- package/Managers/FireSliceAnimation.cs.meta +11 -11
- package/Managers/FiredSliceHandler.cs +92 -92
- package/Managers/FiredSliceHandler.cs.meta +11 -11
- package/Managers/InterjectHandler.cs +139 -139
- package/Managers/InterjectHandler.cs.meta +11 -11
- package/Managers/InterjectHandlerBase.cs +18 -18
- package/Managers/InterjectHandlerBase.cs.meta +11 -11
- package/Managers/RSBuilder.cs +307 -307
- package/Managers/RSBuilder.cs.meta +11 -11
- package/Managers/RSEnemyWinMechanic.cs +177 -177
- package/Managers/RSEnemyWinMechanic.cs.meta +11 -11
- package/Managers/RSGroup.cs +178 -178
- package/Managers/RSGroup.cs.meta +11 -11
- package/Managers/RSGroupManager.cs +378 -378
- package/Managers/RSGroupManager.cs.meta +11 -11
- package/Managers/RSManager.cs +319 -319
- package/Managers/RSManager.cs.meta +11 -11
- package/Managers/RSPanel.cs +38 -38
- package/Managers/RSPanel.cs.meta +11 -11
- package/Managers/RSPhrase.cs +56 -56
- package/Managers/RSPhrase.cs.meta +11 -11
- package/Managers.meta +8 -8
- package/MultiPanelManager.cs +178 -178
- package/MultiPanelManager.cs.meta +11 -11
- package/{Samples → Samples~}/CUT_Canvas.prefab +484 -484
- package/{Samples → Samples~}/CUT_Canvas.prefab.meta +7 -7
- package/{Samples → Samples~}/Cross_Swords_Mechanic_Shell.prefab +64 -64
- package/{Samples → Samples~}/Cross_Swords_Mechanic_Shell.prefab.meta +7 -7
- package/{Samples → Samples~}/Cross_Swords_Mechanic_Template.prefab +485 -485
- package/{Samples → Samples~}/Cross_Swords_Mechanic_Template.prefab.meta +7 -7
- package/{Samples → Samples~}/CutCount.asset +21 -21
- package/{Samples → Samples~}/CutCount.asset.meta +8 -8
- package/{Samples → Samples~}/Cut_Handler.prefab +253 -253
- package/{Samples → Samples~}/Cut_Handler.prefab.meta +7 -7
- package/{Samples → Samples~}/Cut_Limit_Mechanic_UI.prefab +233 -233
- package/{Samples → Samples~}/Cut_Limit_Mechanic_UI.prefab.meta +7 -7
- package/{Samples → Samples~}/Debate_Text_Texture.prefab +75 -75
- package/{Samples → Samples~}/Debate_Text_Texture.prefab.meta +7 -7
- package/{Samples → Samples~}/Fire_Slice_Animation.prefab +308 -308
- package/{Samples → Samples~}/Fire_Slice_Animation.prefab.meta +7 -7
- package/{Samples → Samples~}/Fired_Slice_Handler_Shell.prefab +49 -49
- package/{Samples → Samples~}/Fired_Slice_Handler_Shell.prefab.meta +7 -7
- package/{Samples → Samples~}/Fired_Slice_Handler_Template.prefab +163 -163
- package/{Samples → Samples~}/Fired_Slice_Handler_Template.prefab.meta +7 -7
- package/{Samples → Samples~}/Multi_Line_Processes.prefab +306 -306
- package/{Samples → Samples~}/Multi_Line_Processes.prefab.meta +7 -7
- package/{Samples → Samples~}/Multi_Panel_Canvas_Shell.prefab +140 -140
- package/{Samples → Samples~}/Multi_Panel_Canvas_Shell.prefab.meta +7 -7
- package/{Samples → Samples~}/Multi_Panel_Canvas_Template.prefab +426 -426
- package/{Samples → Samples~}/Multi_Panel_Canvas_Template.prefab.meta +7 -7
- package/{Samples → Samples~}/Multi_Panel_Manager_Shell.prefab +57 -57
- package/{Samples → Samples~}/Multi_Panel_Manager_Shell.prefab.meta +7 -7
- package/{Samples → Samples~}/Multi_Panel_Manager_Template.prefab +316 -316
- package/{Samples → Samples~}/Multi_Panel_Manager_Template.prefab.meta +7 -7
- package/{Samples → Samples~}/OnAdvance.asset +15 -15
- package/{Samples → Samples~}/OnAdvance.asset.meta +8 -8
- package/{Samples → Samples~}/OnDuelEnded.asset +15 -15
- package/{Samples → Samples~}/OnDuelEnded.asset.meta +8 -8
- package/{Samples → Samples~}/OnDuelStarted.asset +15 -15
- package/{Samples → Samples~}/OnDuelStarted.asset.meta +8 -8
- package/{Samples → Samples~}/OnRetreat.asset +15 -15
- package/{Samples → Samples~}/OnRetreat.asset.meta +8 -8
- package/{Samples → Samples~}/OutOfCuts.asset +21 -21
- package/{Samples → Samples~}/OutOfCuts.asset.meta +8 -8
- package/{Samples → Samples~}/Panel_Mask_1.prefab +182 -182
- package/{Samples → Samples~}/Panel_Mask_1.prefab.meta +7 -7
- package/{Samples → Samples~}/Panel_Mask_2.prefab +127 -127
- package/{Samples → Samples~}/Panel_Mask_2.prefab.meta +7 -7
- package/{Samples → Samples~}/RS Mesh Generator.asset +21 -21
- package/{Samples → Samples~}/RS Mesh Generator.asset.meta +8 -8
- package/{Samples → Samples~}/RS Triangle Shatter.asset +31 -31
- package/{Samples → Samples~}/RS Triangle Shatter.asset.meta +8 -8
- package/{Samples → Samples~}/RSCameraRightEnabled.asset +21 -21
- package/{Samples → Samples~}/RSCameraRightEnabled.asset.meta +8 -8
- package/{Samples → Samples~}/RS_Bullet_Canvas_ETemplate.prefab +290 -290
- package/{Samples → Samples~}/RS_Bullet_Canvas_ETemplate.prefab.meta +7 -7
- package/{Samples → Samples~}/RS_Bullet_Canvas_Shell.prefab +156 -156
- package/{Samples → Samples~}/RS_Bullet_Canvas_Shell.prefab.meta +7 -7
- package/{Samples → Samples~}/RS_Bullet_ETemplate.prefab +127 -127
- package/{Samples → Samples~}/RS_Bullet_ETemplate.prefab.meta +7 -7
- package/{Samples → Samples~}/RS_Bullet_Evaluator_Manager_Template.prefab +299 -299
- package/{Samples → Samples~}/RS_Bullet_Evaluator_Manager_Template.prefab.meta +7 -7
- package/{Samples → Samples~}/RS_Bullet_UI_Parent_ETemplate.prefab +164 -164
- package/{Samples → Samples~}/RS_Bullet_UI_Parent_ETemplate.prefab.meta +7 -7
- package/{Samples → Samples~}/RS_Canvas_Shell.prefab +98 -98
- package/{Samples → Samples~}/RS_Canvas_Shell.prefab.meta +7 -7
- package/{Samples → Samples~}/RS_Canvas_Template.prefab +841 -841
- package/{Samples → Samples~}/RS_Canvas_Template.prefab.meta +7 -7
- package/{Samples → Samples~}/RS_Click_Group.prefab +255 -255
- package/{Samples → Samples~}/RS_Click_Group.prefab.meta +7 -7
- package/{Samples → Samples~}/RS_Controls_UI_Handler.prefab +168 -168
- package/{Samples → Samples~}/RS_Controls_UI_Handler.prefab.meta +7 -7
- package/{Samples → Samples~}/RS_Cycle_Bullet_ETemplate.prefab +242 -242
- package/{Samples → Samples~}/RS_Cycle_Bullet_ETemplate.prefab.meta +7 -7
- package/{Samples → Samples~}/RS_Cycle_UI_Canvas_Shell.prefab +232 -232
- package/{Samples → Samples~}/RS_Cycle_UI_Canvas_Shell.prefab.meta +7 -7
- package/{Samples → Samples~}/RS_Cycle_UI_Canvas_Template.prefab +443 -443
- package/{Samples → Samples~}/RS_Cycle_UI_Canvas_Template.prefab.meta +7 -7
- package/{Samples → Samples~}/RS_Enemy_Win_Mechanic_Shell.prefab +106 -106
- package/{Samples → Samples~}/RS_Enemy_Win_Mechanic_Shell.prefab.meta +7 -7
- package/{Samples → Samples~}/RS_Enemy_Win_Mechanic_Template.prefab +230 -230
- package/{Samples → Samples~}/RS_Enemy_Win_Mechanic_Template.prefab.meta +7 -7
- package/{Samples → Samples~}/RS_Fire_Bullet_UI_Handler_Template.prefab +1234 -1234
- package/{Samples → Samples~}/RS_Fire_Bullet_UI_Handler_Template.prefab.meta +7 -7
- package/{Samples → Samples~}/RS_Firing_Sword_UI_ETemplate.prefab +405 -405
- package/{Samples → Samples~}/RS_Firing_Sword_UI_ETemplate.prefab.meta +7 -7
- package/{Samples → Samples~}/RS_Group_Manager_Shell.prefab +145 -145
- package/{Samples → Samples~}/RS_Group_Manager_Shell.prefab.meta +7 -7
- package/{Samples → Samples~}/RS_Group_Manager_Template.prefab +537 -537
- package/{Samples → Samples~}/RS_Group_Manager_Template.prefab.meta +7 -7
- package/{Samples → Samples~}/RS_Line_Manager_Template.prefab +191 -191
- package/{Samples → Samples~}/RS_Line_Manager_Template.prefab.meta +7 -7
- package/{Samples → Samples~}/RS_Loading_Bullet_Canvas_Shell.prefab +204 -204
- package/{Samples → Samples~}/RS_Loading_Bullet_Canvas_Shell.prefab.meta +7 -7
- package/{Samples → Samples~}/RS_Loading_Bullet_Canvas_Template.prefab +411 -411
- package/{Samples → Samples~}/RS_Loading_Bullet_Canvas_Template.prefab.meta +7 -7
- package/{Samples → Samples~}/RS_Manager_Shell.prefab +514 -514
- package/{Samples → Samples~}/RS_Manager_Shell.prefab.meta +7 -7
- package/{Samples → Samples~}/RS_Manager_Template.prefab +1526 -1526
- package/{Samples → Samples~}/RS_Manager_Template.prefab.meta +7 -7
- package/{Samples → Samples~}/RS_Text_Camera.prefab +125 -125
- package/{Samples → Samples~}/RS_Text_Camera.prefab.meta +7 -7
- package/{Samples → Samples~}/RS_UI_Shatter_Canvas_Template.prefab +150 -150
- package/{Samples → Samples~}/RS_UI_Shatter_Canvas_Template.prefab.meta +7 -7
- package/{Samples → Samples~}/ShowRSUI.asset +15 -15
- package/{Samples → Samples~}/ShowRSUI.asset.meta +8 -8
- package/{Samples → Samples~}/Split_Seam_UI.prefab +120 -120
- package/{Samples → Samples~}/Split_Seam_UI.prefab.meta +7 -7
- package/{Samples → Samples~}/Swipe_Sword.prefab +81 -81
- package/{Samples → Samples~}/Swipe_Sword.prefab.meta +7 -7
- package/{Samples → Samples~}/Swipe_Visualizer_Image.prefab +102 -102
- package/{Samples → Samples~}/Swipe_Visualizer_Image.prefab.meta +7 -7
- package/{Samples → Samples~}/Sword_Hit_Listeners.prefab +49 -49
- package/{Samples → Samples~}/Sword_Hit_Listeners.prefab.meta +7 -7
- package/SplitScreenHandler.cs +263 -263
- package/SplitScreenHandler.cs.meta +11 -11
- package/SwipeSword.cs +235 -235
- package/SwipeSword.cs.meta +11 -11
- package/SwipeVisualizer.cs +241 -241
- package/SwipeVisualizer.cs.meta +11 -11
- package/package.json +57 -52
- package/package.json.meta +7 -7
- package/Samples.meta +0 -8
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
fileFormatVersion: 2
|
|
2
|
-
guid: a53406f39601c64448afb18b909d5e5f
|
|
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: a53406f39601c64448afb18b909d5e5f
|
|
3
|
+
MonoImporter:
|
|
4
|
+
externalObjects: {}
|
|
5
|
+
serializedVersion: 2
|
|
6
|
+
defaultReferences: []
|
|
7
|
+
executionOrder: 0
|
|
8
|
+
icon: {instanceID: 0}
|
|
9
|
+
userData:
|
|
10
|
+
assetBundleName:
|
|
11
|
+
assetBundleVariant:
|
package/CutHandler.cs
CHANGED
|
@@ -1,287 +1,287 @@
|
|
|
1
|
-
//Author: Benjamin "Sweden" Jillson : Discord: sweden_gaming For Project Eden's Garden
|
|
2
|
-
using DREditor.EventObjects;
|
|
3
|
-
using DREditor.UIHandling;
|
|
4
|
-
using System.Collections;
|
|
5
|
-
using System.Collections.Generic;
|
|
6
|
-
using System.Linq;
|
|
7
|
-
using UnityEngine;
|
|
8
|
-
using UnityEngine.Events;
|
|
9
|
-
using UnityEngine.InputSystem;
|
|
10
|
-
using static UnityEngine.InputSystem.InputAction;
|
|
11
|
-
|
|
12
|
-
namespace DREditor.Minigames.RS
|
|
13
|
-
{
|
|
14
|
-
/// <summary>
|
|
15
|
-
///
|
|
16
|
-
/// </summary>
|
|
17
|
-
/// <remarks></remarks>
|
|
18
|
-
[ClassHeader(nameof(ControlledComponent) +
|
|
19
|
-
"\n\n")]
|
|
20
|
-
public class CutHandler : ControlledComponent
|
|
21
|
-
{
|
|
22
|
-
/// <summary>
|
|
23
|
-
///
|
|
24
|
-
/// </summary>
|
|
25
|
-
[Tooltip("")]
|
|
26
|
-
[SerializeField] protected InputActionReference swipe = null;
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
/// <summary>
|
|
30
|
-
///
|
|
31
|
-
/// </summary>
|
|
32
|
-
[Header("")]
|
|
33
|
-
[Divider]
|
|
34
|
-
[Tooltip("")]
|
|
35
|
-
[SerializeField] protected bool outputDebugSwipeLogs = false;
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
/// <summary>
|
|
39
|
-
///
|
|
40
|
-
/// </summary>
|
|
41
|
-
[Header("")]
|
|
42
|
-
[Divider]
|
|
43
|
-
[Tooltip("")]
|
|
44
|
-
[SerializeField] protected EvaluateBoolCondition preventCutsCondition;
|
|
45
|
-
|
|
46
|
-
/// <summary>
|
|
47
|
-
///
|
|
48
|
-
/// </summary>
|
|
49
|
-
[Tooltip("")]
|
|
50
|
-
[SerializeField] protected int frameWindowForInput = 5;
|
|
51
|
-
|
|
52
|
-
/// <summary>
|
|
53
|
-
///
|
|
54
|
-
/// </summary>
|
|
55
|
-
[Tooltip("")]
|
|
56
|
-
[SerializeField] protected float timeForSwordToCut = 0.2f;
|
|
57
|
-
|
|
58
|
-
/// <summary>
|
|
59
|
-
///
|
|
60
|
-
/// </summary>
|
|
61
|
-
[Tooltip("")]
|
|
62
|
-
[SerializeField] protected float cutCooldown = 0.1f;
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
[Header("")]
|
|
66
|
-
[SerializeField] protected UnityEvent<Vector3, Vector3> OnSwiped;
|
|
67
|
-
|
|
68
|
-
[Header("")]
|
|
69
|
-
[SerializeField] protected UnityEvent OnHit;
|
|
70
|
-
|
|
71
|
-
[Header("")]
|
|
72
|
-
[SerializeField] protected UnityEvent OnMissed;
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
/// <summary>
|
|
76
|
-
///
|
|
77
|
-
/// </summary>
|
|
78
|
-
protected readonly List<Vector2> inputs = new();
|
|
79
|
-
|
|
80
|
-
/// <summary>
|
|
81
|
-
///
|
|
82
|
-
/// </summary>
|
|
83
|
-
protected ISword cutSword;
|
|
84
|
-
|
|
85
|
-
/// <summary>
|
|
86
|
-
///
|
|
87
|
-
/// </summary>
|
|
88
|
-
protected ISwipeListener[] swipeListeners;
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
/// <inheritdoc/>
|
|
92
|
-
protected override void Awake()
|
|
93
|
-
{
|
|
94
|
-
base.Awake();
|
|
95
|
-
|
|
96
|
-
swipeListeners = transform.root.GetComponentsInChildren<ISwipeListener>();
|
|
97
|
-
|
|
98
|
-
cutSword = GetComponentsInChildren<ISword>()?.First();
|
|
99
|
-
|
|
100
|
-
if (cutSword == null)
|
|
101
|
-
UnityEngine.Debug.LogError($"ALERT: No {nameof(ISword)} found in children of {name}");
|
|
102
|
-
}
|
|
103
|
-
|
|
104
|
-
/// <inheritdoc/>
|
|
105
|
-
protected override void OnEnable()
|
|
106
|
-
{
|
|
107
|
-
base.OnEnable();
|
|
108
|
-
|
|
109
|
-
cutSword?.StopDetectingCuts();
|
|
110
|
-
|
|
111
|
-
foreach (var listener in swipeListeners)
|
|
112
|
-
if (listener != null)
|
|
113
|
-
OnSwiped.AddListener(listener.OnSwiped);
|
|
114
|
-
}
|
|
115
|
-
|
|
116
|
-
/// <inheritdoc/>
|
|
117
|
-
protected override void OnDisable()
|
|
118
|
-
{
|
|
119
|
-
base.OnDisable();
|
|
120
|
-
|
|
121
|
-
DeactivateControls();
|
|
122
|
-
|
|
123
|
-
foreach (var listener in swipeListeners)
|
|
124
|
-
if (listener != null)
|
|
125
|
-
OnSwiped.RemoveListener(listener.OnSwiped);
|
|
126
|
-
}
|
|
127
|
-
|
|
128
|
-
/// <inheritdoc/>
|
|
129
|
-
public override void ActivateControls()
|
|
130
|
-
{
|
|
131
|
-
inputs.Clear();
|
|
132
|
-
|
|
133
|
-
if (outputDebugSwipeLogs)
|
|
134
|
-
UnityEngine.Debug.LogWarning($"REPORT: Enabling Controls");
|
|
135
|
-
|
|
136
|
-
swipe.action.performed += Swipe;
|
|
137
|
-
}
|
|
138
|
-
|
|
139
|
-
/// <inheritdoc/>
|
|
140
|
-
public override void DeactivateControls()
|
|
141
|
-
{
|
|
142
|
-
StopAllCoroutines();
|
|
143
|
-
|
|
144
|
-
cutSword?.StopDetectingCuts();
|
|
145
|
-
|
|
146
|
-
if (outputDebugSwipeLogs)
|
|
147
|
-
UnityEngine.Debug.LogWarning($"REPORT: Disabling Controls");
|
|
148
|
-
|
|
149
|
-
swipe.action.performed -= Swipe;
|
|
150
|
-
}
|
|
151
|
-
|
|
152
|
-
/// <summary>
|
|
153
|
-
///
|
|
154
|
-
/// </summary>
|
|
155
|
-
/// <param name="context"></param>
|
|
156
|
-
protected virtual void Swipe(CallbackContext context)
|
|
157
|
-
{
|
|
158
|
-
if (preventCutsCondition != null && preventCutsCondition.Evaluate())
|
|
159
|
-
return;
|
|
160
|
-
|
|
161
|
-
Vector2 direction = context.ReadValue<Vector2>();
|
|
162
|
-
|
|
163
|
-
if (!InputDirectionValid(direction))
|
|
164
|
-
return;
|
|
165
|
-
|
|
166
|
-
if (inputs.Count == 0)
|
|
167
|
-
StartCoroutine(BufferSwipe());
|
|
168
|
-
|
|
169
|
-
inputs.Add(direction);
|
|
170
|
-
}
|
|
171
|
-
|
|
172
|
-
/// <summary>
|
|
173
|
-
///
|
|
174
|
-
/// </summary>
|
|
175
|
-
/// <param name="direction"></param>
|
|
176
|
-
/// <returns></returns>
|
|
177
|
-
protected virtual bool InputDirectionValid(Vector2 direction)
|
|
178
|
-
{
|
|
179
|
-
bool directionEmpty = direction == Vector2.zero;
|
|
180
|
-
|
|
181
|
-
bool roundedDirectionEmpty = Mathf.Round(direction.x) == 0 && Mathf.Round(direction.y) == 0;
|
|
182
|
-
|
|
183
|
-
bool directionValid = !directionEmpty && !roundedDirectionEmpty;
|
|
184
|
-
|
|
185
|
-
if (directionEmpty && outputDebugSwipeLogs)
|
|
186
|
-
UnityEngine.Debug.Log($"REPORT: Attempted Cut Direction was Zero");
|
|
187
|
-
|
|
188
|
-
if (roundedDirectionEmpty && outputDebugSwipeLogs)
|
|
189
|
-
UnityEngine.Debug.Log($"REPORT: Swipe Input did not reach the threshold: " + direction);
|
|
190
|
-
|
|
191
|
-
if (!directionValid)
|
|
192
|
-
StartCoroutine(Cooldown());
|
|
193
|
-
|
|
194
|
-
return directionValid;
|
|
195
|
-
}
|
|
196
|
-
|
|
197
|
-
/// <summary>
|
|
198
|
-
///
|
|
199
|
-
/// </summary>
|
|
200
|
-
protected virtual IEnumerator BufferSwipe()
|
|
201
|
-
{
|
|
202
|
-
yield return new WaitForEndOfFrame();
|
|
203
|
-
|
|
204
|
-
yield return new WaitForSecondsRealtime(Time.deltaTime * frameWindowForInput);
|
|
205
|
-
|
|
206
|
-
DeactivateControls();
|
|
207
|
-
|
|
208
|
-
SwipeAtDirection(CombineInputDirections());
|
|
209
|
-
|
|
210
|
-
StartCoroutine(SwipeProcess());
|
|
211
|
-
}
|
|
212
|
-
|
|
213
|
-
/// <summary>
|
|
214
|
-
///
|
|
215
|
-
/// </summary>
|
|
216
|
-
/// <returns></returns>
|
|
217
|
-
protected virtual Vector2 CombineInputDirections()
|
|
218
|
-
{
|
|
219
|
-
Vector2 combine = Vector2.zero;
|
|
220
|
-
|
|
221
|
-
foreach (var i in inputs)
|
|
222
|
-
{
|
|
223
|
-
combine.x += Mathf.Round(i.x);
|
|
224
|
-
|
|
225
|
-
combine.y += Mathf.Round(i.y);
|
|
226
|
-
|
|
227
|
-
if (outputDebugSwipeLogs)
|
|
228
|
-
UnityEngine.Debug.Log($"REPORT: Input Filtered: " + i);
|
|
229
|
-
}
|
|
230
|
-
|
|
231
|
-
combine.x = Mathf.Clamp(combine.x, -1, 1);
|
|
232
|
-
|
|
233
|
-
combine.y = Mathf.Clamp(combine.y, -1, 1);
|
|
234
|
-
|
|
235
|
-
inputs.Clear();
|
|
236
|
-
|
|
237
|
-
return combine;
|
|
238
|
-
}
|
|
239
|
-
|
|
240
|
-
/// <summary>
|
|
241
|
-
///
|
|
242
|
-
/// </summary>
|
|
243
|
-
/// <param name="direction"></param>
|
|
244
|
-
protected virtual void SwipeAtDirection(Vector2 direction)
|
|
245
|
-
{
|
|
246
|
-
if (outputDebugSwipeLogs)
|
|
247
|
-
UnityEngine.Debug.Log($"REPORT: Verified Swipe Direction is: " + direction);
|
|
248
|
-
|
|
249
|
-
OnSwiped?.Invoke(cutSword.AngleSword(direction), direction);
|
|
250
|
-
}
|
|
251
|
-
|
|
252
|
-
/// <summary>
|
|
253
|
-
///
|
|
254
|
-
/// </summary>
|
|
255
|
-
protected virtual IEnumerator SwipeProcess()
|
|
256
|
-
{
|
|
257
|
-
cutSword?.StartDetectingCuts();
|
|
258
|
-
|
|
259
|
-
yield return new WaitForSeconds(timeForSwordToCut);
|
|
260
|
-
|
|
261
|
-
cutSword?.StopDetectingCuts();
|
|
262
|
-
|
|
263
|
-
if (cutSword.RecentlyLandedHit)
|
|
264
|
-
OnHit?.Invoke();
|
|
265
|
-
else
|
|
266
|
-
OnMissed?.Invoke();
|
|
267
|
-
|
|
268
|
-
yield return Cooldown();
|
|
269
|
-
}
|
|
270
|
-
|
|
271
|
-
/// <summary>
|
|
272
|
-
///
|
|
273
|
-
/// </summary>
|
|
274
|
-
protected virtual IEnumerator Cooldown()
|
|
275
|
-
{
|
|
276
|
-
if (outputDebugSwipeLogs)
|
|
277
|
-
UnityEngine.Debug.Log($"REPORT: Started cooldown");
|
|
278
|
-
|
|
279
|
-
yield return new WaitForSeconds(cutCooldown);
|
|
280
|
-
|
|
281
|
-
if (outputDebugSwipeLogs)
|
|
282
|
-
UnityEngine.Debug.Log($"REPORT: Ended Cooldown");
|
|
283
|
-
|
|
284
|
-
ActivateControls();
|
|
285
|
-
}
|
|
286
|
-
}
|
|
1
|
+
//Author: Benjamin "Sweden" Jillson : Discord: sweden_gaming For Project Eden's Garden
|
|
2
|
+
using DREditor.EventObjects;
|
|
3
|
+
using DREditor.UIHandling;
|
|
4
|
+
using System.Collections;
|
|
5
|
+
using System.Collections.Generic;
|
|
6
|
+
using System.Linq;
|
|
7
|
+
using UnityEngine;
|
|
8
|
+
using UnityEngine.Events;
|
|
9
|
+
using UnityEngine.InputSystem;
|
|
10
|
+
using static UnityEngine.InputSystem.InputAction;
|
|
11
|
+
|
|
12
|
+
namespace DREditor.Minigames.RS
|
|
13
|
+
{
|
|
14
|
+
/// <summary>
|
|
15
|
+
///
|
|
16
|
+
/// </summary>
|
|
17
|
+
/// <remarks></remarks>
|
|
18
|
+
[ClassHeader(nameof(ControlledComponent) +
|
|
19
|
+
"\n\n")]
|
|
20
|
+
public class CutHandler : ControlledComponent
|
|
21
|
+
{
|
|
22
|
+
/// <summary>
|
|
23
|
+
///
|
|
24
|
+
/// </summary>
|
|
25
|
+
[Tooltip("")]
|
|
26
|
+
[SerializeField] protected InputActionReference swipe = null;
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
/// <summary>
|
|
30
|
+
///
|
|
31
|
+
/// </summary>
|
|
32
|
+
[Header("")]
|
|
33
|
+
[Divider]
|
|
34
|
+
[Tooltip("")]
|
|
35
|
+
[SerializeField] protected bool outputDebugSwipeLogs = false;
|
|
36
|
+
|
|
37
|
+
|
|
38
|
+
/// <summary>
|
|
39
|
+
///
|
|
40
|
+
/// </summary>
|
|
41
|
+
[Header("")]
|
|
42
|
+
[Divider]
|
|
43
|
+
[Tooltip("")]
|
|
44
|
+
[SerializeField] protected EvaluateBoolCondition preventCutsCondition;
|
|
45
|
+
|
|
46
|
+
/// <summary>
|
|
47
|
+
///
|
|
48
|
+
/// </summary>
|
|
49
|
+
[Tooltip("")]
|
|
50
|
+
[SerializeField] protected int frameWindowForInput = 5;
|
|
51
|
+
|
|
52
|
+
/// <summary>
|
|
53
|
+
///
|
|
54
|
+
/// </summary>
|
|
55
|
+
[Tooltip("")]
|
|
56
|
+
[SerializeField] protected float timeForSwordToCut = 0.2f;
|
|
57
|
+
|
|
58
|
+
/// <summary>
|
|
59
|
+
///
|
|
60
|
+
/// </summary>
|
|
61
|
+
[Tooltip("")]
|
|
62
|
+
[SerializeField] protected float cutCooldown = 0.1f;
|
|
63
|
+
|
|
64
|
+
|
|
65
|
+
[Header("")]
|
|
66
|
+
[SerializeField] protected UnityEvent<Vector3, Vector3> OnSwiped;
|
|
67
|
+
|
|
68
|
+
[Header("")]
|
|
69
|
+
[SerializeField] protected UnityEvent OnHit;
|
|
70
|
+
|
|
71
|
+
[Header("")]
|
|
72
|
+
[SerializeField] protected UnityEvent OnMissed;
|
|
73
|
+
|
|
74
|
+
|
|
75
|
+
/// <summary>
|
|
76
|
+
///
|
|
77
|
+
/// </summary>
|
|
78
|
+
protected readonly List<Vector2> inputs = new();
|
|
79
|
+
|
|
80
|
+
/// <summary>
|
|
81
|
+
///
|
|
82
|
+
/// </summary>
|
|
83
|
+
protected ISword cutSword;
|
|
84
|
+
|
|
85
|
+
/// <summary>
|
|
86
|
+
///
|
|
87
|
+
/// </summary>
|
|
88
|
+
protected ISwipeListener[] swipeListeners;
|
|
89
|
+
|
|
90
|
+
|
|
91
|
+
/// <inheritdoc/>
|
|
92
|
+
protected override void Awake()
|
|
93
|
+
{
|
|
94
|
+
base.Awake();
|
|
95
|
+
|
|
96
|
+
swipeListeners = transform.root.GetComponentsInChildren<ISwipeListener>();
|
|
97
|
+
|
|
98
|
+
cutSword = GetComponentsInChildren<ISword>()?.First();
|
|
99
|
+
|
|
100
|
+
if (cutSword == null)
|
|
101
|
+
UnityEngine.Debug.LogError($"ALERT: No {nameof(ISword)} found in children of {name}");
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
/// <inheritdoc/>
|
|
105
|
+
protected override void OnEnable()
|
|
106
|
+
{
|
|
107
|
+
base.OnEnable();
|
|
108
|
+
|
|
109
|
+
cutSword?.StopDetectingCuts();
|
|
110
|
+
|
|
111
|
+
foreach (var listener in swipeListeners)
|
|
112
|
+
if (listener != null)
|
|
113
|
+
OnSwiped.AddListener(listener.OnSwiped);
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
/// <inheritdoc/>
|
|
117
|
+
protected override void OnDisable()
|
|
118
|
+
{
|
|
119
|
+
base.OnDisable();
|
|
120
|
+
|
|
121
|
+
DeactivateControls();
|
|
122
|
+
|
|
123
|
+
foreach (var listener in swipeListeners)
|
|
124
|
+
if (listener != null)
|
|
125
|
+
OnSwiped.RemoveListener(listener.OnSwiped);
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
/// <inheritdoc/>
|
|
129
|
+
public override void ActivateControls()
|
|
130
|
+
{
|
|
131
|
+
inputs.Clear();
|
|
132
|
+
|
|
133
|
+
if (outputDebugSwipeLogs)
|
|
134
|
+
UnityEngine.Debug.LogWarning($"REPORT: Enabling Controls");
|
|
135
|
+
|
|
136
|
+
swipe.action.performed += Swipe;
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
/// <inheritdoc/>
|
|
140
|
+
public override void DeactivateControls()
|
|
141
|
+
{
|
|
142
|
+
StopAllCoroutines();
|
|
143
|
+
|
|
144
|
+
cutSword?.StopDetectingCuts();
|
|
145
|
+
|
|
146
|
+
if (outputDebugSwipeLogs)
|
|
147
|
+
UnityEngine.Debug.LogWarning($"REPORT: Disabling Controls");
|
|
148
|
+
|
|
149
|
+
swipe.action.performed -= Swipe;
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
/// <summary>
|
|
153
|
+
///
|
|
154
|
+
/// </summary>
|
|
155
|
+
/// <param name="context"></param>
|
|
156
|
+
protected virtual void Swipe(CallbackContext context)
|
|
157
|
+
{
|
|
158
|
+
if (preventCutsCondition != null && preventCutsCondition.Evaluate())
|
|
159
|
+
return;
|
|
160
|
+
|
|
161
|
+
Vector2 direction = context.ReadValue<Vector2>();
|
|
162
|
+
|
|
163
|
+
if (!InputDirectionValid(direction))
|
|
164
|
+
return;
|
|
165
|
+
|
|
166
|
+
if (inputs.Count == 0)
|
|
167
|
+
StartCoroutine(BufferSwipe());
|
|
168
|
+
|
|
169
|
+
inputs.Add(direction);
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
/// <summary>
|
|
173
|
+
///
|
|
174
|
+
/// </summary>
|
|
175
|
+
/// <param name="direction"></param>
|
|
176
|
+
/// <returns></returns>
|
|
177
|
+
protected virtual bool InputDirectionValid(Vector2 direction)
|
|
178
|
+
{
|
|
179
|
+
bool directionEmpty = direction == Vector2.zero;
|
|
180
|
+
|
|
181
|
+
bool roundedDirectionEmpty = Mathf.Round(direction.x) == 0 && Mathf.Round(direction.y) == 0;
|
|
182
|
+
|
|
183
|
+
bool directionValid = !directionEmpty && !roundedDirectionEmpty;
|
|
184
|
+
|
|
185
|
+
if (directionEmpty && outputDebugSwipeLogs)
|
|
186
|
+
UnityEngine.Debug.Log($"REPORT: Attempted Cut Direction was Zero");
|
|
187
|
+
|
|
188
|
+
if (roundedDirectionEmpty && outputDebugSwipeLogs)
|
|
189
|
+
UnityEngine.Debug.Log($"REPORT: Swipe Input did not reach the threshold: " + direction);
|
|
190
|
+
|
|
191
|
+
if (!directionValid)
|
|
192
|
+
StartCoroutine(Cooldown());
|
|
193
|
+
|
|
194
|
+
return directionValid;
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
/// <summary>
|
|
198
|
+
///
|
|
199
|
+
/// </summary>
|
|
200
|
+
protected virtual IEnumerator BufferSwipe()
|
|
201
|
+
{
|
|
202
|
+
yield return new WaitForEndOfFrame();
|
|
203
|
+
|
|
204
|
+
yield return new WaitForSecondsRealtime(Time.deltaTime * frameWindowForInput);
|
|
205
|
+
|
|
206
|
+
DeactivateControls();
|
|
207
|
+
|
|
208
|
+
SwipeAtDirection(CombineInputDirections());
|
|
209
|
+
|
|
210
|
+
StartCoroutine(SwipeProcess());
|
|
211
|
+
}
|
|
212
|
+
|
|
213
|
+
/// <summary>
|
|
214
|
+
///
|
|
215
|
+
/// </summary>
|
|
216
|
+
/// <returns></returns>
|
|
217
|
+
protected virtual Vector2 CombineInputDirections()
|
|
218
|
+
{
|
|
219
|
+
Vector2 combine = Vector2.zero;
|
|
220
|
+
|
|
221
|
+
foreach (var i in inputs)
|
|
222
|
+
{
|
|
223
|
+
combine.x += Mathf.Round(i.x);
|
|
224
|
+
|
|
225
|
+
combine.y += Mathf.Round(i.y);
|
|
226
|
+
|
|
227
|
+
if (outputDebugSwipeLogs)
|
|
228
|
+
UnityEngine.Debug.Log($"REPORT: Input Filtered: " + i);
|
|
229
|
+
}
|
|
230
|
+
|
|
231
|
+
combine.x = Mathf.Clamp(combine.x, -1, 1);
|
|
232
|
+
|
|
233
|
+
combine.y = Mathf.Clamp(combine.y, -1, 1);
|
|
234
|
+
|
|
235
|
+
inputs.Clear();
|
|
236
|
+
|
|
237
|
+
return combine;
|
|
238
|
+
}
|
|
239
|
+
|
|
240
|
+
/// <summary>
|
|
241
|
+
///
|
|
242
|
+
/// </summary>
|
|
243
|
+
/// <param name="direction"></param>
|
|
244
|
+
protected virtual void SwipeAtDirection(Vector2 direction)
|
|
245
|
+
{
|
|
246
|
+
if (outputDebugSwipeLogs)
|
|
247
|
+
UnityEngine.Debug.Log($"REPORT: Verified Swipe Direction is: " + direction);
|
|
248
|
+
|
|
249
|
+
OnSwiped?.Invoke(cutSword.AngleSword(direction), direction);
|
|
250
|
+
}
|
|
251
|
+
|
|
252
|
+
/// <summary>
|
|
253
|
+
///
|
|
254
|
+
/// </summary>
|
|
255
|
+
protected virtual IEnumerator SwipeProcess()
|
|
256
|
+
{
|
|
257
|
+
cutSword?.StartDetectingCuts();
|
|
258
|
+
|
|
259
|
+
yield return new WaitForSeconds(timeForSwordToCut);
|
|
260
|
+
|
|
261
|
+
cutSword?.StopDetectingCuts();
|
|
262
|
+
|
|
263
|
+
if (cutSword.RecentlyLandedHit)
|
|
264
|
+
OnHit?.Invoke();
|
|
265
|
+
else
|
|
266
|
+
OnMissed?.Invoke();
|
|
267
|
+
|
|
268
|
+
yield return Cooldown();
|
|
269
|
+
}
|
|
270
|
+
|
|
271
|
+
/// <summary>
|
|
272
|
+
///
|
|
273
|
+
/// </summary>
|
|
274
|
+
protected virtual IEnumerator Cooldown()
|
|
275
|
+
{
|
|
276
|
+
if (outputDebugSwipeLogs)
|
|
277
|
+
UnityEngine.Debug.Log($"REPORT: Started cooldown");
|
|
278
|
+
|
|
279
|
+
yield return new WaitForSeconds(cutCooldown);
|
|
280
|
+
|
|
281
|
+
if (outputDebugSwipeLogs)
|
|
282
|
+
UnityEngine.Debug.Log($"REPORT: Ended Cooldown");
|
|
283
|
+
|
|
284
|
+
ActivateControls();
|
|
285
|
+
}
|
|
286
|
+
}
|
|
287
287
|
}
|
package/CutHandler.cs.meta
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
fileFormatVersion: 2
|
|
2
|
-
guid: 8b6b53a1398817a4dbf208329069363a
|
|
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: 8b6b53a1398817a4dbf208329069363a
|
|
3
|
+
MonoImporter:
|
|
4
|
+
externalObjects: {}
|
|
5
|
+
serializedVersion: 2
|
|
6
|
+
defaultReferences: []
|
|
7
|
+
executionOrder: 0
|
|
8
|
+
icon: {instanceID: 0}
|
|
9
|
+
userData:
|
|
10
|
+
assetBundleName:
|
|
11
|
+
assetBundleVariant:
|