Example #1
0
    public static void Generate()
    {
        Debug.Log("Generating Level...");

        Clear();

        int height = Random.Range(8, 12);
        int width  = Random.Range(8, 12);

        height <<= 1;
        width  <<= 1;

        height++;
        width++;

        Walls = null;

        Walls = new GameObject[width, height];

        Create.Reset();

        int count = Height * Width * 10;

        Create.Border();

        for (int i = 0; i < count; i++)
        {
            Create.Room();
        }

        for (int i = 0; i < count; i++)
        {
            Create.Hall();
        }

        for (int i = 0; i < count; i++)
        {
            Create.Pillar();
        }

        Create.Item();
        Create.Item();

        Create.Player();

        Create.Enemy();
        Create.Enemy();
        Create.Enemy();

        if (Create.Exit() == null)
        {
            Debug.Log("Rejecting level!");
            Generate();
            return;
        }

        Paint.Floors();
        Paint.Walls();

        // Pathfinder.Cache.PreCache ();

        if (Camera.main == null)
        {
            return;
        }

        Camera.main.backgroundColor = Color.black;
    }