예제 #1
0
 /// <summary>
 /// Consumes the effect.
 /// </summary>
 /// <param name="effectManager">Effect manager to apply the effect to.</param>
 void ConsumeEffect(EffectManager effectManager)
 {
     effectManager.ApplyEffect(_effect);
     Destroy(gameObject);
     OnConsumed?.Invoke(this, new System.EventArgs());
     Debug.Log(string.Format("effect {0} applied to {1}", _effect, effectManager));
 }
예제 #2
0
        public void Consume()
        {
            if (consumed)
            {
                return;
            }

            consumed = true;
            OnConsumed?.Invoke(this);
        }
예제 #3
0
 internal void ConsumeSoul()
 {
     _isEscaping = false;
     OnConsumed?.Invoke(this, EventArgs.Empty);
     print("Soul consumed!");
     _rigidbody.velocity = Vector2.zero;
     KillCount++;
     print("adding " + _baseReward * KillCount);
     InventoryManager.Instance.AddSoulFragments(_currentReward);
     this.enabled = false;
 }
예제 #4
0
        private void ThreadExecutionHandler(object obj)
        {
            var cr = obj as ConsumeResult <string, string>;

            var timeWatch = new Stopwatch();

            timeWatch.Start();

            var data = cr.Message.Value;

            var base64String = DecryptEncodedData(data);
            var values       = base64String.Split("#".ToCharArray());
            var actualData   = Convert.FromBase64String(values[0]);// Convert.FromBase64String(base64String);
            var producedTime = long.Parse(values[1]);

            var stopWatch = new Stopwatch();

            stopWatch.Start();
            while (stopWatch.ElapsedMilliseconds < 80)
            {
                // Simulate heavy load.
                continue;
            }
            stopWatch.Stop();
            timeWatch.Stop();
            var elapsedMilli = timeWatch.ElapsedMilliseconds;

            lock (lockObject)
            {
                totalEllapsed += elapsedMilli;
                totalMessages++;
                if (elapsedMilli > maxDelay)
                {
                    maxDelay = elapsedMilli;
                    Console.WriteLine($"Maximum delay now - {maxDelay}");
                }
            }

            if (string.Equals(base64String, "LS0tU3RhcnQgb2YgVGVzdC0tLQ=="))
            {
                statisticsStartTime = DateTime.Now;
                isTestingInProgress = true;
            }
            else if (string.Equals(base64String, "LS0tRW5kIG9mIFRlc3QtLS0="))
            {
                statisticsEndTime   = DateTime.Now;
                isTestingInProgress = false;
            }
            if (elapsedMilli >= maxDelayThreshold)
            {
                // Console.WriteLine("Total time spent in handler - {0}ms", elapsedMilli); // Only print if elapsed is > 50ms
                lock (lockObject)
                {
                    totalMessageAboveThreshold++;
                }
            }

            if (producedTime != cr.Message.Timestamp.UtcDateTime.ToFileTimeUtc())
            {
                Console.WriteLine($"Difference found in timestamp produced and consumed. Produced at {producedTime}, as per consumer produced time {cr.Message.Timestamp.UtcDateTime.ToFileTimeUtc()}");
            }

            OnConsumed?.Invoke(cr, this);
        }
예제 #5
0
파일: Food.cs 프로젝트: Pinkolik/Aquarium
 public void Consume()
 {
     OnConsumed?.Invoke(this, EventArgs.Empty);
 }