public void Break(string reason) { Broken?.Invoke(this, new BrokenArgs() { Reason = reason }); }
public void StartWork() { _isWorking = true; while (_isWorking) { if (_rnd.NextDouble() <= _crashProbability && !IsBroken) { IsBroken = true; Broken?.Invoke(this); _hpTimer = new Timer(TimeSpan.FromSeconds(HP).TotalMilliseconds); _hpTimer.Elapsed += (o, e) => { Destroyed?.Invoke(this); StopWork(); _hpTimer?.Stop(); }; _hpTimer.Start(); return; } if (!IsBroken && Store.CurrentVolume < Store.Capacity) { Store.AddIron(1); } Thread.Sleep(1000); } }
public void StartWork() { IsWorking = true; while (IsWorking) { Y += 2; if (_rnd.NextDouble() <= _brokeChance && !IsBroken && !IsRodsDisconnect) { IsBroken = true; Broken?.Invoke(this); _liveTimer = new Timer(TimeSpan.FromSeconds(TimeToDistraction).TotalMilliseconds); _liveTimer.Elapsed += (o, e) => { Dead?.Invoke(this); StopWork(); _liveTimer?.Stop(); }; _liveTimer.Start(); return; } if (_rnd.NextDouble() <= _rodDisconnectChance && !IsRodsDisconnect && !IsBroken) { IsBroken = true; RodsDisconnect?.Invoke(this); return; } Thread.Sleep(200); } }
public void OnBreak() { if (destroyedClip != null) { audioSourceMultichannel.GetChannel().PlayOneShot(destroyedClip); } isPlaced = true; Placed?.Invoke(false, transform.position); rigidbody2D.mass = 10; snapOpen = false; sprite.enabled = false; breakingSprite.enabled = false; brokenSprite.enabled = true; highlightSprite.enabled = false; isHeld = false; placedTrigger.active = false; placedTrigger.pickableObject = null; placedTrigger.canBePlaced = false; brokeEffect.SetActive(true); brokeEffect.GetComponent <ParticleSystem>().Play(); health = 0; Fallen?.Invoke(); Broken?.Invoke(); pickableTrigger.enabled = false; StartCoroutine(FadingOutBroken()); }
public override void RecieveMoneyForInsurance(TimeSpan time) { lock (lockObj) { Thread.Sleep(time); Broken?.Invoke(this); StopWork(); } }
public void StartWork() { IsWorking = true; while (IsWorking) { Y -= 10; if (Y <= 100) { Succeed?.Invoke(this); SignalizeAboutSuccess(TimeSpan.FromSeconds(3)); return; } if (_rnd.NextDouble() <= _brokeChance && !IsBroken) { IsBroken = true; Broken?.Invoke(this); return; } Thread.Sleep(200); } }
void OnBroken(Exception last, TimeSpan next) { Broken?.Invoke(this, new BrokenArgs { Last = last, Wait = next }); }
private void OnBroken() { Broken?.Invoke(this, EventArgs.Empty); }
protected virtual void OnBroken() { Broken?.Invoke(this, EventArgs.Empty); }
private void OnBreak() { status = ServerState.Failure.ToString(); Broken?.Invoke(this, EventArgs.Empty); }