private static void GenerateShapes(Transform boardParent, GeneratorShapePrefs genPrefs) { // check for invalid input if (genPrefs == null || boardParent == null) { return; } // Generate list of available slots List <int> availableSlots = new List <int>(); for (int s = 0; s < boardParent.childCount; s++) { if (boardParent.GetChild(s).GetComponent <GameSlot>() != null) { availableSlots.Add(s); } } // Generating the shapes List <ShapeData> shapesToCreate = genPrefs.GetShapeDataList(); GameSlot targetGameSlot = null; int targetSlotIndex; foreach (ShapeData shapeData in shapesToCreate) { targetSlotIndex = Random.Range(0, availableSlots.Count - 1); targetGameSlot = boardParent.GetChild(availableSlots[targetSlotIndex]).GetComponent <GameSlot>(); GameSlotTools.CreateSlotShape(targetGameSlot.transform, shapeData.shapeType, shapeData.shapeColor, genPrefs.targetShapeScale); EditorUtility.SetDirty(targetGameSlot); availableSlots.RemoveAt(targetSlotIndex); } }
public static void GenerateGameboardShapes(GeneratorShapePrefs genPrefs) { if (gameManager == null) { GetGameManager(); } Transform gameboardParent = gameManager.gameBoardParent; GenerateShapes(gameboardParent, genPrefs); }