Esempio n. 1
0
    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);
    }
Esempio n. 2
0
    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;
                }
            }
        }
    }
Esempio n. 3
0
    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;
    }
Esempio n. 4
0
    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);
    }
Esempio n. 5
0
    public Transform GetBlockTransform(WallBlockPosition wallPos)
    {
        TempleWallBlock block = GetBlockAtPosition(wallPos);

        return(block.gameObject.transform);
    }
Esempio n. 6
0
    private void DisableBlock(WallBlockPosition wallPos)
    {
        TempleWallBlock block = GetBlockAtPosition(wallPos);

        Destroy(block.gameObject);
    }