Skip to content

Commit

Permalink
feat: Added data for charged attacks.
Browse files Browse the repository at this point in the history
Attacks can now define windows frames where you can charge the move, and for how long.
  • Loading branch information
christides11 committed Aug 7, 2020
1 parent 3c64b5b commit e1ca903
Show file tree
Hide file tree
Showing 6 changed files with 91 additions and 15 deletions.
2 changes: 2 additions & 0 deletions Assets/CAF/Combat/Attack/AttackDefinition.cs
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@ public class AttackDefinition : ScriptableObject
public List<Vector2Int> commandAttackCancelWindows = new List<Vector2Int>();
#endregion

[SerializeReference] public List<ChargeDefinition> chargeWindows = new List<ChargeDefinition>();

[SerializeReference] public List<BoxGroup> boxGroups = new List<BoxGroup>();

[SerializeReference] public List<AttackEventDefinition> events = new List<AttackEventDefinition>();
Expand Down
13 changes: 13 additions & 0 deletions Assets/CAF/Combat/ChargeDefinition.cs
Original file line number Diff line number Diff line change
@@ -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;
}
}
11 changes: 11 additions & 0 deletions Assets/CAF/Combat/ChargeDefinition.cs.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

78 changes: 63 additions & 15 deletions Assets/CAF/Editor/Combat/Attack/AttackDefinitionEditorWindow.cs
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ protected virtual void DrawMenuBar()
{
currentMenu = 0;
}
if (GUILayout.Button("Cancels"))
if (GUILayout.Button("Windows"))
{
currentMenu = 1;
}
Expand All @@ -77,7 +77,7 @@ protected virtual void DrawMenu()
}
if (currentMenu == 1)
{
DrawCancelWindows();
DrawWindowsMenu();
}
if(currentMenu == 2)
{
Expand Down Expand Up @@ -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<Vector2Int> jumpCancelWindows = new List<Vector2Int>(attack.jumpCancelWindows);
List<Vector2Int> enemyStepWindows = new List<Vector2Int>(attack.enemyStepWindows);
List<Vector2Int> landCancelWindows = new List<Vector2Int>(attack.landCancelWindows);
List<Vector2Int> commandAttackCancelWindows = new List<Vector2Int>(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<Vector2Int> windows, float width)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ MonoBehaviour:
enemyStepWindows: []
landCancelWindows: []
commandAttackCancelWindows: []
chargeWindows: []
boxGroups:
- id: 0
events: []
Expand Down
1 change: 1 addition & 0 deletions CAF.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@
<Compile Include="Assets\CAF\Combat\Boxes\Hitbox.cs" />
<Compile Include="Assets\CAF\Combat\Boxes\Hurtbox.cs" />
<Compile Include="Assets\CAF\Combat\Boxes\HurtboxState.cs" />
<Compile Include="Assets\CAF\Combat\ChargeDefinition.cs" />
<Compile Include="Assets\CAF\Combat\ForceType.cs" />
<Compile Include="Assets\CAF\Combat\HitInfo.cs" />
<Compile Include="Assets\CAF\Combat\HitReaction.cs" />
Expand Down

0 comments on commit e1ca903

Please sign in to comment.