Skip to content
Snippets Groups Projects
Commit bc266f3e authored by Robin Halseth Sandvik's avatar Robin Halseth Sandvik
Browse files

Added support for invisibility status.

parent a4450dde
No related branches found
No related tags found
1 merge request!34Dodge
......@@ -180,7 +180,7 @@ namespace BigSock {
return false;
// Start new IFrames
SetIFrames(IFrameDuration);
AddIFrames(IFrameDuration);
// Trigger the event for taking damage.
OnTakeDamage?.Invoke(this, attack.Actor, attack);
......@@ -456,13 +456,36 @@ namespace BigSock {
public partial class Character {
/*
Indicates whether or not the characer is a live.
Indicates whether or not the characer is alive.
*/
public bool Alive { get; private set; } = true;
/*
How long between each time the character can take damage.
*/
public TimeSpan IFrameDuration {
get => _iFrameDuration;
private set => _iFrameDuration = value;
}
public TimeSpan _iFrameDuration = new TimeSpan(0, 0, 0, 0, 333);
/*
Is the character visible.
*/
public bool IsInvisible => NextTimeVisible > DateTime.Now;
/*
Stores the next time the character can recieve damage.
*/
public DateTime NextTimeVisible { get; private set; } = DateTime.Now;
/*
Indicates whether or not the characer is a live.
Is the character invincible.
*/
public bool HasIFrames => NextTimeCanTakeDamage > DateTime.Now;
......@@ -471,21 +494,60 @@ namespace BigSock {
*/
public DateTime NextTimeCanTakeDamage { get; private set; } = DateTime.Now;
/*
How long between each time the character can take damage.
Adds a status effect to the character.
*/
public TimeSpan IFrameDuration {
get => _iFrameDuration;
private set => _iFrameDuration = value;
public bool AddStatusEffect(StatusEffectType statusType, TimeSpan amount) {
switch(statusType) {
case StatusEffectType.Invincible: return AddIFrames(amount);
case StatusEffectType.Invisible: return AddInvisibility(amount);
default: return false;
}
}
/*
Adds invisibility for the character.
*/
public bool AddInvisibility(TimeSpan amount) {
// Get when the status effect would expire.
var wouldExpire = DateTime.Now + IFrameDuration;
// Only if that's later than current.
if(wouldExpire > NextTimeVisible) {
// If character currently doesn't have the status effect.
if(NextTimeVisible < DateTime.Now) {
ApplyInvisibility();
}
// Set new time.
NextTimeVisible = wouldExpire;
return true;
}
return false;
}
/*
Appies invisibility to the character.
*/
private void ApplyInvisibility() {
}
/*
Removes invisibility for the character.
*/
private void RemoveInvisibility() {
}
public TimeSpan _iFrameDuration = new TimeSpan(0, 0, 0, 0, 333);
/*
Sets IFrames for the character.
Adds IFrames for the character.
*/
public bool SetIFrames(TimeSpan amount) {
public bool AddIFrames(TimeSpan amount) {
// Get when the IFrames would expire.
var nextCanTakeDamage = DateTime.Now + IFrameDuration;
......@@ -502,7 +564,6 @@ namespace BigSock {
}
return false;
}
/*
Appies IFrames to the character.
*/
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment