private void DestroyAdjacentWall(int row, int column)
    {
        bool wallDestroyed = false;

        while (!wallDestroyed)
        {
            // int direction = Random.Range (1, 5);
            int direction = ProceduralNumberGenerator.GetNextNumber();

            if (direction == 1 && row > 0 && mazeCells [row - 1, column].visited)
            {
                DestroyWallIfItExists(mazeCells [row, column].northWall);
                DestroyWallIfItExists(mazeCells [row - 1, column].southWall);
                wallDestroyed = true;
            }
            else if (direction == 2 && row < (mazeRows - 2) && mazeCells [row + 1, column].visited)
            {
                DestroyWallIfItExists(mazeCells [row, column].southWall);
                DestroyWallIfItExists(mazeCells [row + 1, column].northWall);
                wallDestroyed = true;
            }
            else if (direction == 3 && column > 0 && mazeCells [row, column - 1].visited)
            {
                DestroyWallIfItExists(mazeCells [row, column].westWall);
                DestroyWallIfItExists(mazeCells [row, column - 1].eastWall);
                wallDestroyed = true;
            }
            else if (direction == 4 && column < (mazeColumns - 2) && mazeCells [row, column + 1].visited)
            {
                DestroyWallIfItExists(mazeCells [row, column].eastWall);
                DestroyWallIfItExists(mazeCells [row, column + 1].westWall);
                wallDestroyed = true;
            }
        }
    }
Пример #2
0
        private void DestroyAdjacentWall(int row, int column)
        {
            var wallDestroyed = false;

            while (!wallDestroyed)
            {
                //var direction = Random.Range(1, 5);
                var direction = ProceduralNumberGenerator.GetNextNumber();

                if (direction == 1 && row > -XHalfExt && GetCell(row - 1, column).Visited)
                {
                    DestroyWallIfItExists(GetCell(row, column).NorthWall);
                    DestroyWallIfItExists(GetCell(row - 1, column).SouthWall);
                    wallDestroyed = true;
                }
                else if (direction == 2 && row < XHalfExt - 2 && GetCell(row + 1, column).Visited)
                {
                    DestroyWallIfItExists(GetCell(row, column).SouthWall);
                    DestroyWallIfItExists(GetCell(row + 1, column).NorthWall);
                    wallDestroyed = true;
                }
                else if (direction == 3 && column > -ZHalfExt && GetCell(row, column - 1).Visited)
                {
                    DestroyWallIfItExists(GetCell(row, column).WestWall);
                    DestroyWallIfItExists(GetCell(row, column - 1).EastWall);
                    wallDestroyed = true;
                }
                else if (direction == 4 && column < ZHalfExt - 2 && GetCell(row, column + 1).Visited)
                {
                    DestroyWallIfItExists(GetCell(row, column).EastWall);
                    DestroyWallIfItExists(GetCell(row, column + 1).WestWall);
                    wallDestroyed = true;
                }
            }
        }
    private void DestroyGrid()
    {
        while (RouteStillAvailable(currentRow, currentColumn))
        {
            int direction = ProceduralNumberGenerator.GetNextNumber();

            if (direction == 1 && CellIsAvailable(currentRow - 1, currentColumn))
            {
                // North
                DestroyWallIfItExists(mazeCells [currentRow - 1, currentColumn].southWall);
                currentRow--;
            }
            else if (direction == 2 && CellIsAvailable(currentRow + 1, currentColumn))
            {
                // South
                DestroyWallIfItExists(mazeCells [currentRow, currentColumn].southWall);
                currentRow++;
            }
            else if (direction == 3 && CellIsAvailable(currentRow, currentColumn + 1))
            {
                // east
                DestroyWallIfItExists(mazeCells [currentRow, currentColumn].eastWall);
                currentColumn++;
            }
            else if (direction == 4 && CellIsAvailable(currentRow, currentColumn - 1))
            {
                // west
                DestroyWallIfItExists(mazeCells [currentRow, currentColumn - 1].eastWall);
                currentColumn--;
            }

            mazeCells [currentRow, currentColumn].visited = true;
        }
    }
Пример #4
0
    private void DestroyAdjacentWall(int row, int column)
    {
        bool wallDestroyed = false;

        while (!wallDestroyed)
        {
            int direction = ProceduralNumberGenerator.GetNextNumber(seed);

            if (direction == 1 && row > 0 && mazeCells[row - 1, column].visited)
            {
                if (DestroyWallIfItExists(mazeCells[row, column].topWall))
                {
                    mazeCells[row, column].topWall = null;
                }
                if (DestroyWallIfItExists(mazeCells[row - 1, column].bottomWall))
                {
                    mazeCells[row - 1, column].bottomWall = null;
                }
                wallDestroyed = true;
            }
            else if (direction == 2 && row < (mazeRows - 2) && mazeCells[row + 1, column].visited)
            {
                if (DestroyWallIfItExists(mazeCells[row, column].bottomWall))
                {
                    mazeCells[row, column].bottomWall = null;
                }
                if (DestroyWallIfItExists(mazeCells[row + 1, column].topWall))
                {
                    mazeCells[row + 1, column].topWall = null;
                }
                wallDestroyed = true;
            }
            else if (direction == 3 && column > 0 && mazeCells[row, column - 1].visited)
            {
                if (DestroyWallIfItExists(mazeCells[row, column].leftWall))
                {
                    mazeCells[row, column].leftWall = null;
                }
                if (DestroyWallIfItExists(mazeCells[row, column - 1].rightWall))
                {
                    mazeCells[row, column - 1].rightWall = null;
                }
                wallDestroyed = true;
            }
            else if (direction == 4 && column < (mazeColumns - 2) && mazeCells[row, column + 1].visited)
            {
                if (DestroyWallIfItExists(mazeCells[row, column].rightWall))
                {
                    mazeCells[row, column].rightWall = null;
                }
                if (DestroyWallIfItExists(mazeCells[row, column + 1].leftWall))
                {
                    mazeCells[row, column + 1].leftWall = null;
                }
                wallDestroyed = true;
            }
        }
    }
Пример #5
0
    private void Kill()
    {
        //photonview = GameObject.Find("RoomController").GetPhotonView();
        //photonview.RPC(nameof(ProceduralNumberGenerator.Generate), RpcTarget.AllBuffered);

        while (RouteStillAvailable(currentRow, currentColumn))
        {
            //int i = 0;


            int direction = ProceduralNumberGenerator.GetNextNumber();

            //if (MazeValues.isArPlayer)
            //{
            //    // int direction = Random.Range (1, 5);
            //    //direction = ProceduralNumberGenerator.GetNextNumber();

            //    KillKeys.Add(direction);
            //}

            //else
            //{
            //    //direction = ProceduralNumberGenerator.GetNextNumber();
            //    direction = MazeValues.KillKeys[i];
            //}

            if (direction == 1 && CellIsAvailable(currentRow - 1, currentColumn))
            {
                // North
                DestroyWallIfItExists(mazeCells[currentRow, currentColumn].northWall);
                DestroyWallIfItExists(mazeCells[currentRow - 1, currentColumn].southWall);
                currentRow--;
            }
            else if (direction == 2 && CellIsAvailable(currentRow + 1, currentColumn))
            {
                // South
                DestroyWallIfItExists(mazeCells[currentRow, currentColumn].southWall);
                DestroyWallIfItExists(mazeCells[currentRow + 1, currentColumn].northWall);
                currentRow++;
            }
            else if (direction == 3 && CellIsAvailable(currentRow, currentColumn + 1))
            {
                // East
                DestroyWallIfItExists(mazeCells[currentRow, currentColumn].eastWall);
                DestroyWallIfItExists(mazeCells[currentRow, currentColumn + 1].westWall);
                currentColumn++;
            }
            else if (direction == 4 && CellIsAvailable(currentRow, currentColumn - 1))
            {
                // West
                DestroyWallIfItExists(mazeCells[currentRow, currentColumn].westWall);
                DestroyWallIfItExists(mazeCells[currentRow, currentColumn - 1].eastWall);
                currentColumn--;
            }

            mazeCells[currentRow, currentColumn].visited = true;
        }
    }
    private void Kill()
    {
        while (RouteStillAvailable(currentRow, currentColumn))
        {
            int direction = -1, previousRow = currentRow, previousColumn = currentColumn;

            if (loading)
            {
                direction = ProceduralNumberGenerator.GetNextNumber();
            }
            else
            {
                direction = Random.Range(1, 5);
            }

            if (direction == 1 && CellIsAvailable(currentRow - 1, currentColumn))
            {
                // North
                DestroyWallIfItExists(mazeCells[currentRow, currentColumn].northWall);
                DestroyWallIfItExists(mazeCells[currentRow - 1, currentColumn].southWall);
                currentRow--;
            }
            else if (direction == 2 && CellIsAvailable(currentRow + 1, currentColumn))
            {
                // South
                DestroyWallIfItExists(mazeCells[currentRow, currentColumn].southWall);
                DestroyWallIfItExists(mazeCells[currentRow + 1, currentColumn].northWall);
                currentRow++;
            }
            else if (direction == 3 && CellIsAvailable(currentRow, currentColumn + 1))
            {
                // east
                DestroyWallIfItExists(mazeCells[currentRow, currentColumn].eastWall);
                DestroyWallIfItExists(mazeCells[currentRow, currentColumn + 1].westWall);
                currentColumn++;
            }
            else if (direction == 4 && CellIsAvailable(currentRow, currentColumn - 1))
            {
                // west
                DestroyWallIfItExists(mazeCells[currentRow, currentColumn].westWall);
                DestroyWallIfItExists(mazeCells[currentRow, currentColumn - 1].eastWall);
                currentColumn--;
            }

            if (currentRow != previousRow || currentColumn != previousColumn)
            {
                seed += direction.ToString();
            }

            mazeCells[currentRow, currentColumn].visited = true;
        }
    }
    private void Kill()
    {
        while (RouteStillAvailable(currentRow, currentColumn))
        {
            // int direction = Random.Range (1, 5);
            int direction = ProceduralNumberGenerator.GetNextNumber();

            if (direction == 1 && CellIsAvailable(currentRow - 1, currentColumn))
            {
                // North
                DestroyWallIfItExists(mazeCells [currentRow, currentColumn].northWall);
                DestroyWallIfItExists(mazeCells [currentRow - 1, currentColumn].southWall);
                currentRow--;
            }
            else if (direction == 2 && CellIsAvailable(currentRow + 1, currentColumn))
            {
                // South
                DestroyWallIfItExists(mazeCells [currentRow, currentColumn].southWall);
                DestroyWallIfItExists(mazeCells [currentRow + 1, currentColumn].northWall);
                currentRow++;
            }
            else if (direction == 3 && CellIsAvailable(currentRow, currentColumn + 1))
            {
                // east
                DestroyWallIfItExists(mazeCells [currentRow, currentColumn].eastWall);
                DestroyWallIfItExists(mazeCells [currentRow, currentColumn + 1].westWall);
                currentColumn++;
            }
            else if (direction == 4 && CellIsAvailable(currentRow, currentColumn - 1))
            {
                // west
                DestroyWallIfItExists(mazeCells [currentRow, currentColumn].westWall);
                DestroyWallIfItExists(mazeCells [currentRow, currentColumn - 1].eastWall);
                currentColumn--;
            }

            mazeCells [currentRow, currentColumn].visited = true;
        }

        if (!RouteStillAvailable(currentRow, currentColumn))
        {
            //	Debug.Log ("End of Route");
            Vector3 pos = mazeCells [currentRow, currentColumn].eastWall.transform.position;
            Debug.Log(pos);

            //	Instantiate(deadEndSpawnPos,
            //deadEndSpawnPos.position = mazeCells [currentRow, currentColumn].eastWall.transform.position;
            //Debug.Log (deadEndSpawnPos);
        }
    }
Пример #8
0
    private IEnumerator CoKill()
    {
        // WaitForSeconds delay = new WaitForSeconds(generationStepDelay);
        //int direction = Random.Range (1, 5);
        int direction = ProceduralNumberGenerator.GetNextNumber();

        if (direction == 1 && CellIsAvailable(currentRow - 1, currentColumn))
        {
            // North
            // yield return new WaitForSecondsRealtime(3);
            DestroyWallIfItExists(mazeCells[currentRow, currentColumn].northWall);
            DestroyWallIfItExists(mazeCells[currentRow - 1, currentColumn].southWall);
            currentRow--;
        }


        else if (direction == 2 && CellIsAvailable(currentRow + 1, currentColumn))
        {
            // South
            //yield return new WaitForSecondsRealtime(3);
            DestroyWallIfItExists(mazeCells[currentRow, currentColumn].southWall);
            DestroyWallIfItExists(mazeCells[currentRow + 1, currentColumn].northWall);
            currentRow++;
        }
        else if (direction == 3 && CellIsAvailable(currentRow, currentColumn + 1))
        {
            // east
            //yield return new WaitForSecondsRealtime(3);
            DestroyWallIfItExists(mazeCells[currentRow, currentColumn].eastWall);
            DestroyWallIfItExists(mazeCells[currentRow, currentColumn + 1].westWall);
            currentColumn++;
        }
        else if (direction == 4 && CellIsAvailable(currentRow, currentColumn - 1))
        {
            // west
            //yield return new WaitForSecondsRealtime(3);
            DestroyWallIfItExists(mazeCells[currentRow, currentColumn].westWall);
            DestroyWallIfItExists(mazeCells[currentRow, currentColumn - 1].eastWall);
            currentColumn--;
        }
        mazeCells[currentRow, currentColumn].visited = true;
        // yield break;
        yield return(new WaitForSecondsRealtime(3));
    } // End CoKill()
    private void Kill()
    {
        while (mazeHelp.RouteStillAvailable(currentRow, currentColumn))
        {
            //int direction = UnityEngine.Random.Range(1, 5);
            int direction = ProceduralNumberGenerator.GetNextNumber();

            if (direction == 1 && mazeHelp.CellIsAvailable(currentRow - 1, currentColumn))
            {
                // North
                mazeCells[currentRow, currentColumn].northOpen     = true;
                mazeCells[currentRow - 1, currentColumn].southOpen = true;
                currentRow--;
            }
            else if (direction == 2 && mazeHelp.CellIsAvailable(currentRow + 1, currentColumn))
            {
                // South
                mazeCells[currentRow, currentColumn].southOpen     = true;
                mazeCells[currentRow + 1, currentColumn].northOpen = true;
                currentRow++;
            }
            else if (direction == 3 && mazeHelp.CellIsAvailable(currentRow, currentColumn + 1))
            {
                // east
                mazeCells[currentRow, currentColumn].eastOpen     = true;
                mazeCells[currentRow, currentColumn + 1].westOpen = true;
                currentColumn++;
            }
            else if (direction == 4 && mazeHelp.CellIsAvailable(currentRow, currentColumn - 1))
            {
                // west
                mazeCells[currentRow, currentColumn].westOpen     = true;
                mazeCells[currentRow, currentColumn - 1].eastOpen = true;
                currentColumn--;
            }

            mazeCells[currentRow, currentColumn].visited = true;
        }
    }
Пример #10
0
    private void Kill()
    {
        while (RouteStillAvailable(currentRow, currentColumn))
        {
            int direction = ProceduralNumberGenerator.GetNextNumber(seed);

            if (direction == 1 && CellIsAvailable(currentRow - 1, currentColumn))
            {
                // Up
                if (DestroyWallIfItExists(mazeCells[currentRow, currentColumn].topWall))
                {
                    mazeCells[currentRow, currentColumn].topWall = null;
                }
                if (DestroyWallIfItExists(mazeCells[currentRow - 1, currentColumn].bottomWall))
                {
                    mazeCells[currentRow - 1, currentColumn].bottomWall = null;
                }
                currentRow--;
            }
            else if (direction == 2 && CellIsAvailable(currentRow + 1, currentColumn))
            {
                // Down
                if (DestroyWallIfItExists(mazeCells[currentRow, currentColumn].bottomWall))
                {
                    mazeCells[currentRow, currentColumn].bottomWall = null;
                }
                if (DestroyWallIfItExists(mazeCells[currentRow + 1, currentColumn].topWall))
                {
                    mazeCells[currentRow + 1, currentColumn].topWall = null;
                }
                currentRow++;
            }
            else if (direction == 3 && CellIsAvailable(currentRow, currentColumn + 1))
            {
                // Left
                if (DestroyWallIfItExists(mazeCells[currentRow, currentColumn].rightWall))
                {
                    mazeCells[currentRow, currentColumn].rightWall = null;
                }
                if (DestroyWallIfItExists(mazeCells[currentRow, currentColumn + 1].leftWall))
                {
                    mazeCells[currentRow, currentColumn + 1].leftWall = null;
                }
                currentColumn++;
            }
            else if (direction == 4 && CellIsAvailable(currentRow, currentColumn - 1))
            {
                // Right
                if (DestroyWallIfItExists(mazeCells[currentRow, currentColumn].leftWall))
                {
                    mazeCells[currentRow, currentColumn].leftWall = null;
                }
                if (DestroyWallIfItExists(mazeCells[currentRow, currentColumn - 1].rightWall))
                {
                    mazeCells[currentRow, currentColumn - 1].rightWall = null;
                }
                currentColumn--;
            }

            mazeCells[currentRow, currentColumn].visited = true;
        }
    }
 public override void LoadMaze(string seed)
 {
     loading = true;
     ProceduralNumberGenerator.SetKey(seed);
     HuntAndKill();
 }