Exemplo n.º 1
0
 public void Update(UpdateContext updateContext)
 {
     foreach (ParticleEffect particleEffect in _particleEffectsByKey.Values)
     {
         particleEffect.Update(updateContext);
     }
 }
        public sealed override void Update(UpdateContext updateContext)
        {
            long currentMemory = GC.GetTotalMemory(false);
            _elapsedTime += TimeSpan.FromTicks(updateContext.GameTime.DeltaTicks);
            if (_elapsedTime > DebugInformationComponent.UpdateFrequency)
            {
                _elapsedTime -= DebugInformationComponent.UpdateFrequency;
                _frameRate = _frameCounter;
                _frameCounter = 0;

                this.FPS = (int)(_frameRate / UpdateFrequency.TotalSeconds);

                // Memory
                int newKilobytesPerSecond = (int)((currentMemory - _previousKilobytes) / DebugInformationComponent.UpdateFrequency.TotalSeconds / 1024);
                if (newKilobytesPerSecond >= 0)
                {
                    _newKilobytesPerSecond = newKilobytesPerSecond;
                }
                _previousKilobytes = currentMemory;
            }

            // GC
            if (currentMemory < _previousMemory)
            {
                _garbageCollections++;
            }
            _previousMemory = currentMemory;
        }
Exemplo n.º 3
0
 public void Update(UpdateContext updateContext)
 {
     if (_enabled && this.Initialized)
     {
         this.UpdateInner(updateContext);
     }
 }
Exemplo n.º 4
0
 public override void Update(UpdateContext updateContext)
 {
     if (updateContext.InputState.IsNewKeyPress(_screenshotKey) && !string.IsNullOrEmpty(_folderPath) && Directory.Exists(_folderPath))
     {
         _takeScreenshot = true;
     }
 }
Exemplo n.º 5
0
 protected override void UpdateInner(UpdateContext updateContext)
 {
     if (_adManager != null)
     {
         _adManager.Update(((IXnaGameTimeProvider)updateContext).GameTime);
     }
 }
 protected override sealed void Process(UpdateContext updateContext, ReadOnlyBag<Entity> entities)
 {
     for (int i = 0; i < entities.Count; i++)
     {
         this.Process(updateContext, entities[i]);
     }
 }
        public override void Process(UpdateContext updateContext, ref ParticleBuffer.Iterator iterator)
        {
            Vector3 deltaColorFirst = _medianColor - _initialColor;
            Vector3 deltaColorLast = _finalColor - _medianColor;
            Particle particle = iterator.First;

            do
            {
                if (particle.Age < _median)
                {
                    float ageMultiplier = particle.Age / _median;
                    particle.Color.X = _initialColor.X + deltaColorFirst.X * ageMultiplier;
                    particle.Color.Y = _initialColor.Y + deltaColorFirst.Y * ageMultiplier;
                    particle.Color.Z = _initialColor.Z + deltaColorFirst.Z * ageMultiplier;
                }
                else
                {
                    float ageMultiplier = (particle.Age - _median) / (1f - _median);
                    particle.Color.X = _medianColor.X + deltaColorLast.X * particle.Age;
                    particle.Color.Y = _medianColor.Y + deltaColorLast.Y * particle.Age;
                    particle.Color.Z = _medianColor.Z + deltaColorLast.Z * particle.Age;
                }

            } while (iterator.MoveNext(ref particle));
        }
Exemplo n.º 8
0
        public override void Update(UpdateContext updateContext)
        {
            base.Update(updateContext);
#if WINDOWS
            if (_area.Contains(updateContext.InputState.MousePosition) && updateContext.InputState.WasMouseButtonPressed(MouseButton.Left) && updateContext.InputState.IsMouseButtonReleased(MouseButton.Left))
            {
                this.OnClickInner();
            }
#elif WINDOWS_PHONE
            bool isTapped = false;

            // Use Tap-gesture if it is enabled
            if (TouchPanel.EnabledGestures.ContainsFlag(GestureType.Tap))
            {
                isTapped = updateContext.InputState.HasGesture(GestureType.Tap, base.Area.ToRectangle());
            }
            else if (updateContext.InputState.IsTouchAt(base.Area.ToRectangle(), TouchLocationState.Released))
            {
                isTapped = true;
            }

            if (isTapped)
            {
                this.OnClickInner();
            }
#endif
        }
Exemplo n.º 9
0
 protected override void Update(UpdateContext updateContext, bool otherScreenHasFocus, bool coveredByOtherScreen)
 {
     if (updateContext.InputState.IsNewKeyPress(_actionKey) && (_canDoActionMultipleTimes || !_hasDoneAction))
     {
         _action();
     }
 }
 public override void Process(UpdateContext updateContext, ref ParticleBuffer.Iterator iterator)
 {
     Particle particle = iterator.First;
     do
     {
         particle.Rotation = FlaiMath.GetAngle(particle.Velocity);
     } while (iterator.MoveNext(ref particle));
 }
 protected override void Update(UpdateContext updateContext)
 {
     int toProcess = FlaiMath.Min(_maxEntitiesToProcess, _entities.Count);
     for (int i = 0; i < toProcess; i++)
     {
         this.Process(updateContext, _entities.Dequeue());
     }
 }
 internal override void ExecuteModifiers(UpdateContext updateContext, ParticleModifierCollection modifiers, ref ParticleBuffer.Iterator iterator)
 {
     foreach (ParticleModifier modifier in modifiers)
     {
         modifier.Process(updateContext, ref iterator);
         iterator.Reset();
     }
 }
Exemplo n.º 13
0
 protected internal override void PostUpdate(UpdateContext updateContext)
 {
     this.TimeRemaining -= updateContext.DeltaSeconds;
     if (this.TimeRemaining <= 0)
     {
         this.Entity.Delete();
     }
 }
Exemplo n.º 14
0
 public override void Update(UpdateContext updateContext)
 {
     base.Update(updateContext);
     if (_needsToUpdateArea)
     {
         this.UpdateArea();
     }
 }
 protected sealed override void Process(UpdateContext updateContext, ReadOnlyBag<Entity> entities)
 {
     _currentTime += TimeSpan.FromTicks(updateContext.GameTime.DeltaTicks);
     if (_currentTime >= _interval)
     {
         _currentTime -= _interval;
         this.ProcessInner(updateContext, entities);
     }
 }
Exemplo n.º 16
0
 internal void OnUpdate(UpdateContext updateContext)
 {
     if (this.IsEnabled)
     {
         this.BeginUpdate(updateContext);
         this.Update(updateContext);
         this.EndUpdate(updateContext);
     }
 }
Exemplo n.º 17
0
 protected sealed override void Update(UpdateContext updateContext)
 {
     if (this.ShouldProcess)
     {
         this.EntityWorld.EntityRefreshManager.BeginLock();
         this.Process(updateContext, _readOnlyEntities);
         this.EntityWorld.EntityRefreshManager.EndLock();
     }
 }
 internal override void ExecuteModifiers(UpdateContext updateContext, ParticleModifierCollection modifiers, ref ParticleBuffer.Iterator iterator)
 {
     ParticleBuffer.Iterator iter = iterator; // make sure that the iterator is always copied, so that all modifiers don't concurrently process the same iterator
     System.Threading.Tasks.Parallel.ForEach(modifiers, modifier =>
     {
         ParticleBuffer.Iterator iterInner = iter; // make sure that the iterator is always copied, so that all modifiers don't concurrently process the same iterator
         modifier.Process(updateContext, ref iterInner);
     });
 }
        public override void Process(UpdateContext updateContext, ref ParticleBuffer.Iterator iterator)
        {
            float scaleDelta = _finalScale - _initialScale;
            Particle particle = iterator.First;

            do
            {
                particle.Scale = _initialScale + scaleDelta * particle.Age;
            } while (iterator.MoveNext(ref particle));
        }
        public override void Process(UpdateContext updateContext, ref ParticleBuffer.Iterator iterator)
        {
            float opacityDelta = _finalOpacity - _initialOpacity;
            Particle particle = iterator.First;

            do
            {
                particle.Opacity = _initialOpacity + opacityDelta * particle.Age;
            } while (iterator.MoveNext(ref particle));
        }
Exemplo n.º 21
0
        public override void Process(UpdateContext updateContext, ref ParticleBuffer.Iterator iterator)
        {
            float hueChange = this.HueShiftAmount * updateContext.DeltaSeconds * FlaiMath.Pi / 180f;
            Matrix hueShiftMatrix = HueShifter.CreateHueTransformationMatrix(hueChange);

            Particle particle = iterator.First;
            do
            {
                HueShifter.Shift(ref particle.Color, ref hueShiftMatrix);
            } while (iterator.MoveNext(ref particle));
        }
        protected internal override void Update(UpdateContext updateContext)
        {
            _movement += Vector2.Distance(_previousPosition, _transform.Position);
            if (_movement >= _triggerDistance)
            {
                _movement -= _triggerDistance;
                this.ParticleEffect.Trigger(_transform);
            }

            _previousPosition = _transform.Position;
        }
        protected internal override void Update(UpdateContext updateContext)
        {
            Ensure.NotNull(_transform); // transform can't be null anymore when updating

            _timeUntilTrigger += updateContext.DeltaSeconds;
            if (_timeUntilTrigger >= _triggerPeriod)
            {
                _timeUntilTrigger -= _triggerPeriod;
                this.ParticleEffect.Trigger(_transform);
            }
        }
        public override void Process(UpdateContext updateContext, ref ParticleBuffer.Iterator iterator)
        {
            const float Multiplier = 200;
            float tempAttractionPower = this.AttractionPower * updateContext.DeltaSeconds * Multiplier;
            Particle particle = iterator.First;

            do
            {
                float distance = Vector2.Distance(this.AttractionPoint, particle.Position);
                particle.Velocity += (this.AttractionPoint - particle.Position) * tempAttractionPower / distance;
            } while (iterator.MoveNext(ref particle));
        }
        public override void Process(UpdateContext updateContext, ref ParticleBuffer.Iterator iterator)
        {
            Vector3 deltaColor = _finalColor - _initialColor;
            Particle particle = iterator.First;
            do
            {
                particle.Color.X = _initialColor.X + deltaColor.X * particle.Age;
                particle.Color.Y = _initialColor.Y + deltaColor.Y * particle.Age;
                particle.Color.Z = _initialColor.Z + deltaColor.Z * particle.Age;

            } while (iterator.MoveNext(ref particle));
        }
Exemplo n.º 26
0
        public override void Update(UpdateContext updateContext)
        {
            _elapsedTime += updateContext.GameTime.ElapsedGameTime;
            if (_elapsedTime > FpsComponent.UpdateFrequency)
            {
                _elapsedTime -= FpsComponent.UpdateFrequency;
                _frameRate = _frameCounter;
                _frameCounter = 0;

                _fps = (int)(_frameRate / FpsComponent.UpdateFrequency.TotalSeconds);
            }
        }
Exemplo n.º 27
0
 public void Update(UpdateContext updateContext)
 {
     // is cancelled here?
     if (!this.IsPaused)
     {
         this.TimeRemaining -= updateContext.DeltaSeconds;
         if (this.TimeRemaining < 0)
         {
             this.TimeRemaining = 0;
         }
     }
 }
Exemplo n.º 28
0
        protected sealed override void Update(UpdateContext updateContext, bool otherScreenHasFocus, bool coveredByOtherScreen)
        {
            base.Update(updateContext, otherScreenHasFocus, coveredByOtherScreen);

            if (_hasDrawn && !_hasLoaded)
            {
                this.PreloadAssets();
                LoadingScreen.Load(base.ScreenManager, false, _screensToLoad);
                _hasLoaded = true;

                GC.Collect();
                base.ScreenManager.Game.ResetElapsedTime();
            }
        }
Exemplo n.º 29
0
        public override void Process(UpdateContext updateContext, ref ParticleBuffer.Iterator iterator)
        {
            if (this.RotationRate <= float.Epsilon)
            {
                return;
            }

            float deltaRotation = this.RotationRate * updateContext.DeltaSeconds;
            Particle particle = iterator.First;
            do
            {
                particle.Rotation += deltaRotation;
            } while (iterator.MoveNext(ref particle));
        }
Exemplo n.º 30
0
        public override void Process(UpdateContext updateContext, ref ParticleBuffer.Iterator iterator)
        {
            float deltaStrength = this.Strength * updateContext.DeltaSeconds;
            if (deltaStrength == 0f || _direction == Vector2.Zero)
            {
                return;
            }

            Vector2 deltaGravity = _direction * deltaStrength;
            Particle particle = iterator.First;
            do
            {
                particle.Velocity += deltaGravity;
            } while (iterator.MoveNext(ref particle));
        }