Exemplo n.º 1
0
        private void SetupLevel(LevelComponent levelComponent)
        {
            levelComponent.HasLoaded.Value = false;

            defaultCollection.RemoveEntitiesContaining(typeof(GameBoardComponent),
                                                       typeof(FoodComponent), typeof(WallComponent),
                                                       typeof(EnemyComponent), typeof(ExitComponent));

            Observable.Interval(TimeSpan.FromSeconds(_gameConfiguration.IntroLength))
            .First()
            .Subscribe(x => levelComponent.HasLoaded.Value = true);

            defaultCollection.CreateEntity(new GameBoardBlueprint());

            for (var i = 0; i < levelComponent.FoodCount; i++)
            {
                defaultCollection.CreateEntity(new FoodBlueprint());
            }

            for (var i = 0; i < levelComponent.WallCount; i++)
            {
                defaultCollection.CreateEntity(new WallBlueprint());
            }

            for (var i = 0; i < levelComponent.EnemyCount; i++)
            {
                defaultCollection.CreateEntity(new EnemyBlueprint());
            }

            defaultCollection.CreateEntity(new ExitBlueprint());
        }