public void IntegrateNewBlock(TempleWallBlock newBlock, WallBlockType blockType, WallBlockPosition wallPos) { Transform oldBlockTransform = GetBlockTransform(wallPos); CodeTools.CopyTransform(oldBlockTransform, newBlock.transform, true, true, false); DisableBlock(wallPos); AssignBlockToPosition(newBlock, wallPos); }
private void CollectBlocks() { foreach (Transform child in transform) { TempleWallBlock block = child.GetComponent <TempleWallBlock>(); if (block != null) { if ((block.blockPosition == WallBlockPosition.TopLeft) && (topLeft == null)) { topLeft = block; } if ((block.blockPosition == WallBlockPosition.TopCenter) && (topCenter == null)) { topCenter = block; } if ((block.blockPosition == WallBlockPosition.TopRight) && (topRight == null)) { topRight = block; } if ((block.blockPosition == WallBlockPosition.MiddleLeft) && (middleLeft == null)) { middleLeft = block; } if ((block.blockPosition == WallBlockPosition.MiddleCenter) && (middleCenter == null)) { middleCenter = block; } if ((block.blockPosition == WallBlockPosition.MiddleRight) && (middleRight == null)) { middleRight = block; } if ((block.blockPosition == WallBlockPosition.BottomLeft) && (bottomLeft == null)) { bottomLeft = block; } if ((block.blockPosition == WallBlockPosition.BottomCenter) && (bottomCenter == null)) { bottomCenter = block; } if ((block.blockPosition == WallBlockPosition.BottomRight) && (bottomRight == null)) { bottomRight = block; } } } }
private void AssignBlockToPosition(TempleWallBlock newBlock, WallBlockPosition wallPos) { switch (wallPos) { case WallBlockPosition.TopLeft: topLeft = newBlock; break; case WallBlockPosition.TopCenter: topCenter = newBlock; break; case WallBlockPosition.TopRight: topRight = newBlock; break; case WallBlockPosition.MiddleLeft: middleLeft = newBlock; break; case WallBlockPosition.MiddleCenter: middleCenter = newBlock; break; case WallBlockPosition.MiddleRight: middleRight = newBlock; break; case WallBlockPosition.BottomLeft: bottomLeft = newBlock; break; case WallBlockPosition.BottomCenter: bottomCenter = newBlock; break; case WallBlockPosition.BottomRight: bottomRight = newBlock; break; } return; }
public void SpawnBlock(WallBlockType blockType, TempleWall wall, WallBlockPosition wallPos) { // fetch the GO prefab using the enum GameObject toSpawn = WallBlockGO(blockType, wall, wallPos); GameObject newBlockGO = (GameObject)Instantiate(toSpawn) as GameObject; newBlockGO.transform.parent = wall.transform; TempleWallBlock newBlock = newBlockGO.GetComponent <TempleWallBlock>(); newBlock.blockPosition = wallPos; // this happens automatically assuming the new block gets parented under "Environment" so, not necessary // if (transform.localScale != Vector3.one) // newBlock.ScaleSelf(transform.localScale); newBlockGO.transform.localScale = Vector3.Scale(newBlockGO.transform.localScale, transform.localScale); wall.IntegrateNewBlock(newBlock, blockType, wallPos); }
public Transform GetBlockTransform(WallBlockPosition wallPos) { TempleWallBlock block = GetBlockAtPosition(wallPos); return(block.gameObject.transform); }
private void DisableBlock(WallBlockPosition wallPos) { TempleWallBlock block = GetBlockAtPosition(wallPos); Destroy(block.gameObject); }