From 59676c744205befb144ca97fb458975e33551648 Mon Sep 17 00:00:00 2001 From: christides11 <29593332+christides11@users.noreply.github.com> Date: Tue, 18 Aug 2020 12:52:58 -0700 Subject: [PATCH] refactor: Removed unused Hitbox overrides. OnHurt overrides were making the event not get called. --- Assets/CAF/Combat/Boxes/Hitbox2D.cs | 1 - Assets/CAF/Combat/Boxes/Hitbox3D.cs | 2 - .../Boxer/BoxerMovesetDefinition.asset | 68 ++++++++++++++- .../Boxer/Moveset/Ground/Ground_A.asset | 6 +- .../Boxer/Moveset/Ground/Ground_AA.asset | 84 +++++++++++++++++++ .../Boxer/Moveset/Ground/Ground_AA.asset.meta | 8 ++ .../Boxer/Moveset/Ground/Ground_AAA.asset | 84 +++++++++++++++++++ .../Moveset/Ground/Ground_AAA.asset.meta | 8 ++ .../Samples/TDAction/Scenes/PlayScene.unity | 5 ++ .../TDAction/Scripts/Camera/CameraHandler.cs | 12 --- .../Entities/Managers/EntityHitboxManager.cs | 2 +- .../Entities/{ => Managers}/EntityManager.cs | 0 .../{ => Managers}/EntityManager.cs.meta | 0 .../TDAction/Scripts/Managers/BootLoader.cs | 9 ++ .../TDAction/Scripts/Managers/GameHandler.cs | 15 +++- .../TDAction/Scripts/Managers/GameManager.cs | 14 +++- .../Scripts/Simulation/SimObjectRegister.cs | 5 +- TDAction_CSharp.csproj | 2 +- 18 files changed, 297 insertions(+), 28 deletions(-) create mode 100644 Assets/CAF/Samples/TDAction/Characters/Boxer/Moveset/Ground/Ground_AA.asset create mode 100644 Assets/CAF/Samples/TDAction/Characters/Boxer/Moveset/Ground/Ground_AA.asset.meta create mode 100644 Assets/CAF/Samples/TDAction/Characters/Boxer/Moveset/Ground/Ground_AAA.asset create mode 100644 Assets/CAF/Samples/TDAction/Characters/Boxer/Moveset/Ground/Ground_AAA.asset.meta rename Assets/CAF/Samples/TDAction/Scripts/Entities/{ => Managers}/EntityManager.cs (100%) rename Assets/CAF/Samples/TDAction/Scripts/Entities/{ => Managers}/EntityManager.cs.meta (100%) diff --git a/Assets/CAF/Combat/Boxes/Hitbox2D.cs b/Assets/CAF/Combat/Boxes/Hitbox2D.cs index b40bb7f3..531137f2 100644 --- a/Assets/CAF/Combat/Boxes/Hitbox2D.cs +++ b/Assets/CAF/Combat/Boxes/Hitbox2D.cs @@ -8,7 +8,6 @@ namespace CAF.Combat { public class Hitbox2D : Hitbox { - public override event Hitbox.HurtAction OnHurt; protected Collider2D coll; diff --git a/Assets/CAF/Combat/Boxes/Hitbox3D.cs b/Assets/CAF/Combat/Boxes/Hitbox3D.cs index 6035df82..faa51321 100644 --- a/Assets/CAF/Combat/Boxes/Hitbox3D.cs +++ b/Assets/CAF/Combat/Boxes/Hitbox3D.cs @@ -7,8 +7,6 @@ namespace CAF.Combat { public class Hitbox3D : Hitbox { - public override event Hitbox.HurtAction OnHurt; - protected Collider coll; public override void Initialize(GameObject owner, Transform directionOwner, BoxShapes shape, diff --git a/Assets/CAF/Samples/TDAction/Characters/Boxer/BoxerMovesetDefinition.asset b/Assets/CAF/Samples/TDAction/Characters/Boxer/BoxerMovesetDefinition.asset index 141d9e92..e993b098 100644 --- a/Assets/CAF/Samples/TDAction/Characters/Boxer/BoxerMovesetDefinition.asset +++ b/Assets/CAF/Samples/TDAction/Characters/Boxer/BoxerMovesetDefinition.asset @@ -1,5 +1,55 @@ %YAML 1.1 %TAG !u! tag:unity3d.com,2011: +--- !u!114 &-5309879101736589152 +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_AA + m_EditorClassIdentifier: + graph: {fileID: 11400000} + position: {x: -8, y: -88} + ports: + keys: + - lastNode + - nextNode + values: + - _fieldName: lastNode + _node: {fileID: -5309879101736589152} + _typeQualifiedName: CAF.Combat.MovesetAttackNode, CAF, Version=0.0.0.0, Culture=neutral, + PublicKeyToken=null + connections: + - fieldName: nextNode 0 + node: {fileID: 4997239229425092478} + reroutePoints: [] + _direction: 0 + _connectionType: 0 + _typeConstraint: 0 + _dynamic: 0 + - _fieldName: nextNode + _node: {fileID: -5309879101736589152} + _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: 4997239229425092478} + executeInputs: + - inputType: 0 + buttonID: 3 + stickDirection: {x: 0, y: 0} + directionDeviation: 0 + inputSequence: [] + attackDefinition: {fileID: 11400000, guid: 2e0abd68fbe37d246b9fe3a7446475be, type: 2} + nextNode: [] --- !u!114 &11400000 MonoBehaviour: m_ObjectHideFlags: 0 @@ -14,6 +64,7 @@ MonoBehaviour: m_EditorClassIdentifier: nodes: - {fileID: 4997239229425092478} + - {fileID: -5309879101736589152} groundAttackCommandNormals: [] groundAttackStartNodes: - {fileID: 4997239229425092478} @@ -37,6 +88,7 @@ MonoBehaviour: keys: - lastNode - nextNode + - nextNode 0 values: - _fieldName: lastNode _node: {fileID: 4997239229425092478} @@ -57,6 +109,18 @@ MonoBehaviour: _connectionType: 0 _typeConstraint: 0 _dynamic: 0 + - _fieldName: nextNode 0 + _node: {fileID: 4997239229425092478} + _typeQualifiedName: CAF.Combat.MovesetAttackNode+nextNodeDefinition, CAF, Version=0.0.0.0, + Culture=neutral, PublicKeyToken=null + connections: + - fieldName: lastNode + node: {fileID: -5309879101736589152} + reroutePoints: [] + _direction: 1 + _connectionType: 0 + _typeConstraint: 0 + _dynamic: 1 lastNode: {fileID: 0} executeInputs: - inputType: 0 @@ -65,4 +129,6 @@ MonoBehaviour: directionDeviation: 0 inputSequence: [] attackDefinition: {fileID: 11400000, guid: 6b5af3166b563264a9461e1318fee445, type: 2} - nextNode: [] + nextNode: + - cancelWindow: {x: 9, y: 60} + node: {fileID: -5309879101736589152} 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 c68d92c2..de258c84 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 @@ -42,7 +42,7 @@ MonoBehaviour: boxes: - shape: 0 offset: {x: 1, y: 0, z: 0} - size: {x: 4, y: 4, z: 0} + size: {x: 2, y: 2.2, z: 0} rotation: {x: 0, y: 0, z: 0} radius: 0 height: 0 @@ -77,8 +77,8 @@ MonoBehaviour: damageOnHit: 0 damageOnBlock: 0 causesTumble: 0 - opponentForceMagnitude: 0.2 - opponentForceDir: {x: 1, y: 1, z: 0} + opponentForceMagnitude: 0.05 + opponentForceDir: {x: 1, y: 0, z: 0} forceIncludeYForce: 0 opponentMaxMagnitude: 1 opponentMinMagnitude: 1 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 new file mode 100644 index 00000000..39eebe37 --- /dev/null +++ b/Assets/CAF/Samples/TDAction/Characters/Boxer/Moveset/Ground/Ground_AA.asset @@ -0,0 +1,84 @@ +%YAML 1.1 +%TAG !u! tag:unity3d.com,2011: +--- !u!114 &11400000 +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: b727ab7513f07da4ab8ca7d2f6d52cc9, type: 3} + m_Name: Ground_AA + m_EditorClassIdentifier: + attackName: Ground AA + description: + stateOverride: -1 + length: 30 + heightRestriction: 0 + gravityScaleAdded: 0 + animationGround: {fileID: 0} + animationAir: {fileID: 0} + wrapMode: 0 + jumpCancelWindows: [] + enemyStepWindows: [] + landCancelWindows: [] + commandAttackCancelWindows: [] + chargeWindows: [] + boxGroups: + - id: 0 + events: [] + references: + version: 1 + 00000000: + type: {class: BoxGroup, ns: CAF.Combat, asm: CAF} + data: + ID: 0 + activeFramesStart: 5 + activeFramesEnd: 8 + hitGroupType: 0 + boxes: + - shape: 0 + offset: {x: 1, y: 0, z: 0} + size: {x: 3, y: 2.2, z: 0} + rotation: {x: 0, y: 0, z: 0} + radius: 0 + height: 0 + attachToEntity: 1 + styleGain: 1 + chargeLevelNeeded: -1 + chargeLevelMax: 1 + hitboxHitInfo: + id: 1 + 00000001: + type: {class: HitInfo, ns: CAF.Combat, asm: CAF} + data: + airOnly: 0 + groundOnly: 0 + hitKills: 1 + continuousHit: 0 + spaceBetweenHits: 0 + opponentResetXForce: 1 + opponentResetYForce: 1 + attackerHitstop: 4 + hitstop: 4 + hitstun: 30 + forceType: 0 + forceRelation: 1 + breakArmor: 0 + unblockable: 0 + knockdown: 0 + groundBounces: 0 + groundBounceForce: 0 + wallBounces: 0 + wallBounceForce: 0 + damageOnHit: 0 + damageOnBlock: 0 + causesTumble: 0 + opponentForceMagnitude: 0.1 + opponentForceDir: {x: 1, y: 0, z: 1} + forceIncludeYForce: 0 + opponentMaxMagnitude: 1 + opponentMinMagnitude: 1 + throwConfirm: {fileID: 0} diff --git a/Assets/CAF/Samples/TDAction/Characters/Boxer/Moveset/Ground/Ground_AA.asset.meta b/Assets/CAF/Samples/TDAction/Characters/Boxer/Moveset/Ground/Ground_AA.asset.meta new file mode 100644 index 00000000..8ebf7d64 --- /dev/null +++ b/Assets/CAF/Samples/TDAction/Characters/Boxer/Moveset/Ground/Ground_AA.asset.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 2e0abd68fbe37d246b9fe3a7446475be +NativeFormatImporter: + externalObjects: {} + mainObjectFileID: 0 + userData: + assetBundleName: + assetBundleVariant: 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 new file mode 100644 index 00000000..2fe1755c --- /dev/null +++ b/Assets/CAF/Samples/TDAction/Characters/Boxer/Moveset/Ground/Ground_AAA.asset @@ -0,0 +1,84 @@ +%YAML 1.1 +%TAG !u! tag:unity3d.com,2011: +--- !u!114 &11400000 +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: b727ab7513f07da4ab8ca7d2f6d52cc9, type: 3} + m_Name: Ground_AAA + m_EditorClassIdentifier: + attackName: Ground AAA + description: + stateOverride: -1 + length: 30 + heightRestriction: 0 + gravityScaleAdded: 0 + animationGround: {fileID: 0} + animationAir: {fileID: 0} + wrapMode: 0 + jumpCancelWindows: [] + enemyStepWindows: [] + landCancelWindows: [] + commandAttackCancelWindows: [] + chargeWindows: [] + boxGroups: + - id: 0 + events: [] + references: + version: 1 + 00000000: + type: {class: BoxGroup, ns: CAF.Combat, asm: CAF} + data: + ID: 0 + activeFramesStart: 5 + activeFramesEnd: 8 + hitGroupType: 0 + boxes: + - shape: 0 + offset: {x: 1, y: 0, z: 0} + size: {x: 3, y: 2.2, z: 0} + rotation: {x: 0, y: 0, z: 0} + radius: 0 + height: 0 + attachToEntity: 1 + styleGain: 1 + chargeLevelNeeded: -1 + chargeLevelMax: 1 + hitboxHitInfo: + id: 1 + 00000001: + type: {class: HitInfo, ns: CAF.Combat, asm: CAF} + data: + airOnly: 0 + groundOnly: 0 + hitKills: 1 + continuousHit: 0 + spaceBetweenHits: 0 + opponentResetXForce: 1 + opponentResetYForce: 1 + attackerHitstop: 4 + hitstop: 4 + hitstun: 30 + forceType: 0 + forceRelation: 1 + breakArmor: 0 + unblockable: 0 + knockdown: 0 + groundBounces: 0 + groundBounceForce: 0 + wallBounces: 0 + wallBounceForce: 0 + damageOnHit: 0 + damageOnBlock: 0 + causesTumble: 0 + opponentForceMagnitude: 0.25 + opponentForceDir: {x: 1, y: 0, z: 1} + forceIncludeYForce: 0 + opponentMaxMagnitude: 1 + opponentMinMagnitude: 1 + throwConfirm: {fileID: 0} diff --git a/Assets/CAF/Samples/TDAction/Characters/Boxer/Moveset/Ground/Ground_AAA.asset.meta b/Assets/CAF/Samples/TDAction/Characters/Boxer/Moveset/Ground/Ground_AAA.asset.meta new file mode 100644 index 00000000..790027de --- /dev/null +++ b/Assets/CAF/Samples/TDAction/Characters/Boxer/Moveset/Ground/Ground_AAA.asset.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 70e3e4c4a9abb8a4fac77a6ca3d3dc29 +NativeFormatImporter: + externalObjects: {} + mainObjectFileID: 0 + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/CAF/Samples/TDAction/Scenes/PlayScene.unity b/Assets/CAF/Samples/TDAction/Scenes/PlayScene.unity index 0146ec60..f4b47eed 100644 --- a/Assets/CAF/Samples/TDAction/Scenes/PlayScene.unity +++ b/Assets/CAF/Samples/TDAction/Scenes/PlayScene.unity @@ -1252,6 +1252,11 @@ PrefabInstance: propertyPath: m_LocalEulerAnglesHint.z value: 0 objectReference: {fileID: 0} + - target: {fileID: 6667267786158460213, guid: 566a2b9082a19f54d9a11fabf7eb2be8, + type: 3} + propertyPath: m_LocalScale.x + value: 1 + objectReference: {fileID: 0} m_RemovedComponents: [] m_SourcePrefab: {fileID: 100100000, guid: 566a2b9082a19f54d9a11fabf7eb2be8, type: 3} --- !u!114 &647645933 stripped diff --git a/Assets/CAF/Samples/TDAction/Scripts/Camera/CameraHandler.cs b/Assets/CAF/Samples/TDAction/Scripts/Camera/CameraHandler.cs index 43fe99ee..1c9ffbbc 100644 --- a/Assets/CAF/Samples/TDAction/Scripts/Camera/CameraHandler.cs +++ b/Assets/CAF/Samples/TDAction/Scripts/Camera/CameraHandler.cs @@ -8,18 +8,6 @@ namespace TDAction.Camera public class CameraHandler : MonoBehaviour { [SerializeField] private CinemachineVirtualCamera followCamera; - - // Start is called before the first frame update - void Start() - { - - } - - // Update is called once per frame - void Update() - { - - } public void SetFollowTarget(Transform target) { diff --git a/Assets/CAF/Samples/TDAction/Scripts/Entities/Managers/EntityHitboxManager.cs b/Assets/CAF/Samples/TDAction/Scripts/Entities/Managers/EntityHitboxManager.cs index c8896394..8b61efc7 100644 --- a/Assets/CAF/Samples/TDAction/Scripts/Entities/Managers/EntityHitboxManager.cs +++ b/Assets/CAF/Samples/TDAction/Scripts/Entities/Managers/EntityHitboxManager.cs @@ -27,7 +27,7 @@ protected override Vector3 GetHitboxPosition(BoxDefinition hitboxDefinition) protected override Quaternion GetHitboxRotation(BoxDefinition hitboxDefinition) { - return Quaternion.Euler(manager.visual.transform.eulerAngles + return Quaternion.Euler(new Vector3(0, 0, manager.visual.transform.localScale.x < 0 ? 180 : 0) + hitboxDefinition.rotation); } } diff --git a/Assets/CAF/Samples/TDAction/Scripts/Entities/EntityManager.cs b/Assets/CAF/Samples/TDAction/Scripts/Entities/Managers/EntityManager.cs similarity index 100% rename from Assets/CAF/Samples/TDAction/Scripts/Entities/EntityManager.cs rename to Assets/CAF/Samples/TDAction/Scripts/Entities/Managers/EntityManager.cs diff --git a/Assets/CAF/Samples/TDAction/Scripts/Entities/EntityManager.cs.meta b/Assets/CAF/Samples/TDAction/Scripts/Entities/Managers/EntityManager.cs.meta similarity index 100% rename from Assets/CAF/Samples/TDAction/Scripts/Entities/EntityManager.cs.meta rename to Assets/CAF/Samples/TDAction/Scripts/Entities/Managers/EntityManager.cs.meta diff --git a/Assets/CAF/Samples/TDAction/Scripts/Managers/BootLoader.cs b/Assets/CAF/Samples/TDAction/Scripts/Managers/BootLoader.cs index 6dcef0aa..648c5369 100644 --- a/Assets/CAF/Samples/TDAction/Scripts/Managers/BootLoader.cs +++ b/Assets/CAF/Samples/TDAction/Scripts/Managers/BootLoader.cs @@ -5,6 +5,10 @@ namespace TDAction.Managers { + /// + /// Handles initializing the game. + /// This is the first script that runs when the game is started. + /// public class BootLoader : MonoBehaviour { public delegate void EmptyAction(); @@ -17,6 +21,7 @@ private void Awake() { OnPlaySceneLoaded += StartGame; + // Play scene is already loaded. if (SceneManager.GetSceneByName(playScene).IsValid()) { OnPlaySceneLoaded.Invoke(); @@ -30,6 +35,10 @@ private void StartGame() gameManager.SetupGame(); } + /// + /// Loads the play scene and sets it as the active one. + /// + /// IEnumerator LoadPlayScene() { var ls = SceneManager.LoadSceneAsync(playScene, LoadSceneMode.Additive); diff --git a/Assets/CAF/Samples/TDAction/Scripts/Managers/GameHandler.cs b/Assets/CAF/Samples/TDAction/Scripts/Managers/GameHandler.cs index 4c81602e..28b4d776 100644 --- a/Assets/CAF/Samples/TDAction/Scripts/Managers/GameHandler.cs +++ b/Assets/CAF/Samples/TDAction/Scripts/Managers/GameHandler.cs @@ -5,6 +5,11 @@ namespace TDAction.Managers { + /// + /// This script handles anything that the game needs to run. + /// The main thing it does is update the simulation with the + /// correct delta time. + /// [System.Serializable] public class GameHandler { @@ -17,12 +22,20 @@ public GameHandler() simulationObjectManager = new SimObjectManager(); } - public virtual void FixedUpdate() + /// + /// Ticks the game. This should be called from FixedUpdate. + /// + public virtual void Tick() { simulationObjectManager.Update(Time.fixedDeltaTime); simulationObjectManager.LateUpdate(Time.fixedDeltaTime); } + /// + /// Spawns the player in the simulation and attaches the camera to them. + /// + /// The entity to spawn that the player controls. + /// The position to spawn them at. public void SpawnPlayer(EntityManager entity, Vector3 spawnPosition) { currentPlayerEntity = GameObject.Instantiate(entity.gameObject, spawnPosition, Quaternion.identity) diff --git a/Assets/CAF/Samples/TDAction/Scripts/Managers/GameManager.cs b/Assets/CAF/Samples/TDAction/Scripts/Managers/GameManager.cs index e1f917d9..6b90781d 100644 --- a/Assets/CAF/Samples/TDAction/Scripts/Managers/GameManager.cs +++ b/Assets/CAF/Samples/TDAction/Scripts/Managers/GameManager.cs @@ -1,9 +1,12 @@ -using System.Collections; -using System.Collections.Generic; -using UnityEngine; +using UnityEngine; namespace TDAction.Managers { + /// + /// Manages the whole game. + /// mainly it sets up the game with the proper variables when it's ready, + /// and then ticks the game every FixedUpdate. + /// public class GameManager : MonoBehaviour { public static GameManager instance; @@ -19,6 +22,9 @@ private void Awake() instance = this; } + /// + /// Starts a game, creating a handler and spawning the player. + /// public void SetupGame() { gameHandler = new GameHandler(); @@ -30,7 +36,7 @@ public void FixedUpdate() { if (gameHandler != null) { - gameHandler.FixedUpdate(); + gameHandler.Tick(); } } } diff --git a/Assets/CAF/Samples/TDAction/Scripts/Simulation/SimObjectRegister.cs b/Assets/CAF/Samples/TDAction/Scripts/Simulation/SimObjectRegister.cs index 510a1f69..d5085250 100644 --- a/Assets/CAF/Samples/TDAction/Scripts/Simulation/SimObjectRegister.cs +++ b/Assets/CAF/Samples/TDAction/Scripts/Simulation/SimObjectRegister.cs @@ -1,11 +1,12 @@ using CAF.Simulation; -using System.Collections; -using System.Collections.Generic; using TDAction.Managers; using UnityEngine; namespace TDAction.Simulation { + /// + /// Registers the object given to the simulation. + /// public class SimObjectRegister : MonoBehaviour { [SerializeField] private SimObject simObject; diff --git a/TDAction_CSharp.csproj b/TDAction_CSharp.csproj index 85561e3e..6543b732 100644 --- a/TDAction_CSharp.csproj +++ b/TDAction_CSharp.csproj @@ -87,7 +87,6 @@ - @@ -95,6 +94,7 @@ +