示例#1
0
    private void OnTriggerEnter2D(Collider2D collision)
    {
        if (collision.tag == "Spawn")
        {
            int newSpawnIndex = collision.GetComponent <SpawnStorage>().SpawnIndex;

            if (newSpawnIndex > MazeHandler.CurrentSpawnIndex)
            {
                MazeHandler.CurrentSpawnIndex = newSpawnIndex;

                if (newSpawnIndex < MazeHandler.GetMaxSpawnNumber() - 1)
                {
                    MazeHandler.HighlightNextSpawn();
                }
            }
        }
        else if (collision.tag == "ButtonAdminConfirm")
        {
            MazeHandler.CurrentButton = MazeHandler.Button.ADMIN_CONFIRM;
        }
        else if (collision.tag == "ButtonProgressDone")
        {
            MazeHandler.CurrentButton = MazeHandler.Button.PROGRESS_DONE;
        }
    }
        public void TraverseMaze_MovingEastNotAtEasternBorder_ReturnsIndexOfEasternNeighbour(int startIndex, int expectedIndex)
        {
            char direction = 'E';

            int?actualIndex = MazeHandler.TraverseMaze(maze, startIndex, direction);

            Assert.Equal(expectedIndex, actualIndex);
        }
        public void TraverseMaze_MovingEastNotAtEasternBorder_ReturnsNotNull()
        {
            int  currentIndex = mazeSize; // Not on right edge
            char direction    = 'E';

            int?actualIndex = MazeHandler.TraverseMaze(maze, currentIndex, direction);

            Assert.NotNull(actualIndex);
        }
        public void TraverseMaze_MovingEastAtEasternBorder_ReturnsNull()
        {
            int  currentIndex = mazeSize - 1; // On right edge
            char direction    = 'E';

            int?result = MazeHandler.TraverseMaze(maze, currentIndex, direction);

            Assert.Null(result);
        }
        public void TraverseMaze_MovingNorthNotAtNorthernBorder_ReturnsNotNull()
        {
            int  currentIndex = mazeSize * 1; // On second row
            char direction    = 'N';

            int?actualIndex = MazeHandler.TraverseMaze(maze, currentIndex, direction);

            Assert.NotNull(actualIndex);
        }
        public void TraverseMaze_MovingNorthAtNorthernBorder_ReturnsNull()
        {
            int  currentIndex = 0; // On first row
            char direction    = 'N';

            int?result = MazeHandler.TraverseMaze(maze, currentIndex, direction);

            Assert.Null(result);
        }
        public void TraverseMaze_MovingWestAtWesternBorder_ReturnsNull()
        {
            int  currentIndex = 0; // On western edge
            char direction    = 'W';

            int?result = MazeHandler.TraverseMaze(maze, currentIndex, direction);

            Assert.Null(result);
        }
        public void TraverseMaze_MovingSouthNotAtSouthernBorder_ReturnsNotNull()
        {
            int  currentIndex = 0; // Not on southern edge
            char direction    = 'S';

            int?actualIndex = MazeHandler.TraverseMaze(maze, currentIndex, direction);

            Assert.NotNull(actualIndex);
        }
        public void TraverseMaze_MovingSouthAtSouthernBorder_ReturnsNull()
        {
            int  currentIndex = mazeSize * (mazeSize - 1); // On southern edge
            char direction    = 'S';

            int?result = MazeHandler.TraverseMaze(maze, currentIndex, direction);

            Assert.Null(result);
        }
示例#10
0
        public void TraverseMaze_InvalidDirection_ThrowsException()
        {
            int  currentIndex = 0; // On western edge
            char direction    = '1';

            var exception = Record.Exception(() => MazeHandler.TraverseMaze(maze, currentIndex, direction));

            Assert.NotNull(exception);
            Assert.IsType <InvalidDirectionException>(exception);
        }
示例#11
0
        public void TrapCheck_GeneratedDoubleAboveThreshold_ReturnsTrue()
        {
            var random = new MockRandomGeneratorMax(); // Always generates 1.0.

            maze = new MockMazeFactoryAllMarshes().Create(null, MazeType.VerySimpleMaze, mazeSize);

            bool result = MazeHandler.TrapCheck(random, maze, 0);

            Assert.True(result);
        }
示例#12
0
    public override void OnInspectorGUI()
    {
        DrawDefaultInspector();
        MazeHandler mazeScript = (MazeHandler)target;

        if (GUILayout.Button("Resize Maze Grid"))
        {
            mazeScript.ClearMaze();
            mazeScript.BuildMaze();
        }
    }
示例#13
0
    void Update()
    {
        if (isBallOutOfPath)
        {
            isBallOutOfPath = false;
            SetBallPosition(MazeHandler.GetCurrentSpawn().transform.position);

            AudioManager.instance.PlayCollisionSound();
        }

        if (Input.GetKeyDown(KeyCode.Escape))
        {
            cursorLocked = false;
        }

        if (!cursorLocked && (Input.GetMouseButton(0) || Input.GetMouseButton(1) || Input.GetMouseButton(2)))
        {
            cursorLocked = true;
        }

        if (cursorLocked &&
            !Parameters.IsOpened)
        {
            Cursor.lockState = CursorLockMode.Locked;

            Vector3 offset = new Vector3(Input.GetAxis("Mouse X"), Input.GetAxis("Mouse Y"), 0) * Parameters.MouseSensitivity;

            RaycastHit2D[] hits = Physics2D.RaycastAll(transform.position, offset, offset.sqrMagnitude);
            //Debug.DrawRay(transform.position, offset, Color.red, 5);

            foreach (RaycastHit2D hit in hits)
            {
                if (hit.collider.tag == "Wall")
                {
                    isBallOutOfPath = true;
                    break;
                }
            }

            if (!isBallOutOfPath)
            {
                MoveBall(offset * Parameters.MouseSensitivity);
            }
        }
    }