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
package/.attestation.p7m
ADDED
|
Binary file
|
package/CrossSwordsMechanic.cs
CHANGED
|
@@ -1,330 +1,330 @@
|
|
|
1
|
-
//Author: Benjamin "Sweden" Jillson : Discord: sweden_gaming For Project Eden's Garden
|
|
2
|
-
using DREditor.Audio;
|
|
3
|
-
using DREditor.EventObjects;
|
|
4
|
-
using DREditor.Minigames.Debates.Mechanics;
|
|
5
|
-
using DREditor.Services;
|
|
6
|
-
using DREditor.UIHandling;
|
|
7
|
-
using System;
|
|
8
|
-
using System.Collections;
|
|
9
|
-
using UnityEngine;
|
|
10
|
-
using UnityEngine.Events;
|
|
11
|
-
using UnityEngine.InputSystem;
|
|
12
|
-
using static UnityEngine.InputSystem.InputAction;
|
|
13
|
-
|
|
14
|
-
namespace DREditor.Minigames.RS
|
|
15
|
-
{
|
|
16
|
-
/// <summary>
|
|
17
|
-
///
|
|
18
|
-
/// </summary>
|
|
19
|
-
[ClassHeader(nameof(ServiceHolder<ITieBreaker>) + ", " + nameof(ITieBreaker) +
|
|
20
|
-
"\n\n")]
|
|
21
|
-
public class CrossSwordsMechanic : ServiceHolder<ITieBreaker>, ITieBreaker
|
|
22
|
-
{
|
|
23
|
-
/// <summary>
|
|
24
|
-
///
|
|
25
|
-
/// </summary>
|
|
26
|
-
[Tooltip("")]
|
|
27
|
-
[SerializeField] protected InputActionReference submit = null;
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
/// <summary>
|
|
31
|
-
///
|
|
32
|
-
/// </summary>
|
|
33
|
-
[Header("")]
|
|
34
|
-
[Divider]
|
|
35
|
-
[Tooltip("")]
|
|
36
|
-
[SerializeField] protected SceneEvent duelStartedEvent;
|
|
37
|
-
|
|
38
|
-
/// <summary>
|
|
39
|
-
///
|
|
40
|
-
/// </summary>
|
|
41
|
-
[Tooltip("")]
|
|
42
|
-
[SerializeField] protected SceneEvent duelEndedEvent;
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
/// <summary>
|
|
46
|
-
///
|
|
47
|
-
/// </summary>
|
|
48
|
-
[Header("")]
|
|
49
|
-
[Divider]
|
|
50
|
-
[Tooltip("")]
|
|
51
|
-
[SerializeField] protected UIVisibilityComponent introAnimation = null;
|
|
52
|
-
|
|
53
|
-
/// <summary>
|
|
54
|
-
///
|
|
55
|
-
/// </summary>
|
|
56
|
-
[Tooltip("")]
|
|
57
|
-
[SerializeField] protected UIVisibilityComponent successAnimation = null;
|
|
58
|
-
|
|
59
|
-
/// <summary>
|
|
60
|
-
///
|
|
61
|
-
/// </summary>
|
|
62
|
-
[Tooltip("")]
|
|
63
|
-
[SerializeField] protected UIVisibilityComponent failureAnimation = null;
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
/// <summary>
|
|
67
|
-
///
|
|
68
|
-
/// </summary>
|
|
69
|
-
[Header("")]
|
|
70
|
-
[Divider]
|
|
71
|
-
[Tooltip("")]
|
|
72
|
-
[SerializeField] protected int totalTaps = 8;
|
|
73
|
-
|
|
74
|
-
/// <summary>
|
|
75
|
-
///
|
|
76
|
-
/// </summary>
|
|
77
|
-
[Tooltip("")]
|
|
78
|
-
[SerializeField] protected float duelDuration = 3;
|
|
79
|
-
|
|
80
|
-
/// <summary>
|
|
81
|
-
///
|
|
82
|
-
/// </summary>
|
|
83
|
-
[Tooltip("")]
|
|
84
|
-
[SerializeField] protected int enemyIndex = 0;
|
|
85
|
-
|
|
86
|
-
/// <summary>
|
|
87
|
-
///
|
|
88
|
-
/// </summary>
|
|
89
|
-
[Tooltip("")]
|
|
90
|
-
[SerializeField] protected float enemyAttackRate = 0.2f;
|
|
91
|
-
|
|
92
|
-
/// <summary>
|
|
93
|
-
///
|
|
94
|
-
/// </summary>
|
|
95
|
-
[Tooltip("")]
|
|
96
|
-
[SerializeField] protected float damage = 5;
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
[Header("")]
|
|
100
|
-
[SerializeField] protected UnityEvent onDuelStarted = null;
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
/// <summary>
|
|
104
|
-
///
|
|
105
|
-
/// </summary>
|
|
106
|
-
[Header("")]
|
|
107
|
-
[Divider]
|
|
108
|
-
[Tooltip("")]
|
|
109
|
-
[SerializeField] protected SoundPlayerDRE successSFX;
|
|
110
|
-
|
|
111
|
-
/// <summary>
|
|
112
|
-
///
|
|
113
|
-
/// </summary>
|
|
114
|
-
[Tooltip("")]
|
|
115
|
-
[SerializeField] protected SoundPlayerDRE failureSFX;
|
|
116
|
-
|
|
117
|
-
/// <summary>
|
|
118
|
-
///
|
|
119
|
-
/// </summary>
|
|
120
|
-
[Tooltip("")]
|
|
121
|
-
[SerializeField] protected SoundPlayerDRE clashingSFX;
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
/// <summary>
|
|
125
|
-
///
|
|
126
|
-
/// </summary>
|
|
127
|
-
protected int currentTaps = 0;
|
|
128
|
-
|
|
129
|
-
/// <summary>
|
|
130
|
-
///
|
|
131
|
-
/// </summary>
|
|
132
|
-
protected ISplitScreen splitService;
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
protected virtual void Start() => InitializeMechanic();
|
|
136
|
-
|
|
137
|
-
/// <summary>
|
|
138
|
-
///
|
|
139
|
-
/// </summary>
|
|
140
|
-
protected virtual void InitializeMechanic()
|
|
141
|
-
{
|
|
142
|
-
if (!InitializationValid())
|
|
143
|
-
OnInitializationFailed();
|
|
144
|
-
}
|
|
145
|
-
|
|
146
|
-
/// <summary>
|
|
147
|
-
///
|
|
148
|
-
/// </summary>
|
|
149
|
-
/// <returns></returns>
|
|
150
|
-
protected virtual bool InitializationValid() => ServiceLocator.HasService(out splitService);
|
|
151
|
-
|
|
152
|
-
/// <summary>
|
|
153
|
-
///
|
|
154
|
-
/// </summary>
|
|
155
|
-
protected virtual void OnInitializationFailed()
|
|
156
|
-
{
|
|
157
|
-
UnityEngine.Debug.LogWarning($"ALERT: The {nameof(CrossSwordsMechanic)} requires " +
|
|
158
|
-
$"an active {nameof(ISplitScreen)} service to function.\n" +
|
|
159
|
-
$"PROPOSAL: Ensure that a service registering {nameof(ISplitScreen)} is available.");
|
|
160
|
-
|
|
161
|
-
UnityEngine.Debug.Log($"REPORT: Destroying {nameof(CrossSwordsMechanic)}.");
|
|
162
|
-
|
|
163
|
-
Destroy(gameObject);
|
|
164
|
-
}
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
/// <inheritdoc/>
|
|
168
|
-
public virtual IEnumerator TieBreakerProcess(Action<bool> result)
|
|
169
|
-
{
|
|
170
|
-
UnityEngine.Debug.Log("REPORT: Starting CrossSwords.");
|
|
171
|
-
|
|
172
|
-
InitializeDuel();
|
|
173
|
-
|
|
174
|
-
InvokeDuelStarted();
|
|
175
|
-
|
|
176
|
-
yield return DisplayStartingDuel();
|
|
177
|
-
|
|
178
|
-
RaiseEvent(duelStartedEvent);
|
|
179
|
-
|
|
180
|
-
EnablePlayerDueling();
|
|
181
|
-
|
|
182
|
-
yield return Duel();
|
|
183
|
-
|
|
184
|
-
DisablePlayerDueling();
|
|
185
|
-
|
|
186
|
-
RaiseEvent(duelEndedEvent);
|
|
187
|
-
|
|
188
|
-
yield return ResolveDuel();
|
|
189
|
-
|
|
190
|
-
result(splitService.WillAdvanceOnTie());
|
|
191
|
-
|
|
192
|
-
UnityEngine.Debug.Log("REPORT: Ending CrossSwords.");
|
|
193
|
-
}
|
|
194
|
-
|
|
195
|
-
/// <summary>
|
|
196
|
-
///
|
|
197
|
-
/// </summary>
|
|
198
|
-
protected virtual void InitializeDuel()
|
|
199
|
-
{
|
|
200
|
-
splitService.AnimateToResetState();
|
|
201
|
-
|
|
202
|
-
currentTaps = totalTaps;
|
|
203
|
-
|
|
204
|
-
var speeds = transform.root.GetComponentsInChildren<SpeedHandlerBase>();
|
|
205
|
-
|
|
206
|
-
foreach (var speed in speeds)
|
|
207
|
-
{
|
|
208
|
-
speed.OnPanelsStopped();
|
|
209
|
-
|
|
210
|
-
speed.DeactivateControls();
|
|
211
|
-
}
|
|
212
|
-
}
|
|
213
|
-
|
|
214
|
-
/// <summary>
|
|
215
|
-
///
|
|
216
|
-
/// </summary>
|
|
217
|
-
/// <returns></returns>
|
|
218
|
-
protected virtual IEnumerator DisplayStartingDuel()
|
|
219
|
-
{
|
|
220
|
-
if (introAnimation != null)
|
|
221
|
-
{
|
|
222
|
-
yield return introAnimation.ShowTillComplete();
|
|
223
|
-
|
|
224
|
-
introAnimation.Hide();
|
|
225
|
-
}
|
|
226
|
-
}
|
|
227
|
-
|
|
228
|
-
/// <summary>
|
|
229
|
-
///
|
|
230
|
-
/// </summary>
|
|
231
|
-
/// <param name="sceneEvent"></param>
|
|
232
|
-
protected virtual void RaiseEvent(SceneEvent sceneEvent)
|
|
233
|
-
{
|
|
234
|
-
if (sceneEvent != null)
|
|
235
|
-
sceneEvent.Raise();
|
|
236
|
-
}
|
|
237
|
-
|
|
238
|
-
/// <summary>
|
|
239
|
-
///
|
|
240
|
-
/// </summary>
|
|
241
|
-
protected virtual void InvokeDuelStarted() => onDuelStarted?.Invoke();
|
|
242
|
-
|
|
243
|
-
/// <summary>
|
|
244
|
-
///
|
|
245
|
-
/// </summary>
|
|
246
|
-
protected virtual void EnablePlayerDueling() => submit.action.started += Tap;
|
|
247
|
-
|
|
248
|
-
/// <summary>
|
|
249
|
-
///
|
|
250
|
-
/// </summary>
|
|
251
|
-
/// <param name="ctx"></param>
|
|
252
|
-
protected virtual void Tap(CallbackContext ctx)
|
|
253
|
-
{
|
|
254
|
-
currentTaps++;
|
|
255
|
-
|
|
256
|
-
splitService.PlayerAttack(damage);
|
|
257
|
-
|
|
258
|
-
if (clashingSFX != null)
|
|
259
|
-
clashingSFX.PlaySFX();
|
|
260
|
-
}
|
|
261
|
-
|
|
262
|
-
/// <summary>
|
|
263
|
-
///
|
|
264
|
-
/// </summary>
|
|
265
|
-
/// <returns></returns>
|
|
266
|
-
protected virtual IEnumerator Duel()
|
|
267
|
-
{
|
|
268
|
-
float timeRemaining = duelDuration;
|
|
269
|
-
|
|
270
|
-
while (timeRemaining > 0 && currentTaps != 0 && currentTaps <= totalTaps)
|
|
271
|
-
{
|
|
272
|
-
yield return new WaitForSeconds(enemyAttackRate);
|
|
273
|
-
|
|
274
|
-
timeRemaining -= enemyAttackRate;
|
|
275
|
-
|
|
276
|
-
splitService.EnemyAttack(enemyIndex, damage);
|
|
277
|
-
|
|
278
|
-
currentTaps--;
|
|
279
|
-
|
|
280
|
-
if (clashingSFX != null)
|
|
281
|
-
clashingSFX.PlaySFX();
|
|
282
|
-
|
|
283
|
-
UnityEngine.Debug.Log("REPORT: Enemy Attacked.");
|
|
284
|
-
|
|
285
|
-
yield return null;
|
|
286
|
-
}
|
|
287
|
-
}
|
|
288
|
-
|
|
289
|
-
/// <summary>
|
|
290
|
-
///
|
|
291
|
-
/// </summary>
|
|
292
|
-
protected virtual void DisablePlayerDueling() => submit.action.started -= Tap;
|
|
293
|
-
|
|
294
|
-
/// <summary>
|
|
295
|
-
///
|
|
296
|
-
/// </summary>
|
|
297
|
-
protected virtual IEnumerator ResolveDuel()
|
|
298
|
-
{
|
|
299
|
-
bool playerWon = splitService.WillAdvanceOnTie();
|
|
300
|
-
|
|
301
|
-
var resultSound = playerWon ? successSFX : failureSFX;
|
|
302
|
-
|
|
303
|
-
var resultAnimation = playerWon ? successAnimation : failureAnimation;
|
|
304
|
-
|
|
305
|
-
if (playerWon)
|
|
306
|
-
splitService.PlayerAttack(damage);
|
|
307
|
-
else
|
|
308
|
-
splitService.EnemyAttack(enemyIndex, damage);
|
|
309
|
-
|
|
310
|
-
if (resultSound != null)
|
|
311
|
-
resultSound.PlaySFX();
|
|
312
|
-
|
|
313
|
-
if (resultAnimation != null)
|
|
314
|
-
{
|
|
315
|
-
yield return resultAnimation.ShowTillComplete();
|
|
316
|
-
|
|
317
|
-
resultAnimation.Hide();
|
|
318
|
-
}
|
|
319
|
-
}
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
/// <inheritdoc/>
|
|
323
|
-
protected override void OnDestroy()
|
|
324
|
-
{
|
|
325
|
-
base.OnDestroy();
|
|
326
|
-
|
|
327
|
-
DisablePlayerDueling();
|
|
328
|
-
}
|
|
329
|
-
}
|
|
1
|
+
//Author: Benjamin "Sweden" Jillson : Discord: sweden_gaming For Project Eden's Garden
|
|
2
|
+
using DREditor.Audio;
|
|
3
|
+
using DREditor.EventObjects;
|
|
4
|
+
using DREditor.Minigames.Debates.Mechanics;
|
|
5
|
+
using DREditor.Services;
|
|
6
|
+
using DREditor.UIHandling;
|
|
7
|
+
using System;
|
|
8
|
+
using System.Collections;
|
|
9
|
+
using UnityEngine;
|
|
10
|
+
using UnityEngine.Events;
|
|
11
|
+
using UnityEngine.InputSystem;
|
|
12
|
+
using static UnityEngine.InputSystem.InputAction;
|
|
13
|
+
|
|
14
|
+
namespace DREditor.Minigames.RS
|
|
15
|
+
{
|
|
16
|
+
/// <summary>
|
|
17
|
+
///
|
|
18
|
+
/// </summary>
|
|
19
|
+
[ClassHeader(nameof(ServiceHolder<ITieBreaker>) + ", " + nameof(ITieBreaker) +
|
|
20
|
+
"\n\n")]
|
|
21
|
+
public class CrossSwordsMechanic : ServiceHolder<ITieBreaker>, ITieBreaker
|
|
22
|
+
{
|
|
23
|
+
/// <summary>
|
|
24
|
+
///
|
|
25
|
+
/// </summary>
|
|
26
|
+
[Tooltip("")]
|
|
27
|
+
[SerializeField] protected InputActionReference submit = null;
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
/// <summary>
|
|
31
|
+
///
|
|
32
|
+
/// </summary>
|
|
33
|
+
[Header("")]
|
|
34
|
+
[Divider]
|
|
35
|
+
[Tooltip("")]
|
|
36
|
+
[SerializeField] protected SceneEvent duelStartedEvent;
|
|
37
|
+
|
|
38
|
+
/// <summary>
|
|
39
|
+
///
|
|
40
|
+
/// </summary>
|
|
41
|
+
[Tooltip("")]
|
|
42
|
+
[SerializeField] protected SceneEvent duelEndedEvent;
|
|
43
|
+
|
|
44
|
+
|
|
45
|
+
/// <summary>
|
|
46
|
+
///
|
|
47
|
+
/// </summary>
|
|
48
|
+
[Header("")]
|
|
49
|
+
[Divider]
|
|
50
|
+
[Tooltip("")]
|
|
51
|
+
[SerializeField] protected UIVisibilityComponent introAnimation = null;
|
|
52
|
+
|
|
53
|
+
/// <summary>
|
|
54
|
+
///
|
|
55
|
+
/// </summary>
|
|
56
|
+
[Tooltip("")]
|
|
57
|
+
[SerializeField] protected UIVisibilityComponent successAnimation = null;
|
|
58
|
+
|
|
59
|
+
/// <summary>
|
|
60
|
+
///
|
|
61
|
+
/// </summary>
|
|
62
|
+
[Tooltip("")]
|
|
63
|
+
[SerializeField] protected UIVisibilityComponent failureAnimation = null;
|
|
64
|
+
|
|
65
|
+
|
|
66
|
+
/// <summary>
|
|
67
|
+
///
|
|
68
|
+
/// </summary>
|
|
69
|
+
[Header("")]
|
|
70
|
+
[Divider]
|
|
71
|
+
[Tooltip("")]
|
|
72
|
+
[SerializeField] protected int totalTaps = 8;
|
|
73
|
+
|
|
74
|
+
/// <summary>
|
|
75
|
+
///
|
|
76
|
+
/// </summary>
|
|
77
|
+
[Tooltip("")]
|
|
78
|
+
[SerializeField] protected float duelDuration = 3;
|
|
79
|
+
|
|
80
|
+
/// <summary>
|
|
81
|
+
///
|
|
82
|
+
/// </summary>
|
|
83
|
+
[Tooltip("")]
|
|
84
|
+
[SerializeField] protected int enemyIndex = 0;
|
|
85
|
+
|
|
86
|
+
/// <summary>
|
|
87
|
+
///
|
|
88
|
+
/// </summary>
|
|
89
|
+
[Tooltip("")]
|
|
90
|
+
[SerializeField] protected float enemyAttackRate = 0.2f;
|
|
91
|
+
|
|
92
|
+
/// <summary>
|
|
93
|
+
///
|
|
94
|
+
/// </summary>
|
|
95
|
+
[Tooltip("")]
|
|
96
|
+
[SerializeField] protected float damage = 5;
|
|
97
|
+
|
|
98
|
+
|
|
99
|
+
[Header("")]
|
|
100
|
+
[SerializeField] protected UnityEvent onDuelStarted = null;
|
|
101
|
+
|
|
102
|
+
|
|
103
|
+
/// <summary>
|
|
104
|
+
///
|
|
105
|
+
/// </summary>
|
|
106
|
+
[Header("")]
|
|
107
|
+
[Divider]
|
|
108
|
+
[Tooltip("")]
|
|
109
|
+
[SerializeField] protected SoundPlayerDRE successSFX;
|
|
110
|
+
|
|
111
|
+
/// <summary>
|
|
112
|
+
///
|
|
113
|
+
/// </summary>
|
|
114
|
+
[Tooltip("")]
|
|
115
|
+
[SerializeField] protected SoundPlayerDRE failureSFX;
|
|
116
|
+
|
|
117
|
+
/// <summary>
|
|
118
|
+
///
|
|
119
|
+
/// </summary>
|
|
120
|
+
[Tooltip("")]
|
|
121
|
+
[SerializeField] protected SoundPlayerDRE clashingSFX;
|
|
122
|
+
|
|
123
|
+
|
|
124
|
+
/// <summary>
|
|
125
|
+
///
|
|
126
|
+
/// </summary>
|
|
127
|
+
protected int currentTaps = 0;
|
|
128
|
+
|
|
129
|
+
/// <summary>
|
|
130
|
+
///
|
|
131
|
+
/// </summary>
|
|
132
|
+
protected ISplitScreen splitService;
|
|
133
|
+
|
|
134
|
+
|
|
135
|
+
protected virtual void Start() => InitializeMechanic();
|
|
136
|
+
|
|
137
|
+
/// <summary>
|
|
138
|
+
///
|
|
139
|
+
/// </summary>
|
|
140
|
+
protected virtual void InitializeMechanic()
|
|
141
|
+
{
|
|
142
|
+
if (!InitializationValid())
|
|
143
|
+
OnInitializationFailed();
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
/// <summary>
|
|
147
|
+
///
|
|
148
|
+
/// </summary>
|
|
149
|
+
/// <returns></returns>
|
|
150
|
+
protected virtual bool InitializationValid() => ServiceLocator.HasService(out splitService);
|
|
151
|
+
|
|
152
|
+
/// <summary>
|
|
153
|
+
///
|
|
154
|
+
/// </summary>
|
|
155
|
+
protected virtual void OnInitializationFailed()
|
|
156
|
+
{
|
|
157
|
+
UnityEngine.Debug.LogWarning($"ALERT: The {nameof(CrossSwordsMechanic)} requires " +
|
|
158
|
+
$"an active {nameof(ISplitScreen)} service to function.\n" +
|
|
159
|
+
$"PROPOSAL: Ensure that a service registering {nameof(ISplitScreen)} is available.");
|
|
160
|
+
|
|
161
|
+
UnityEngine.Debug.Log($"REPORT: Destroying {nameof(CrossSwordsMechanic)}.");
|
|
162
|
+
|
|
163
|
+
Destroy(gameObject);
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
|
|
167
|
+
/// <inheritdoc/>
|
|
168
|
+
public virtual IEnumerator TieBreakerProcess(Action<bool> result)
|
|
169
|
+
{
|
|
170
|
+
UnityEngine.Debug.Log("REPORT: Starting CrossSwords.");
|
|
171
|
+
|
|
172
|
+
InitializeDuel();
|
|
173
|
+
|
|
174
|
+
InvokeDuelStarted();
|
|
175
|
+
|
|
176
|
+
yield return DisplayStartingDuel();
|
|
177
|
+
|
|
178
|
+
RaiseEvent(duelStartedEvent);
|
|
179
|
+
|
|
180
|
+
EnablePlayerDueling();
|
|
181
|
+
|
|
182
|
+
yield return Duel();
|
|
183
|
+
|
|
184
|
+
DisablePlayerDueling();
|
|
185
|
+
|
|
186
|
+
RaiseEvent(duelEndedEvent);
|
|
187
|
+
|
|
188
|
+
yield return ResolveDuel();
|
|
189
|
+
|
|
190
|
+
result(splitService.WillAdvanceOnTie());
|
|
191
|
+
|
|
192
|
+
UnityEngine.Debug.Log("REPORT: Ending CrossSwords.");
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
/// <summary>
|
|
196
|
+
///
|
|
197
|
+
/// </summary>
|
|
198
|
+
protected virtual void InitializeDuel()
|
|
199
|
+
{
|
|
200
|
+
splitService.AnimateToResetState();
|
|
201
|
+
|
|
202
|
+
currentTaps = totalTaps;
|
|
203
|
+
|
|
204
|
+
var speeds = transform.root.GetComponentsInChildren<SpeedHandlerBase>();
|
|
205
|
+
|
|
206
|
+
foreach (var speed in speeds)
|
|
207
|
+
{
|
|
208
|
+
speed.OnPanelsStopped();
|
|
209
|
+
|
|
210
|
+
speed.DeactivateControls();
|
|
211
|
+
}
|
|
212
|
+
}
|
|
213
|
+
|
|
214
|
+
/// <summary>
|
|
215
|
+
///
|
|
216
|
+
/// </summary>
|
|
217
|
+
/// <returns></returns>
|
|
218
|
+
protected virtual IEnumerator DisplayStartingDuel()
|
|
219
|
+
{
|
|
220
|
+
if (introAnimation != null)
|
|
221
|
+
{
|
|
222
|
+
yield return introAnimation.ShowTillComplete();
|
|
223
|
+
|
|
224
|
+
introAnimation.Hide();
|
|
225
|
+
}
|
|
226
|
+
}
|
|
227
|
+
|
|
228
|
+
/// <summary>
|
|
229
|
+
///
|
|
230
|
+
/// </summary>
|
|
231
|
+
/// <param name="sceneEvent"></param>
|
|
232
|
+
protected virtual void RaiseEvent(SceneEvent sceneEvent)
|
|
233
|
+
{
|
|
234
|
+
if (sceneEvent != null)
|
|
235
|
+
sceneEvent.Raise();
|
|
236
|
+
}
|
|
237
|
+
|
|
238
|
+
/// <summary>
|
|
239
|
+
///
|
|
240
|
+
/// </summary>
|
|
241
|
+
protected virtual void InvokeDuelStarted() => onDuelStarted?.Invoke();
|
|
242
|
+
|
|
243
|
+
/// <summary>
|
|
244
|
+
///
|
|
245
|
+
/// </summary>
|
|
246
|
+
protected virtual void EnablePlayerDueling() => submit.action.started += Tap;
|
|
247
|
+
|
|
248
|
+
/// <summary>
|
|
249
|
+
///
|
|
250
|
+
/// </summary>
|
|
251
|
+
/// <param name="ctx"></param>
|
|
252
|
+
protected virtual void Tap(CallbackContext ctx)
|
|
253
|
+
{
|
|
254
|
+
currentTaps++;
|
|
255
|
+
|
|
256
|
+
splitService.PlayerAttack(damage);
|
|
257
|
+
|
|
258
|
+
if (clashingSFX != null)
|
|
259
|
+
clashingSFX.PlaySFX();
|
|
260
|
+
}
|
|
261
|
+
|
|
262
|
+
/// <summary>
|
|
263
|
+
///
|
|
264
|
+
/// </summary>
|
|
265
|
+
/// <returns></returns>
|
|
266
|
+
protected virtual IEnumerator Duel()
|
|
267
|
+
{
|
|
268
|
+
float timeRemaining = duelDuration;
|
|
269
|
+
|
|
270
|
+
while (timeRemaining > 0 && currentTaps != 0 && currentTaps <= totalTaps)
|
|
271
|
+
{
|
|
272
|
+
yield return new WaitForSeconds(enemyAttackRate);
|
|
273
|
+
|
|
274
|
+
timeRemaining -= enemyAttackRate;
|
|
275
|
+
|
|
276
|
+
splitService.EnemyAttack(enemyIndex, damage);
|
|
277
|
+
|
|
278
|
+
currentTaps--;
|
|
279
|
+
|
|
280
|
+
if (clashingSFX != null)
|
|
281
|
+
clashingSFX.PlaySFX();
|
|
282
|
+
|
|
283
|
+
UnityEngine.Debug.Log("REPORT: Enemy Attacked.");
|
|
284
|
+
|
|
285
|
+
yield return null;
|
|
286
|
+
}
|
|
287
|
+
}
|
|
288
|
+
|
|
289
|
+
/// <summary>
|
|
290
|
+
///
|
|
291
|
+
/// </summary>
|
|
292
|
+
protected virtual void DisablePlayerDueling() => submit.action.started -= Tap;
|
|
293
|
+
|
|
294
|
+
/// <summary>
|
|
295
|
+
///
|
|
296
|
+
/// </summary>
|
|
297
|
+
protected virtual IEnumerator ResolveDuel()
|
|
298
|
+
{
|
|
299
|
+
bool playerWon = splitService.WillAdvanceOnTie();
|
|
300
|
+
|
|
301
|
+
var resultSound = playerWon ? successSFX : failureSFX;
|
|
302
|
+
|
|
303
|
+
var resultAnimation = playerWon ? successAnimation : failureAnimation;
|
|
304
|
+
|
|
305
|
+
if (playerWon)
|
|
306
|
+
splitService.PlayerAttack(damage);
|
|
307
|
+
else
|
|
308
|
+
splitService.EnemyAttack(enemyIndex, damage);
|
|
309
|
+
|
|
310
|
+
if (resultSound != null)
|
|
311
|
+
resultSound.PlaySFX();
|
|
312
|
+
|
|
313
|
+
if (resultAnimation != null)
|
|
314
|
+
{
|
|
315
|
+
yield return resultAnimation.ShowTillComplete();
|
|
316
|
+
|
|
317
|
+
resultAnimation.Hide();
|
|
318
|
+
}
|
|
319
|
+
}
|
|
320
|
+
|
|
321
|
+
|
|
322
|
+
/// <inheritdoc/>
|
|
323
|
+
protected override void OnDestroy()
|
|
324
|
+
{
|
|
325
|
+
base.OnDestroy();
|
|
326
|
+
|
|
327
|
+
DisablePlayerDueling();
|
|
328
|
+
}
|
|
329
|
+
}
|
|
330
330
|
}
|