public void Activate(IAffectable caster, params GridSpace[] space) { Activate(new SpellCastInfo(caster) { TargetSpaces = space }); }
public void Activate(IAffectable caster, params IAffectable[] targets) { Activate(new SpellCastInfo(caster) { TargetObjects = targets }); }
private void OnCollisionEnter(Collision other) { Vector3 contactPoint = other.GetContact(0).point; // Approximate the time of the collision, // taking in account the possibility of currently being faster due to catching up float timeOfCollision = lastTime + (lastPosition - _rigidbody.position).magnitude / lastVelocity.magnitude; if (timeOfCollision > _deathTime) { Kill(DeathCause.Timeout, _deathTime); return; } IAffectable affectable = other.collider.GetComponent <IAffectable>(); if (affectable != null) { affectable.Apply(_effect, timeOfCollision, -other.relativeVelocity, contactPoint); Kill(DeathCause.Contact, timeOfCollision); } else if (_bounces > 0) { _bounces--; if (_bounces == 0) { SetBouncyness(false); } AddPositionToRenderer(contactPoint); } else { Kill(DeathCause.Contact, timeOfCollision); } }
public SpellCastInfo(List <SpellAspect> aspects) { int numLoc = 0; int numObj = 0; aspects.ForEach(aspect => { if (aspect.Targeter.Style == TargetingStyle.TargetLocation) { numLoc = Math.Max(numLoc, aspect.Targeter.MaxTargets); } if (aspect.Targeter.Style == TargetingStyle.TargetObject) { numObj = Math.Max(numObj, aspect.Targeter.MaxTargets); } }); // GridSpace targets overlap with objects numLoc -= numObj; if (numLoc < 0) { numLoc = 0; } _targetSpaces = new GridSpace[numLoc]; _targetObjects = new IAffectable[numObj]; }
public EffectInstance NewInstance(IAffectable caster, IAffectable target = null) { EffectInstance instance = this.Copy <EffectInstance>(); instance.IsActive = true; instance.target = target; instance.caster = caster; instance.initialize(); return(instance); }
public void Target(IAffectable target) { if (spellTargets.Contains(target)) { RemoveTarget(target); } else { AddTarget(target); } }
internal void RemoveTarget(IAffectable target) { spellTargets.Remove(target); if (target is NPC) { foreach (GameObject block in ((NPC)target).GridSpace.Blocks) { block.renderer.sharedMaterial = NormalShaderGridspace; } } }
internal void AddTarget(IAffectable target) { spellTargets.Add(target); if (target is NPC) { foreach (GameObject block in ((NPC)target).GridSpace.Blocks) { block.renderer.sharedMaterial = GlowShaderGridSpace; } } }
private void Leave(IAffectable interactor) { if (this._affectables.TryGetValue(interactor, out int effectID)) { this.Leave(interactor, effectID); } else { // never supposed to happen. Debug.LogError($"{this.name}: was left by an unknown interactor {interactor.name}."); } }
public virtual void ApplyEffect(IAffectable caster, EffectInstance effect) { if (effect.TurnsToProcess != 0) { if (ContainsKey(effect.Name)) { this[effect.Name] = this[effect.Name].Merge(effect); } else { this.Add(effect.Name, effect.ActivateOnObject(caster, owner)); } } else { effect.ActivateOnObject(caster, owner); } }
private void OnCollisionEnter2D(Collision2D collision) { Bomb bomb = collision.collider.GetComponent <Bomb>(); if (bomb != null) { Collider2D[] colliders = Physics2D.OverlapCircleAll(transform.position, radius); for (int i = 0; i < colliders.Length; i++) { IAffectable affectable = colliders[i].GetComponent <IAffectable>(); if (affectable != null) { affectable.OnActivate(); } } } }
public virtual void Remove(IAffectable o) { }
public virtual void Init(IAffectable target) { }
public virtual void Apply(IAffectable target) { }
public SpellCastInfo GetCastInfoPrototype(IAffectable caster) { return(new SpellCastInfo(caster, CastInfo)); }
public EffectInstance ActivateOnObject(IAffectable caster, IAffectable o) { EffectInstance instance = NewInstance(caster, o); return(instance); }
public static void BindTo(this IAffectable target, IAffector affector) { target.BindAffectorPose = Matrix.Invert(affector.GlobalPose); target.Affector = affector; affector.Affectable = target; }
public AppliedEffects(IAffectable owner) { this.owner = owner; }
public static void UnBindFrom(this IAffectable target, IAffector affector) { target.BindAffectorPose = Matrix.Identity; target.Affector = null; affector.Affectable = null; }
public SpellCastInfo(IAffectable caster) { Caster = caster; }
//public void ApplyEffect(EffectInstance effect) //{ // Effects.ApplyEffect(effect); //} public void ApplyEffect(IAffectable caster, EffectInstance effect) { Effects.ApplyEffect(caster, effect); }
public SpellCastInfo(IAffectable caster, SpellCastInfo rhs) { Caster = caster; _targetSpaces = new GridSpace[rhs.TargetSpaces.Length]; _targetObjects = new IAffectable[rhs.TargetObjects.Length]; }
private void Leave(IAffectable interactor, int effectID) { interactor.CancelCanTrigger(effectID); this._affectables.Remove(interactor); }
public void Activate(IAffectable caster) { Activate(new SpellCastInfo(caster)); }
/// <summary> /// Extension for <see cref="IAffectable.AffectBy"/> /// </summary> public static void Affect <TEffect>(this TEffect effect, IAffectable <TEffect> affectable) where TEffect : Effect { affectable.AffectBy(effect); }