diff --git a/MrBigsock/Assets/Code/Character.cs b/MrBigsock/Assets/Code/Character.cs index 673cc3bd9eeb3fb4abc4f9ee56b3f5827d17834a..b2836dc80000b67eb03adbd89c56567c7168b38f 100644 --- a/MrBigsock/Assets/Code/Character.cs +++ b/MrBigsock/Assets/Code/Character.cs @@ -471,6 +471,17 @@ namespace BigSock { + /* + Is the character stunned. + */ + public bool IsStunned => NextTimeNotStunned > DateTime.Now; + + /* + Stores the next time the character can isn't stunned. + */ + public DateTime NextTimeNotStunned { get; private set; } = DateTime.Now; + + /* Is the character visible. @@ -503,12 +514,48 @@ namespace BigSock { switch(statusType) { case StatusEffectType.Invincible: return AddIFrames(amount); case StatusEffectType.Invisible: return AddInvisibility(amount); + case StatusEffectType.Stun: return AddStun(amount); default: return false; } } + /* + Adds Stun for the character. + */ + public bool AddStun(TimeSpan amount) { + // Get when the status effect would expire. + var wouldExpire = DateTime.Now + IFrameDuration; + + // Only if that's later than current. + if(wouldExpire > NextTimeNotStunned) { + // If character currently doesn't have the status effect. + if(NextTimeNotStunned < DateTime.Now) { + ApplyStun(); + } + + // Set new time. + NextTimeNotStunned = wouldExpire; + return true; + } + return false; + } + /* + Appies Stun to the character. + */ + private void ApplyStun() { + + } + /* + Removes Stun for the character. + */ + private void RemoveStun() { + + } + + + /* Adds invisibility for the character. */