Exemplo n.º 1
0
    // create a block
    GameObject createBlock(GameObject playArea, General.Block block, int cid)
    {
        GameObject blockObject = Instantiate(blockPrefab);

        blockObject.transform.SetParent(playArea.transform);
        BlockBase script = (BlockBase)blockObject.GetComponent(typeof(BlockBase));

        script.block = block;
        script.createCubes(this, cid);
        script.computeXRange();

        return(blockObject);
    }
Exemplo n.º 2
0
    // preset blocks
    public static Block[] generateBlockTemplate()
    {
        General.Block[] blocks = new General.Block[12];
        blocks[0].block = new int[2, 4, 4] {
            {
                { 0, 0, 0, 0 },
                { 0, 1, 0, 0 },
                { 0, 0, 0, 0 },
                { 0, 0, 0, 0 },
            },
            {
                { 0, 0, 0, 0 },
                { 2, 3, 4, 0 },
                { 0, 0, 0, 0 },
                { 0, 0, 0, 0 }
            }
        };
        // size decide the center of the block (for rotating)
        blocks[0].size = 3;

        blocks[1].block = new int[2, 4, 4] {
            {
                { 0, 1, 0, 0 },
                { 2, 3, 4, 0 },
                { 0, 0, 0, 0 },
                { 0, 0, 0, 0 },
            },
            {
                { 0, 0, 0, 0 },
                { 0, 0, 0, 0 },
                { 0, 0, 0, 0 },
                { 0, 0, 0, 0 },
            }
        };

        blocks[1].size = 3;

        blocks[2].block = new int[2, 4, 4] {
            {
                { 0, 1, 2, 0 },
                { 0, 3, 0, 0 },
                { 0, 4, 0, 0 },
                { 0, 0, 0, 0 },
            },
            {
                { 0, 0, 0, 0 },
                { 0, 0, 0, 0 },
                { 0, 0, 0, 0 },
                { 0, 0, 0, 0 },
            }
        };

        blocks[2].size = 4;

        blocks[3].block = new int[2, 4, 4] {
            {
                { 0, 1, 2, 0 },
                { 0, 0, 3, 0 },
                { 0, 0, 4, 0 },
                { 0, 0, 0, 0 },
            },
            {
                { 0, 0, 0, 0 },
                { 0, 0, 0, 0 },
                { 0, 0, 0, 0 },
                { 0, 0, 0, 0 },
            }
        };

        blocks[3].size = 4;

        blocks[4].block = new int[2, 4, 4] {
            {
                { 0, 1, 0, 0 },
                { 0, 2, 0, 0 },
                { 0, 3, 0, 0 },
                { 0, 0, 0, 0 },
            },
            {
                { 0, 4, 0, 0 },
                { 0, 0, 0, 0 },
                { 0, 0, 0, 0 },
                { 0, 0, 0, 0 },
            }
        };

        blocks[4].size = 3;

        blocks[5].block = new int[2, 4, 4] {
            {
                { 0, 1, 0, 0 },
                { 0, 0, 0, 0 },
                { 0, 0, 0, 0 },
                { 0, 0, 0, 0 },
            },
            {
                { 0, 2, 0, 0 },
                { 0, 3, 0, 0 },
                { 0, 4, 0, 0 },
                { 0, 0, 0, 0 },
            }
        };

        blocks[5].size = 3;

        blocks[6].block = new int[2, 4, 4] {
            {
                { 0, 1, 0, 0 },
                { 0, 2, 0, 0 },
                { 0, 3, 0, 0 },
                { 0, 4, 0, 0 },
            },
            {
                { 0, 0, 0, 0 },
                { 0, 0, 0, 0 },
                { 0, 0, 0, 0 },
                { 0, 0, 0, 0 },
            }
        };

        blocks[6].size = 4;

        blocks[7].block = new int[2, 4, 4] {
            {
                { 0, 0, 0, 0 },
                { 0, 1, 2, 0 },
                { 3, 4, 0, 0 },
                { 0, 0, 0, 0 },
            },
            {
                { 0, 0, 0, 0 },
                { 0, 0, 0, 0 },
                { 0, 0, 0, 0 },
                { 0, 0, 0, 0 },
            }
        };

        blocks[7].size = 3;

        blocks[8].block = new int[2, 4, 4] {
            {
                { 0, 0, 0, 0 },
                { 1, 2, 0, 0 },
                { 0, 3, 4, 0 },
                { 0, 0, 0, 0 },
            },
            {
                { 0, 0, 0, 0 },
                { 0, 0, 0, 0 },
                { 0, 0, 0, 0 },
                { 0, 0, 0, 0 },
            }
        };

        blocks[8].size = 3;

        blocks[9].block = new int[2, 4, 4] {
            {
                { 0, 1, 0, 0 },
                { 0, 2, 0, 0 },
                { 0, 0, 0, 0 },
                { 0, 0, 0, 0 },
            },
            {
                { 0, 3, 0, 0 },
                { 0, 4, 0, 0 },
                { 0, 0, 0, 0 },
                { 0, 0, 0, 0 },
            }
        };

        blocks[9].size = 3;

        blocks[10].block = new int[2, 4, 4] {
            {
                { 1, 2, 0, 0 },
                { 3, 4, 0, 0 },
                { 0, 0, 0, 0 },
                { 0, 0, 0, 0 },
            },
            {
                { 0, 0, 0, 0 },
                { 0, 0, 0, 0 },
                { 0, 0, 0, 0 },
                { 0, 0, 0, 0 },
            }
        };

        blocks[10].size = 2;

        blocks[11].block = new int[2, 4, 4] {
            {
                { 0, 0, 0, 0 },
                { 0, 1, 0, 0 },
                { 0, 0, 0, 0 },
                { 0, 0, 0, 0 },
            },
            {
                { 0, 0, 0, 0 },
                { 0, 0, 0, 0 },
                { 0, 0, 0, 0 },
                { 0, 0, 0, 0 },
            }
        };

        blocks[11].size = 3;

        return(blocks);
    }