Exemplo n.º 1
0
    // Use this for initialization
    void Start()
    {
        for (int x = 0; x < PlayWidth; x++)
        {
            for (int y = 0; y < PlayHeight; y++)
            {
                grid[x, y]         = new GridElement();
                grid[x, y].State   = GridElement.ElementState.Empty;
                grid[x, y].Type    = GridElement.ElementType.Empty;
                grid[x, y].Element = null;
            }
        }

        for (int n = 0; n < BlockManager.BlockStoreSize; n++)
        {
            checkRegistry[n] = new CheckRegistryElement();
        }

        int shortColumn = Random.Range(0, PlayWidth);

        for (int x = PlayWidth - 1; x >= 0; x--)
        {
            int height = (shortColumn == x ? 2 : 7) + Random.Range(0, 2);

            if (height - 1 > topOccupiedRow)
            {
                topOccupiedRow = height - 1;
            }

            for (int y = height - 1; y >= 1; y--)
            {
                int flavor;
                do
                {
                    flavor = Random.Range(0, Block.FlavorCount);

                    if (!(StateAt(x, y + 1) == GridElement.ElementState.Empty) &&
                        BlockAt(x, y + 1).Flavor == flavor)
                    {
                        continue;
                    }

                    if (x == Grid.PlayWidth - 1)
                    {
                        break;
                    }

                    if (!(StateAt(x + 1, y) == GridElement.ElementState.Empty) &&
                        BlockAt(x + 1, y).Flavor == flavor)
                    {
                        continue;
                    }

                    break;
                } while(true);

                // setup creep creation state
                if (y == 2)
                {
                    BlockManager.SecondToLastRowCreep[x] = flavor;
                }
                if (y == 1)
                {
                    BlockManager.LastRowCreep[x] = flavor;
                }

                // create the block
                BlockManager.NewBlock(x, y, flavor);
            }
        }

        topEffectiveRow = topOccupiedRow;
    }
Exemplo n.º 2
0
    // Use this for initialization
    void Start()
    {
        for(int x = 0; x < PlayWidth; x++)
        {
            for(int y = 0; y < PlayHeight; y++)
            {
                grid[x, y] = new GridElement();
                grid[x, y].State = GridElement.ElementState.Empty;
                grid[x, y].Type = GridElement.ElementType.Empty;
                grid[x, y].Element = null;
            }
        }

        for(int n = 0; n < BlockManager.BlockStoreSize; n++)
        {
            checkRegistry[n] = new CheckRegistryElement();
        }

        int shortColumn = Random.Range(0, PlayWidth);

        for(int x = PlayWidth - 1; x >= 0; x--)
        {
            int height = (shortColumn == x ? 2 : 7) + Random.Range(0, 2);

            if(height - 1 > topOccupiedRow)
                topOccupiedRow = height - 1;

            for(int y = height - 1; y >= 1; y--)
            {
                int flavor;
                do
                {
                    flavor = Random.Range(0, Block.FlavorCount);

                    if(!(StateAt(x, y + 1) == GridElement.ElementState.Empty) &&
                       BlockAt(x, y + 1).Flavor == flavor)
                        continue;

                    if(x == Grid.PlayWidth - 1)
                        break;

                    if(!(StateAt(x + 1, y) == GridElement.ElementState.Empty) &&
                       BlockAt(x + 1, y).Flavor == flavor)
                        continue;

                    break;
                } while(true);

                // setup creep creation state
                if(y == 2)
                    BlockManager.SecondToLastRowCreep[x] = flavor;
                if(y == 1)
                    BlockManager.LastRowCreep[x] = flavor;

                // create the block
                BlockManager.NewBlock(x, y, flavor);
            }
        }

        topEffectiveRow = topOccupiedRow;
    }