Added knockback control
This commit is contained in:
parent
785f1d1ef1
commit
6883df0d14
@ -40,11 +40,11 @@ AnimatorStateTransition:
|
||||
m_Mute: 0
|
||||
m_IsExit: 0
|
||||
serializedVersion: 3
|
||||
m_TransitionDuration: 0.25
|
||||
m_TransitionDuration: 0
|
||||
m_TransitionOffset: 0
|
||||
m_ExitTime: 0
|
||||
m_HasExitTime: 1
|
||||
m_HasFixedDuration: 1
|
||||
m_HasFixedDuration: 0
|
||||
m_InterruptionSource: 0
|
||||
m_OrderedInterruption: 1
|
||||
m_CanTransitionToSelf: 1
|
||||
@ -124,11 +124,11 @@ AnimatorStateTransition:
|
||||
m_Mute: 0
|
||||
m_IsExit: 0
|
||||
serializedVersion: 3
|
||||
m_TransitionDuration: 0.25
|
||||
m_TransitionDuration: -0
|
||||
m_TransitionOffset: 0
|
||||
m_ExitTime: 0
|
||||
m_HasExitTime: 1
|
||||
m_HasFixedDuration: 1
|
||||
m_HasFixedDuration: 0
|
||||
m_InterruptionSource: 0
|
||||
m_OrderedInterruption: 1
|
||||
m_CanTransitionToSelf: 1
|
||||
@ -167,8 +167,8 @@ AnimatorState:
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_Name: Slash2
|
||||
m_Speed: 0.5
|
||||
m_Name: Slash1
|
||||
m_Speed: 0.3
|
||||
m_CycleOffset: 0
|
||||
m_Transitions:
|
||||
- {fileID: 1744850431499835666}
|
||||
@ -235,8 +235,8 @@ AnimatorState:
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_Name: Slash1
|
||||
m_Speed: 0.5
|
||||
m_Name: Slash2
|
||||
m_Speed: 0.3
|
||||
m_CycleOffset: 0
|
||||
m_Transitions:
|
||||
- {fileID: -7287591005394286135}
|
||||
|
||||
@ -23,10 +23,12 @@ AnimationClip:
|
||||
- time: 0
|
||||
value: {fileID: 2084452910934024698, guid: 309d09cd04eabea43bdf7c83eace0ecd, type: 3}
|
||||
- time: 0.016666668
|
||||
value: {fileID: -2736451627376223018, guid: 309d09cd04eabea43bdf7c83eace0ecd, type: 3}
|
||||
value: {fileID: 2084452910934024698, guid: 309d09cd04eabea43bdf7c83eace0ecd, type: 3}
|
||||
- time: 0.033333335
|
||||
value: {fileID: -893459440294663468, guid: 309d09cd04eabea43bdf7c83eace0ecd, type: 3}
|
||||
value: {fileID: -2736451627376223018, guid: 309d09cd04eabea43bdf7c83eace0ecd, type: 3}
|
||||
- time: 0.05
|
||||
value: {fileID: -893459440294663468, guid: 309d09cd04eabea43bdf7c83eace0ecd, type: 3}
|
||||
- time: 0.06666667
|
||||
value: {fileID: 5053079929507107595, guid: 309d09cd04eabea43bdf7c83eace0ecd, type: 3}
|
||||
attribute: m_Sprite
|
||||
path:
|
||||
@ -51,6 +53,7 @@ AnimationClip:
|
||||
isSerializeReferenceCurve: 0
|
||||
pptrCurveMapping:
|
||||
- {fileID: 2084452910934024698, guid: 309d09cd04eabea43bdf7c83eace0ecd, type: 3}
|
||||
- {fileID: 2084452910934024698, guid: 309d09cd04eabea43bdf7c83eace0ecd, type: 3}
|
||||
- {fileID: -2736451627376223018, guid: 309d09cd04eabea43bdf7c83eace0ecd, type: 3}
|
||||
- {fileID: -893459440294663468, guid: 309d09cd04eabea43bdf7c83eace0ecd, type: 3}
|
||||
- {fileID: 5053079929507107595, guid: 309d09cd04eabea43bdf7c83eace0ecd, type: 3}
|
||||
@ -59,7 +62,7 @@ AnimationClip:
|
||||
m_AdditiveReferencePoseClip: {fileID: 0}
|
||||
m_AdditiveReferencePoseTime: 0
|
||||
m_StartTime: 0
|
||||
m_StopTime: 0.06666667
|
||||
m_StopTime: 0.083333336
|
||||
m_OrientationOffsetY: 0
|
||||
m_Level: 0
|
||||
m_CycleOffset: 0
|
||||
|
||||
@ -55,10 +55,12 @@ AnimationClip:
|
||||
- time: 0
|
||||
value: {fileID: 2084452910934024698, guid: 309d09cd04eabea43bdf7c83eace0ecd, type: 3}
|
||||
- time: 0.016666668
|
||||
value: {fileID: -2736451627376223018, guid: 309d09cd04eabea43bdf7c83eace0ecd, type: 3}
|
||||
value: {fileID: 2084452910934024698, guid: 309d09cd04eabea43bdf7c83eace0ecd, type: 3}
|
||||
- time: 0.033333335
|
||||
value: {fileID: -893459440294663468, guid: 309d09cd04eabea43bdf7c83eace0ecd, type: 3}
|
||||
value: {fileID: -2736451627376223018, guid: 309d09cd04eabea43bdf7c83eace0ecd, type: 3}
|
||||
- time: 0.05
|
||||
value: {fileID: -893459440294663468, guid: 309d09cd04eabea43bdf7c83eace0ecd, type: 3}
|
||||
- time: 0.06666667
|
||||
value: {fileID: 5053079929507107595, guid: 309d09cd04eabea43bdf7c83eace0ecd, type: 3}
|
||||
attribute: m_Sprite
|
||||
path:
|
||||
@ -101,6 +103,7 @@ AnimationClip:
|
||||
isSerializeReferenceCurve: 0
|
||||
pptrCurveMapping:
|
||||
- {fileID: 2084452910934024698, guid: 309d09cd04eabea43bdf7c83eace0ecd, type: 3}
|
||||
- {fileID: 2084452910934024698, guid: 309d09cd04eabea43bdf7c83eace0ecd, type: 3}
|
||||
- {fileID: -2736451627376223018, guid: 309d09cd04eabea43bdf7c83eace0ecd, type: 3}
|
||||
- {fileID: -893459440294663468, guid: 309d09cd04eabea43bdf7c83eace0ecd, type: 3}
|
||||
- {fileID: 5053079929507107595, guid: 309d09cd04eabea43bdf7c83eace0ecd, type: 3}
|
||||
@ -109,7 +112,7 @@ AnimationClip:
|
||||
m_AdditiveReferencePoseClip: {fileID: 0}
|
||||
m_AdditiveReferencePoseTime: 0
|
||||
m_StartTime: 0
|
||||
m_StopTime: 0.06666667
|
||||
m_StopTime: 0.083333336
|
||||
m_OrientationOffsetY: 0
|
||||
m_Level: 0
|
||||
m_CycleOffset: 0
|
||||
|
||||
@ -86315,15 +86315,15 @@ SpriteRenderer:
|
||||
m_SortingLayerID: 651355007
|
||||
m_SortingLayer: 4
|
||||
m_SortingOrder: 0
|
||||
m_Sprite: {fileID: 2084452910934024698, guid: 309d09cd04eabea43bdf7c83eace0ecd, type: 3}
|
||||
m_Sprite: {fileID: 0}
|
||||
m_Color: {r: 1, g: 1, b: 1, a: 1}
|
||||
m_FlipX: 0
|
||||
m_FlipY: 0
|
||||
m_DrawMode: 0
|
||||
m_Size: {x: 1.25, y: 1.22}
|
||||
m_Size: {x: 7.8125, y: 7.625}
|
||||
m_AdaptiveModeThreshold: 0.5
|
||||
m_SpriteTileMode: 0
|
||||
m_WasSpriteAssigned: 1
|
||||
m_WasSpriteAssigned: 0
|
||||
m_MaskInteraction: 0
|
||||
m_SpriteSortPoint: 0
|
||||
--- !u!95 &1868591329
|
||||
|
||||
@ -128,7 +128,7 @@ public class Gobler : Alive {
|
||||
|
||||
|
||||
case State.TakeDamage:
|
||||
Rigidbody.linearVelocity = DirectionOfDamage * 100 * InvincibilityLeft;
|
||||
Rigidbody.linearVelocity = DirectionOfDamage * Knockback * 10 * InvincibilityLeft;
|
||||
Materials.ForEach(x => x.SetFloat("_FlashAmount", InvincibilityLeft));
|
||||
if (!IsInvincible) SetState(State.None);
|
||||
break;
|
||||
@ -235,14 +235,16 @@ public class Alive {
|
||||
|
||||
protected int DamageTaken;
|
||||
protected Vector2 DirectionOfDamage;
|
||||
protected int Knockback;
|
||||
|
||||
public void TakeDamage(int amount, Vector2 hitDirection) {
|
||||
public void Damage(int amount, Vector2 hitDirection, int knockback = 1) {
|
||||
if (IsDead || IsInvincible) return;
|
||||
|
||||
CurrentHealth -= amount;
|
||||
CurrentHealth = Mathf.Max(CurrentHealth, 0);
|
||||
InvincibleUntil = Time.time + InvincibilityDuration;
|
||||
DamageTaken = amount;
|
||||
Knockback = knockback;
|
||||
|
||||
hitDirection = hitDirection.normalized;
|
||||
if (hitDirection == Vector2.zero) hitDirection = Vector2.up;
|
||||
|
||||
@ -98,11 +98,12 @@ public class ClassBase {
|
||||
|
||||
|
||||
protected Coroutine AttackCoroutine;
|
||||
protected void CreateHitBoxOffset(float centerOffset, float radius, float hitDelay, float hitDuration) {
|
||||
protected void CreateHitBoxOffset(float centerOffset, float radius, float hitDelay, float hitDuration, int knockback) {
|
||||
if (AttackCoroutine != null)
|
||||
Player.Instance.StopCoroutine(AttackCoroutine);
|
||||
var center = PlayerPos + Player.PrevDirection * centerOffset;
|
||||
hitDelay = 0;
|
||||
HitBoxDraw.Knockback = knockback;
|
||||
AttackCoroutine = Player.Instance.StartCoroutine(CreateHitBoxHelper(center, radius, hitDelay, hitDuration));
|
||||
}
|
||||
|
||||
@ -130,5 +131,6 @@ public class ClassBase {
|
||||
public Vector2 Center;
|
||||
public float Radius;
|
||||
public Color Color;
|
||||
public int Knockback;
|
||||
}
|
||||
}
|
||||
|
||||
@ -232,17 +232,17 @@ public class MeleeFighterClass : ClassBase {
|
||||
|
||||
case AttackState.BasicAttack1:
|
||||
AnimationToPlay = "Attack1";
|
||||
CreateHitBoxOffset(4, 4, 0.1f, 0.1f);
|
||||
CreateHitBoxOffset(4, 4, 0.1f, 0.1f, 10);
|
||||
break;
|
||||
|
||||
case AttackState.BasicAttack2:
|
||||
AnimationToPlay = "Attack2";
|
||||
CreateHitBoxOffset(4, 4, 0.1f, 0.1f);
|
||||
CreateHitBoxOffset(4, 4, 0.1f, 0.1f, 15);
|
||||
break;
|
||||
|
||||
case AttackState.BasicAttack3:
|
||||
AnimationToPlay = "Attack1";
|
||||
CreateHitBoxOffset(4, 4, 0.1f, 0.1f);
|
||||
CreateHitBoxOffset(4, 4, 0.1f, 0.1f, 20);
|
||||
break;
|
||||
|
||||
case AttackState.KineticSurgeRelease:
|
||||
|
||||
@ -204,7 +204,7 @@ public class Player : MonoBehaviour {
|
||||
|
||||
GameObject parent = hit.transform.parent?.gameObject;
|
||||
//EnemySpawnerData.EnemyMap[parent].TakeDamage(0, transform.position - parent.transform.position);
|
||||
EnemySpawnerData.EnemyMap[parent].TakeDamage(0, PrevDirection);
|
||||
EnemySpawnerData.EnemyMap[parent].Damage(0, PrevDirection, ActiveClass.HitBoxDraw.Knockback);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user