public void ApplyStampCollection(StampCollection stampCollection) { if (stampCollection != null) //May not have a stamp collection to apply to this topography { stampCollection.ApplyStamp(marchingGrid, oreGrid); destructableArray = oreGrid.GetDestructableArray(); //Refresh the stored destructable array marchingGrid.InterpolateAll(); } }
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> (); }