コード例 #1
0
        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();
            }
        }
コード例 #2
0
        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();
            }
        }
コード例 #3
0
ファイル: GameSnapshotTests.cs プロジェクト: suzuke/forge
        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);
        }
コード例 #4
0
        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();
            }
        }