Beispiel #1
0
    public void GenerateNewMaze(int sizeRows, int sizeCols)
    {
        if (sizeRows % 2 == 0 && sizeCols % 2 == 0)
        {
            Debug.LogError("Odd numbers work better for dungeon size.");
        }

        data = dataGenerator.FromDimensions(sizeRows, sizeCols);

        DisplayMaze();
    }
Beispiel #2
0
    public void GenerateNewMaze(int sizeRows, int sizeCols,
                                TriggerEventHandler startCallback = null, TriggerEventHandler goalCallback = null)
    {
        //Генерация стен
        // Предупреждение о том, что лучше использовать нечетные числа для генерации лабиринта
        if (sizeRows % 2 == 0 && sizeCols % 2 == 0)
        {
            Debug.LogError("Odd numbers work better for dungeon size.");
        }

        DisposeOldMaze();

        data = dataGenerator.FromDimensions(sizeRows, sizeCols);

        FindStartPosition();
        FindGoalPosition();

        // store values used to generate this mesh
        hallWidth  = meshGenerator.width;
        hallHeight = meshGenerator.height;

        DisplayMaze();

        PlaceStartTrigger(startCallback);
        PlaceGoalTrigger(goalCallback);
    }
Beispiel #3
0
    public void GenerateNewMaze(int maxRows, int maxCols,
                                TriggerEventHandler startCallback = null, TriggerEventHandler goalCallback = null,
                                TriggerEventHandler gunCallback   = null)
    {
        if (maxCols % 2 == 0 || maxRows % 2 == 0)
        {
            //This is because the maze is surrounded by walls
            Debug.LogWarning("Odd numbers work better for maze size");
        }
        DisposeOldMaze();
        data = dataGenerator.FromDimensions(maxRows, maxCols);
        FindStartPosition();
        FindGoalPosition();

        hallHeight = floor.GetComponentInChildren <MeshRenderer>().bounds.size[0];
        hallWidth  = floor.GetComponentInChildren <MeshRenderer>().bounds.size[1];

        GlobalVars.hallHeight = hallHeight;
        GlobalVars.hallWidth  = hallWidth;

        DisplayMaze();

        PlaceStartTrigger(startCallback);
        PlaceGoalTrigger(goalCallback);
        PlaceGunPickup(gunCallback);
        PlaceLandmarks();

        GlobalVars.freeSpots = freeSpots;
    }
Beispiel #4
0
    public void GenerateNewMaze(int sizeRows, int sizeCols,
                                TriggerEventHandler startCallback = null, TriggerEventHandler goalCallback = null)
    {
        if (sizeRows % 2 == 0 && sizeCols % 2 == 0)
        {
            Debug.LogError("Odd numbers work better for dungeon size.");
        }

        DisposeOldMaze();

        data = dataGenerator.FromDimensions(sizeRows, sizeCols);



        // store values used to generate this mesh
        hallWidth  = meshGenerator.width;
        hallHeight = meshGenerator.height;

        Debug.Log("HallWidth" + hallWidth);
        Debug.Log("HallHeight" + hallHeight);

        FindStartPosition1();
        PlaceStartTrigger(startCallback);
        FindStartPosition2();
        PlaceStartTrigger(startCallback);
        FindStartPosition3();
        PlaceStartTrigger(startCallback);
        FindStartPosition4();
        PlaceStartTrigger(startCallback);
        FindGoalPosition();
        DisplayMaze();
        PlaceGoalTrigger(goalCallback);
    }
Beispiel #5
0
    public void GenerateNewMaze(int sizeRows, int sizeCols,
                                TriggerEventHandler startCallback = null, TriggerEventHandler goalCallback = null, TriggerEventHandler healthCallback = null)
    {
        if (sizeRows % 2 == 0 && sizeCols % 2 == 0)
        {
            Debug.LogError("Odd numbers work better for dungeon size.");
        }

        DisposeOldMaze();

        data = dataGenerator.FromDimensions(sizeRows, sizeCols);

        FindStartPosition();
        FindGoalPosition();
        FindHealthPosition();

        // store values used to generate this mesh
        hallWidth  = 1;
        hallHeight = 1;

        DisplayMaze();

        PlaceStartTrigger(startCallback);
        PlaceGoalTrigger(goalCallback);
        PlaceHealthTrigger(healthCallback);

        FindAndPlaceEnemies();
    }
Beispiel #6
0
    // parameters data taken form gamecontroller
    public void GenerateNewMaze(int sizeRows, int sizeCols,
                                TriggerEventHandler startCallback = null, TriggerEventHandler goalCallback = null)
    {
        // if the ints are divisible by 2, log an error & reduce by one to prevent errors
        if (sizeRows % 2 == 0)
        {
            sizeRows--;
            Debug.Log(sizeRows + " Odd numbers work better for dungeon size.");
        }
        if (sizeCols % 2 == 0)
        {
            sizeCols--;
            Debug.Log(sizeCols + " Odd numbers work better for dungeon size.");
        }
        // run func
        DisposeOldMaze();
        // data is equal to the fromdimensions func output with the sizerows and sizecols parameters from gamecontroller
        data = dataGenerator.FromDimensions(sizeRows, sizeCols);

        FindStartPosition();
        FindGoalPosition();

        // store values used to generate this mesh
        hallWidth  = meshGenerator.width;
        hallHeight = meshGenerator.height;
        // run function that adds colliders, meshrenderers etc to new gameobjects
        DisplayMaze();

        PlaceStartTrigger(startCallback);
        PlaceGoalTrigger(goalCallback);
    }
    public void GenerateNewMaze(int rows, int columns, float trapChance,
                                TriggerEventHandler startCallback = null, TriggerEventHandler goalCallback = null)
    {
        if (rows % 2 == 0 && columns % 2 == 0)
        {
            Debug.LogError("Use odd numbers for dungeon size.");
        }

        bool valid = false;

        while (!valid)
        {
            DestroyPrevMaze();

            data = mazeGenerator.FromDimensions(rows, columns, trapChance);

            GenerateStart();
            GenerateGoal();

            valid = mazeGenerator.validMaze(startRow, startColumn, goalRow, goalColumn);
            //Debug.Log("valid: " + valid);
        }

        Debug.Log("Maze Start!");

        corridorWidth  = meshGenerator.width;
        corridorHeight = meshGenerator.height;

        DisplayMaze();

        PlaceStartTrigger(startCallback);
        PlaceGoalTrigger(goalCallback);
    }
 /*
  * Method which generates a new maze
  * @param rows Heihgt of the new maze
  * @param columns Width of the new maze
  */
 public void GenerateNewMaze(int rows, int columns)
 {
     if (rows % 2 == 0 && columns % 2 == 0)
     {
         Debug.LogError("Odd numbers work better for dungeon size.");
     }
     mazeData = dataGenerator.FromDimensions(rows, columns);
     DisplayMaze();
 }
    public void GenerateMaze(int sizeRows, int sizeCols)
    {
        if (sizeRows % 2 == 0 && sizeCols % 2 == 0)
        {
            Debug.LogError("Odd numbers work better for dungeon size");
        }

        dataGenerator.emptyPositions    = emptyPositions;
        dataGenerator.obstaclePositions = obstaclePositions;
        data = dataGenerator.FromDimensions(sizeRows, sizeCols);
        DisplayMaze();
    }
    public void GenerateNewMaze(int sizeRows, int sizeCols)
    {
        if (sizeRows % 2 == 0 && sizeCols % 2 == 0)
        {
            Debug.LogError("Odd numbers work better for dungeon size.");
        }

        data = dataGenerator.FromDimensions(sizeRows, sizeCols);

        player.GetComponent <UnityStandardAssets.Characters.FirstPerson.FirstPersonController>().m_WalkSpeed = player.GetComponent <UnityStandardAssets.Characters.FirstPerson.FirstPersonController>().m_StartSpeed;

        FindStartPosition();
        FindGoalPosition();
        DisplayMaze();
    }
    public void GenerateNewMaze(int sizeRows, int sizeCols)
    {
        if (sizeRows % 2 == 0 && sizeCols % 2 == 0)
        {
            Debug.LogError("Odd numbers work better for dungeon size.");
        }

        Data     = dataGenerator.FromDimensions(sizeRows, sizeCols);
        CopyData = Data;

        GeneratorLists();                          // генерируем списки

        DisplayMaze(sizeRows, sizeCols, Data);     // отображаем лабиринт
        FindRandomPosition(sizeList, listPrefabs); // раскидываем игрока, ключи, выход и монстров
        FindRandomPosition(amountGold, listGold);  // раскидываем золото
    }
    public void GenerateNewMaze(int sizeRows, int sizeCols,
                                TriggerEventHandler startCallback = null, TriggerEventHandler goalCallback = null)
    {
        DisposeOldMaze();

        data = dataGenerator.FromDimensions(sizeRows, sizeCols);

        FindStartPosition();
        FindGoalPosition();

        hallWidth  = meshGenerator.width;
        hallHeight = meshGenerator.height;

        DisplayMaze();

        PlaceStartTrigger(startCallback);
        PlaceGoalTrigger(goalCallback);
    }
    public void GenerateNewMaze(List <int> constrMaze)
    {
        listDeletedObject = new List <GameObject>();
        //получение данных
        sizeRows       = constrMaze[0];
        sizeCols       = constrMaze[1];
        amountKeys     = constrMaze[2];
        amountMonster  = constrMaze[3];
        amountMonster1 = constrMaze[4];
        amountMonster2 = constrMaze[5];


        Data     = dataGenerator.FromDimensions(sizeRows, sizeCols);                            //генерация лабиринта
        CopyData = Data;

        amountGold  = (sizeRows + sizeCols) / 2;                                                // определяем количество золота
        minDistance = amountGold / 2;

        GeneratorListMonster();                                                                 // генерируем список монстров

        int[] posExit = FindRandomPosition();
        CopyData[posExit[0], posExit[1]] = 2;                                                   //ставим выход
        int[] posPlayer = FindRandomPositionDistanceTarget(posExit, minDistance);
        CopyData[posPlayer[0], posPlayer[1]] = 3;                                               //ставим игрока
        for (int i = 0; i < amountKeys; i++)
        {
            int[] posKey = FindRandomPositionDistanceTarget(posExit, minDistance - 2);
            CopyData[posKey[0], posKey[1]] = 4;                                                 //раскидываем ключи
        }
        for (int i = 0; i < listMonster.Length; i++)
        {
            int[] posMonster = FindRandomPositionDistanceTarget(posPlayer, minDistance - 2);
            CopyData[posMonster[0], posMonster[1]] = listMonster[i];                            //ставим монстров
        }
        for (int i = 0; i < amountGold; i++)
        {
            int[] posGold = FindRandomPosition();
            CopyData[posGold[0], posGold[1]] = 8;                                               //раскидываем золото
        }

        DisplayMaze(CopyData);      // отображаем лабиринт
    }
Beispiel #14
0
    public void GenerateNewMaze(int sizeCols, int sizeRows,
                                TriggerEventHandler startCallback = null, TriggerEventHandler goalCallback = null)
    {
        if (sizeRows % 2 == 0 && sizeCols % 2 == 0)
        {
            Debug.LogError("Odd numbers work better for dungeon size.");
        }

        // DisposeOldMaze();

        data = dataGenerator.FromDimensions(sizeRows, sizeCols);

        // FindStartPosition();
        // FindGoalPosition();

        DisplayMaze();

        // PlaceStartTrigger(startCallback);
        // PlaceGoalTrigger(goalCallback);
    }
    public void GenerateNewMaze(int sizeRows, int sizeCols, bool isFirstTime)
    {
        DisposeOldMaze();

        data = dataGenerator.FromDimensions(sizeRows, sizeCols);
        if (isFirstTime)
        {
            FindStartPosition();
        }
        else
        {
            startRow = goalRow;
            startCol = goalCol;
        }
        FindGoalPosition();

        // store values used to generate this mesh
        //hallWidth = meshGenerator.width;
        //hallHeight = meshGenerator.height;

        DisplayMaze();
    }
Beispiel #16
0
    public void GenerateNewMaze(int sizeRows, int sizeCols, TriggerEvent endCallback = null, TriggerEvent startCallback = null)
    {
        if (sizeRows % 2 == 0 && sizeCols % 2 == 0)
        {
            Debug.LogError("Odd numbers work better for dungeon size.");
        }

        DisposeOldMaze();                                        //removes the old mazes so a new one is generated each time

        data = dataGenerator.FromDimensions(sizeRows, sizeCols); //generates the layout based on given dimensions

        FindStartPosition();
        FindGoalPosition();

        // store values used to generate this mesh
        hallWidth  = meshGenerator.width;
        hallHeight = meshGenerator.height;

        DisplayMaze();//generates maze in the scene
        PlaceStart(startCallback);
        PlaceEnd(endCallback);
    }
Beispiel #17
0
    public GameObject GenerateNewMaze(int sizeRows, int sizeCols)
    {
        if (sizeRows % 2 == 0 && sizeCols % 2 == 0)
        {
            Debug.LogError("Odd numbers work better for dungeon size.");
        }

        DisposeOldMaze();

        data = dataGenerator.FromDimensions(sizeRows, sizeCols);
        // data[0,1] = 0;
        // data[12, 13] = 0;
        FindStartPosition();
        FindGoalPosition();

        // store values used to generate this mesh
        hallWidth  = meshGenerator.width;
        hallHeight = meshGenerator.height;

        DisplayMaze();
        return(maze);
    }
    public void GenerateNewMaze(int sizeRows, int sizeCols,
                                TriggerEventHandler startCallback = null, TriggerEventHandler goalCallback = null)
    {
        if (sizeRows % 2 == 0 && sizeCols % 2 == 0)
        {
            Debug.LogError("Odd numbers work better for dungeon size.");//Для размеров лучше использовать нечётные числа, потому что сгенерированный лабиринт будет окружён стенами.
        }

        DisposeOldMaze();                                        //Вызываем метод DisposeOldMaze() для удаления лабиринта

        data = dataGenerator.FromDimensions(sizeRows, sizeCols); //Вызываем FromDimensions() в GenerateNewMaze() передавая размер сетки и сохраняя получившиеся данные.

        FindStartPosition();                                     //находим стартовую позицию для игрока
        FindGoalPosition();                                      //находим позицию для цели

        // store values used to generate this mesh
        hallWidth  = meshGenerator.width;
        hallHeight = meshGenerator.height;

        DisplayMaze();                    //Вызываем метод DisplayMaze() для отображения лабиринта

        PlaceStartTrigger(startCallback); //устанавливаем стартовые координаты игрока
        PlaceGoalTrigger(goalCallback);   //устанавливаем координаты цели
    }
Beispiel #19
0
 //Takes the data from the MazeDataGenerator, and uses it to generate a maze. The DisplayMaze function makes it visual.
 public void GenerateNewMaze(int sizeRows, int sizeCols)
 {
     data = dataGen.FromDimensions(sizeRows, sizeCols);
     DisplayMaze();
 }
 /// <summary>
 /// Method used to Generate the random maze considering the size given in parameters
 /// </summary>
 /// <param name="sizeRows"></param>
 /// <param name="sizeCols"></param>
 public void GenerateNewMaze(int sizeRows, int sizeCols)
 {
     data = dataGenerator.FromDimensions(sizeRows, sizeCols);
     BuildMaze();
 }