diff --git a/Assets/CAF/Combat/Boxes/Hitbox.cs b/Assets/CAF/Combat/Boxes/Hitbox.cs index df89ecf0..e241fc4e 100644 --- a/Assets/CAF/Combat/Boxes/Hitbox.cs +++ b/Assets/CAF/Combat/Boxes/Hitbox.cs @@ -17,8 +17,8 @@ public abstract class Hitbox : SimObject public List ignoreList = null; public List hitHurtables = new List(); - public abstract void Initialize(GameObject owner, Transform directionOwner, BoxShapes shape, - HitInfoBase hitInfo, BoxDefinition boxDefinition, List ignoreList = null); + public abstract void Initialize(GameObject owner, Transform directionOwner, int team, + BoxShapes shape, HitInfoBase hitInfo, BoxDefinition boxDefinition, List ignoreList = null); public virtual void Activate() { diff --git a/Assets/CAF/Combat/Boxes/Hitbox2D.cs b/Assets/CAF/Combat/Boxes/Hitbox2D.cs index 531137f2..2b94aa29 100644 --- a/Assets/CAF/Combat/Boxes/Hitbox2D.cs +++ b/Assets/CAF/Combat/Boxes/Hitbox2D.cs @@ -11,8 +11,8 @@ public class Hitbox2D : Hitbox protected Collider2D coll; - public override void Initialize(GameObject owner, Transform directionOwner, BoxShapes shape, - HitInfoBase hitInfo, BoxDefinition boxDefinition, List ignoreList = null) + public override void Initialize(GameObject owner, Transform directionOwner, int team, + BoxShapes shape, HitInfoBase hitInfo, BoxDefinition boxDefinition, List ignoreList = null) { this.owner = owner; this.directionOwner = directionOwner; diff --git a/Assets/CAF/Combat/Boxes/Hitbox3D.cs b/Assets/CAF/Combat/Boxes/Hitbox3D.cs index faa51321..6b61578b 100644 --- a/Assets/CAF/Combat/Boxes/Hitbox3D.cs +++ b/Assets/CAF/Combat/Boxes/Hitbox3D.cs @@ -9,8 +9,8 @@ public class Hitbox3D : Hitbox { protected Collider coll; - public override void Initialize(GameObject owner, Transform directionOwner, BoxShapes shape, - HitInfoBase hitInfo, BoxDefinition boxDefinition, List ignoreList = null) + public override void Initialize(GameObject owner, Transform directionOwner, int team, + BoxShapes shape, HitInfoBase hitInfo, BoxDefinition boxDefinition, List ignoreList = null) { this.owner = owner; this.directionOwner = directionOwner; diff --git a/Assets/CAF/Entities/Managers/EntityHitboxManager.cs b/Assets/CAF/Entities/Managers/EntityHitboxManager.cs index 8b1b4948..da21377f 100644 --- a/Assets/CAF/Entities/Managers/EntityHitboxManager.cs +++ b/Assets/CAF/Entities/Managers/EntityHitboxManager.cs @@ -1,6 +1,5 @@ using CAF.Combat; using System; -using System.Collections; using System.Collections.Generic; using UnityEngine; @@ -148,8 +147,8 @@ public virtual void CreateHitboxGroup(int index) hitbox.transform.SetParent(manager.transform, true); } - hitbox.Initialize(manager.gameObject, manager.visual.transform, currentGroup.boxes[i].shape, - currentGroup.hitboxHitInfo, hitboxDefinition, hurtablesHit[currentGroup.ID]); + hitbox.Initialize(manager.gameObject, manager.visual.transform, manager.CombatManager.GetTeam(), + currentGroup.boxes[i].shape, currentGroup.hitboxHitInfo, hitboxDefinition, hurtablesHit[currentGroup.ID]); int cID = currentGroup.ID; int groupIndex = index; hitbox.OnHurt += (hurtable, hitInfo) => { OnHitboxHurt(hurtable, hitInfo, cID, groupIndex); }; diff --git a/Assets/CAF/Samples/TDAction/Characters/Boxer/Boxer.prefab b/Assets/CAF/Samples/TDAction/Characters/Boxer/Boxer.prefab index bf9291e8..f5a44dae 100644 --- a/Assets/CAF/Samples/TDAction/Characters/Boxer/Boxer.prefab +++ b/Assets/CAF/Samples/TDAction/Characters/Boxer/Boxer.prefab @@ -323,6 +323,8 @@ MonoBehaviour: healthManager: {fileID: 1715174515004957371} hitboxPrefab: {fileID: 8701306930311813587, guid: 615623af5916ce74fbef98bec30a2efd, type: 3} + hitstopShakeAmt: 0.02 + hitstopShakeInv: 1 --- !u!114 &5384823916746293231 MonoBehaviour: m_ObjectHideFlags: 0 diff --git a/Assets/CAF/Samples/TDAction/Scenes/PlayScene.unity b/Assets/CAF/Samples/TDAction/Scenes/PlayScene.unity index a8eb5131..cf5f584e 100644 --- a/Assets/CAF/Samples/TDAction/Scenes/PlayScene.unity +++ b/Assets/CAF/Samples/TDAction/Scenes/PlayScene.unity @@ -4084,7 +4084,7 @@ GameObject: - component: {fileID: 1629233911} - component: {fileID: 1629233913} - component: {fileID: 1629233912} - m_Layer: 0 + m_Layer: 9 m_Name: Slope_128x64_Grey m_TagString: Untagged m_Icon: {fileID: 0} @@ -4842,7 +4842,7 @@ GameObject: - component: {fileID: 2142067202} - component: {fileID: 2142067204} - component: {fileID: 2142067203} - m_Layer: 0 + m_Layer: 9 m_Name: Slope_64x64_Grey m_TagString: Untagged m_Icon: {fileID: 0} diff --git a/Assets/CAF/Samples/TDAction/Scripts/Entities/Managers/EntityManager.cs b/Assets/CAF/Samples/TDAction/Scripts/Entities/Managers/EntityManager.cs index 8808fb5e..fc82cdb1 100644 --- a/Assets/CAF/Samples/TDAction/Scripts/Entities/Managers/EntityManager.cs +++ b/Assets/CAF/Samples/TDAction/Scripts/Entities/Managers/EntityManager.cs @@ -31,6 +31,21 @@ public override void SimStart() { base.SimStart(); SetupStates(); + CombatManager.OnExitHitStop += (self) => { visual.transform.localPosition = Vector3.zero; }; + } + + public override void SimUpdate(float deltaTime) + { + // Shake during hitstop (only when you got hit by an attack). + if(CombatManager.HitStop > 0 + && CombatManager.HitStun > 0) + { + Vector3 pos = visual.transform.localPosition; + pos.x = (Mathf.Sign(pos.x) > 0 ? -1 : 0) * .02f; + visual.transform.localPosition = pos; + } + + base.SimUpdate(deltaTime); } protected virtual void SetupStates() diff --git a/Assets/CAF/Samples/TDAction/Scripts/Entities/States/EntityStateAttack.cs b/Assets/CAF/Samples/TDAction/Scripts/Entities/States/EntityStateAttack.cs index d51180ff..240f23f3 100644 --- a/Assets/CAF/Samples/TDAction/Scripts/Entities/States/EntityStateAttack.cs +++ b/Assets/CAF/Samples/TDAction/Scripts/Entities/States/EntityStateAttack.cs @@ -48,11 +48,13 @@ public override void OnUpdate() return; } + // Process events. bool eventCancel = false; for (int i = 0; i < currentAttack.events.Count; i++) { if (HandleEvents(currentAttack.events[i])) { + // Event wants us to stall on the current frame. eventCancel = true; return; }