diff --git a/MrBigsock/Assets/Code/Character.cs b/MrBigsock/Assets/Code/Character.cs index 186c7eb259eb85d101613466554d7e5d458d63e3..bf17da2bc2e33ea6d8908547dcd08a1a339e9908 100644 --- a/MrBigsock/Assets/Code/Character.cs +++ b/MrBigsock/Assets/Code/Character.cs @@ -166,6 +166,9 @@ namespace BigSock { Adds damage to the character if they don't have IFrames. */ public virtual bool TakeDamage(AttackStats attack) { + if(attack == null) throw new ArgumentNullException(nameof(attack)); + if(!attack.IsCalculated) throw new ArgumentException("Attack needs to be calculated.", nameof(attack)); + // Check if player has IFrames if(NextTimeCanTakeDamage > DateTime.Now) return false; @@ -243,7 +246,7 @@ namespace BigSock { Method for what to do when the character takes damage. */ protected virtual void AfterDamage(IAttackStats attack) { - print($"[Character.AfterDamage()] {HP + attack.Damage:N1} - {attack.Damage:N1} = {HP:N1}"); + print($"[Character.AfterDamage()] {HP + attack.Damage:N1} - {attack.Damage:N1} = {HP:N1} {(attack.IsCrit ? "[CRIT]":"")}"); KnockBack(attack); } diff --git a/MrBigsock/Assets/Code/Core/AttackStats.cs b/MrBigsock/Assets/Code/Core/AttackStats.cs index 74fd330d62c9e734baa79132991dfdec1723657a..2554ea7cdd493ce5d0b18df8fc2f329c23afe375 100644 --- a/MrBigsock/Assets/Code/Core/AttackStats.cs +++ b/MrBigsock/Assets/Code/Core/AttackStats.cs @@ -51,7 +51,7 @@ namespace BigSock { /* How much the damage can vary in percent. */ - public float DamageVariance { get; set; } = 0.2; + public float DamageVariance { get; set; } = 0.2f; @@ -83,21 +83,21 @@ namespace BigSock { (Takes crit and damage spread and calculates the final values) Cannot calculate a calculated attack. */ - public IAttackStats Calculate(ICharacterStats char = null) { + public IAttackStats Calculate(ICharacterStats charStats = null) { // Check that this attack hasn't been calculated already. if(IsCalculated) throw new InvalidOperationException("This attack has already been calculated!"); // Creates return object. AttackStats res; - if(char != null) res = (AttackStats) this.Apply(char); - else res = Clone(); + if(charStats != null) res = (AttackStats) this.Apply(charStats); + else res = Clone(); // Mark the calculated attack as calculated. res.IsCalculated = true; // Calculate damage variety. var mod = (1-DamageVariance) + RND.NextDouble() * DamageVariance * 2; - Damage *= mod; + Damage *= (float) mod; // Check for crits. if(RND.NextDouble() <= CritChance) { @@ -112,7 +112,7 @@ namespace BigSock { /* Creates a clone of this object. */ - public static AttackStats Clone() { + public AttackStats Clone() { return new AttackStats{ Damage = Damage, Knockback = Knockback, diff --git a/MrBigsock/Assets/Code/Core/IAttackStats.cs b/MrBigsock/Assets/Code/Core/IAttackStats.cs index c35a50e6934f50ed21f2e8b61eb79c7dcc03ace9..c6c493eb668c54361a90bb195f4e8312002fae8c 100644 --- a/MrBigsock/Assets/Code/Core/IAttackStats.cs +++ b/MrBigsock/Assets/Code/Core/IAttackStats.cs @@ -79,7 +79,7 @@ namespace BigSock { Calculates the final attack stats. (Takes crit and damage spread and calculates the final values) */ - IAttackStats Calculate(ICharacterStats char = null); + IAttackStats Calculate(ICharacterStats charStats = null); }