Exemplo n.º 1
0
 public void SetUp()
 {
     cell       = new MazeCell(new Point2D(1, 1));
     wall       = new MazeWall(new Point2D(1, 1));
     exit       = new MazeExit(new Point2D(1, 1));
     entrance   = new MazeEntrance(new Point2D(1, 1));
     collection = new MazeCellCollection();
 }
Exemplo n.º 2
0
 void Start()
 {
     grid           = FindObjectOfType <GridContructor> ();
     mazeExit       = FindObjectOfType <MazeExit> ();
     turnController = FindObjectOfType <TurnController> ();
     player         = FindObjectsOfType <Player> ();
     minotaurLife   = player.Length;
 }
Exemplo n.º 3
0
    void HandleMazeMinigame()
    {
        MazeExit exit      = currentInteractive.GetComponent <MazeExit>();
        Vector2  direction = exit.direction;

        MazeController.instance.ChangeNode(direction);
        playingInteraction = false;
    }
Exemplo n.º 4
0
    private MazeExit CreateExit(IntVector2 coordinates)
    {
        MazeExit newCell = Instantiate(exitPrefab) as MazeExit;

        cells[coordinates.x, coordinates.y] = newCell;
        newCell.coordinates = coordinates;
        newCell.name = "Maze Exit " + coordinates.x + ", " + coordinates.y;
        newCell.transform.parent = transform;
        newCell.transform.localPosition = new Vector3(
            coordinates.x * newCell.size.x - size.x * 0.5f * newCell.size.x + 0.5f * newCell.size.x,
            coordinates.y * newCell.size.y - size.y * 0.5f * newCell.size.y  + 0.5f * newCell.size.y,
            0f
        );

        return newCell;
    }
Exemplo n.º 5
0
    private void CreateExit(List <MazeCellEdge> createdWalls, List <MazeCell> cells)
    {
        /* Version 3
         *
         */
        //Debug statement, if the function is called but the exit has been created already
        if (ExitCreated)
        {
            return;
        }

        outsideCells = new List <MazeCell>();
        foreach (MazeCell cell in cells)
        {
            if (cell.coordinates.x == 0 && cell.coordinates.z < size.z ||
                cell.coordinates.x < size.x && cell.coordinates.z == 0 ||
                cell.coordinates.x == size.x - 1 && cell.coordinates.z < size.z ||
                cell.coordinates.x < size.x && cell.coordinates.z == size.z - 1)
            {
                outsideCells.Add(cell);
            }
        }
        while (!ExitCreated)
        {
            int      cellIndex    = Random.Range(0, outsideCells.Count - 1);
            MazeCell selectedCell = outsideCells[cellIndex];
            int      wallIndex    = 0;
            //wall is child
            foreach (MazeCellEdge wall in createdWalls)
            {
                if (selectedCell.coordinates.x == 0 && selectedCell.coordinates.z < size.z && wall.direction == MazeDirection.West ||
                    selectedCell.coordinates.x < size.x && selectedCell.coordinates.z == 0 && wall.direction == MazeDirection.South ||
                    selectedCell.coordinates.x == size.x - 1 && selectedCell.coordinates.z < size.z && wall.direction == MazeDirection.East ||
                    selectedCell.coordinates.x < size.x && selectedCell.coordinates.z == size.z - 1 && wall.direction == MazeDirection.North)
                {
                    Destroy(selectedCell.GetComponentInChildren <MazeCell>().GetEdge(wall.direction).gameObject);

                    MazeExit exitWall = Instantiate(exitPrefab) as MazeExit;
                    exitWall.Initialize(selectedCell, null, wall.direction);
                    ExitCreated = true;
                    break;
                }
                wallIndex++;
            }
        }
    }