protected override void Execute() { // Create four walls: 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; } SimpleRow newRow = CreateSymbol <SimpleRow>("wall", localPosition, Quaternion.Euler(0, i * 90, 0)); newRow.Initialize(i % 2 == 1 ? Width : Depth, wallStyle); newRow.Generate(); } // Continue with a stock or with a roof (random choice): float randomValue = Random.value; if (randomValue < stockContinueChance) { SimpleStock nextStock = CreateSymbol <SimpleStock>("stock", new Vector3(0, 1, 0)); nextStock.Initialize(Width, Depth, wallStyle, roofStyle); nextStock.Generate(buildDelay); } else { SimpleRoof nextRoof = CreateSymbol <SimpleRoof>("roof", new Vector3(0, 1, 0)); nextRoof.Initialize(Width, Depth, roofStyle, wallStyle); nextRoof.Generate(buildDelay); } }
void CreateNextPart() { // randomly continue with a roof or a stock: if (newWidth <= 0 || newDepth <= 0) { return; } float randomValue = Random.value; if (randomValue < roofContinueChance) // continue with the roof { SimpleRoof nextRoof = CreateSymbol <SimpleRoof>("roof"); nextRoof.Initialize(newWidth, newDepth, roofStyle, wallStyle); nextRoof.Generate(buildDelay); } else // continue with a stock { SimpleStock nextStock = CreateSymbol <SimpleStock>("stock"); nextStock.Initialize(newWidth, newDepth, wallStyle, roofStyle); nextStock.Generate(buildDelay); } }