diff --git a/MrBigsock/Assets/Code/Character.cs b/MrBigsock/Assets/Code/Character.cs index 75120bfb210fa3f8f124b0e374222f6ceb2059e4..cbed6e51c1926918ef5d0bf72d9373503ddcc1b5 100644 --- a/MrBigsock/Assets/Code/Character.cs +++ b/MrBigsock/Assets/Code/Character.cs @@ -88,6 +88,9 @@ namespace BigSock { // The direction the character last moved. protected Vector2 moveDir; + // trigger for in knockback. + protected bool inKnockBack = false; + /* The inventory of the character. @@ -178,20 +181,30 @@ namespace BigSock { MovementDir = moveDir, }; } - - + /* + Using a courutine to set trigger in knockback. + */ + IEnumerator knockBackTimer() + { + inKnockBack = true; + yield return new WaitForSeconds(0.15F); + rb.velocity = Vector2.zero; + inKnockBack = false; + } /* - Add Knockback. + Add Knockback. (used only for dash ?) */ public void KnockBack(float force, Vector2 difference) { rb.AddForce(difference * force, ForceMode2D.Impulse); + StartCoroutine(knockBackTimer()); + + //rb.MovePosition((Vector2)transform.position + (difference * force * Time.fixedDeltaTime)); } public void KnockBack(IAttackStats attack) { Vector2 difference = ((Vector2) transform.position - attack.Source).normalized; - //KnockBack(attack.Knockback, difference); rb.AddForce(difference * attack.Knockback, ForceMode2D.Impulse); - + StartCoroutine(knockBackTimer()); } /* @@ -199,8 +212,11 @@ namespace BigSock { */ protected virtual bool TryMove(Vector2 direction) { moveDir = direction; - if(direction != Vector2.zero) { - rb.AddForce(direction * (float) MovementSpeed * Time.fixedDeltaTime, ForceMode2D.Impulse); + if(direction != Vector2.zero && !inKnockBack) { + //Using movePosition to get a "snappy" movement. + //rb.AddForce(direction * (float) MovementSpeed * Time.fixedDeltaTime, ForceMode2D.Impulse); + rb.MovePosition((Vector2)transform.position + (direction * (float) MovementSpeed * Time.fixedDeltaTime)); + //rb.velocity = (direction * (float) MovementSpeed); return true; } return false; @@ -299,6 +315,7 @@ namespace BigSock { var res = HP + amount; if(res > MaxHP) res = MaxHP; HP = res; + AfterHeal(); return true; } @@ -310,6 +327,10 @@ namespace BigSock { KnockBack(attack); } + + protected virtual void AfterHeal() { + + } /* Method for what to do when the character dies. */ diff --git a/MrBigsock/Assets/Code/Core/Abilities/AbilityDodge.cs b/MrBigsock/Assets/Code/Core/Abilities/AbilityDodge.cs index d3be2c1a5c405f3fd9f5415fda21837c3f90c019..cc57a2d438bbe01eed14a98d335ea23e16107947 100644 --- a/MrBigsock/Assets/Code/Core/Abilities/AbilityDodge.cs +++ b/MrBigsock/Assets/Code/Core/Abilities/AbilityDodge.cs @@ -13,7 +13,7 @@ namespace BigSock { A basic dodge move that gives a push and a short invincibility. */ public class AbilityDodge : BaseAbility { - public static readonly float BASE_FORCE = 0.5f; + public static readonly float BASE_FORCE = 1f; public static readonly TimeSpan IFRAME_DURATION = new TimeSpan(0, 0, 0, 0, 500); public override ulong Id => 201; diff --git a/MrBigsock/Assets/Code/PlayerController.cs b/MrBigsock/Assets/Code/PlayerController.cs index d423498a3763cb56be1333ef956ba4cb8f8b0da5..b3f633f0768031e4567843acdbb72f1d1198f8f8 100644 --- a/MrBigsock/Assets/Code/PlayerController.cs +++ b/MrBigsock/Assets/Code/PlayerController.cs @@ -395,6 +395,10 @@ namespace BigSock { utilBar?.WithHealth(Convert.ToInt32(HP)); } + protected override void AfterHeal() { + utilBar?.WithHealth(Convert.ToInt32(HP)); + } + public void GainXp(float xp) { GiveXp(xp * XP_SCALE_RATE); CheckXp(); diff --git a/MrBigsock/Assets/Code/orc/Enemy_orc_range.cs b/MrBigsock/Assets/Code/orc/Enemy_orc_range.cs index 023fb2b17d29795fc67b7443be4074c4bdaf0e79..b542f4b3a04bd5ffe2572590a03499e5159b05d6 100644 --- a/MrBigsock/Assets/Code/orc/Enemy_orc_range.cs +++ b/MrBigsock/Assets/Code/orc/Enemy_orc_range.cs @@ -29,15 +29,15 @@ namespace BigSock { /* Minimum idle time. */ - protected static readonly TimeSpan IDLE_WAIT_TIME = new TimeSpan(0, 0, 0, 1, 0); + protected static readonly TimeSpan IDLE_WAIT_TIME = new TimeSpan(0, 0, 0, 0, 400); /* Minimum animation time. */ - protected static readonly TimeSpan CHARGE_WAIT_TIME = new TimeSpan(0, 0, 0, 2, 0); + protected static readonly TimeSpan CHARGE_WAIT_TIME = new TimeSpan(0, 0, 0, 0, 400); /* Maximum time the slime should attack before it can idle. */ - protected static readonly TimeSpan ATTACK_WAIT_TIME = new TimeSpan(0, 0, 0, 4, 0); + protected static readonly TimeSpan ATTACK_WAIT_TIME = new TimeSpan(0, 0, 0, 1, 0); protected Animator m_Animator_bow; diff --git a/MrBigsock/Assets/Resources/Prefabs/Enemy_Slime.prefab b/MrBigsock/Assets/Resources/Prefabs/Enemy_Slime.prefab index 813c795aaf676256a3ca78b241e4739c354d08ce..120d64008f039798ee05fb3e853a958385385cb5 100644 --- a/MrBigsock/Assets/Resources/Prefabs/Enemy_Slime.prefab +++ b/MrBigsock/Assets/Resources/Prefabs/Enemy_Slime.prefab @@ -176,8 +176,8 @@ MonoBehaviour: baseMovementSpeed: 2 baseDamage: 1 knockbackForce: 3 - baseHP: 20 - baseMaxHP: 20 + baseHP: 7 + baseMaxHP: 7 dropXP: 20 xp: 0 maxXp: 0 diff --git a/MrBigsock/Assets/Resources/Prefabs/enemy_orc_range.prefab b/MrBigsock/Assets/Resources/Prefabs/enemy_orc_range.prefab index 16f16233be453563253b159247dfac44e8212b2f..005f53298e32988fb5415bd8538c3608afa5e807 100644 --- a/MrBigsock/Assets/Resources/Prefabs/enemy_orc_range.prefab +++ b/MrBigsock/Assets/Resources/Prefabs/enemy_orc_range.prefab @@ -170,7 +170,7 @@ MonoBehaviour: m_Script: {fileID: 11500000, guid: e5613a049bf8e2c4cbae8505b526107e, type: 3} m_Name: m_EditorClassIdentifier: - baseAttackSpeed: 1 + baseAttackSpeed: 8 source: [] TakeDamageAudio: {fileID: 8300000, guid: 0d78a0205a770454c86c53710a0b4ff1, type: 3} baseMovementSpeed: 1 diff --git a/MrBigsock/Assets/Resources/Sprites/Enemy/Animations/slime/jumpingEnemy.anim b/MrBigsock/Assets/Resources/Sprites/Enemy/Animations/slime/jumpingEnemy.anim index 0ee4af7b72717cd85994472666384ae9d533fa8a..ee612cd6586eb63fe5c072893704f15de34f6bf5 100644 --- a/MrBigsock/Assets/Resources/Sprites/Enemy/Animations/slime/jumpingEnemy.anim +++ b/MrBigsock/Assets/Resources/Sprites/Enemy/Animations/slime/jumpingEnemy.anim @@ -17,21 +17,54 @@ AnimationClip: m_PositionCurves: [] m_ScaleCurves: [] m_FloatCurves: [] - m_PPtrCurves: [] - m_SampleRate: 60 + m_PPtrCurves: + - curve: + - time: 0 + value: {fileID: -19692615, guid: 93b51a3f2b608b7478fe0c2d5b0696a8, type: 3} + - time: 0.083333336 + value: {fileID: -1152038991, guid: 93b51a3f2b608b7478fe0c2d5b0696a8, type: 3} + - time: 0.16666667 + value: {fileID: 229421652, guid: 93b51a3f2b608b7478fe0c2d5b0696a8, type: 3} + - time: 0.25 + value: {fileID: -556319578, guid: 93b51a3f2b608b7478fe0c2d5b0696a8, type: 3} + - time: 0.33333334 + value: {fileID: -99956278, guid: 93b51a3f2b608b7478fe0c2d5b0696a8, type: 3} + - time: 0.41666666 + value: {fileID: -1010177793, guid: 93b51a3f2b608b7478fe0c2d5b0696a8, type: 3} + - time: 0.5 + value: {fileID: 844625333, guid: 93b51a3f2b608b7478fe0c2d5b0696a8, type: 3} + attribute: m_Sprite + path: + classID: 212 + script: {fileID: 0} + m_SampleRate: 12 m_WrapMode: 0 m_Bounds: m_Center: {x: 0, y: 0, z: 0} m_Extent: {x: 0, y: 0, z: 0} m_ClipBindingConstant: - genericBindings: [] - pptrCurveMapping: [] + genericBindings: + - serializedVersion: 2 + path: 0 + attribute: 0 + script: {fileID: 0} + typeID: 212 + customType: 23 + isPPtrCurve: 1 + pptrCurveMapping: + - {fileID: -19692615, guid: 93b51a3f2b608b7478fe0c2d5b0696a8, type: 3} + - {fileID: -1152038991, guid: 93b51a3f2b608b7478fe0c2d5b0696a8, type: 3} + - {fileID: 229421652, guid: 93b51a3f2b608b7478fe0c2d5b0696a8, type: 3} + - {fileID: -556319578, guid: 93b51a3f2b608b7478fe0c2d5b0696a8, type: 3} + - {fileID: -99956278, guid: 93b51a3f2b608b7478fe0c2d5b0696a8, type: 3} + - {fileID: -1010177793, guid: 93b51a3f2b608b7478fe0c2d5b0696a8, type: 3} + - {fileID: 844625333, guid: 93b51a3f2b608b7478fe0c2d5b0696a8, type: 3} m_AnimationClipSettings: serializedVersion: 2 m_AdditiveReferencePoseClip: {fileID: 0} m_AdditiveReferencePoseTime: 0 m_StartTime: 0 - m_StopTime: 1 + m_StopTime: 0.5833333 m_OrientationOffsetY: 0 m_Level: 0 m_CycleOffset: 0