void InstantiatePlayField() { float offsetFromCenter = sideBound / 2f; GameObject coverBoxHolder = new GameObject("coverBoxHolder"); coverBoxHolder.transform.parent = transform; for (int y = 0; y < 2; y++) { for (int x = -sideBound; x <= sideBound; x += sideBound / 2) { InstantiateBoxRow(5, x, 4 + y * 1.2f, coverBoxHolder.transform); } } void InstantiateBoxRow(int count, float offset, float y, Transform parentTransform) { GameObject rowHolder = new GameObject($"row {offset}"); rowHolder.transform.parent = parentTransform; float sideOffset = 1.2f * count / 2f - .6f; for (int x = 0; x < count; x++) { CoverBox cB = Instantiate(coverBoxPrefab); cB.transform.position = new Vector3(x * 1.2f + offset - sideOffset, y, 0); cB.transform.parent = rowHolder.transform; } } }
void InstantiateCoverBlockInGrid(int xCoord, int zCoord) { float offsetX = 1.1f + .55f; float offsetZ = .55f; for (int z = 0; z < 2; z++) { for (int x = 0; x < 4; x++) { CoverBox cB = Instantiate(coverBoxPrefab); cB.transform.position = tiles[zCoord][xCoord].transform.position + new Vector3(x * 1.1f - offsetX, z * 1.1f - offsetZ, 0); tiles[zCoord][xCoord].isTaken = true; } } }