Ejemplo n.º 1
0
    public void SpawnGameGridTiles(Level levelToSpawn)
    {
        int xPos = -1;
        int yPos = 0;

        for (int i = 0; i < levelToSpawn.gameGridTileIds.Count; i++)
        {
            if (i % 10 == 0)
            {
                xPos++;
                yPos = 0;
            }
            yPos++;
            if (levelToSpawn.gameGridTileIds[i] != 0)
            {
                Tile tile = Instantiate(gameGridTilePrefabs[levelToSpawn.gameGridTileIds[i]], new Vector3(xPos, 1, yPos - 1), Quaternion.identity).GetComponent <Tile>();
                gameGrid.AddTileToGrid(tile, i);
            }
            else
            {
                gameGrid.AddTileToGrid(null, i);
            }
            if (i == levelToSpawn.playerPos)
            {
                playerBall = Instantiate(player, new Vector3(xPos, 1, yPos - 1), Quaternion.Euler(-25f, 45, 0)).GetComponent <BallMovement>();
                playerBall.SetGameGrid(gameGrid);
                gameGrid.AddPlayer(playerBall.transform, i);
            }
        }
    }