From e1ca9037decaf7a35681e646d02c6e5e33661ada Mon Sep 17 00:00:00 2001 From: christides11 Date: Fri, 7 Aug 2020 00:48:59 -0700 Subject: [PATCH] feat: Added data for charged attacks. Attacks can now define windows frames where you can charge the move, and for how long. --- Assets/CAF/Combat/Attack/AttackDefinition.cs | 2 + Assets/CAF/Combat/ChargeDefinition.cs | 13 ++++ Assets/CAF/Combat/ChargeDefinition.cs.meta | 11 +++ .../Attack/AttackDefinitionEditorWindow.cs | 78 +++++++++++++++---- .../Boxer/Moveset/Ground/Ground_A.asset | 1 + CAF.csproj | 1 + 6 files changed, 91 insertions(+), 15 deletions(-) create mode 100644 Assets/CAF/Combat/ChargeDefinition.cs create mode 100644 Assets/CAF/Combat/ChargeDefinition.cs.meta diff --git a/Assets/CAF/Combat/Attack/AttackDefinition.cs b/Assets/CAF/Combat/Attack/AttackDefinition.cs index 0d63463f..bb8b1f3f 100644 --- a/Assets/CAF/Combat/Attack/AttackDefinition.cs +++ b/Assets/CAF/Combat/Attack/AttackDefinition.cs @@ -28,6 +28,8 @@ public class AttackDefinition : ScriptableObject public List commandAttackCancelWindows = new List(); #endregion + [SerializeReference] public List chargeWindows = new List(); + [SerializeReference] public List boxGroups = new List(); [SerializeReference] public List events = new List(); diff --git a/Assets/CAF/Combat/ChargeDefinition.cs b/Assets/CAF/Combat/ChargeDefinition.cs new file mode 100644 index 00000000..db8cbaa2 --- /dev/null +++ b/Assets/CAF/Combat/ChargeDefinition.cs @@ -0,0 +1,13 @@ +using System.Collections; +using System.Collections.Generic; +using UnityEngine; + +namespace CAF.Combat +{ + [System.Serializable] + public class ChargeDefinition + { + public int frame = 1; + public int maxChargeFrames = 30; + } +} \ No newline at end of file diff --git a/Assets/CAF/Combat/ChargeDefinition.cs.meta b/Assets/CAF/Combat/ChargeDefinition.cs.meta new file mode 100644 index 00000000..d80aad69 --- /dev/null +++ b/Assets/CAF/Combat/ChargeDefinition.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: c7595b51c1617e241bac4e731804551d +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/CAF/Editor/Combat/Attack/AttackDefinitionEditorWindow.cs b/Assets/CAF/Editor/Combat/Attack/AttackDefinitionEditorWindow.cs index 1aae94bc..e16a7fe9 100644 --- a/Assets/CAF/Editor/Combat/Attack/AttackDefinitionEditorWindow.cs +++ b/Assets/CAF/Editor/Combat/Attack/AttackDefinitionEditorWindow.cs @@ -55,7 +55,7 @@ protected virtual void DrawMenuBar() { currentMenu = 0; } - if (GUILayout.Button("Cancels")) + if (GUILayout.Button("Windows")) { currentMenu = 1; } @@ -77,7 +77,7 @@ protected virtual void DrawMenu() } if (currentMenu == 1) { - DrawCancelWindows(); + DrawWindowsMenu(); } if(currentMenu == 2) { @@ -145,28 +145,76 @@ protected virtual void DrawGeneralMenu() protected bool enemyStepWindowsFoldout; protected bool landCancelWindowsFoldout; protected bool commandAttackCancelWindowsFoldout; - protected virtual void DrawCancelWindows() + protected bool chargeWindowsFoldout; + protected bool cancelWindowsFoldout; + + protected virtual void DrawWindowsMenu() { - EditorGUI.BeginChangeCheck(); + chargeWindowsFoldout = EditorGUILayout.Foldout(chargeWindowsFoldout, "CHARGE WINDOWS", true, EditorStyles.boldLabel); + if (chargeWindowsFoldout) + { + EditorGUI.indentLevel++; + EditorGUI.BeginChangeCheck(); + if (GUILayout.Button("Add Window")) + { + attack.chargeWindows.Add(CreateChargeDefinition()); + } + for(int i = 0; i < attack.chargeWindows.Count; i++) + { + DrawChargeWindow(i); + EditorGUILayout.Space(); + } + if (EditorGUI.EndChangeCheck()) + { + Undo.RecordObject(attack, "Changed Charge Window."); + } + EditorGUI.indentLevel--; + } + cancelWindowsFoldout = EditorGUILayout.Foldout(cancelWindowsFoldout, "CANCEL WINDOWS", true, EditorStyles.boldLabel); List jumpCancelWindows = new List(attack.jumpCancelWindows); List enemyStepWindows = new List(attack.enemyStepWindows); List landCancelWindows = new List(attack.landCancelWindows); List commandAttackCancelWindows = new List(attack.commandAttackCancelWindows); + if (cancelWindowsFoldout) + { + EditorGUI.indentLevel++; + EditorGUI.BeginChangeCheck(); + DrawCancelWindow("Jump Cancel Windows", ref jumpCancelWindowsFoldout, ref jumpCancelWindows, 180); + DrawCancelWindow("Enemy Step Windows", ref enemyStepWindowsFoldout, ref enemyStepWindows, 180); + DrawCancelWindow("Land Cancel Windows", ref landCancelWindowsFoldout, ref landCancelWindows, 180); + DrawCancelWindow("Command Attack Cancel Windows", ref commandAttackCancelWindowsFoldout, ref commandAttackCancelWindows, 230); + if (EditorGUI.EndChangeCheck()) + { + Undo.RecordObject(attack, "Changed Cancel Window."); + attack.jumpCancelWindows = jumpCancelWindows; + attack.enemyStepWindows = enemyStepWindows; + attack.landCancelWindows = landCancelWindows; + attack.commandAttackCancelWindows = commandAttackCancelWindows; + } + EditorGUI.indentLevel--; + } + } - DrawCancelWindow("Jump Cancel Windows", ref jumpCancelWindowsFoldout, ref jumpCancelWindows, 180); - DrawCancelWindow("Enemy Step Windows", ref enemyStepWindowsFoldout, ref enemyStepWindows, 180); - DrawCancelWindow("Land Cancel Windows", ref landCancelWindowsFoldout, ref landCancelWindows, 180); - DrawCancelWindow("Command Attack Cancel Windows", ref commandAttackCancelWindowsFoldout, ref commandAttackCancelWindows, 230); - - if (EditorGUI.EndChangeCheck()) + protected virtual void DrawChargeWindow(int i) + { + EditorGUILayout.BeginHorizontal(); + if (GUILayout.Button("X", GUILayout.Width(30))) { - Undo.RecordObject(attack, "Changed Cancel Window."); - attack.jumpCancelWindows = jumpCancelWindows; - attack.enemyStepWindows = enemyStepWindows; - attack.landCancelWindows = landCancelWindows; - attack.commandAttackCancelWindows = commandAttackCancelWindows; + attack.chargeWindows.RemoveAt(i); + return; } + GUILayout.Label($"{i}."); + EditorGUILayout.EndHorizontal(); + EditorGUI.indentLevel++; + attack.chargeWindows[i].frame = EditorGUILayout.IntField("Frame", attack.chargeWindows[i].frame); + attack.chargeWindows[i].maxChargeFrames = EditorGUILayout.IntField("Max Charge Frames", attack.chargeWindows[i].maxChargeFrames); + EditorGUI.indentLevel--; + } + + protected virtual ChargeDefinition CreateChargeDefinition() + { + return new ChargeDefinition(); } protected virtual void DrawCancelWindow(string foldoutName, ref bool foldout, ref List windows, float width) diff --git a/Assets/CAF/Samples/TDAction/Characters/Boxer/Moveset/Ground/Ground_A.asset b/Assets/CAF/Samples/TDAction/Characters/Boxer/Moveset/Ground/Ground_A.asset index 735265e6..a5671595 100644 --- a/Assets/CAF/Samples/TDAction/Characters/Boxer/Moveset/Ground/Ground_A.asset +++ b/Assets/CAF/Samples/TDAction/Characters/Boxer/Moveset/Ground/Ground_A.asset @@ -25,6 +25,7 @@ MonoBehaviour: enemyStepWindows: [] landCancelWindows: [] commandAttackCancelWindows: [] + chargeWindows: [] boxGroups: - id: 0 events: [] diff --git a/CAF.csproj b/CAF.csproj index 57b948d9..620963ee 100644 --- a/CAF.csproj +++ b/CAF.csproj @@ -75,6 +75,7 @@ +