private static bool MutationPosX(BuildingLot _lot) { if (_lot.GetOffsetX() + _lot.GetCurrentBuildingWidth() < _lot.GetLotWidth()) { return(true); } return(false); }
private static void GeneratePosXMutation(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.GetLotWidth() - (_lot.GetOffsetX() + _lot.GetNegZWidth()))); int newLength = (int)Random.Range(1, _lot.GetPosXWidth() + 1); if (newLength == 1) { return; } // Generate panels! Vector3 pos = _lot.transform.position + new Vector3(_lot.GetOffsetX() + _lot.GetNegZWidth(), 0.0f, _lot.GetOffsetZ() + (float)panelSize / 2); GenerateNegXPanels(_lot, newLength, pos, addedPanels); pos = _lot.transform.position + new Vector3(_lot.GetOffsetX() + _lot.GetNegZWidth() + newWidth, 0.0f, _lot.GetOffsetZ() + (float)panelSize / 2); GeneratePosXPanels(_lot, newLength, pos, addedPanels); pos = _lot.transform.position + new Vector3(_lot.GetOffsetX() + _lot.GetNegZWidth() + (float)panelSize / 2, 0.0f, _lot.GetOffsetZ()); GenerateNegZPanels(_lot, newWidth, pos, addedPanels); pos = _lot.transform.position + new Vector3(_lot.GetOffsetX() + _lot.GetNegZWidth() + (float)panelSize / 2, 0.0f, _lot.GetOffsetZ() + newLength); GeneratePosZPanels(_lot, newWidth, pos, addedPanels); pos = _lot.transform.position + new Vector3(_lot.GetOffsetX() + _lot.GetNegZWidth() + (float)panelSize / 2, newHeight - (float)panelSize / 2, _lot.GetOffsetZ() + (float)panelSize / 2); GeneratePosYPanels(_lot, newWidth, newLength, pos, addedPanels); // if the length of mutation == faceWidth, update if (newLength == _lot.GetPosXWidth()) { _lot.SetNegZWidth(_lot.GetNegZWidth() + newWidth); _lot.SetPosZWidth(_lot.GetPosZWidth() + newWidth); } MergeList(_lot, addedPanels); }