public static void BurnIfTouchingSomethingHot <T>(T me, TimeSpan?burnTime = null, char?symbol = null, bool disposeOnBurn = false) where T : SpacialElement { burnTime = burnTime.HasValue ? burnTime.Value : TimeSpan.FromSeconds(3); if (SpaceTime.CurrentSpaceTime.Elements.Where(e => e.HasSimpleTag("hot") && e.CalculateDistanceTo(me) < 2).Any()) { if (SpaceTime.CurrentSpaceTime.Elements.WhereAs <Fire>().Where(f => f.Left == me.Left && f.Top == me.Top).Count() == 0) { var fire = new Fire(burnTime.Value) { SymbolOverride = symbol }; fire.MoveTo(me.Left, me.Top, me.ZIndex + 1); fire.ResizeTo(me.Width, me.Height); SpaceTime.CurrentSpaceTime.Add(fire); if (disposeOnBurn) { me.Lifetime.Dispose(); } } } }
private void Evaluate() { if (Time.CurrentTime.Now - initialTime > TimeSpan.FromSeconds(5)) { foreach (var matter in Composite) { matter.Lifetime.Dispose(); } } else { Fire.BurnIfTouchingSomethingHot(this); var distance = this.CalculateDistanceTo(initialBonds); if (distance > 10) { foreach (var matter in Composite) { matter.Speed.Stop(); } } } }
public override void Evaluate() { Fire.BurnIfTouchingSomethingHot(this, TimeSpan.FromSeconds(.1), this.Symbol.Value); }
private void Evaluate() { Fire.BurnIfTouchingSomethingHot(this, TimeSpan.FromSeconds(4), this.Symbol.Value, true); }