コード例 #1
0
 // Use this for initialization
 void Start()
 {
     if (mazeColumns > 0 && mazeRows > 0)
     {
         if (mazeColumns < 30 && mazeRows < 30)            //change maximum size here
         {
             if ((startRow <= mazeRows && startColumn <= mazeColumns && startRow > 0 && startColumn > 0) && (endRow <= mazeRows && endColumn <= mazeColumns && endRow > 0 && endColumn > 0) && (endRow != startRow || endColumn != startColumn))
             {
                 InitializeMaze();
                 MazeAlgorithm ma = new HuntAndKillMazeAlgorithm(mazeCells);
                 ma.CreateMaze();
             }
             else
             {
                 print("I am not like yours to break easily");
             }
         }
         else
         {
             print("I cant handle such big like your mouth");
         }
     }
     else
     {
         print("too small like yours");
     }
 }
コード例 #2
0
    public void StartingGame(int c, int col, int row)
    {
        round      = 1;
        idt        = 0; //tile id
        maxColumns = col;
        maxRows    = row;
        tiles      = new Tile[maxColumns, maxRows];
        size       = 8f;                      // if changed you need to change *8f in cameracontroller panlimit
        idc        = 1;                       //character id
        cMax       = c;                       // max characters
        characters = new List <Character> (); // set character list
        Spawner s = GetComponent <Spawner> ();

        dedCharacters = new List <Character> ();

        //Creating tiles
        for (int x = 0; x < maxColumns; x++)
        {
            for (int z = 0; z < maxRows; z++)
            {
                tiles[x, z] = s.AddTile(idt, x, z, size, maxRows);
                tiles[x, z].GetComponent <TileEvent> ().SetTileEvent(Random.Range(1, 10));
                idt++;
            }
        }
        MazeAlgorithm ma = new HuntAndKillMazeAlgorithm(tiles);

        ma.CreateMaze();
        foreach (Tile t in tiles)
        {
            t.SetVisited(false);
        }
    }
コード例 #3
0
    public void CreateNew()
    {
        //Clear the children list
        children.Clear();

        //Used to destroy any older maze wall and floors when creating a new maze
        for (int i = 0; i < mazeHolder.transform.childCount; i++)
        {
            children.Add(mazeHolder.transform.GetChild(i).gameObject);
        }

        for (int i = 0; i < children.Count; i++)
        {
            Destroy(children[i]);
        }

        //Set the maze rows and columns value to a random value between 4 and 21
        mazeRows    = Random.Range(4, 21);
        mazeColumns = Random.Range(4, 21);

        //Call the InitializeMaze method
        InitializeMaze();

        MazeAlgorithm ma = new HuntAndKillMazeAlgorithm(mazeCells);

        //Call the CreateMaze method from MazeAlgorithm script
        ma.CreateMaze();
    }
コード例 #4
0
    public void GenerateNewMaze()
    {
        foreach (Transform child in parent.transform)
        {
            Destroy(child.gameObject);
        }

        foreach (KeyValuePair <Vector3, GameObject> child in nodeNetwork.nodeReference)
        {
            Destroy(child.Value);
        }
        nodeNetwork.walkablePositions = new Dictionary <Vector3, bool>();
        nodeNetwork.nodeReference     = new Dictionary <Vector3, GameObject>();

        Destroy(GameObject.Find("Player"));
        Debug.Log("CreatePlayer");
        var newPlayer = Instantiate(playerPrefab);

        newPlayer.name = "Player";

        mazeColumns = (int)widthSlider.value;
        mazeRows    = (int)heightSlider.value;

        InitializeMaze();
        MazeAlgorithm ma = new HuntAndKillMazeAlgorithm(mazeCells);

        ma.CreateMaze();
    }
コード例 #5
0
    public void CreateNew()
    {
        //Clear the children list
        children.Clear();

        //Used to destroy any older maze wall and floors when creating a new maze
        for (int i = 0; i < mazeHolder.transform.childCount; i++)
        {
            children.Add(mazeHolder.transform.GetChild(i).gameObject);
        }

        for (int i = 0; i < children.Count; i++)
        {
            Destroy(children[i]);
        }

        //Values for mazeRows and mazeColumns parsed from the input fields
        mazeRows = int.Parse(rowIF.text);
        mazeColumns = int.Parse(colIF.text);

        //Call the InitializeMaze method
        InitializeMaze();

        MazeAlgorithm ma = new HuntAndKillMazeAlgorithm(mazeCells);

        //Call the CreateMaze method from the MazeAlgoritm variable
        ma.CreateMaze();

        //Set timeScale to 1 to resume game playing at real time
        Time.timeScale = 1f;
        //Set the inputPanel gameObject to inactive so the player doesn't see it
        inputPanel.SetActive(false);
        //Set the gamePanel gameObject to active for the player to see
        gamePanel.SetActive(true);
    }
コード例 #6
0
    // Use this for initialization
    void Start()
    {
        InitializeMaze();
        character = Instantiate(character, new Vector3(66, -2, 102), Quaternion.identity);
        MazeAlgorithm ma = new HuntAndKillMazeAlgorithm(mazeCells);

        ma.CreateMaze();
    }
コード例 #7
0
    // Use this for initialization
    void Start()
    {
        InitializeMaze();

        MazeAlgorithm ma = new HuntAndKillMazeAlgorithm(mazeCells);

        ma.CreateMaze();
    }
コード例 #8
0
ファイル: MazeGenerator.cs プロジェクト: siq10/agents_maze
    // Start is called before the first frame update
    void Start()
    {
        Debug.Log("I am alive!");

        InitializeMaze();
        MazeAlgorithm ma = new HuntAndKillMazeAlgorithm(mazeCells);

        ma.CreateMaze();
    }
コード例 #9
0
ファイル: MazeLoader.cs プロジェクト: CastBart/WorkExperience
    // Use this for initialization
    void Start()
    {
        InitializeMaze();

        MazeAlgorithm ma = new HuntAndKillMazeAlgorithm(mazeCells);

        ma.CreateMaze();
        present.transform.position = new Vector3(6 * (mazeRows - 1), -2, 6 * (mazeColumns - 1));
    }
コード例 #10
0
ファイル: MapLoader.cs プロジェクト: YannDesjardins/IFT-JV
    // Use this for initialization
    void Start()
    {
        particleSystemPool = GameObject.FindGameObjectWithTag("MapLoader").GetComponent <ParticleSystemPool>();
        numberGenerator    = new PseudoRandomNumberGenerator(StaticGameStats.Seed);
        Initialize();
        HuntAndKillMazeAlgorithm ma = new HuntAndKillMazeAlgorithm(cells, StaticGameStats.Seed);

        ma.CreateMap();
    }
コード例 #11
0
ファイル: MazeLoader.cs プロジェクト: maahnaaz/Maze-Runner
    // Use this for initialization
    void Start()
    {
        allcoin.text  = " / " + coinnumber.ToString();
        NumberOfcoins = coinnumber;
        timeBycoins   = mazeRows;
        InitializeMaze();
        MazeAlgorithm ma = new HuntAndKillMazeAlgorithm(mazeCells);

        ma.CreateMaze();
    }
コード例 #12
0
    public void LoadMaze()
    {
        InitializeMaze();

        MazeAlgorithm ma = new HuntAndKillMazeAlgorithm(mazeCells);

        ma.CreateMaze();

        ma.ResetVisitedValues();
    }
コード例 #13
0
    // Use this for initialization
    void Start()
    {
        InitializeMaze();

        MazeAlgorithm ma = new HuntAndKillMazeAlgorithm(mazeCells);

        ma.CreateMaze();
        spawnObjects();
        first = true;
    }
コード例 #14
0
ファイル: MazeLoader.cs プロジェクト: juhomer/XRMaze
    //public static List<int> KillKeys = new List<int>();
    //public static List<int> DestroyKeys = new List<int>();
    //public List<int> KillKeys2 = new List<int>();
    //public List<int> DestroyKeys2 = new List<int>();

    //Is the player ar or vr?
    //ar = maze is randomized
    //vr = maze is created with ar KillKeys and DestroyKeys values

    //public static bool arPlayer = true;

    // Use this for initialization
    void Awake()
    {
        randomDirection           = Random.Range(1, 5);
        randomRemovableWallNumber = Random.Range(0, Mathf.Min(mazeRows, mazeColumns));

        InitializeMaze();

        MazeAlgorithm ma = new HuntAndKillMazeAlgorithm(mazeCells);

        ma.CreateMaze();
    }
コード例 #15
0
    // Use this for initialization
    public void GenerateMaze()
    {
        ClearMaze();
        InitializeMaze();

        MazeAlgorithm ma = new HuntAndKillMazeAlgorithm(mazeCells);

        ma.CreateMaze();

        Instantiate(playerPrfab, GameObject.Find("Floor 0,0").transform.position, Quaternion.identity);
    }
コード例 #16
0
    // Use this for initialization
    void Start()
    {
        InitializeMaze();

        MazeAlgorithm ma = new HuntAndKillMazeAlgorithm(mazeCells);

        ma.CreateMaze();

        //  GameObject Player = Random.Range(0,100)>Random.Range(0,100) ? Instantiate (player, new Vector3 (Random.Range(0,100)>Random.Range(0,100) ? -10 : 210, 3, Random.Range(-10,221) ), Quaternion.identity) as GameObject : Instantiate (player, new Vector3 (Random.Range(-10,221), 3, Random.Range(0,100)>Random.Range(0,100) ? -10 : 210 ), Quaternion.identity) as GameObject ;
        //  GameObject Player2 = Random.Range(0,100)>Random.Range(0,100) ? Instantiate (player2, new Vector3 (Random.Range(0,100)>Random.Range(0,100) ? -10 : 210, 3, Random.Range(-10,221) ), Quaternion.identity) as GameObject : Instantiate (player2, new Vector3 (Random.Range(-10,221), 3, Random.Range(0,100)>Random.Range(0,100) ? -10 : 210 ), Quaternion.identity) as GameObject ; //player2
    }
コード例 #17
0
    // Use this for initialization
    void Start()
    {
        //BenchMarking
        Stopwatch sw = Stopwatch.StartNew();

        GenerateMaze();
        MazeGen mg = new HuntAndKillMazeAlgorithm(mazeCells);

        mg.BuildMaze();

        sw.Stop();
        UnityEngine.Debug.Log("Debug BenchMark :" + sw.ElapsedMilliseconds + "ms");
    }
コード例 #18
0
ファイル: MazeLoader.cs プロジェクト: jackt0310/Maze-Explorer
    // Use this for initialization
    void Start()
    {
        //create maze grid
        InitializeMaze();

        if (!arenaMode)
        {
            // call hunt and kill algorithm to knock down random walls and create maze
            MazeAlgorithm ma = new HuntAndKillMazeAlgorithm(mazeCells);
            // create maze from maze algorithm
            ma.CreateMaze();
        }
    }
コード例 #19
0
    public void Load(string seed)
    {
        // Create a full maze grid
        InitializeMaze();

        // Create a maze by removing cells based on the seed given
        MazeAlgorithm ma = new HuntAndKillMazeAlgorithm(mazeCells);

        ma.LoadMaze(seed);

        // Set certain cells to contain powerups or be the start/end cell
        SetCellTypes(true);
    }
コード例 #20
0
    public string Create()
    {
        // Create a full maze grid
        InitializeMaze();

        // Create a maze by removing walls and save the seed
        MazeAlgorithm ma   = new HuntAndKillMazeAlgorithm(mazeCells);
        string        seed = ma.CreateMaze();

        // Set certain cells to contain powerups or be the start/end cell
        SetCellTypes(false);

        return(seed);
    }
コード例 #21
0
    // Use this for initialization
    void Start()
    {
        CreateBackground();
        InitializeMaze();
        MazeAlgorithm ma = new HuntAndKillMazeAlgorithm(mazeCells);

        // MazeAlgorithm ma = new DFSMazeAlgorithm(mazeCells);
        ma.CreateMaze();

        // activate player GameObject
        GameObject player = GameObject.FindGameObjectWithTag("Player");

        player.GetComponent <PlayerController>().Initialize();
    }
コード例 #22
0
    void Start()
    {
        // Initialize the maze by building the cells
        InitializeMaze();

        // Carve a path out of the cells to create a maze
        MazeAlgorithm ma = new HuntAndKillMazeAlgorithm(mazeCells);

        ma.CreateMaze();

        // Update the nav mesh
        mazeChanged = true;

        // Invoke the method that changes the different sections of the maze
        InvokeRepeating("BuildNewMazeSection", 1.0f, 1.0f);
    }
コード例 #23
0
    // Use this for initialization
    void Start()
    {
        //Set the maze rows and columns value to a random value between 4 and 21
        mazeRows    = Random.Range(4, 21);
        mazeColumns = Random.Range(4, 21);

        //Call the InitializeMaze method
        InitializeMaze();

        MazeAlgorithm ma = new HuntAndKillMazeAlgorithm(mazeCells);

        //Call the CreateMaze method from MazeAlgorithm script
        ma.CreateMaze();

        //Get the Rigidbody component from the player
        playerRB = player.GetComponent <Rigidbody>();
    }
コード例 #24
0
    // Use this for initialization
    void Start()
    {
        //System.Console.WriteLine(Global.keycounter);
        Camera.main.clearFlags = CameraClearFlags.Skybox;
        Camera.main.rect       = new Rect(0f, 0f, 1f, 1f);
        InitializeMaze();
        MazeAlgorithm ma = new HuntAndKillMazeAlgorithm(mazeCells);

        ma.CreateMaze();
        Camera.main.clearFlags = CameraClearFlags.Depth;
        Camera.main.rect       = new Rect(0f, 0f, 0.5f, 0.5f);

        //add keys
        InitializeKey();
        InitializeStairs();
        InitializeStairsExit();
        InitializeTerrian();
        GameObject player = Instantiate(Player, new Vector3(34.5f, 88f, -136f), Quaternion.identity) as GameObject;

        player.name = "player";
        InitializeMazecells();
    }
コード例 #25
0
    // Use this for initialization
    void Start()
    {
        Cursor.visible = false;

        // initializing maze

        InitializeMaze();

        // building the maze with the hunt and kill algorithm
        MazeAlgorithm ma = new HuntAndKillMazeAlgorithm(mazeCells);

        ma.CreateMaze();

        // building the navmesh for the navAgent
        surface.BuildNavMesh();

        // instantiating the endobject at endpoint
        endObject = Instantiate(endObject, endPoint, Quaternion.identity);

        // giving the endobject audio source to the player
        playerHelp = player.GetComponent <GettingHelp>();
        playerHelp.setEnding(endObject.GetComponent <AudioSource>());
    }
コード例 #26
0
 void mazeGenerate()
 {
     HuntAndKillMazeAlgorithm ma = new HuntAndKillMazeAlgorithm(mazeCells);
 }
    public static void CreateMaze(MazeCell[,] mazeCells, string seed)
    {
        MazeAlgorithm ma = new HuntAndKillMazeAlgorithm(mazeCells, seed);

        ma.CreateMaze();
    }
コード例 #28
0
    /**
     * Reset the map and build a new maze.
     */
    private void BuildNewMazeSection()
    {
        // Exit if the game is paused
        if (PauseMenu.isPaused)
        {
            return;
        }

        // Check if the remaining time is divisible by 5 by checking the last digit (using mod causes this to be true longer than we want for some reason, so we do it this way)
        bool correctInterval = timeController.timeLeft.ToString().EndsWith("5") || timeController.timeLeft.ToString().EndsWith("0");

        // Don't build new sections while time is reversing or the time remaining isn't divisible by 5
        if (timeController.isReversing || !correctInterval)
        {
            return;
        }

        // Copy the maze layout
        CopyCurrentMazeLayout();

        // Randomly choose a section of the maze that the player ISN'T in to change
        int section = UnityEngine.Random.Range(1, 5);

        switch (section)
        {
        case 1:
            if (playerSectionTag == "SECTION ONE")
            {
                BuildNewMazeSection();
                break;
            }
            GenerateMazeSection(0, 0, 6, 9, "SectionOne");
            break;

        case 2:
            if (playerSectionTag == "SECTION TWO")
            {
                BuildNewMazeSection();
                break;
            }
            GenerateMazeSection(0, 9, 6, 18, "SectionTwo");
            break;

        case 3:
            if (playerSectionTag == "SECTION THREE")
            {
                BuildNewMazeSection();
                break;
            }
            GenerateMazeSection(6, 0, 12, 9, "SectionThree");
            break;

        case 4:
            if (playerSectionTag == "SECTION FOUR")
            {
                BuildNewMazeSection();
                break;
            }
            GenerateMazeSection(6, 9, 12, 18, "SectionFour");
            break;
        }

        // Carve a path out of the cells to create a maze
        MazeAlgorithm ma = new HuntAndKillMazeAlgorithm(mazeCells);

        ma.CreateMaze();

        // Update the nav mesh
        mazeChanged = true;
    }