From 77d6a90f29611aed84811f4ddf564b48023c02ce Mon Sep 17 00:00:00 2001 From: christides11 <29593332+christides11@users.noreply.github.com> Date: Tue, 18 Aug 2020 13:43:12 -0700 Subject: [PATCH] feat: Added method to get hit list. List of hit hurtables per group can now be accessed via GetHitList. --- .../Entities/Managers/EntityHitboxManager.cs | 9 +++ .../Boxer/BoxerMovesetDefinition.asset | 70 ++++++++++++++++++- .../Boxer/Moveset/Ground/Ground_A.asset | 27 ++++++- .../Boxer/Moveset/Ground/Ground_AA.asset | 30 +++++++- .../Boxer/Moveset/Ground/Ground_AAA.asset | 29 +++++--- .../Samples/TDAction/Scenes/PlayScene.unity | 18 +++++ .../TDAction/Scripts/Combat/Events.meta | 8 +++ .../Scripts/Combat/Events/ApplyFriction.cs | 52 ++++++++++++++ .../Combat/Events/ApplyFriction.cs.meta | 11 +++ .../Entities/States/EntityStateAttack.cs | 48 ++++++++++++- TDAction_CSharp.csproj | 1 + 11 files changed, 285 insertions(+), 18 deletions(-) create mode 100644 Assets/CAF/Samples/TDAction/Scripts/Combat/Events.meta create mode 100644 Assets/CAF/Samples/TDAction/Scripts/Combat/Events/ApplyFriction.cs create mode 100644 Assets/CAF/Samples/TDAction/Scripts/Combat/Events/ApplyFriction.cs.meta diff --git a/Assets/CAF/Entities/Managers/EntityHitboxManager.cs b/Assets/CAF/Entities/Managers/EntityHitboxManager.cs index 6cdb499a..8b1b4948 100644 --- a/Assets/CAF/Entities/Managers/EntityHitboxManager.cs +++ b/Assets/CAF/Entities/Managers/EntityHitboxManager.cs @@ -28,6 +28,15 @@ public EntityHitboxManager(EntityCombatManager combatManager, EntityManager mana this.manager = manager; } + public virtual List GetHitList(int group) + { + if (!hurtablesHit.ContainsKey(group)) + { + return null; + } + return hurtablesHit[group]; + } + /// /// Destroys all boxes and clears variables. /// diff --git a/Assets/CAF/Samples/TDAction/Characters/Boxer/BoxerMovesetDefinition.asset b/Assets/CAF/Samples/TDAction/Characters/Boxer/BoxerMovesetDefinition.asset index e993b098..75256a86 100644 --- a/Assets/CAF/Samples/TDAction/Characters/Boxer/BoxerMovesetDefinition.asset +++ b/Assets/CAF/Samples/TDAction/Characters/Boxer/BoxerMovesetDefinition.asset @@ -13,11 +13,12 @@ MonoBehaviour: m_Name: Ground_AA m_EditorClassIdentifier: graph: {fileID: 11400000} - position: {x: -8, y: -88} + position: {x: -56, y: -104} ports: keys: - lastNode - nextNode + - nextNode 0 values: - _fieldName: lastNode _node: {fileID: -5309879101736589152} @@ -41,6 +42,18 @@ MonoBehaviour: _connectionType: 0 _typeConstraint: 0 _dynamic: 0 + - _fieldName: nextNode 0 + _node: {fileID: -5309879101736589152} + _typeQualifiedName: CAF.Combat.MovesetAttackNode+nextNodeDefinition, CAF, Version=0.0.0.0, + Culture=neutral, PublicKeyToken=null + connections: + - fieldName: lastNode + node: {fileID: 7783888192108734346} + reroutePoints: [] + _direction: 1 + _connectionType: 0 + _typeConstraint: 0 + _dynamic: 1 lastNode: {fileID: 4997239229425092478} executeInputs: - inputType: 0 @@ -49,7 +62,9 @@ MonoBehaviour: directionDeviation: 0 inputSequence: [] attackDefinition: {fileID: 11400000, guid: 2e0abd68fbe37d246b9fe3a7446475be, type: 2} - nextNode: [] + nextNode: + - cancelWindow: {x: 9, y: 60} + node: {fileID: 7783888192108734346} --- !u!114 &11400000 MonoBehaviour: m_ObjectHideFlags: 0 @@ -65,6 +80,7 @@ MonoBehaviour: nodes: - {fileID: 4997239229425092478} - {fileID: -5309879101736589152} + - {fileID: 7783888192108734346} groundAttackCommandNormals: [] groundAttackStartNodes: - {fileID: 4997239229425092478} @@ -132,3 +148,53 @@ MonoBehaviour: nextNode: - cancelWindow: {x: 9, y: 60} node: {fileID: -5309879101736589152} +--- !u!114 &7783888192108734346 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 0} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 5cf4d5189da6b334e93745642899b7ca, type: 3} + m_Name: Ground_AAA + m_EditorClassIdentifier: + graph: {fileID: 11400000} + position: {x: 184, y: -104} + ports: + keys: + - lastNode + - nextNode + values: + - _fieldName: lastNode + _node: {fileID: 7783888192108734346} + _typeQualifiedName: CAF.Combat.MovesetAttackNode, CAF, Version=0.0.0.0, Culture=neutral, + PublicKeyToken=null + connections: + - fieldName: nextNode 0 + node: {fileID: -5309879101736589152} + reroutePoints: [] + _direction: 0 + _connectionType: 0 + _typeConstraint: 0 + _dynamic: 0 + - _fieldName: nextNode + _node: {fileID: 7783888192108734346} + _typeQualifiedName: System.Collections.Generic.List`1[[CAF.Combat.MovesetAttackNode+nextNodeDefinition, + CAF, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null]], mscorlib, Version=4.0.0.0, + Culture=neutral, PublicKeyToken=b77a5c561934e089 + connections: [] + _direction: 1 + _connectionType: 0 + _typeConstraint: 0 + _dynamic: 0 + lastNode: {fileID: -5309879101736589152} + executeInputs: + - inputType: 0 + buttonID: 3 + stickDirection: {x: 0, y: 0} + directionDeviation: 0 + inputSequence: [] + attackDefinition: {fileID: 11400000, guid: 70e3e4c4a9abb8a4fac77a6ca3d3dc29, type: 2} + nextNode: [] 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 de258c84..d6f81e38 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 @@ -29,7 +29,8 @@ MonoBehaviour: chargeWindows: [] boxGroups: - id: 0 - events: [] + events: + - id: 1 references: version: 1 00000000: @@ -51,8 +52,25 @@ MonoBehaviour: chargeLevelNeeded: -1 chargeLevelMax: 4 hitboxHitInfo: - id: 1 + id: 2 00000001: + type: {class: AttackEventDefinition, ns: CAF.Combat, asm: CAF} + data: + nickname: X Friction + active: 1 + onHit: 0 + onHitHitboxGroup: 0 + startFrame: 3 + endFrame: 30 + attackEvent: + id: 3 + variables: + intVars: + floatVars: + - 0.01 + objectVars: [] + curveVars: [] + 00000002: type: {class: HitInfo, ns: CAF.Combat, asm: CAF} data: airOnly: 0 @@ -83,3 +101,8 @@ MonoBehaviour: opponentMaxMagnitude: 1 opponentMinMagnitude: 1 throwConfirm: {fileID: 0} + 00000003: + type: {class: ApplyFriction, ns: TDAction.Combat.Events, asm: TDAction_CSharp} + data: + xFriction: 1 + yFriction: 0 diff --git a/Assets/CAF/Samples/TDAction/Characters/Boxer/Moveset/Ground/Ground_AA.asset b/Assets/CAF/Samples/TDAction/Characters/Boxer/Moveset/Ground/Ground_AA.asset index 39eebe37..38b038ff 100644 --- a/Assets/CAF/Samples/TDAction/Characters/Boxer/Moveset/Ground/Ground_AA.asset +++ b/Assets/CAF/Samples/TDAction/Characters/Boxer/Moveset/Ground/Ground_AA.asset @@ -21,14 +21,16 @@ MonoBehaviour: animationGround: {fileID: 0} animationAir: {fileID: 0} wrapMode: 0 - jumpCancelWindows: [] + jumpCancelWindows: + - {x: 9, y: 60} enemyStepWindows: [] landCancelWindows: [] commandAttackCancelWindows: [] chargeWindows: [] boxGroups: - id: 0 - events: [] + events: + - id: 1 references: version: 1 00000000: @@ -50,8 +52,25 @@ MonoBehaviour: chargeLevelNeeded: -1 chargeLevelMax: 1 hitboxHitInfo: - id: 1 + id: 2 00000001: + type: {class: AttackEventDefinition, ns: CAF.Combat, asm: CAF} + data: + nickname: X Friction + active: 1 + onHit: 0 + onHitHitboxGroup: 0 + startFrame: 1 + endFrame: 1 + attackEvent: + id: 3 + variables: + intVars: + floatVars: + - 0.01 + objectVars: [] + curveVars: [] + 00000002: type: {class: HitInfo, ns: CAF.Combat, asm: CAF} data: airOnly: 0 @@ -82,3 +101,8 @@ MonoBehaviour: opponentMaxMagnitude: 1 opponentMinMagnitude: 1 throwConfirm: {fileID: 0} + 00000003: + type: {class: ApplyFriction, ns: TDAction.Combat.Events, asm: TDAction_CSharp} + data: + xFriction: 1 + yFriction: 0 diff --git a/Assets/CAF/Samples/TDAction/Characters/Boxer/Moveset/Ground/Ground_AAA.asset b/Assets/CAF/Samples/TDAction/Characters/Boxer/Moveset/Ground/Ground_AAA.asset index 2fe1755c..5681fd80 100644 --- a/Assets/CAF/Samples/TDAction/Characters/Boxer/Moveset/Ground/Ground_AAA.asset +++ b/Assets/CAF/Samples/TDAction/Characters/Boxer/Moveset/Ground/Ground_AAA.asset @@ -15,28 +15,37 @@ MonoBehaviour: attackName: Ground AAA description: stateOverride: -1 - length: 30 + length: 35 heightRestriction: 0 gravityScaleAdded: 0 animationGround: {fileID: 0} animationAir: {fileID: 0} wrapMode: 0 - jumpCancelWindows: [] + jumpCancelWindows: + - {x: 11, y: 60} enemyStepWindows: [] landCancelWindows: [] commandAttackCancelWindows: [] - chargeWindows: [] - boxGroups: + chargeWindows: - id: 0 + boxGroups: + - id: 1 events: [] references: version: 1 00000000: + type: {class: ChargeDefinition, ns: CAF.Combat, asm: CAF} + data: + frame: 6 + releaseOnCompletion: 1 + chargeLevels: + - maxChargeFrames: 15 + 00000001: type: {class: BoxGroup, ns: CAF.Combat, asm: CAF} data: ID: 0 - activeFramesStart: 5 - activeFramesEnd: 8 + activeFramesStart: 7 + activeFramesEnd: 10 hitGroupType: 0 boxes: - shape: 0 @@ -50,8 +59,8 @@ MonoBehaviour: chargeLevelNeeded: -1 chargeLevelMax: 1 hitboxHitInfo: - id: 1 - 00000001: + id: 2 + 00000002: type: {class: HitInfo, ns: CAF.Combat, asm: CAF} data: airOnly: 0 @@ -61,8 +70,8 @@ MonoBehaviour: spaceBetweenHits: 0 opponentResetXForce: 1 opponentResetYForce: 1 - attackerHitstop: 4 - hitstop: 4 + attackerHitstop: 6 + hitstop: 6 hitstun: 30 forceType: 0 forceRelation: 1 diff --git a/Assets/CAF/Samples/TDAction/Scenes/PlayScene.unity b/Assets/CAF/Samples/TDAction/Scenes/PlayScene.unity index f4b47eed..a8eb5131 100644 --- a/Assets/CAF/Samples/TDAction/Scenes/PlayScene.unity +++ b/Assets/CAF/Samples/TDAction/Scenes/PlayScene.unity @@ -997,6 +997,7 @@ GameObject: - component: {fileID: 597232825} - component: {fileID: 597232827} - component: {fileID: 597232826} + - component: {fileID: 597232828} m_Layer: 0 m_Name: cm m_TagString: Untagged @@ -1072,6 +1073,23 @@ MonoBehaviour: m_Script: {fileID: 11500000, guid: ac0b09e7857660247b1477e93731de29, type: 3} m_Name: m_EditorClassIdentifier: +--- !u!114 &597232828 +MonoBehaviour: + m_ObjectHideFlags: 3 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 597232824} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 68bb026fafb42b14791938953eaace77, type: 3} + m_Name: + m_EditorClassIdentifier: + m_NoiseProfile: {fileID: 11400000, guid: 69ce8388f6785dd4c8c39915efece2f4, type: 2} + m_PivotOffset: {x: 0, y: 0, z: 0} + m_AmplitudeGain: 1 + m_FrequencyGain: 0 + mNoiseOffsets: {x: 0, y: 0, z: 0} --- !u!1 &599076303 GameObject: m_ObjectHideFlags: 0 diff --git a/Assets/CAF/Samples/TDAction/Scripts/Combat/Events.meta b/Assets/CAF/Samples/TDAction/Scripts/Combat/Events.meta new file mode 100644 index 00000000..73ea0cfe --- /dev/null +++ b/Assets/CAF/Samples/TDAction/Scripts/Combat/Events.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 66d5ebdd62fded841ba1899b7384baa8 +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/CAF/Samples/TDAction/Scripts/Combat/Events/ApplyFriction.cs b/Assets/CAF/Samples/TDAction/Scripts/Combat/Events/ApplyFriction.cs new file mode 100644 index 00000000..c053e2e8 --- /dev/null +++ b/Assets/CAF/Samples/TDAction/Scripts/Combat/Events/ApplyFriction.cs @@ -0,0 +1,52 @@ +using System.Collections.Generic; +using UnityEngine; +using CAF.Combat; +#if UNITY_EDITOR +using UnityEditor; +#endif + +namespace TDAction.Combat.Events +{ + public class ApplyFriction : AttackEvent + { + public bool xFriction; + public bool yFriction; + + public override string GetName() + { + return "Friction"; + } + + public override bool Evaluate(uint frame, uint endFrame, + CAF.Entities.EntityManager controller, AttackEventVariables variables) + { + if (xFriction) + { + controller.PhysicsManager.ApplyMovementFriction(variables.floatVars[0]); + } + if (yFriction) + { + controller.PhysicsManager.ApplyGravityFriction(variables.floatVars[0]); + } + return false; + } + +#if UNITY_EDITOR + public override void DrawEventVariables(CAF.Combat.AttackEventDefinition eventDefinition) + { + if (eventDefinition.variables.floatVars == null + || eventDefinition.variables.floatVars.Count != 1) + { + eventDefinition.variables.floatVars = new List(1); + eventDefinition.variables.floatVars.Add(0); + } + + xFriction = EditorGUILayout.Toggle("X-Axis", xFriction); + yFriction = EditorGUILayout.Toggle("Y-Axis", yFriction); + + eventDefinition.variables.floatVars[0] = EditorGUILayout.FloatField("Friction", + eventDefinition.variables.floatVars[0]); + } +#endif + } +} \ No newline at end of file diff --git a/Assets/CAF/Samples/TDAction/Scripts/Combat/Events/ApplyFriction.cs.meta b/Assets/CAF/Samples/TDAction/Scripts/Combat/Events/ApplyFriction.cs.meta new file mode 100644 index 00000000..6909a5f2 --- /dev/null +++ b/Assets/CAF/Samples/TDAction/Scripts/Combat/Events/ApplyFriction.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 843d53ab54ad9d94eb5494618993a9e5 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/CAF/Samples/TDAction/Scripts/Entities/States/EntityStateAttack.cs b/Assets/CAF/Samples/TDAction/Scripts/Entities/States/EntityStateAttack.cs index 7d112902..d51180ff 100644 --- a/Assets/CAF/Samples/TDAction/Scripts/Entities/States/EntityStateAttack.cs +++ b/Assets/CAF/Samples/TDAction/Scripts/Entities/States/EntityStateAttack.cs @@ -48,16 +48,62 @@ public override void OnUpdate() return; } + bool eventCancel = false; + for (int i = 0; i < currentAttack.events.Count; i++) + { + if (HandleEvents(currentAttack.events[i])) + { + eventCancel = true; + return; + } + } + if (CheckInterrupt()) { return; } - if (!HandleChargeLevels(entityManager, currentAttack)) + if (!eventCancel && !HandleChargeLevels(entityManager, currentAttack)) { entityManager.StateManager.IncrementFrame(); } } + /// + /// Handles the lifetime of events. + /// + /// The event being processed. + /// True if the current attack state was canceled by the event. + protected virtual bool HandleEvents(CAF.Combat.AttackEventDefinition currentEvent) + { + if (!currentEvent.active) + { + return false; + } + EntityManager e = GetEntityManager(); + if (e.StateManager.CurrentStateFrame >= currentEvent.startFrame + && e.StateManager.CurrentStateFrame <= currentEvent.endFrame) + { + if (currentEvent.onHit) + { + List ihList = + ((EntityHitboxManager)e.CombatManager.hitboxManager).GetHitList(currentEvent.onHitHitboxGroup); + if (ihList == null) + { + return false; + } + if (ihList.Count <= 1) + { + return false; + } + } + return currentEvent.attackEvent.Evaluate(e.StateManager.CurrentStateFrame - currentEvent.startFrame, + currentEvent.endFrame - currentEvent.startFrame, + e, + currentEvent.variables); + } + return false; + } + /// /// Handles processing the charge levels of the current attack. /// diff --git a/TDAction_CSharp.csproj b/TDAction_CSharp.csproj index 6543b732..7087a726 100644 --- a/TDAction_CSharp.csproj +++ b/TDAction_CSharp.csproj @@ -82,6 +82,7 @@ +