Пример #1
0
    private void PlaceExitDoor()
    {
        while (true)
        {
            MazeCell rcell = cells[Random.Range(0, size.x), Random.Range(0, size.z)];
            for (int i = 0; i < MazeDirections.Count; i++)
            {
                MazeDirection dir  = MazeDirection.North + i;
                MazeCellEdge  edge = rcell.GetEdge(dir);
                if (edge is MazeWall)
                {
                    rcell.DestroyEdge(dir);
                    Vector2i coordinates = rcell.coordinates + dir.ToVector2i();
                    if (ContainsCoordinates(coordinates))
                    {
                        exitDoor = CreateChangeStageDoor(rcell, GetCell(coordinates), dir, 1);
                    }
                    else
                    {
                        exitDoor = CreateChangeStageDoor(rcell, null, dir, 1);
                    }

                    return;
                }
            }
        }
    }
Пример #2
0
    public DoorChangeStage CreateChangeStageDoor(MazeCell cell, MazeCell otherCell, MazeDirection direction, uint delta)
    {
        DoorChangeStage newDoor = GameObject.Instantiate(exitDoorPrefab as Behaviour, transform.position, transform.rotation) as DoorChangeStage;

        newDoor.Delta = delta;

        newDoor.Initialize(cell, otherCell, direction);

        return(newDoor);
    }