From 60c24408ee3906607847b1b18aab36b95fd8d63a Mon Sep 17 00:00:00 2001 From: christides11 <29593332+christides11@users.noreply.github.com> Date: Sun, 16 Aug 2020 17:09:00 -0700 Subject: [PATCH] feat: Moveset changing. Added method to change the current moveset of a entity, along with an event that fires when it happens. --- .../Attack/AttackDefinitionEditorWindow.cs | 4 +- .../Entities/Managers/EntityCombatManager.cs | 13 ++++++ .../Characters/Boxer/BoxerDefinition.asset | 2 + .../Boxer/Moveset/Ground/Ground_A.asset | 44 +++++++------------ .../Characters/Boxer/Scripts/BoxerManager.cs | 8 +++- .../TDAction/Scripts/Combat/HitInfo.cs | 11 ----- .../TDAction/Scripts/Combat/HitInfo.cs.meta | 11 ----- .../Scripts/Entities/EntityDefinition.cs | 2 +- TDAction_CSharp.csproj | 1 - 9 files changed, 43 insertions(+), 53 deletions(-) delete mode 100644 Assets/CAF/Samples/TDAction/Scripts/Combat/HitInfo.cs delete mode 100644 Assets/CAF/Samples/TDAction/Scripts/Combat/HitInfo.cs.meta diff --git a/Assets/CAF/Editor/Combat/Attack/AttackDefinitionEditorWindow.cs b/Assets/CAF/Editor/Combat/Attack/AttackDefinitionEditorWindow.cs index 9999056e..ec94a869 100644 --- a/Assets/CAF/Editor/Combat/Attack/AttackDefinitionEditorWindow.cs +++ b/Assets/CAF/Editor/Combat/Attack/AttackDefinitionEditorWindow.cs @@ -325,12 +325,14 @@ protected virtual void BoxesMenuNavigationBar() if (GUILayout.Button("Add", GUILayout.Width(50))) { + Undo.RecordObject(attack, "Added Box Group"); AddBoxGroup(); } if (GUILayout.Button("Remove", GUILayout.Width(60))) { + Undo.RecordObject(attack, "Removed Box Group"); attack.boxGroups.RemoveAt(currentHitboxGroupIndex); - currentHitboxGroupIndex--; + currentHitboxGroupIndex--; } } diff --git a/Assets/CAF/Entities/Managers/EntityCombatManager.cs b/Assets/CAF/Entities/Managers/EntityCombatManager.cs index 1fa81860..21339aab 100644 --- a/Assets/CAF/Entities/Managers/EntityCombatManager.cs +++ b/Assets/CAF/Entities/Managers/EntityCombatManager.cs @@ -10,6 +10,7 @@ public class EntityCombatManager : MonoBehaviour, IHurtable { public delegate void EntityEmptyAction(EntityManager self); public delegate void EntityHealthChangedAction(EntityManager initializer, EntityManager self, HitInfoBase hitInfo); + public delegate void EntityMovesetChangedAction(EntityManager self, MovesetDefinition lastMoveset); public event EntityHealthChangedAction OnHit; public event EntityHealthChangedAction OnHealed; public event EntityEmptyAction OnEnterHitStop; @@ -18,6 +19,7 @@ public class EntityCombatManager : MonoBehaviour, IHurtable public event EntityEmptyAction OnHitStunAdded; public event EntityEmptyAction OnExitHitStop; public event EntityEmptyAction OnExitHitStun; + public event EntityMovesetChangedAction OnMovesetChanged; public int Team { get; set; } = 0; public int HitStun { get; protected set; } = 0; @@ -73,6 +75,10 @@ public virtual void SetAttack(MovesetAttackNode attackNode) public virtual MovesetAttackNode TryAttack() { + if(CurrentMoveset == null) + { + return null; + } if(CurrentAttack == null) { return CheckStartingNodes(); @@ -278,6 +284,13 @@ public virtual void AddHitStun(int value) OnHitStunAdded?.Invoke(controller); } + public virtual void SetMoveset(MovesetDefinition moveset) + { + MovesetDefinition oldMoveset = CurrentMoveset; + CurrentMoveset = moveset; + OnMovesetChanged?.Invoke(controller, oldMoveset); + } + public virtual HitReaction Hurt(Vector3 center, Vector3 forward, Vector3 right, HitInfoBase hitInfo) { HitReaction hr = new HitReaction(); diff --git a/Assets/CAF/Samples/TDAction/Characters/Boxer/BoxerDefinition.asset b/Assets/CAF/Samples/TDAction/Characters/Boxer/BoxerDefinition.asset index d5e99b94..988d38aa 100644 --- a/Assets/CAF/Samples/TDAction/Characters/Boxer/BoxerDefinition.asset +++ b/Assets/CAF/Samples/TDAction/Characters/Boxer/BoxerDefinition.asset @@ -15,3 +15,5 @@ MonoBehaviour: entityPrefab: {fileID: 8147816337253296054, guid: 566a2b9082a19f54d9a11fabf7eb2be8, type: 3} entityStats: {fileID: 11400000, guid: 8146d0caba1679d42a9e707c89dba1cb, type: 2} + movesets: + - {fileID: 11400000, guid: d767c8566af37be4fb1c760ebd85d96f, type: 2} 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 6b8ab553..84904f44 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 @@ -12,10 +12,10 @@ MonoBehaviour: m_Script: {fileID: 11500000, guid: b727ab7513f07da4ab8ca7d2f6d52cc9, type: 3} m_Name: Ground_A m_EditorClassIdentifier: - attackName: + attackName: Ground A description: stateOverride: -1 - length: 1 + length: 45 heightRestriction: 0 gravityScaleAdded: 0 animationGround: {fileID: 0} @@ -25,43 +25,39 @@ MonoBehaviour: enemyStepWindows: [] landCancelWindows: [] commandAttackCancelWindows: [] - chargeWindows: - - id: 0 + chargeWindows: [] boxGroups: - - id: 1 + - id: 0 events: [] references: version: 1 00000000: - type: {class: ChargeDefinition, ns: CAF.Combat, asm: CAF} - data: - frame: 1 - releaseOnCompletion: 1 - chargeLevels: - - maxChargeFrames: 30 - - maxChargeFrames: 30 - - maxChargeFrames: 30 - 00000001: type: {class: BoxGroup, ns: CAF.Combat, asm: CAF} data: ID: 0 - activeFramesStart: 0 - activeFramesEnd: 0 + activeFramesStart: 5 + activeFramesEnd: 8 hitGroupType: 0 boxes: [] attachToEntity: 1 styleGain: 1 hitboxHitInfo: - id: 2 - 00000002: - type: {class: HitInfo, ns: TDAction.Combat, asm: TDAction} + id: 1 + 00000001: + type: {class: HitInfo, ns: CAF.Combat, asm: CAF} data: - forceType: 0 - forceRelation: 0 airOnly: 0 groundOnly: 0 + hitKills: 1 continuousHit: 0 spaceBetweenHits: 0 + opponentResetXForce: 1 + opponentResetYForce: 1 + attackerHitstop: 0 + hitstop: 0 + hitstun: 0 + forceType: 0 + forceRelation: 0 breakArmor: 0 unblockable: 0 knockdown: 0 @@ -71,12 +67,6 @@ MonoBehaviour: wallBounceForce: 0 damageOnHit: 0 damageOnBlock: 0 - hitKills: 1 - attackerHitstop: 0 - hitstop: 0 - hitstun: 0 - opponentResetXForce: 1 - opponentResetYForce: 1 causesTumble: 0 opponentForceMagnitude: 1 opponentForceDir: {x: 0, y: 0, z: 1} diff --git a/Assets/CAF/Samples/TDAction/Characters/Boxer/Scripts/BoxerManager.cs b/Assets/CAF/Samples/TDAction/Characters/Boxer/Scripts/BoxerManager.cs index 4b5a630c..79db07c4 100644 --- a/Assets/CAF/Samples/TDAction/Characters/Boxer/Scripts/BoxerManager.cs +++ b/Assets/CAF/Samples/TDAction/Characters/Boxer/Scripts/BoxerManager.cs @@ -1,4 +1,5 @@ -using System.Collections; +using CAF.Input; +using System.Collections; using System.Collections.Generic; using UnityEngine; @@ -6,6 +7,11 @@ namespace TDAction.Entities.Characters.Boxer { public class BoxerManager : CharacterManager { + public override void Initialize(InputControlType controlType) + { + base.Initialize(controlType); + CombatManager.SetMoveset(entityDefinition.movesets[0]); + } protected override void SetupStates() { diff --git a/Assets/CAF/Samples/TDAction/Scripts/Combat/HitInfo.cs b/Assets/CAF/Samples/TDAction/Scripts/Combat/HitInfo.cs deleted file mode 100644 index 2b3c5e54..00000000 --- a/Assets/CAF/Samples/TDAction/Scripts/Combat/HitInfo.cs +++ /dev/null @@ -1,11 +0,0 @@ -using System.Collections; -using System.Collections.Generic; -using UnityEngine; - -namespace TDAction.Combat -{ - public class HitInfo : CAF.Combat.HitInfo - { - - } -} \ No newline at end of file diff --git a/Assets/CAF/Samples/TDAction/Scripts/Combat/HitInfo.cs.meta b/Assets/CAF/Samples/TDAction/Scripts/Combat/HitInfo.cs.meta deleted file mode 100644 index 83f61654..00000000 --- a/Assets/CAF/Samples/TDAction/Scripts/Combat/HitInfo.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: e38e58eda351a014ab79f5b0dd959158 -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/CAF/Samples/TDAction/Scripts/Entities/EntityDefinition.cs b/Assets/CAF/Samples/TDAction/Scripts/Entities/EntityDefinition.cs index bb7f8778..64aa932e 100644 --- a/Assets/CAF/Samples/TDAction/Scripts/Entities/EntityDefinition.cs +++ b/Assets/CAF/Samples/TDAction/Scripts/Entities/EntityDefinition.cs @@ -10,7 +10,7 @@ public class EntityDefinition : ScriptableObject { [SerializeField] protected EntityManager entityPrefab; [SerializeField] protected EntityStats entityStats; - [SerializeField] protected List movesets = new List(); + [SerializeField] public List movesets = new List(); public virtual EntityStats GetEntityStats() { diff --git a/TDAction_CSharp.csproj b/TDAction_CSharp.csproj index 5051a9a9..804f534c 100644 --- a/TDAction_CSharp.csproj +++ b/TDAction_CSharp.csproj @@ -83,7 +83,6 @@ -