Ejemplo n.º 1
0
        private void CheckIfFinshed()
        {
            if (!finishedLock)
            {
                var boxes = FindObjectsOfType <BoxManager>();
                if (boxes.Length > 0)
                {
                    var finished = true;
                    foreach (var box in boxes)
                    {
                        if (box.IsInGoal == false)
                        {
                            finished = false;
                        }
                    }

                    if (finished)
                    {
                        finishedLock = true;
                        CommunicationService.DisplayInfo("Finish");
                        this.Delay(2, () =>
                        {
                            GameState.CurrentLevelIndex = GameState.CurrentLevelIndex < GameState.CurrentCollectionLevels.Length ? GameState.CurrentLevelIndex + 1 : 0;
                            CommunicationService.ChangeLevel(GameState.CurrentCollectionLevels[GameState.CurrentLevelIndex]);
                            finishedLock = false;
                        });
                    }
                }
            }
        }
Ejemplo n.º 2
0
        void Start()
        {
            // register game objects
            GameObjectRegistry.WallPrefab      = wallPrefab;
            GameObjectRegistry.FloorEvenPrefab = floorEvenPrefab;
            GameObjectRegistry.FloorOddPrefab  = floorOddPrefab;
            GameObjectRegistry.BoxPrefab       = boxPrefab;
            GameObjectRegistry.GoalPrefab      = goalPrefab;
            GameObjectRegistry.Player          = player;


            // add levelbuilder
            gameObject.AddComponent <LevelBuilder>();

            // load levels
            if (GameState.Collections == null)
            {
                GameState.Collections             = LevelFileLoader.ListCollections();
                GameState.CurrentCollectionIndex  = 0;
                GameState.CurrentCollectionLevels = LevelFileLoader.GetLevels(GameState.Collections[0]).ToArray();
            }

            // show info on level change
            CommunicationService.LevelChange += (Tuple <string, char[][]> level) =>
            {
                CommunicationService.DisplayInfo(level.Item1);
            };
        }