internal void Update(GameTime gameTime)
        {
            if (isClear)
            {
                return;
            }
            if (collectionsToUpdate.Count > 0)
            {
                CollectionUtils.Clear(collectionsToUpdate);
            }
            foreach (IGameComponent drawable  in  collections)
            {
                CollectionUtils.Add(collectionsToUpdate, drawable);
            }
            IGameComponent _drawable;
            int            screenIndex;

            for (; collectionsToUpdate.Count > 0;)
            {
                screenIndex = collectionsToUpdate.Count - 1;
                _drawable   = collectionsToUpdate[screenIndex];

                CollectionUtils.RemoveAt(collectionsToUpdate, screenIndex);

                if (_drawable is IUpdateable)
                {
                    IUpdateable comp = (IUpdateable)_drawable;
                    comp.Update(gameTime);
                }
            }
        }
Example #2
0
        /// <summary>
        /// Updates a single <see cref="IUpdateable"/>.
        /// </summary>
        protected virtual void Update(IUpdateable updateable, double elapsedGameTime)
        {
            #region Sanity checks
            if (updateable == null)
            {
                throw new ArgumentNullException(nameof(updateable));
            }
            #endregion

            updateable.Update(elapsedGameTime);
        }
 public override void Update(GameTime gameTime)
 {
     for (int i = 0; i < m_UpdateableComponents.Count; i++)
     {
         IUpdateable updatable = m_UpdateableComponents[i];
         if (updatable.Enabled)
         {
             updatable.Update(gameTime);
         }
     }
 }
Example #4
0
 protected virtual void Update(GameTime gameTime)
 {
     for (int i = 0; i < this._updateableComponents.Count; i++)
     {
         IUpdateable updateable = this._updateableComponents[i];
         if (updateable.Enabled)
         {
             updateable.Update(gameTime);
         }
     }
 }
Example #5
0
 /// <summary>
 /// Update all game components in this manager that impliment the IUpdateable interface and have their
 /// Enabled property set to true.
 /// </summary>
 /// <param name="gameTime">Snapshot of the game's time when update was started.</param>
 public virtual void Update(GameTime gameTime)
 {
     for (int i = 0; i < myUpdateableComponents.Count; i++)
     {
         IUpdateable uComponent = myUpdateableComponents[i];
         if (uComponent.Enabled)
         {
             uComponent.Update(gameTime);
         }
     }
 }
Example #6
0
        private void UpdateRestriction(float deltaTime)
        {
            _updateableRestriction?.Update(deltaTime);

            _restrictionInfo.DisplayRestriction(_restriction);
            RestrictionText.color = _restriction.Ignored ? restrictionDisabledColour : Color.white;

            if (_restriction.ViolatedRestriction())
            {
                RestrictionViolated?.Invoke();
            }
        }
        public void Update()
        {
            foreach (var updateablePresenter in _presentersInOrder)
            {
                updateablePresenter.PreModelUpdate();
            }

            _applicationModel.Update();

            foreach (var updateablePresenter in _presentersInOrder)
            {
                updateablePresenter.PostModelUpdate();
            }
        }
Example #8
0
        public override void Update(GameTime gameTime)
        {
            foreach (var comp in _components)
            {
                IUpdateable cell = comp as IUpdateable;

                if (cell != null)
                {
                    cell.Update(gameTime);
                }
            }

            base.Update(gameTime);
        }
Example #9
0
        protected virtual void Update(GameTime gameTime)
        {
            IntPtr fg = GetForegroundWindow();

            IsActive = fg.Equals(Window.Handle);

            for (int i = 0; i < this.updateableComponents.Count; i++)
            {
                IUpdateable updateable = this.updateableComponents[i];
                if (updateable.Enabled)
                {
                    updateable.Update(gameTime);
                }
            }
        }
Example #10
0
        /// <summary>
        /// Updates the internal state of the object based on game time.
        /// </summary>
        public override void Update(float elapsedTime)
        {
            if (State == AnimationState.Playing)
            {
                for (int i = 0; i < animations.Count; ++i)
                {
                    IUpdateable update = animations[i] as IUpdateable;
                    if (update != null)
                    {
                        update.Update(elapsedTime);
                    }
                }

                bool allStopped = true;

                if (KeyAnimation != null)
                {
                    allStopped = (KeyAnimation.State == AnimationState.Stopped);
                }
                else
                {
                    for (int i = 0; i < animations.Count; ++i)
                    {
                        if (animations[i].State != AnimationState.Stopped)
                        {
                            allStopped = false;
                        }
                    }
                }

                if (allStopped)
                {
                    repeatCounter++;
                    if (repeatCounter == Repeat)
                    {
                        OnCompleted();
                    }
                    else
                    {
                        for (int i = 0; i < animations.Count; ++i)
                        {
                            animations[i].OnStarted();
                        }
                        OnRepeated();
                    }
                }
            }
        }
Example #11
0
        private void UpdateLimit(float deltaTime)
        {
            _updateableLimit?.Update(deltaTime);

            Limit.text = _gameLimit.GetLimitText();

            if (!LevelManager.Instance.DailyChallenge)
            {
                LimitProgress.UpdateProgressBar(_gameLimit.PercentComplete());
            }

            if (_gameLimit.ReachedLimit())
            {
                LimitReached?.Invoke();
            }
        }
Example #12
0
        /// <summary>
        /// Updates a node and all its children.
        /// </summary>
        /// <param name="elapsedTime">Time elapsed since the last update.</param>
        /// <param name="node">Node which is to be updated.</param>
        private void UpdateNode(TimeSpan elapsedTime, Node node)
        {
            //Verify if the node is updateable.
            IUpdateable updateable = node as IUpdateable;

            //Only update the node and it's children if the node is enabled.
            if (updateable != null && updateable.Enabled)
            {
                //Update the node.
                updateable.Update(elapsedTime);

                foreach (Node n in node.Children)
                {
                    UpdateNode(elapsedTime, n);
                }
            }
        }
Example #13
0
        /// <inheritdoc />
        public virtual void Update(GameTime gameTime)
        {
            lock (_updateableComponent)
            {
                _currentlyUpdateableComponent.AddRange(_updateableComponent);
            }

            for (int i = 0; i < _currentlyUpdateableComponent.Count; i++)
            {
                IUpdateable updateable = _currentlyUpdateableComponent[i];
                if (updateable.Enabled)
                {
                    updateable.Update(gameTime);
                }
            }

            _currentlyUpdateableComponent.Clear();
        }
Example #14
0
        protected virtual void OnIsOpenChanged(bool pOldValue, bool pNewValue)
        {
            if (pNewValue)
            {
                this.RaiseRoutedEvent(OpenedEvent);

                IUpdateable lUpdateableContent = this.DropDownContent as IUpdateable;
                if (lUpdateableContent != null)
                {
                    lUpdateableContent.Update();
                }

                if (this.DropDownVisibilityDelay > 0.0)
                {
                    this.mVisibilityTimer.Start();
                }
            }
            else
            {
                this.mVisibilityTimer.Stop();
                this.RaiseRoutedEvent(ClosedEvent);
            }
        }
Example #15
0
        private void UpdateControllers(GameClock gameclock)
        {
            SychronizeSpeed();

            for (int i = 0; i < _controllers.Count; i++)
            {
                IUpdateable update = _controllers[i].Controller as IUpdateable;
                if (update != null)
                {
                    update.Update(gameclock);
                }
            }

            bool allStopped = true;

            if (_keyController != null)
            {
                allStopped = _keyController.State == AnimationState.Stopped;
            }
            else
            {
                for (int i = 0; i < _controllers.Count; i++)
                {
                    IAnimation animation = _controllers[i].Controller as IAnimation;
                    if (animation == null || animation.State != AnimationState.Stopped)
                    {
                        allStopped = false;
                    }
                }
            }

            if (allStopped)
            {
                Stop();
                OnCompleted();
            }
        }
Example #16
0
        /// <summary>
        /// Updates the internal state of the object based on game time.
        /// </summary>
        /// <param name="elapsedTime"></param>
        public override void Update(float elapsedTime)
        {
            if (State == AnimationState.Playing)
            {
                IUpdateable update = Current as IUpdateable;

                if (update != null)
                {
                    update.Update(elapsedTime);
                }

                if (Current != null && Current.State != AnimationState.Playing)
                {
                    currentIndex++;

                    if (CurrentIndex < Animations.Count)
                    {
                        Current.OnStarted();
                    }
                }

                if (CurrentIndex == Animations.Count)
                {
                    repeatCounter++;
                    if (repeatCounter == Repeat)
                    {
                        OnCompleted();
                    }
                    else
                    {
                        Seek(0);
                        OnRepeated();
                    }
                }
            }
        }
 private void Increase()
 {
     _strings.Insert(0, "New " + _count);
     _count++;
     _header.Update("HEADER - " + _count);
 }
Example #18
0
 /// <summary>Called when the component needs to update its state.</summary>
 /// <param name="gameTime">Provides a snapshot of the Game's timing values</param>
 public void Update(GameTime gameTime)
 {
     _updateableInputCapturer?.Update(gameTime);
     _updateableGuiVisualizer?.Update(gameTime);
 }
Example #19
0
 public void Execute()
 {
     _target.Update(_expression.Value);
 }
Example #20
0
        /// <summary>
        /// Updates the game's clock and calls Update and Draw.
        /// </summary>
        public void Tick()
        {
            // If this instance is existing, then don't make any further update/draw
            if (isExiting)
            {
                return;
            }

            // If this instance is not active, sleep for an inactive sleep time
            if (!IsActive)
            {
                SharpDX.Utilities.Sleep(InactiveSleepTime);
            }

            // Update the timer
            timer.Tick();

            var elapsedAdjustedTime = timer.ElapsedAdjustedTime;

            if (forceElapsedTimeToZero)
            {
                elapsedAdjustedTime    = TimeSpan.Zero;
                forceElapsedTimeToZero = false;
            }

            if (elapsedAdjustedTime > maximumElapsedTime)
            {
                elapsedAdjustedTime = maximumElapsedTime;
            }

            bool suppressNextDraw       = true;
            int  updateCount            = 1;
            var  singleFrameElapsedTime = elapsedAdjustedTime;

            if (IsFixedTimeStep)
            {
                // If the rounded TargetElapsedTime is equivalent to current ElapsedAdjustedTime
                // then make ElapsedAdjustedTime = TargetElapsedTime. We take the same internal rules as XNA
                if (Math.Abs(elapsedAdjustedTime.Ticks - TargetElapsedTime.Ticks) < (TargetElapsedTime.Ticks >> 6))
                {
                    elapsedAdjustedTime = TargetElapsedTime;
                }

                // Update the accumulated time
                accumulatedElapsedGameTime += elapsedAdjustedTime;

                // Calculate the number of update to issue
                updateCount = (int)(accumulatedElapsedGameTime.Ticks / TargetElapsedTime.Ticks);

                // If there is no need for update, then exit
                if (updateCount == 0)
                {
                    // check if we can sleep the thread to free CPU resources
                    var sleepTime = TargetElapsedTime - accumulatedElapsedGameTime;
                    if (sleepTime > TimeSpan.Zero)
                    {
                        SharpDX.Utilities.Sleep(sleepTime);
                    }
                    return;
                }

                // Calculate a moving average on updateCount
                lastUpdateCount[nextLastUpdateCountIndex] = updateCount;
                float updateCountMean = 0;
                for (int i = 0; i < lastUpdateCount.Length; i++)
                {
                    updateCountMean += lastUpdateCount[i];
                }

                updateCountMean         /= lastUpdateCount.Length;
                nextLastUpdateCountIndex = (nextLastUpdateCountIndex + 1) % lastUpdateCount.Length;

                // Test when we are running slowly
                drawRunningSlowly = updateCountMean > updateCountAverageSlowLimit;

                // We are going to call Update updateCount times, so we can subtract this from accumulated elapsed game time
                accumulatedElapsedGameTime = new TimeSpan(accumulatedElapsedGameTime.Ticks - (updateCount * TargetElapsedTime.Ticks));
                singleFrameElapsedTime     = TargetElapsedTime;
            }
            else
            {
                Array.Clear(lastUpdateCount, 0, lastUpdateCount.Length);
                nextLastUpdateCountIndex = 0;
                drawRunningSlowly        = false;
            }

            // Reset the time of the next frame
            for (lastFrameElapsedAppTime = TimeSpan.Zero; updateCount > 0 && !isExiting; updateCount--)
            {
                appTime.Update(totalTime, singleFrameElapsedTime, drawRunningSlowly);
                try
                {
                    updateCallback.Update(appTime);

                    // If there is no exception, then we can draw the frame
                    suppressNextDraw &= suppressDraw;
                    suppressDraw      = false;
                }
                finally
                {
                    lastFrameElapsedAppTime += singleFrameElapsedTime;
                    totalTime += singleFrameElapsedTime;
                }
            }

            if (!suppressNextDraw)
            {
                RenderFrame();
            }
        }