コード例 #1
0
ファイル: Maze.cs プロジェクト: malikouda/thief-and-co
    //checks if the cell is in a 1x1 corridor
    private bool CellTooNarrow(MazeCell cell)
    {
        bool NS = cell.GetEdge(MazeDirection.North) is MazeWall && cell.GetEdge(MazeDirection.South) is MazeWall;
        bool EW = cell.GetEdge(MazeDirection.East) is MazeWall && cell.GetEdge(MazeDirection.West) is MazeWall;

        return(NS || EW);
    }
コード例 #2
0
ファイル: Player.cs プロジェクト: DaneLinsky/ZombieMaze
    private void Move(MazeDirection direction)
    {
        MazeCellEdge edge = currentCell.GetEdge(direction);

        if (edge is MazePassage)
        {
            SetLocation(edge.otherCell);
        }
    }
コード例 #3
0
ファイル: Maze.cs プロジェクト: Judgy53/DungeonStalker
    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;
                }
            }
        }
    }
コード例 #4
0
    public IEnumerator Generate()
    {
        WaitForSeconds delay    = new WaitForSeconds(generationStepDelay);
        int            cooldown = 0;

        cells = new MazeCell[size.x, size.z];
        List <MazeCell> activeCells = new List <MazeCell>();

        DoFirstGenerationStep(activeCells);

        while (activeCells.Count > 0)
        {
            if (cooldown > generationStepDelay_multiplier && generationStepDelay_multiplier != -1)
            {
                cooldown = 0;
                yield return(delay);
            }
            cooldown++;
            DoNextGenerationStep(activeCells);
        }

        for (int i = 0; i < 4; i++)
        {
            if (!start.GetEdge((MazeDirection)i).haswall)
            {
                start_direction = (MazeDirection)i;
            }
        }

        finish.gameObject.transform.FindChild("Quad").GetComponent <MeshRenderer> ().material = red;
        finish.gameObject.name = "FinishCell";
    }
コード例 #5
0
ファイル: Player.cs プロジェクト: kurtdekker/MazeVenture
    public void MoveDirection(MazeDirection direction)
    {       // If it is possible for the player to move the specified direction
        // from the last cell in player's route, the cell in that direction from
        // the last cell in player's route is added to the route.
        MazeCell cellToMoveFrom = GetDestinationCell();

        MazeCellEdge edge = cellToMoveFrom.GetEdge(direction);

        //Debug.Log(string.Format("Move:{0} from {1} to {2}", direction, cellToMoveFrom.name, edge.otherCell.name));
        if (edge is MazePassage)
        {
            if (cellToMoveFrom == edge.otherCell)
            {
                MoveToCell(edge.cell);
            }
            else if (cellToMoveFrom == edge.cell)
            {
                MoveToCell(edge.otherCell);
            }
            else
            {
                Debug.LogError(string.Format("Move:{0} from {1} to {2}", direction, cellToMoveFrom.name, edge.otherCell.name));
            }
        }
    }
コード例 #6
0
ファイル: Maze.cs プロジェクト: malikouda/thief-and-co
    //Checks if the cell is in a dead end or a corner
    private bool CellinDeadEndOrCorner(MazeCell cell)
    {
        //check the numbe of walls surrounding the cell
        int numWalls = 0;

        MazeDirection[] directions = new MazeDirection[4] {
            MazeDirection.North, MazeDirection.East, MazeDirection.South, MazeDirection.West
        };
        for (int i = 0; i < 4; i++)
        {
            if (cell.GetEdge(directions[i]) is MazeWall)
            {
                ++numWalls;
            }
        }

        //If the cell has 3 walls, it's a dead end
        if (numWalls == 3)
        {
            return(true);
        }

        //If the cell has 2 walls, but they aren't opposite each other, it's in a corner
        if (numWalls == 2 && !CellTooNarrow(cell))
        {
            return(true);
        }
        else
        {
            return(false);
        }
    }
コード例 #7
0
ファイル: Player.cs プロジェクト: dasinlsb/3d-game-learning
    private void TryMove(MazeDirection direction)
    {
        MazeCellEdge edge = currentCell.GetEdge(direction);

        if (edge is MazePassage)
        {
            if (edge is MazeDoor && !(edge as MazeDoor).IsOpened)
            {
                return;
            }
            if (edge.otherCell.role != "Empty")
            {
                return;
            }
            EnterCell(edge.otherCell, direction);
        }
    }
コード例 #8
0
ファイル: Maze.cs プロジェクト: Judgy53/DungeonStalker
    private IEnumerator GenerateChestsInRoom(MazeRoom room, int number)
    {
        int             chestsGenerated = 0;
        List <MazeCell> activeCells     = new List <MazeCell>(room.Cells);

        while (chestsGenerated < number)
        {
            if (chests.Count % 10 == 0)
            {
                yield return(false);
            }

            if (activeCells.Count == 0)
            {
                break;
            }

            MazeCell randCell = activeCells[Random.Range(0, activeCells.Count)];
            activeCells.Remove(randCell);
            MazePassage passage = null;
            if (randCell.IsFree)
            {
                int passageCount = 0;
                for (int i = 0; i < 4; i++)
                {
                    MazeCellEdge edge = randCell.GetEdge(i);
                    if (edge is MazePassage)
                    {
                        passage = edge as MazePassage;
                        passageCount++;
                        if (passageCount > 1)
                        {
                            break;
                        }
                    }
                }

                if (passageCount > 1)
                {
                    continue;
                }

                randCell.RegisterEntity();

                Container chest = GameObject.Instantiate(chestPrefab) as Container;
                chest.transform.parent = transform;

                chest.transform.localPosition = new Vector3(randCell.coordinates.x - size.x * 0.5f + 0.5f,
                                                            transform.position.y,
                                                            randCell.coordinates.z - size.z * 0.5f + 0.5f);
                chest.transform.localRotation = passage.direction.ToRotation();

                chestsGenerated++;

                chests.Add(chest);
            }
        }
    }
コード例 #9
0
    private void Move(MazeDirection direction)
    {
        MazeCellEdge edge = curCell.GetEdge(direction);

        if (edge is MazePath)
        {
            SetLocation(edge.neighCell);
        }
    }
コード例 #10
0
ファイル: Player.cs プロジェクト: LJK150030/PGHauntedHouse
    //moves the stand's location based on the players cordinates
    private void Move(MazeDirection direction)
    {
        MazeCellEdge edge = currentCell.GetEdge(direction); //Returns the edge

        if (edge is MazePassage)
        {
            SetLocationA(edge.otherCell); //Returns the cell on the other side of the door
        }
    }
コード例 #11
0
    /// <summary>
    /// Movement should only happen if the edge we would cross is a passage, otherwise we're blocked.
    /// </summary>
    /// <param name="direction">Direction from player.</param>
    private void Move(MazeDirection direction)
    {
        // Declare variables.
        MazeCellEdge edge = _currentMazeCell.GetEdge(direction);

        if (edge is MazePassage)
        {
            SetLocation(edge.OtherCell);
        }
    }
コード例 #12
0
ファイル: Maze.cs プロジェクト: malikouda/thief-and-co
    private bool CellNextToObject(MazeCell cell)
    {
        bool nextToObject = false;

        MazeDirection[] directions = new MazeDirection[4] {
            MazeDirection.North, MazeDirection.East, MazeDirection.South, MazeDirection.West
        };
        for (int i = 0; i < 4; i++)
        {
            if (cell.GetEdge(directions[i]).otherCell != null)
            {
                if (cell.GetEdge(directions[i]).otherCell.occupied)
                {
                    nextToObject = true;
                    break;
                }
            }
        }
        return(nextToObject);
    }
コード例 #13
0
    private void Move(MazeDirection direction)
    {
        MazeCellEdge edge = currentCell.GetEdge(direction);

        if (edge is MazeWall)
        {
        }
        else
        {
            SetLocation(edge.OtherCell());
        }
    }
コード例 #14
0
ファイル: Maze.cs プロジェクト: Judgy53/DungeonStalker
    private void CheckWallside(MazeCell cell, MazeDirection dir, int delta)
    {
        if (cell.GetEdge(dir + delta) is MazeWall)
        {
            if (closedTurnWallDecorPrefab != null && !cell.IsCornerInitialized(dir, delta))
            {
                cell.InitializeCorner(closedTurnWallDecorPrefab, dir, delta);
            }
            return;
        }

        if (ContainsCoordinates(cell.coordinates + (dir + delta).ToVector2i() + dir.ToVector2i()))
        {
            MazeCell otherCell = GetCell(cell.coordinates + (dir + delta).ToVector2i() + dir.ToVector2i());
            if (otherCell.GetEdge(dir - delta) is MazeWall)
            {
                if (openTurnWallDecorPrefab != null)
                {
                    if (!cell.IsCornerInitialized(dir, delta))
                    {
                        cell.InitializeCorner(openTurnWallDecorPrefab, dir, delta);
                    }

                    if (ContainsCoordinates(cell.coordinates + (dir + delta).ToVector2i()))
                    {
                        MazeCell sideCell = GetCell(cell.coordinates + (dir + delta).ToVector2i());
                        if (!sideCell.IsCornerInitialized(dir, -delta))
                        {
                            sideCell.InitializeCorner(openTurnWallDecorPrefab, dir, -delta);
                        }
                    }
                }
                return;
            }
        }

        if (ContainsCoordinates(cell.coordinates + (dir + delta).ToVector2i()))
        {
            MazeCell otherCell = GetCell(cell.coordinates + (dir + delta).ToVector2i());
            if (otherCell.GetEdge(dir) is MazeWall)
            {
                if (straightWallDecorPrefab != null && !cell.IsCornerInitialized(dir, delta))
                {
                    cell.InitializeCorner(straightWallDecorPrefab, dir, delta);
                }
                return;
            }
        }
    }
コード例 #15
0
ファイル: Maze.cs プロジェクト: malikouda/thief-and-co
    private bool CellNextToDoor(MazeCell cell)
    {
        bool nextToDoor = false;

        MazeDirection[] directions = new MazeDirection[4] {
            MazeDirection.North, MazeDirection.East, MazeDirection.South, MazeDirection.West
        };
        for (int i = 0; i < 4; i++)
        {
            if (cell.GetEdge(directions[i]) is MazeDoor)
            {
                nextToDoor = true;
                break;
            }
        }
        return(nextToDoor);
    }
コード例 #16
0
ファイル: Maze.cs プロジェクト: malikouda/thief-and-co
    private bool CellNextToWall(MazeCell cell, out MazeDirection wall)
    {
        MazeDirection[] directions = new MazeDirection[4] {
            MazeDirection.North, MazeDirection.East, MazeDirection.South, MazeDirection.West
        };
        for (int i = 0; i < 4; i++)
        {
            if (cell.GetEdge(directions[i]) is MazeWall)
            {
                wall = directions[i];
                return(true);
            }
        }

        wall = MazeDirection.Null;
        return(false);
    }
コード例 #17
0
ファイル: Player.cs プロジェクト: warppoint42/SonicMaze
    //public void SetLocation(MazeDoor cell, bool sound)
    //{
    //    if (sound)
    //    {
    //        SetLocation(cell);
    //        return;
    //    }
    //    if (currentCell != null)
    //    {
    //        currentCell.OnPlayerExited();
    //    }
    //    currentCell = cell;
    //    transform.localPosition = cell.transform.localPosition;
    //    currentCell.OnPlayerEnteredNoSound();
    //}

    private void Move(MazeDirection direction)
    {
        MazeCellEdge edge = currentCell.GetEdge(direction);

        if (edge is MazePassage)
        {
            SetLocation(edge.otherCell);
        }
        if (edge is MazeDoor)
        {
            bool correct = maze.doorSignal((MazeDoor)edge);
            if (correct)
            {
                cd++;
            }
            //SetLocation(edge.otherCell, correct);
            done = maze.makePath(currentCell.room);
        }
    }
コード例 #18
0
    private void DestroyMazeCellEdge(MazeCell cell, MazeDirection dir)
    {
        MazeCellEdge edge = cell.GetEdge(dir);

        Destroy(edge.gameObject);
    }
コード例 #19
0
 private void DestroyMazeCellEdge(MazeCell cell, MazeDirection dir) {
     MazeCellEdge edge = cell.GetEdge(dir);
     Destroy(edge.gameObject);
 }