Пример #1
0
    public void GenerateLevel()
    {
        maxX = minX + (blockSize * totalColumns);
        maxY = minY + (blockSize * totalRows);

        //Set up Block field
        //Rows
        for (float ix = minX; ix < maxX; ix += blockSize)
        {
            randNum = Random.Range(0, blockRateX);

            if (randNum != 0)
            {
                blockRateX--;
                //Columns
                for (float iy = minY; iy < maxY; iy += blockSize)
                {
                    blockPos = new Vector3(ix, iy, blockZ);

                    randNum = Random.Range(0, blockRateY);
                    if (randNum != 0)
                    {
                        GameObject newBlock = (GameObject)Instantiate(block, blockPos, Quaternion.identity);
                        newBlock.GetComponent <Block>().SetFiringVectorByAngle(0.0f);
                        newBlock.GetComponent <Block>().SetSpeed(GetComponent <GameHandlerScript>().spawner.speed / 120.0f);
                        newBlock.GetComponent <Block>().isInAir = false;
                        //b.enabled = false;

                        if (!grid.AddBlockToGrid(newBlock.GetComponent <Block>()))
                        {
                            DestroyObject(newBlock);
                        }

                        blockRateY--;
                    }
                    else
                    {
                        blockRateY = totalRows - 1;
                        break;
                    }
                    //}
                }
            }
            else
            {
                blockRateX = totalColumns - 1;
            }
        }
    }
Пример #2
0
 void FloorCollide()
 {
     grid.AddBlockToGrid(this);
     EmitParticles(5, transform.position + new Vector3(0, -0.5f * gameHandler.blockSize, 0));
     Land();
 }