public void CreateEngine(IGameSnapshot snapshot, ITemplateGroup templateGroup) { IGameEngine engine = GameEngineFactory.CreateEngine(snapshot, templateGroup).Value; for (int i = 0; i < 20; ++i) { engine.Update().Wait(); engine.SynchronizeState().Wait(); engine.DispatchEvents(); } }
public void CreateEngineUpdateNonList() { IGameEngine engine = GameEngineFactory.CreateEngine(LevelManager.CreateSnapshot(), LevelManager.CreateTemplateGroup()).Value; for (int i = 0; i < 20; ++i) { engine.Update(new LinkedList <IGameInput>()).Wait(); engine.SynchronizeState().Wait(); engine.DispatchEvents(); } }
public void GotAddedEventsForInitialDatabase(IGameSnapshot snapshot, ITemplateGroup templates) { IGameEngine engine = GameEngineFactory.CreateEngine(snapshot, templates).Value; engine.Update().Wait(); int notifiedCount = 0; engine.EventNotifier.OnEvent <EntityAddedEvent>(evnt => { ++notifiedCount; }); engine.DispatchEvents(); Assert.Equal(1 + snapshot.AddedEntities.Count() + snapshot.ActiveEntities.Count() + snapshot.RemovedEntities.Count(), notifiedCount); engine.SynchronizeState().Wait(); engine.Update().Wait(); notifiedCount = 0; engine.DispatchEvents(); Assert.Equal(0, notifiedCount); }
public void Update(float elapsedMilliseconds) { // update network and the turn game _networkContext.Update(); _turnGame.Update(elapsedMilliseconds); // try to update the game List <IGameCommand> commands; if (_turnGame.TryUpdate(out commands)) { _gameEngine.Update(commands.Cast <IGameInput>()).Wait(); _gameEngine.SynchronizeState().Wait(); _gameEngine.DispatchEvents(); } }