public ActiveEffect(float duration, Personage sender, Personage target = null) : base(false, sender, target) { nameId = 6; MaxCount = 0; HasTick = false; this.duration = duration; }
public void StopCast() { if (CurrentCastSpell != null) { CurrentCastSpell.Stop(); } CurrentCastSpell = null; castTarget = null; MaxCastTime = 0f; CurrentCastTime = 0f; }
public virtual bool Dispel(Personage helper) { if (NoLongerNeeded || !Dispellable || helper == null) { return(false); } if (helper.NoLongerNeeded || helper.IsDead) { return(false); } return(true); }
public virtual void Use(Personage sender = null) { if (Count > 0) { Count--; return; } if (Delay > 0) { delayTimer = 0f; } }
public Effect(bool isPassive, Personage sender, Personage target = null) { nameId = 5; iconID = 0; Timer = 0f; Count = 0; IsPassive = isPassive; Dispellable = true; NoLongerNeeded = false; CurrentCharacteristic = Characteristic.CreateEmpty(); Sender = sender; Target = target; }
public virtual void Use(Personage target = null) { }
private T[] find <T>(Personage sender) where T : Effect { return((from e in effects where e is T && e.Sender == sender select e as T).ToArray()); }
public bool IsFriendlyOf(Personage personage) { return(relationship == personage.relationship); }
public void Cast(Spell spell) { if (GlobalCoolDown != 0f) { onCast(CastResult.NoReady); return; } if (CurrentCastSpell != null || spell == null) { StopCast(); onCast(CastResult.NoSpell); return; } if (!spell.ReadyToUse() || NoLongerNeeded || isDead) { onCast(CastResult.NoReady); return; } if (spell.MinLevel > Level) { onCast(CastResult.LackOfLevel); return; } if (!spell.EnableCastInRun && !IsStopped) { onCast(CastResult.CanNotUseNow); return; } if (spell.MaxCount > 0 && spell.Count == 0) { onCast(CastResult.CanNotUseNow); return; } if (!spell.EnableCastInAir) { if (IsInAir()) { onCast(CastResult.CanNotUseNow); return; } } var takeAmount = spell.TakeResourcesAmount; if (spell.TakeResources != TypeOfResources.Nothing && spell.TakeResourcesAmount > 0) { switch (spell.TakeResources) { case TypeOfResources.Health: takeAmount *= level; if (takeAmount > currentHealth) { onCast(CastResult.LackOfHealth, TypeOfResources.Health); return; } break; case TypeOfResources.Mana: takeAmount *= level; if (takeAmount > currentMana) { onCast(CastResult.LackOfMana, TypeOfResources.Mana); return; } break; case TypeOfResources.Energy: if (spell.TakeResourcesAmount > currentEnergy) { onCast(CastResult.LackOfEnergy, TypeOfResources.Energy); return; } break; } } if (IsTargetItYourself()) { if (spell.Mode != ModeOfCast.OnlySender) { onCast(CastResult.ForbiddenTarget); return; } if (spell.CastOnlyInSpine) { onCast(CastResult.CanNotUseNow); return; } } else { if (Target.NoLongerNeeded) { onCast(CastResult.CanNotUseNow); return; } if (!spell.EnableCastInDeadTarget && Target.isDead) { onCast(CastResult.CanNotUseNow); return; } if (!IsTurnedFaceTo(Target)) { onCast(CastResult.CanNotUseNow); return; } if (spell.CastOnlyInSpine && Target.IsTurnedFaceTo(this)) { onCast(CastResult.CanNotUseNow); return; } switch (spell.Mode) { case ModeOfCast.OnlyFriendly: if (!IsFriendlyOf(Target)) { onCast(CastResult.ForbiddenTarget); return; } break; case ModeOfCast.OnlyNotFriendly: if (IsFriendlyOf(Target)) { onCast(CastResult.ForbiddenTarget); return; } break; case ModeOfCast.OnlySender: onCast(CastResult.ForbiddenTarget); return; } var distance = DistanceTo(Target); if (spell.MinRange > distance || distance > spell.MaxRange) { onCast(CastResult.OutRange); return; } if (!IsFreeDistanceTo(Target)) { onCast(CastResult.CanNotUseNow); return; } } if (spell.Type != TypeOfSpell.Reproduction) { AddDamage(spell.TakeResources, takeAmount); GlobalCoolDown = 1f; spell.Use(this); } onCast(CastResult.Done); if (spell.Type == TypeOfSpell.Instant) { StopCast(); return; } castTarget = Target; CurrentCastTime = 0f; MaxCastTime = spell.CastTime; CurrentCastSpell = spell; }