Пример #1
0
 public WhileCondition(int totalIterations, DelegateBehavior behavior)
     : base(totalIterations, behavior)
 {
     if (behavior != DelegateBehavior.Success && behavior != DelegateBehavior.Faulted)
     {
         throw new ArgumentException("Unsupported behavior for while condition");
     }
 }
Пример #2
0
 public WhileBody(int maxExecutions, DelegateBehavior behavior)
 {
     MaxExecutions = maxExecutions;
     Behavior      = behavior;
     if (behavior == DelegateBehavior.Faulted || behavior == DelegateBehavior.SyncFaulted)
     {
         ExpectedException = new FormatException();
     }
 }
Пример #3
0
        protected override void OnTriggerEntered(Collider other)
        {
            var collector = other.GameObject.GetComponent <PointCollector>();

            if (collector != null)
            {
                collector.CollectPoint();
                if (!SoundEffect.ID.IsEmpty)
                {
                    _audio.PlaySound(_assetSystem.Database.LoadAsset(SoundEffect), Volume);
                }

                ParticleSystem particleSystem = GameObject.GetComponent <Engine.Graphics.ParticleSystem>();
                if (particleSystem != null)
                {
                    var effect = new ParticleVacuumEffect(
                        particleSystem,
                        collector.Transform,
                        _assetSystem.Database.LoadAsset(ParticleCollectionSoundEffect),
                        1.0f);
                    GameObject.AddComponent(effect);

                    PointLight pointLight = GameObject.GetComponent <PointLight>();
                    if (pointLight != null)
                    {
                        float            elapsed          = 0f;
                        const float      totalFadeTime    = 1.3f;
                        float            initialIntensity = pointLight.Intensity;
                        float            initialRange     = pointLight.Range;
                        DelegateBehavior lightFader       = new DelegateBehavior(deltaSeconds =>
                        {
                            elapsed += deltaSeconds;
                            if (elapsed > totalFadeTime)
                            {
                                return;
                            }

                            pointLight.Intensity = MathUtil.Lerp(initialIntensity, 0f, elapsed / totalFadeTime);
                            pointLight.Range     = MathUtil.Lerp(initialRange, initialRange * 3f, elapsed / totalFadeTime);
                        });
                        GameObject.AddComponent(lightFader);
                    }

                    particleSystem.EmissionRate     = 0f;
                    particleSystem.ParticleLifetime = 10f;
                    Enabled = false;
                }
                else
                {
                    GameObject.Destroy();
                }
            }
        }
Пример #4
0
        public void when_behavior_matches_invocation_then_it_is_called()
        {
            var mock = new TestMock();
            IInvocation invocation = null;

            var behavior = new DelegateBehavior(i => invocation = i);

            mock.Behaviors.Add(behavior);

            mock.Invoke(new TestInvocation(() => null));

            Assert.NotNull(invocation);
        }
Пример #5
0
        public void when_behavior_matches_invocation_then_it_is_called()
        {
            var         mock       = new TestMock();
            IInvocation invocation = null;

            var behavior = new DelegateBehavior(i => invocation = i);

            mock.Behaviors.Add(behavior);

            mock.Invoke(new TestInvocation(() => null));

            Assert.NotNull(invocation);
        }
Пример #6
0
            protected BaseWhileCondition(int totalIterations, DelegateBehavior behavior)
            {
                if (totalIterations < 0)
                {
                    throw new ArgumentOutOfRangeException("totalIterations");
                }

                TotalIterations = totalIterations;
                Behavior        = behavior;
                if (behavior == DelegateBehavior.Faulted || behavior == DelegateBehavior.SyncFaulted)
                {
                    ExpectedException = new ArithmeticException();
                }
            }
            protected BaseWhileCondition(int totalIterations, DelegateBehavior behavior)
            {
                if (totalIterations < 0)
                    throw new ArgumentOutOfRangeException("totalIterations");

                TotalIterations = totalIterations;
                Behavior = behavior;
                if (behavior == DelegateBehavior.Faulted || behavior == DelegateBehavior.SyncFaulted)
                    ExpectedException = new ArithmeticException();
            }
 public AsyncWhileCondition(int totalIterations, DelegateBehavior behavior)
     : base(totalIterations, behavior)
 {
 }
 public WhileCondition(int totalIterations, DelegateBehavior behavior)
     : base(totalIterations, behavior)
 {
     if (behavior != DelegateBehavior.Success && behavior != DelegateBehavior.Faulted)
         throw new ArgumentException("Unsupported behavior for while condition");
 }
 public WhileBody(int maxExecutions, DelegateBehavior behavior)
 {
     MaxExecutions = maxExecutions;
     Behavior = behavior;
     if (behavior == DelegateBehavior.Faulted || behavior == DelegateBehavior.SyncFaulted)
         ExpectedException = new FormatException();
 }
Пример #11
0
 public AsyncWhileCondition(int totalIterations, DelegateBehavior behavior)
     : base(totalIterations, behavior)
 {
 }