public Matches() { _gameTime = new GameTime(); _matchManager = new MatchManager(); _updateLoop = new HighFrequencyTimer(GlobalConfiguration.UPDATE_INTERVAL, id => Update(id)); _updateLoop.Start(); }
public void Update(GameTime gameTime) { if (State == MatchState.Playing) { Game.Update(gameTime); } }
public void Update(GameTime gameTime) { var velocityZero = _owner.MovementController.Velocity.IsZero(); if (_deathStartedAt.HasValue && gameTime.Now - _deathStartedAt >= DEATH_AFTER && velocityZero) { // We've died _owner.Die(_killedBy); } else if (!velocityZero) { _deathStartedAt = null; _killedBy = null; } }
public void Update(GameTime gameTime) { PendingMovement pendingMovement; _pendingMovements.TryPeek(out pendingMovement); if (_pendingMovements.Count > 0 && pendingMovement.ReadyToMove(_owner)) { PendingMovement currentMovement; _pendingMovements.TryDequeue(out currentMovement); applyMovement(currentMovement); // If there's another movement in the queue if (_pendingMovements.Count > 0) { PendingMovement nextMovement; _pendingMovements.TryPeek(out nextMovement); nextMovement.StartLocation = _owner.MovementController.Position; nextMovement.CurrentMapLocation = _owner.MovementController.HeadLocation; } } }
public void Update(GameTime gameTime) { List<long> keysToRemove = new List<long>(_matches.Count); Parallel.ForEach(_matches, match => { if (match.Value.State != MatchState.Completed) { match.Value.Update(gameTime); } else // Match completed { keysToRemove.Add(match.Key); } }); for (int i = keysToRemove.Count - 1; i >= 0; i--) { Match garbage; _matches.TryRemove(keysToRemove[i], out garbage); garbage.Dispose(); } }
public void Update(GameTime gameTime) { _cycleManager.Update(gameTime); _map.Update(gameTime); }
public virtual void Update(GameTime gameTime) { }
public void Update(GameTime gameTime) { foreach (var cycle in _cycles.Values) { // If the cycle is Colliding then the position hasn't changed and we've already dealt with it if (!cycle.Colliding) { Debug.WriteLine("Cycle at: " + cycle.MovementController.HeadLocation + " is requesting to be at " + Utilities.ToMapLocation(cycle.MovementController.RequestedPosition, cycle.MovementController.Velocity) + " | " + cycle.MovementController.Position + " => " + cycle.MovementController.RequestedPosition); // Validate the requested position on the cycle, updates the cycles position _requestValidator.ValidateRequestedPosition(cycle); _collisionChecker.ValidateCollision(cycle); Debug.WriteLine("Cycle now at: " + Utilities.ToMapLocation(cycle.MovementController) + " | " + cycle.MovementController.Position); var newLocation = Utilities.ToMapLocation(cycle.MovementController); // If our current location is colliding then we need our MovementController.HeadLocation to be just before the // collision location mark. if (cycle.Colliding) { Debug.Write("Cycle was colliding at: " + Utilities.ToMapLocation(cycle.MovementController) + " and new location is " + newLocation); var difference = cycle.MovementController.HeadLocation - newLocation; var incrementor = difference.Normalized().Abs(); Debug.WriteLine(" and incrementor = " + incrementor); // If the requested location is going in the negative direction then we need our incrementor // to also be pointing in the negative direction. if (difference > 0) { incrementor *= -1; } newLocation -= incrementor; } Debug.Write("Checking if cycles head location " + cycle.MovementController.HeadLocation + " differs from " + newLocation + " = "); // We only need to perform markings if we've moved from our location if (!cycle.MovementController.HeadLocation.SameAs(newLocation)) { Debug.WriteLine("TRUE"); var distance = cycle.MovementController.HeadLocation - newLocation; // used by mark location to bool inclusive = true; if (cycle.Colliding) { // If we're 1 away from the head location while colliding, no need to mark anything, just noop if (distance.NonZeroValue() == 1) { this[cycle.MovementController.HeadLocation] = cycle.ID; this[newLocation] = -cycle.ID; cycle.MovementController.HeadLocation = newLocation; continue; } inclusive = false; } // Fills in any unmarked spots between the last head location and the current new location _mapMarker.MarkArea(cycle.MovementController.HeadLocation, newLocation, cycle.ID, inclusive); // Update the headlocation Debug.WriteLine("Marking old MovementController.HeadLocation: " + cycle.MovementController.HeadLocation + " as " + cycle.ID + " and new MovementController.HeadLocation: " + newLocation + " as " + -cycle.ID); this[cycle.MovementController.HeadLocation] = cycle.ID; this[newLocation] = -cycle.ID; cycle.MovementController.HeadLocation = newLocation; } else { Debug.WriteLine("FALSE"); } } } }
public override void Update(GameTime gameTime) { base.Update(gameTime); var incrementor = Velocity * gameTime.FractionOfSecond; RequestedPosition = Position + incrementor; }
public virtual void Update(GameTime gameTime) { MovementController.Update(gameTime); }