// Textures pit-related objects private void TexturePit(int pitIndex, GridTexturer gridTexturer) { // Texture the top of the pit transform.GetChild(pitIndex).GetChild(0).GetComponent <MeshRenderer>().material = gridTexturer.pit; // If the "horizontal" wall type is active: if (transform.GetChild(pitIndex).GetChild(1).gameObject.activeSelf) { transform.GetChild(pitIndex).GetChild(1).GetChild(0).GetComponent <MeshRenderer>().material = gridTexturer.basicFloorWall; transform.GetChild(pitIndex).GetChild(1).GetChild(1).GetComponent <MeshRenderer>().material = gridTexturer.basicFloorWall; } // If the "vertical" wall type is active: if (transform.GetChild(pitIndex).GetChild(2).gameObject.activeSelf) { transform.GetChild(pitIndex).GetChild(2).GetChild(0).GetComponent <MeshRenderer>().material = gridTexturer.basicFloorWall; transform.GetChild(pitIndex).GetChild(2).GetChild(1).GetComponent <MeshRenderer>().material = gridTexturer.basicFloorWall; } // If the "corner" wall type is active: if (transform.GetChild(pitIndex).GetChild(3).gameObject.activeSelf) { transform.GetChild(pitIndex).GetChild(3).GetChild(0).GetComponent <MeshRenderer>().material = gridTexturer.halfFloorWall1; transform.GetChild(pitIndex).GetChild(3).GetChild(1).GetComponent <MeshRenderer>().material = gridTexturer.halfFloorWall2; } }
// Places textures on the space according to its type public void TextureSpace(GridTexturer gridTexturer) { if (lockTextures) { return; } Debug.Log(coordinates); switch (type) { // Applies textures to the floor objects case SpaceType.Ground: transform.GetChild(0).GetChild(0).GetComponent <MeshRenderer>().material = gridTexturer.basicFloor; // If the floor object's walls are active, texture them, as well if (transform.GetChild(0).GetChild(2).gameObject.activeSelf) { for (int i = 2; i < 6; ++i) { transform.GetChild(0).GetChild(i).GetComponent <MeshRenderer>().material = gridTexturer.basicFloorWall; } } break; // Applies textures to the wall objects case SpaceType.Wall: // If the wall isn't overlooking a pit: if (transform.GetChild(0).gameObject.name != (wall.name + "(Clone)") && transform.childCount > 1) { transform.GetChild(0).GetChild(0).GetComponent <MeshRenderer>().material = gridTexturer.wallEdge180; for (int i = 2; i < 6; ++i) { transform.GetChild(0).GetChild(i).GetComponent <MeshRenderer>().material = gridTexturer.basicFloorWall; } transform.GetChild(1).GetChild(0).GetComponent <MeshRenderer>().material = gridTexturer.bottomWall; transform.GetChild(1).GetChild(1).GetComponent <MeshRenderer>().material = gridTexturer.topWall; transform.GetChild(1).GetChild(2).GetComponent <MeshRenderer>().material = gridTexturer.bar; } // If the wall is overlooking a pit: else if (transform.GetChild(0).gameObject.name == (wall.name + "(Clone)") && transform.childCount > 1) { // Texture the wall transform.GetChild(0).GetChild(0).GetComponent <MeshRenderer>().material = gridTexturer.bottomWall; transform.GetChild(0).GetChild(1).GetComponent <MeshRenderer>().material = gridTexturer.topWall; transform.GetChild(0).GetChild(2).GetComponent <MeshRenderer>().material = gridTexturer.bar; // Textures the pit TexturePit(1, gridTexturer); } // If the wall has a pit, but no "wall" object or box: else if (transform.childCount == 1 && transform.GetChild(0).name == (pit.name + "(Clone)")) { TexturePit(0, gridTexturer); } // If the wall has a box, but no "wall" object or pit: else if (transform.childCount == 1 && transform.GetChild(0).name != (pit.name + "(Clone)")) { transform.GetChild(0).GetChild(0).GetComponent <MeshRenderer>().material = gridTexturer.wallEdge180; for (int i = 2; i < 6; ++i) { transform.GetChild(0).GetChild(i).GetComponent <MeshRenderer>().material = gridTexturer.basicFloorWall; } } break; // Applies textures to the inward-facing corner wall objects case SpaceType.InwardWall: // If the wall isn't overlooking a pit: if (transform.GetChild(0).gameObject.name != (inwardCornerWall.name + "(Clone)") && transform.childCount > 1) { transform.GetChild(0).GetChild(0).GetComponent <MeshRenderer>().material = gridTexturer.wallEdge90; for (int i = 2; i < 6; ++i) { transform.GetChild(0).GetChild(i).GetComponent <MeshRenderer>().material = gridTexturer.basicFloorWall; } // Textures the outer portions of the wall for (int i = 0; i < 2; ++i) { transform.GetChild(1).GetChild(i).GetChild(0).GetComponent <MeshRenderer>().material = gridTexturer.bottomInnerWall; transform.GetChild(1).GetChild(i).GetChild(1).GetComponent <MeshRenderer>().material = gridTexturer.topWall; transform.GetChild(1).GetChild(i).GetChild(2).GetComponent <MeshRenderer>().material = gridTexturer.bar; } // Textures the inner portions of the wall for (int i = 2; i < 4; ++i) { transform.GetChild(1).GetChild(i).GetChild(0).GetComponent <MeshRenderer>().material = gridTexturer.bottomInnerWall; transform.GetChild(1).GetChild(i).GetChild(1).GetComponent <MeshRenderer>().material = gridTexturer.topInnerWall; transform.GetChild(1).GetChild(i).GetChild(2).GetComponent <MeshRenderer>().material = gridTexturer.bar; } // Textures the center bars transform.GetChild(1).GetChild(4).GetComponent <MeshRenderer>().material = gridTexturer.bar; transform.GetChild(1).GetChild(5).GetComponent <MeshRenderer>().material = gridTexturer.wallCornerBar; } // If the wall is overlooking a pit: else if (transform.GetChild(0).gameObject.name == (inwardCornerWall.name + "(Clone)") && transform.childCount > 1) { // Textures the outer portions of the wall for (int i = 0; i < 2; ++i) { transform.GetChild(0).GetChild(i).GetChild(0).GetComponent <MeshRenderer>().material = gridTexturer.bottomInnerWall; transform.GetChild(0).GetChild(i).GetChild(1).GetComponent <MeshRenderer>().material = gridTexturer.topWall; transform.GetChild(0).GetChild(i).GetChild(2).GetComponent <MeshRenderer>().material = gridTexturer.bar; } // Textures the inner portions of the wall for (int i = 2; i < 4; ++i) { transform.GetChild(0).GetChild(i).GetChild(0).GetComponent <MeshRenderer>().material = gridTexturer.bottomInnerWall; transform.GetChild(0).GetChild(i).GetChild(1).GetComponent <MeshRenderer>().material = gridTexturer.topInnerWall; transform.GetChild(0).GetChild(i).GetChild(2).GetComponent <MeshRenderer>().material = gridTexturer.bar; } // Textures the center bars transform.GetChild(0).GetChild(4).GetComponent <MeshRenderer>().material = gridTexturer.bar; transform.GetChild(0).GetChild(5).GetComponent <MeshRenderer>().material = gridTexturer.wallCornerBar; // Textures the pit TexturePit(1, gridTexturer); } break; // Applies textures to the inward-facing corner wall objects case SpaceType.OutwardWall: // If the wall isn't overlooking a pit: if (transform.GetChild(0).gameObject.name != (outwardCornerWall.name + "(Clone)") && transform.childCount > 1) { transform.GetChild(0).GetChild(0).GetComponent <MeshRenderer>().material = gridTexturer.wallEdge270; // Textures the angled part of the wall for (int i = 0; i < 2; ++i) { transform.GetChild(1).GetChild(i).GetChild(0).GetComponent <MeshRenderer>().material = gridTexturer.angleWall_75; transform.GetChild(1).GetChild(i).GetChild(1).GetComponent <MeshRenderer>().material = gridTexturer.angleWall_5; transform.GetChild(1).GetChild(i).GetChild(2).GetComponent <MeshRenderer>().material = gridTexturer.angleWall_32; transform.GetChild(1).GetChild(i).GetChild(3).GetComponent <MeshRenderer>().material = gridTexturer.angleWall_1875; } // Textures the flat part of the wall for (int i = 0; i < 4; ++i) { transform.GetChild(1).GetChild(2).GetChild(i).GetComponent <MeshRenderer>().material = gridTexturer.flatWall_375; } transform.GetChild(1).GetChild(2).GetChild(4).GetComponent <MeshRenderer>().material = gridTexturer.flatWall_75; transform.GetChild(1).GetChild(2).GetChild(5).GetComponent <MeshRenderer>().material = gridTexturer.flatWall_5; transform.GetChild(1).GetChild(2).GetChild(6).GetComponent <MeshRenderer>().material = gridTexturer.flatWall_32; for (int i = 7; i < 9; ++i) { transform.GetChild(1).GetChild(2).GetChild(i).GetComponent <MeshRenderer>().material = gridTexturer.flatWall_25; } // Textures the center bar transform.GetChild(1).GetChild(3).GetComponent <MeshRenderer>().material = gridTexturer.bar; } // If the wall is overlooking a pit: else if (transform.GetChild(0).gameObject.name == (outwardCornerWall.name + "(Clone)") && transform.childCount > 1) { // Textures the angled part of the wall for (int i = 0; i < 2; ++i) { transform.GetChild(0).GetChild(i).GetChild(0).GetComponent <MeshRenderer>().material = gridTexturer.angleWall_75; transform.GetChild(0).GetChild(i).GetChild(1).GetComponent <MeshRenderer>().material = gridTexturer.angleWall_5; transform.GetChild(0).GetChild(i).GetChild(2).GetComponent <MeshRenderer>().material = gridTexturer.angleWall_32; transform.GetChild(0).GetChild(i).GetChild(3).GetComponent <MeshRenderer>().material = gridTexturer.angleWall_1875; } // Textures the flat part of the wall for (int i = 0; i < 4; ++i) { transform.GetChild(0).GetChild(2).GetChild(i).GetComponent <MeshRenderer>().material = gridTexturer.flatWall_375; } transform.GetChild(0).GetChild(2).GetChild(4).GetComponent <MeshRenderer>().material = gridTexturer.flatWall_75; transform.GetChild(0).GetChild(2).GetChild(5).GetComponent <MeshRenderer>().material = gridTexturer.flatWall_5; transform.GetChild(0).GetChild(2).GetChild(6).GetComponent <MeshRenderer>().material = gridTexturer.flatWall_32; for (int i = 7; i < 9; ++i) { transform.GetChild(0).GetChild(2).GetChild(i).GetComponent <MeshRenderer>().material = gridTexturer.flatWall_25; } // Textures the center bar transform.GetChild(0).GetChild(3).GetComponent <MeshRenderer>().material = gridTexturer.bar; // Textures the pit TexturePit(1, gridTexturer); } break; // Applies textures to the ceiling objects case SpaceType.Ceiling: if (transform.childCount > 1) { transform.GetChild(1).GetComponent <MeshRenderer>().material = gridTexturer.basicCeiling; } break; } }