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); } } }
/// <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); } } }
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); } } }
/// <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); } } }
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(); } }
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); }
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); } } }
/// <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(); } } } }
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(); } }
/// <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); } } }
/// <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(); }
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); } }
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(); } }
/// <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); }
/// <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); }
public void Execute() { _target.Update(_expression.Value); }
/// <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(); } }