Created
November 8, 2019 03:55
-
-
Save Ellisande/65ef88db3eda553837cded9016b18f3a to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class Poison : DamageOverTime | |
{ | |
private Damage DamagePerTick; | |
private static float DEFAULT_DURATION = 10f; | |
private static float DEFAULT_PERIOD = 1f; | |
private static HashSet<DamageType> damageTypes = new HashSet<DamageType> { DamageType.DAMAGE_OVER_TIME, DamageType.POISON }; | |
public Poison(float damageAmountPerTick) : base(new Damage(damageTypes, damageAmountPerTick * (DEFAULT_DURATION / DEFAULT_PERIOD)), DEFAULT_PERIOD, DEFAULT_DURATION) | |
{ | |
DamagePerTick = new Damage(damageTypes, damageAmountPerTick * (DEFAULT_DURATION / DEFAULT_PERIOD)); | |
} | |
public Poison(float damageAmountPerTick, float timeRemaining) : this(damageAmountPerTick) | |
{ | |
this.timeRemaining = timeRemaining; | |
damageRemaining = DamagePerTick * TicksRemaining(); | |
elapsedTime = duration - timeRemaining; | |
} | |
public override Damage TickDamage => DamagePerTick; | |
public override DamageOverTime Add(DamageOverTime otherDot) | |
{ | |
if(!Matches(otherDot)) { | |
return this; | |
} | |
if(otherDot.TickDamage.Amount > TickDamage.Amount) | |
{ | |
return otherDot; | |
} | |
return this; | |
} | |
public override List<Attribute> GetAttributes() | |
{ | |
return new List<Attribute> { }; | |
} | |
public override bool Matches(DamageOverTime otherDot) | |
{ | |
return otherDot is Poison; | |
} | |
public override DamageOverTime Multiply(float damageScalar) | |
{ | |
return new Poison(DamagePerTick.Amount * damageScalar, timeRemaining); | |
} | |
public override Pair<Damage, DamageOverTime> Tick() | |
{ | |
float newTimeRemaining = timeRemaining - period; | |
if (newTimeRemaining <= 0) | |
{ | |
return new Pair<Damage, DamageOverTime>(Damage.zero(), Expired); | |
} | |
return Pair<Damage, DamageOverTime>.Of(DamagePerTick, new Poison(DamagePerTick.Amount, newTimeRemaining)); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment