private static void GenerateMain(BuildingLot _lot) { // PosX Vector3 pos = _lot.transform.position + new Vector3(_lot.GetOffsetX() + _lot.GetCurrentBuildingWidth(), 0.0f, _lot.GetOffsetZ() + (float)panelSize / 2); GeneratePosXPanels(_lot, (int)_lot.GetCurrentBuildingLength(), pos, _lot.GetBuildingPanels()); // PosZ pos = _lot.transform.position + new Vector3(_lot.GetOffsetX() + (float)panelSize / 2, 0.0f, _lot.GetOffsetZ() + _lot.GetCurrentBuildingLength()); GeneratePosZPanels(_lot, (int)_lot.GetCurrentBuildingWidth(), pos, _lot.GetBuildingPanels()); // NegX pos = _lot.transform.position + new Vector3(_lot.GetOffsetX(), 0.0f, _lot.GetOffsetZ() + (float)panelSize / 2); GenerateNegXPanels(_lot, (int)_lot.GetCurrentBuildingLength(), pos, _lot.GetBuildingPanels()); // NegZ pos = _lot.transform.position + new Vector3(_lot.GetOffsetX() + (float)panelSize / 2, 0.0f, _lot.GetOffsetZ()); GenerateNegZPanels(_lot, (int)_lot.GetCurrentBuildingWidth(), pos, _lot.GetBuildingPanels()); // PosY pos = _lot.transform.position + new Vector3(_lot.GetOffsetX() + (float)panelSize / 2, _lot.GetCurrentBuildingHeight() - (float)panelSize / 2, _lot.GetOffsetZ() + (float)panelSize / 2); GeneratePosYPanels(_lot, (int)_lot.GetCurrentBuildingWidth(), (int)_lot.GetCurrentBuildingLength(), pos, _lot.GetBuildingPanels()); }
private static void GeneratePosZPanels(BuildingLot _lot, int _sectionWidth, Vector3 _startPos, List <Panel> _panels) { Vector3 pos = _startPos; Vector3 rot = new Vector3(90.0f, 0.0f, 0.0f); for (int h = 0; h < _lot.GetCurrentBuildingHeight(); h++) { for (int w = 0; w < _sectionWidth; w++) { var panel = new Panel(h, w, pos, rot); _panels.Add(panel); pos.x += panelSize; } pos.x -= _sectionWidth; pos.y += panelSize; } }
private static void GeneratePosZMutation(BuildingLot _lot) { List <Panel> addedPanels = new List <Panel>(); // set new height, width and length // Calculate size of mutation int newHeight = (int)_lot.GetCurrentBuildingHeight() / 2; newHeight = (int)Random.Range(newHeight, _lot.GetCurrentBuildingHeight()); if (newHeight <= 1) { return; } _lot.SetCurrentBuildingHeight(newHeight); int newWidth = (int)Random.Range(1, (_lot.GetPosZWidth() + 1)); int newLength = (int)Random.Range(1, _lot.GetLotLength() - (_lot.GetNegXWidth() + _lot.GetOffsetZ()) + 1); if (newWidth == 1) { return; } // Generate panels! Vector3 pos = _lot.transform.position + new Vector3(_lot.GetOffsetX(), 0.0f, _lot.GetOffsetZ() + _lot.GetNegXWidth() + (float)panelSize / 2); GenerateNegXPanels(_lot, newLength, pos, addedPanels); pos = _lot.transform.position + new Vector3(_lot.GetOffsetX() + newWidth, 0.0f, _lot.GetOffsetZ() + _lot.GetNegXWidth() + (float)panelSize / 2); GeneratePosXPanels(_lot, newLength, pos, addedPanels); pos = _lot.transform.position + new Vector3(_lot.GetOffsetX() + (float)panelSize / 2, 0.0f, _lot.GetOffsetZ() + _lot.GetNegXWidth()); GenerateNegZPanels(_lot, newWidth, pos, addedPanels); pos = _lot.transform.position + new Vector3(_lot.GetOffsetX() + (float)panelSize / 2, 0.0f, _lot.GetOffsetZ() + _lot.GetNegXWidth() + newLength); GeneratePosZPanels(_lot, newWidth, pos, addedPanels); pos = _lot.transform.position + new Vector3(_lot.GetOffsetX() + (float)panelSize / 2, newHeight - (float)panelSize / 2, _lot.GetOffsetZ() + _lot.GetNegXWidth() + (float)panelSize / 2); GeneratePosYPanels(_lot, newWidth, newLength, pos, addedPanels); if (newWidth == _lot.GetPosZWidth()) { _lot.SetNegXWidth(_lot.GetNegXWidth() + newLength); _lot.SetPosXWidth(_lot.GetPosXWidth() + newLength); } MergeList(_lot, addedPanels); }