public void Reset(TemplatePiece template) { color = template.color; bulkSize = (int)Mathf.Sqrt(template.shape.Length); for (int y = 0; y < bulkSize; y++) { for (int x = 0; x < bulkSize; x++) { shape[x, y] = template.shape[x, y]; } } }
private void InitializeTemplatePiecesFromPrefabs() { templatePieces = new TemplatePiece[templatePrefabs.Length]; for (int i = 0; i < templatePieces.Length; i++) { var template = templatePrefabs[i]; int bulkSz = template.childCount; templatePieces[i].shape = new bool[bulkSz, bulkSz]; for (int y = 0; y < bulkSz; y++) { for (int x = 0; x < bulkSz; x++) { Transform cell = template.GetChild(x).GetChild(y); if (cell.localScale.x > .95f) //smaller cells represent empty space within the bulk { templatePieces[i].shape[x, y] = true; templatePieces[i].color = cell.GetComponent <MeshRenderer>().sharedMaterial.color; } } } } }
private void DisplayNextPiece(TemplatePiece nextPiece) { for (int y = 0; y < maxBulkSize; y++) { for (int x = 0; x < maxBulkSize; x++) { slots[x, y].enabled = false; } } int N = (int)Mathf.Sqrt(nextPiece.shape.Length); for (int y = 0; y < N; y++) { for (int x = 0; x < N; x++) { if (nextPiece.shape[x, y]) { slots[x, y].enabled = true; slots[x, y].material.color = nextPiece.color; } } } }