|
|
@ -10,6 +10,9 @@ public class TileManager : MonoBehaviour |
|
|
|
[SerializeField] |
|
|
|
private int trackTiles = 10; |
|
|
|
|
|
|
|
[SerializeField] |
|
|
|
private TileData m_finalTile; |
|
|
|
|
|
|
|
|
|
|
|
private int m_bendProfile = 0; |
|
|
|
|
|
|
@ -30,10 +33,10 @@ public class TileManager : MonoBehaviour |
|
|
|
|
|
|
|
for (int i = 0; i < trackTiles; i++) |
|
|
|
{ |
|
|
|
SpawnRandomTile(); |
|
|
|
SpawnTile(); |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
SpawnTile(m_finalTile); |
|
|
|
} |
|
|
|
|
|
|
|
// Update is called once per frame
|
|
|
@ -58,16 +61,23 @@ public class TileManager : MonoBehaviour |
|
|
|
}*/ |
|
|
|
} |
|
|
|
|
|
|
|
void SpawnRandomTile() |
|
|
|
/// <summary>
|
|
|
|
/// Spawn next tile
|
|
|
|
/// </summary>
|
|
|
|
/// <param name="tileData">Leave null for random</param>
|
|
|
|
void SpawnTile(TileData tileData = null) |
|
|
|
{ |
|
|
|
var _startBendProfile = m_bendProfile; |
|
|
|
TileData _selectedTile = new TileData(); |
|
|
|
TileData _selectedTile = tileData; |
|
|
|
|
|
|
|
do |
|
|
|
if(_selectedTile == null) |
|
|
|
{ |
|
|
|
_selectedTile = m_tileList[Random.Range(0, m_tileList.Count - 1)]; |
|
|
|
do |
|
|
|
{ |
|
|
|
_selectedTile = m_tileList[Random.Range(0, m_tileList.Count - 1)]; |
|
|
|
} |
|
|
|
while (Mathf.Abs(m_bendProfile + (int)_selectedTile.tileType) >= 2); |
|
|
|
} |
|
|
|
while (Mathf.Abs(m_bendProfile + (int)_selectedTile.tileType) >= 2); |
|
|
|
|
|
|
|
m_bendProfile += (int)_selectedTile.tileType; |
|
|
|
|
|
|
|