I'm working on a Tile-Based game and I can't figure out how to make my tiles fall down smoothly like in candy crush. All column tiles fall-down at the same time. And spawn new like how many tile place if null.
What I want:
Update [25.12.2015]
But the my code works like this:
Update [26.12.2015]
Hello Again,
World Scale (x,y) World Scale OLD: (10,10) World Scale NEW: (10,11)
Y=11 Tiles type = Empty
Now, when i click the random place like (5,7),above all blocks down to : block.transform.pozition += new Vector3(0,-1,0); It's working. But again, when i click same place (5,7) not working...
I changed Y scale 10 to 11. Because, when i clicked tile, the tile will return to Y=11 position and fall down, how many tile place null.
When Tiles state "fallling down", the space between two blocks distance not more "0.01".
I do not know how to do. But I approached. I need to more improve this.
Thanks...
Pseudo-code:
When I click the (4,7) coord, the tiles,
tile(4,8) is smooth down the coord(4,7)
tile(4,9) is smooth down the coord(4,8)
tile(4,9) is generate new tile.
What I have (Code not working properly :( ):
World.Height = 10
World.Widht = 10
Tile X and Y {get, protected set}
public void ColumnDown(int x , int yStart)
{
if (IsColumnFull(x)) return;
for (int y = yStart; y < World.Height; y++)
{
//Yeni tile spawnla
if (y + 1 >= World.Height) continue;
Tile tile = World.GetTileAt(x, y);
Tile tile2 = World.GetTileAt(x, y + 1);
GameObject go_Tile = GameObject.Find("Tile-(" + x + "," + y + ")");
GameObject go_Tile2 = GameObject.Find("Tile-(" + x + "," + (y + 1) + ")");
if (tile != null)
{
if (go_Tile == null && go_Tile2 == null)
{
Debug.Log("go_Tile NULL");
continue;
}
tile2 = tile;
go_Tile2.transform.position += new Vector3(0, -1, 0);
go_Tile.name = "Tile-(" + x + "," + (y + 1) + ")";
go_Tile2.name = "Tile-(" + x + "," + (y) + ")";
}
}
}