Esempio n. 1
0
    void Start()
    {
        GameObject player = GameObject.FindWithTag("Player");

        if (mg == null)
        {
            mg = HexMazeGenerator.GetInstance();
        }
        mg.init(W, H);
        mg.maxVisits = complexity;
        mg.BuildMaze(UnityEngine.Random.Range(1, W - 1), UnityEngine.Random.Range(1, H - 1));
        DrawMaze();

        player.transform.position = GetSpawnPosition();

        if (FullScreen)
        {
            Destroy(Camera.main.GetComponent <CameraController>());
            Camera.main.transform.position = new Vector3Int(W / 2, H / 2, -10);
            Camera.main.orthographicSize   = (W > H ? H : W) / 2 + 1;
        }
        aiList = new List <GameObject>();
        for (int i = 0; i < numEnemies; i++)
        {
            GameObject e = GameObject.Instantiate(ai);
            e.transform.position = mg.GetSpawnPosition();
            aiList.Add(e);
            e.name = "AI";
        }
        for (int i = 0; i < numTreasures; i++)
        {
            GameObject g = GameObject.Instantiate(treasure);
            g.name = "Treasure";
        }
    }
Esempio n. 2
0
 public static HexMazeGenerator GetInstance()
 {
     if (mg == null)
     {
         mg = new HexMazeGenerator();
     }
     return(mg);
 }
Esempio n. 3
0
 HexMazeGenerator()
 {
     mg = this;
 }
Esempio n. 4
0
 public HexMazeGenerator(int W, int H)
 {
     mg = this;
     init(W, H);
 }