public void generateBuilding(int index, int x, int y) { Color c = inputMap.GetPixel(x, y); if (c.grayscale != 0) { GameObject house = Instantiate(houseBase, new Vector3(x * houseWidth + 1, 0, y * houseHeight + 1), Quaternion.identity); stockComponent = house.GetComponent <Demo.Stock>(); parameComponent = house.GetComponent <Demo.BuildingParameters>(); stockComponent.Width = houseWidth - 1; stockComponent.Depth = houseHeight - 1; parameComponent.maxHeight = (int)(c.grayscale * 256f) / 20; stockComponent.Generate(); } }
void CreateNextPart() { if (newWidth <= 0 || newDepth <= 0) { return; } BuildingParameters param = (BuildingParameters)parameters; double randomValue = param.Rand.NextDouble(); if (randomValue < param.RoofContinueChance || HeightRemaining <= 0) // continue with the roof { Roof nextRoof = CreateSymbol <Roof>("roof"); nextRoof.Initialize(newWidth, newDepth, HeightRemaining); nextRoof.Generate(param.buildDelay); } else // continue with a stock { Stock nextStock = CreateSymbol <Stock>("stock"); nextStock.Initialize(newWidth, newDepth, HeightRemaining); nextStock.Generate(param.buildDelay); } }
protected override void Execute() { GameObject[] walls = new GameObject[4]; for (int i = 0; i < 4; i++) { Vector3 localPosition = new Vector3(); switch (i) { case 0: localPosition = new Vector3(-(Width - 1) * 0.5f, 0, 0); // left break; case 1: localPosition = new Vector3(0, 0, (Depth - 1) * 0.5f); // back break; case 2: localPosition = new Vector3((Width - 1) * 0.5f, 0, 0); // right break; case 3: localPosition = new Vector3(0, 0, -(Depth - 1) * 0.5f); // front break; } Row newRow = CreateSymbol<Row>("wall", localPosition, Quaternion.Euler(0, i * 90, 0), transform); if (HeightRemaining != param.maxHeight) { newRow.Initialize( i % 2 == 1 ? Width : Depth, param.wallStyle, param.wallPattern ); Debug.Log("initializing normal wall"); } else { newRow.Initialize( i % 2 == 1 ? Width : Depth, param.wallStyle, param.doorStyle, param.wallPattern ); Debug.Log("initializing doors"); } newRow.Generate(); } double randomValue = param.Rand.NextDouble(); if (HeightRemaining > 0 && randomValue < param.StockContinueChance) { Stock nextStock = CreateSymbol<Stock>("stock", new Vector3(0, 1, 0), Quaternion.identity, transform); nextStock.Initialize(Width, Depth, HeightRemaining - 1); nextStock.Generate(param.buildDelay); } else { Roof nextRoof = CreateSymbol<Roof>("roof", new Vector3(0, 1, 0), Quaternion.identity, transform); nextRoof.Initialize(Width, Depth, HeightRemaining - 1); nextRoof.Generate(param.buildDelay); } }