private Game() { Configuration = new GameConfigurationManager(); DRAW_AFTER = Configuration.gameConfig.DRAW_INTERVAL / Configuration.gameConfig.UPDATE_INTERVAL; _drawFPS = 1000 / Configuration.gameConfig.DRAW_INTERVAL; _gameLoop = new HighFrequencyTimer(1000 / Configuration.gameConfig.UPDATE_INTERVAL, id => Update(id), () => { }, () => { }, (fps) => { _actualFPS = fps; }); _leaderboardLoop = new Timer(UpdateLeaderboard, null, Configuration.gameConfig.LEADERBOARD_PUSH_INTERVAL, Configuration.gameConfig.LEADERBOARD_PUSH_INTERVAL); _gameTime = new GameTime(); _space = new Map(); GameHandler = new GameHandler(_space); _payloadManager = new PayloadManager(); UserHandler = new UserHandler(GameHandler); Leaderboard = new Leaderboard(UserHandler); ConnectionManager = new ConnectionManager(UserHandler, _locker); RegistrationHandler = new RegistrationHandler(); RuntimeConfiguration = new RuntimeConfiguration(); _gameLoop.Start(); }
public void Update(GameTime gameTime) { bool[] bulletsToKeepAround = new bool[Bullets.Count]; Parallel.For(0, Bullets.Count, i => { Bullet currentBullet = Bullets[i]; if (currentBullet.ShouldDispose(GameTime.Now)) { currentBullet.Dispose(); } if (currentBullet.Disposed) { bulletsToKeepAround[i] = false; // don't keep me around } else { currentBullet.Update(gameTime); bulletsToKeepAround[i] = true; // keep me around } }); lock (_locker) { for (int i = bulletsToKeepAround.Length - 1; i >= 0; i--) { if (!bulletsToKeepAround[i]) { Bullets[i] = Bullets[Bullets.Count - 1]; Bullets.RemoveAt(Bullets.Count - 1); } } } }
public void Update(GameTime gameTime) { lock (_lock) { _positionTween.Update(gameTime); _rotationTween.Update(gameTime); } }
public void Update(GameTime gameTime) { _shipManager.Update(gameTime); _powerupManager.Update(gameTime); BulletManager.Update(gameTime); _collisionManager.Update(gameTime); }
public void Update(GameTime gameTime) { bool[] objectsToKeepAround = new bool[_objects.Count]; Parallel.For(0, _objects.Count, i => { Collidable thisObject = _objects[i]; if (thisObject.Disposed) { objectsToKeepAround[i] = false; return; } // Retrieve objects that it could be colliding with List<Collidable> potentials = thisObject.GetMapArea().GetSubTreeContents(); for (int j = 0; j < potentials.Count; j++) { Collidable thisPotential = potentials[j]; // If the potential object is our outer object then move on if (thisPotential.Collided || thisPotential.ServerID() == thisObject.ServerID()) { continue; } if (thisObject.IsCollidingWith(thisPotential)) { thisObject.HandleCollisionWith(thisPotential, _space); thisPotential.HandleCollisionWith(thisObject, _space); if (thisObject.Disposed) { objectsToKeepAround[i] = false; return; } } } objectsToKeepAround[i] = true; }); for (int i = objectsToKeepAround.Length - 1; i >= 0; i--) { if (!objectsToKeepAround[i]) { _objects[i] = _objects[_objects.Count - 1]; _objects.RemoveAt(_objects.Count - 1); } } }
public void Update(GameTime gameTime) { for (int i = _powerupList.Count - 1; i >= 0; i--) { if (_powerupList[i].Disposed) { _powerupList[i--] = _powerupList[_powerupList.Count - 1]; _powerupList.RemoveAt(_powerupList.Count - 1); } else { _powerupList[i].Update(GameTime.Now); } } }
private Game() { Configuration = new GameConfigurationManager(); DRAW_AFTER = TimeSpan.FromMilliseconds(Configuration.gameConfig.DRAW_INTERVAL); _gameLoop = new HighFrequencyTimer(1000 / Configuration.gameConfig.UPDATE_INTERVAL, id => Update(id)); _leaderboardLoop = new Timer(UpdateLeaderboard, null, Configuration.gameConfig.LEADERBOARD_PUSH_INTERVAL, Configuration.gameConfig.LEADERBOARD_PUSH_INTERVAL); _gameTime = new GameTime(); _space = new Map(); GameHandler = new GameHandler(_space); _payloadManager = new PayloadManager(); UserHandler = new UserHandler(GameHandler); Leaderboard = new Leaderboard(UserHandler); ConnectionManager = new ConnectionManager(UserHandler, _locker); RegistrationHandler = new RegistrationHandler(); RuntimeConfiguration = new RuntimeConfiguration(); _gameLoop.Start(); }
public void Update(GameTime gameTime) { lock (_updateLock) { // Remove old snapshots while ((GameTime.Now - _snapShotHead.At) > _snapShotLifetime && _snapShotHead.Next != null) { _snapShotHead = _snapShotHead.Next; } _snapShotTail.Next = new BoundsSnapShot { Position = _ship.MovementController.Position, At = GameTime.Now, Next = null }; _snapShotTail = _snapShotTail.Next; _bounds.X = Convert.ToInt32(_snapShotHead.Position.X); _bounds.Y = Convert.ToInt32(_snapShotHead.Position.Y); } }
public void Update(GameTime gameTime) { _respawnManager.Update(); List<string> keysToRemove = new List<string>(Ships.Count); Parallel.ForEach(Ships, currentShip => { if (!currentShip.Value.Disposed) { currentShip.Value.Update(gameTime); } else { keysToRemove.Add(currentShip.Key); } }); for (int i = keysToRemove.Count - 1; i >= 0; i--) { Remove(keysToRemove[i]); } }
public void Update(GameTime gameTime) { Update(gameTime.PercentOfSecond); }
public void Update(GameTime gameTime) { Update(GameTime.CalculatePercentOfSecond(LastUpdated)); }
public virtual void Update(GameTime gameTime) { WeaponController.Update(GameTime.Now); _interpolationManager.Update(gameTime); if (!_interpolationManager.Interpolating) { MovementController.Update(gameTime); } AbilityHandler.Update(GameTime.Now); _snapShotManager.Update(gameTime); base.Update(); Action command; while (_enqueuedCommands.Count > 0) { if (_enqueuedCommands.TryDequeue(out command) && !this.Disposed) { command(); } } }
public void Update(GameTime gameTime) { MovementController.Update(gameTime.PercentOfSecond); base.Update(); }
public override void Update(GameTime gameTime) { DateTime now = DateTime.UtcNow; // Used to convert the calculated ship rotation to a usable 0-360 rotation UpdateCurrentRotation(); CheckCurrentState(now); ActOnCurrentState(now); base.Update(gameTime); }