예제 #1
0
 public void Break(string reason)
 {
     Broken?.Invoke(this, new BrokenArgs()
     {
         Reason = reason
     });
 }
예제 #2
0
 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);
     }
 }
예제 #3
0
        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);
            }
        }
예제 #4
0
 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());
 }
예제 #5
0
 public override void RecieveMoneyForInsurance(TimeSpan time)
 {
     lock (lockObj)
     {
         Thread.Sleep(time);
         Broken?.Invoke(this);
         StopWork();
     }
 }
예제 #6
0
 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);
     }
 }
예제 #7
0
 void OnBroken(Exception last, TimeSpan next)
 {
     Broken?.Invoke(this, new BrokenArgs {
         Last = last, Wait = next
     });
 }
예제 #8
0
 private void OnBroken()
 {
     Broken?.Invoke(this, EventArgs.Empty);
 }
예제 #9
0
 protected virtual void OnBroken()
 {
     Broken?.Invoke(this, EventArgs.Empty);
 }
예제 #10
0
 private void OnBreak()
 {
     status = ServerState.Failure.ToString();
     Broken?.Invoke(this, EventArgs.Empty);
 }