Ejemplo n.º 1
0
 public GameComponents(Block[] blocks, GameTimer timer, GameUI gameUI, LevelGrid levelGrid,
                       GameRulesController rulesController, Player player, FollowerGO camera, LevelConfig gameConfig, TagsObserver tagsObserver)
 {
     this.blocks          = blocks;
     this.timer           = timer;
     this.gameUI          = gameUI;
     this.levelGrid       = levelGrid;
     this.rulesController = rulesController;
     this.player          = player;
     this.camera          = camera;
     this.gameConfig      = gameConfig;
     this.tagsObserver    = tagsObserver;
 }
Ejemplo n.º 2
0
        public IEnumerator ProgrammCreateComponents(Action <GameComponents> callBack, Transform root)
        {
            Time.timeScale = 0;

            //show loading screen
            loadingScreen.gameObject.SetActive(true);

            yield return(new WaitForSecondsRealtime(0.1f));

            //Generate game level
            Level level = gameConfig.generator.Generate();

            yield return(new WaitForSecondsRealtime(0.1f));

            //Create game level
            Builder builder = new Builder(prefabs, level, root);

            Block[] blocks = builder.CreateBlocks();
            yield return(new WaitForSecondsRealtime(0.1f));

            navmeshSurface.BuildNavMesh();
            //spawn monsters

            MonsterAI[] monsters = builder.CreateCreatures();

            //Create timer
            GameObject goTimer = new GameObject("Game Timer");
            GameTimer  timer   = goTimer.AddComponent <GameTimer>();

            //Create Tag
            TagsObserver tagsObserver = new TagsObserver("Monster");

            //hide loading screen
            loadingScreen.gameObject.SetActive(false);


            GameComponents components = new GameComponents(blocks, timer, gameUI, levelGrid, rulesController, player, cameraRoot, gameConfig, tagsObserver);

            callBack(components);

            Time.timeScale = 1;
        }