Exemple #1
0
        public void Generate(LabyrinthBuilder builder)
        {
            bool isSolvable = false;

            while (!isSolvable)
            {
                builder.InitiateGrid();
                builder.AddObjects();
                builder.AddPlayer();

                isSolvable = builder.TestIfSolvable();
            }
        }
        public void Generate(LabyrinthBuilder builder)
        {
            bool isSolvable = false;

            while(!isSolvable)
            {
                builder.InitiateGrid();
                builder.AddObjects();
                builder.AddPlayer();

               isSolvable = builder.TestIfSolvable();
            }
        }
Exemple #3
0
    public void Initialise(float vesselSize)
    {
        this.vesselRadius = vesselSize / 2f;

        //Ensure enough chunks to contain vessel. Could add a buffer to build above this level.
        numChunks    = (int)Mathf.Ceil(vesselSize / chunkSize);
        worldSizeX   = numChunks * chunkSize;
        worldSizeY   = numChunks * chunkSize;
        vesselCenter = new Vector3((float)worldSizeX / 2f, (float)worldSizeY / 2f, 0f);

        GameObject marchingGridGO = Instantiate(marchingGridPrefab, this.transform.position, Quaternion.identity) as GameObject;

        marchingGrid = marchingGridGO.GetComponent <MarchingSquaresGrid> () as MarchingSquaresGrid;
        marchingGrid.Initialise(worldSizeX, worldSizeY, isSolid);

        oreGrid = new OreGrid();
        oreGrid.GenerateMap(worldSizeX, worldSizeY);

        destructableArray = oreGrid.GetDestructableArray();

        LabyrinthBuilder labyrinthBuilder = GetComponentInChildren <LabyrinthBuilder> () as LabyrinthBuilder;

        if (labyrinthBuilder != null)
        {
            labyrinthBuilder.GenerateLabyrinth();
        }

        rootStampCollection = this.transform.GetComponentInChildren <StampCollection> () as StampCollection;
        ApplyStampCollection(rootStampCollection);

        renderChunkPool                = new Stack <RenderChunk> ();
        renderChunkUpdateQueue         = new Queue <RenderChunk> ();
        renderChunkPriorityUpdateQueue = new Queue <RenderChunk> ();
        renderChunkArray               = new RenderChunk[numChunks, numChunks];

        collisionChunkPool                = new Stack <CollisionChunk> ();
        collisionChunkUpdateQueue         = new Queue <CollisionChunk> ();
        collisionChunkPriorityUpdateQueue = new Queue <CollisionChunk> ();
        collisionChunkArray               = new CollisionChunk[numChunks, numChunks];

        this.faceGO = Instantiate(facePrefab, new Vector3(0f, 0f, 0f), Quaternion.identity) as GameObject;

        this.interiorGO = Instantiate(interiorPrefab, new Vector3(0f, 0f, 0f), Quaternion.identity) as GameObject;

        renderFoci = new List <GameObject> ();
    }