Ejemplo n.º 1
0
        private static void VerifyLevelSplittedCorrectly(string levelToSplit, string[] expectedLevelStrings)
        {
            Level level = Level.ReadLevel(levelToSplit);

            Level[]  actualLevels       = LevelSplitter.SplitLevel(level).ToArray();
            string[] actuallevelStrings = actualLevels.Select(x => TestTools.RemoveInvisibleCharacters(x.ToString())).ToArray();

            foreach (var splittedLevel in expectedLevelStrings)
            {
                string expected = TestTools.RemoveInvisibleCharacters(splittedLevel);
                int    index    = Array.IndexOf(actuallevelStrings, expected);
                Assert.IsTrue(index != -1, $"Failed to find the expected splitted level. Expected: {Environment.NewLine}{splittedLevel}{Environment.NewLine}{Environment.NewLine}Level was split up into the following levels: {string.Join(Environment.NewLine + Environment.NewLine, actualLevels.Select(x => x.ToString()))}");
            }
        }
Ejemplo n.º 2
0
 void victory()
 {
     if (solveCount == puzzleCount && puzzleCount > 0 && (lives > 0 || TimeRemaining > 0)
         ||
         Input.GetKeyDown(KeyCode.Q))
     {
         if (levelSplitter.checkMe)
         {
             LevelSplitter.SetActive(true);
             LevelSplitter ls = LevelSplitter.GetComponent <LevelSplitter>();
             ls.minimap = ls.splitLevel.printTextures();
         }
         else
         {
             recordVictory();
         }
     }
 }
Ejemplo n.º 3
0
    void Awake()
    {
        solveCount = 0;

        OverRect = new Rect(Screen.width * 0.2f, Screen.height * 0.1f, Screen.width * 0.6f, Screen.height * 0.8f);

        gameGUI       = GameObject.Find("GameGUI").GetComponent <GameGUI>();
        playerData    = GameObject.Find("PlayerData").GetComponent <PlayerData>();
        puzzleParser  = GameObject.Find("PuzzleGenerator").GetComponent <PuzzleParser>();
        levelSplitter = LevelSplitter.GetComponent <LevelSplitter>();
        TimeRemaining = puzzleParser.currentPuzzle.rows.Count *
                        puzzleParser.currentPuzzle.rows[0].cells.Count * 12;

        levelIndex = puzzleParser.currentLevelIndex;

        watcher += victory;
        watcher += defeat;
        watcher += countdown;
        watcher += overDetect;
    }
Ejemplo n.º 4
0
    void OnGUI()
    {
        GUI.depth   = 5;
        GUI.enabled = !puzzleWatcher.end && !paused;

        if (GUI.Button(pause.AnchoredRect(), pause.content, pause.style))
        {
            audio.Play();
            paused         = true;
            Time.timeScale = 0;
            pause.menuObject.SetActive(true);
            GameObject[] clues = GameObject.FindGameObjectsWithTag("Clue");
            foreach (GameObject clue in clues)
            {
                clue.GetComponent <ClueBehavior>().clearClues(true);
            }
        }

        if (GUI.Button(help.AnchoredRect(), help.content, help.style) && anyTrue(helpCounter))
        {
            audio.Play();
            GameObject[]      cells    = GameObject.FindGameObjectsWithTag("Cell");
            List <GameObject> cellList = new List <GameObject>();
            foreach (GameObject cell in cells)
            {
                if (!cell.GetComponent <BoxBehaviour>().isOpen)
                {
                    cellList.Add(cell);
                }
            }
            cellList[Random.Range(0, cellList.Count - 1)].GetComponent <BoxBehaviour>().open();
            helpCount--;
        }

        for (int i = 0; i < helpCounter.Length; i++)
        {
            helpCounter[i] = (helpCount > i);
            Rect offset = helpIcon.AnchoredRect();
            offset.x += i * helpCounterOffset;
            GUI.Toggle(offset, helpCounter[i], helpIcon.content, helpIcon.style);
        }

        if (playerData.CurrentPlayer.settings.playmode == 1)
        {
            if (GUI.Toggle(shotgun.AnchoredRect(), ShotgunMode, shotgun.content, shotgun.style))
            {
                audio.Play();
                ShotgunMode = true;
                BasketMode  = false;
            }
            if (GUI.Toggle(basket.AnchoredRect(), BasketMode, basket.content, basket.style))
            {
                audio.Play();
                ShotgunMode = false;
                BasketMode  = true;
            }
        }
        else if (playerData.CurrentPlayer.settings.playmode == 0)
        {
            if (GUI.Button(shotgun.AnchoredRect(), shotgun.content, shotgun.style))
            {
                audio.Play();
                groupClick("shotgun");
            }
            if (GUI.Button(basket.AnchoredRect(), basket.content, basket.style))
            {
                audio.Play();
                groupClick("hand");
            }
        }


        for (int i = 0; i < lifeCounter.Length; i++)
        {
            lifeCounter[i] = (puzzleWatcher.lives > i);
            Rect offset = life.AnchoredRect();
            offset.x += i * lifeCounterOffset;
            GUI.Toggle(offset, lifeCounter[i], life.content, life.style);
        }

        GUI.Label(timer.AnchoredRect(), timer.content, timer.style);

        if (puzzleWatcher.levelIndex > 2)
        {
            if (zoomedIn)
            {
                if (GUI.Button(microscopeOut.AnchoredRect(), microscopeOut.content, microscopeOut.style))
                {
                    foreach (GameObject grid in GameObject.FindGameObjectsWithTag("Grid"))
                    {
                        GridBehavior g = grid.GetComponent <GridBehavior>();
                        g.ZoomOut();
                        zoomedIn = false;
                    }
                }
            }
            else
            {
                canZoom = (GUI.Toggle(microscopeIn.AnchoredRect(), canZoom, microscopeIn.content, microscopeIn.style));
                foreach (GameObject grid in GameObject.FindGameObjectsWithTag("Grid"))
                {
                    GridBehavior g = grid.GetComponent <GridBehavior>();
                    g.setGridsActive(canZoom);
                }
            }
        }
        if (puzzleWatcher.levelIndex > 5)
        {
            if (GUI.Button(petriDish.AnchoredRect(), petriDish.content, petriDish.style))
            {
                LevelSplitter levelSplitter = petriDish.menuObject.GetComponent <LevelSplitter>();
                levelSplitter.minimap = levelSplitter.splitLevel.printTextures();
                paused         = true;
                Time.timeScale = 0;
                petriDish.menuObject.SetActive(true);
            }
        }
    }