private void AddMissleMoverSubscriptions() { _missleMover.MisslesCollided += (mFirst, mSecond, e) => Debug.WriteLine("Collision!"); _missleMover.MisslesCollided += (missle, collision, e) => { var healing = missle as HealingMissle; if (healing == null) return; var block = collision as WallBlock; if (block == null) return; block.ChangeHitpoints(w => w.HitPoints + healing.Healing, (w) => Debug.WriteLine("Could not heal")); healing.Collide(block); }; _missleMover.MisslesCollided += (mFirst, mSecond, e) => { if (mFirst.IsDestroyed || mSecond.IsDestroyed) return; mFirst.Collide(mSecond); mSecond.Collide(mFirst); }; _missleMover.MisslesCollided += delegate (Missle first, ICollidable second, EventArgs e) { var otherMissle = second as Missle; if (otherMissle == null || _wasBrokenIntoPieces.Contains(first) || _wasBrokenIntoPieces.Contains(second)) { _wasBrokenIntoPieces.Remove(first); _wasBrokenIntoPieces.Remove(otherMissle); return; } Missle m1 = new Missle(first.CastedSpell, first.Position, new Vector2D(1, 1), TimeHelper.GetCurrentTime()); Missle m2 = new Missle(first.CastedSpell, first.Position, new Vector2D(-1, -1), TimeHelper.GetCurrentTime()); Missle m3 = new Missle(otherMissle.CastedSpell, first.Position, new Vector2D(1, -1), TimeHelper.GetCurrentTime()); Missle m4 = new Missle(otherMissle.CastedSpell, first.Position, new Vector2D(-1, 1), TimeHelper.GetCurrentTime()); _missleMover.AddMissle(m1); _missleMover.AddMissle(m2); _missleMover.AddMissle(m3); _missleMover.AddMissle(m4); _wasBrokenIntoPieces.AddRange(new [] {m1, m2, m3, m4}); }; }
public Missle(Missle copyMissle) { if (copyMissle == null) throw new ArgumentNullException(); CastedSpell = copyMissle.CastedSpell; Position = copyMissle.Position; Direction = copyMissle.Direction; _timeCasted = copyMissle._timeCasted; }
public SpinningMissle(Missle copyMissle) : base(copyMissle) { _spinningMissleState = SpinningMissleState.None; }
public HealingMissle(Missle copyMissle, int healing) : base(copyMissle) { Healing = healing; }
protected virtual void OnSpellCasted(ICastable sender, Missle missle) { SpellCasted?.Invoke(sender, new SpellCastedEventArgs {Missle = missle}); }
public void AddMissle(Missle missle) { _missles.Add(missle); }
private void RemoveMissle(Missle missle) { _missles.Remove(missle); }
private bool RemoveIfDestroyed(Missle missle) { if (missle.IsDestroyed) { RemoveMissle(missle); return true; } return false; }