|
|
@ -10,9 +10,6 @@ public class TileManager : MonoBehaviour |
|
|
|
[SerializeField] |
|
|
|
private Transform m_camTransform; |
|
|
|
|
|
|
|
[SerializeField] |
|
|
|
private float m_exitCullDistance = 3f; |
|
|
|
|
|
|
|
private int m_bendProfile = 0; |
|
|
|
|
|
|
|
private TileController m_previousTile; |
|
|
@ -34,7 +31,9 @@ public class TileManager : MonoBehaviour |
|
|
|
// Update is called once per frame
|
|
|
|
void Update() |
|
|
|
{ |
|
|
|
if(m_previousTile != null) |
|
|
|
|
|
|
|
/* |
|
|
|
if (m_previousTile != null) |
|
|
|
{ |
|
|
|
if (Vector3.Distance(m_previousTile.transform.position, Camera.main.transform.position) > m_exitCullDistance) |
|
|
|
{ |
|
|
@ -42,6 +41,7 @@ public class TileManager : MonoBehaviour |
|
|
|
m_previousTile = null; |
|
|
|
} |
|
|
|
} |
|
|
|
*/ |
|
|
|
|
|
|
|
if(Input.GetKeyDown(KeyCode.Space)) |
|
|
|
{ |
|
|
@ -58,17 +58,20 @@ public class TileManager : MonoBehaviour |
|
|
|
{ |
|
|
|
_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; |
|
|
|
|
|
|
|
var _newTileObj = Instantiate(_selectedTile.prefab); |
|
|
|
_newTileObj.transform.forward = m_currentTile.transform.forward; |
|
|
|
_newTileObj.transform.forward = m_currentTile.exitAnchor.transform.forward; |
|
|
|
|
|
|
|
var _newTileController = _newTileObj.GetComponent<TileController>(); |
|
|
|
|
|
|
|
Vector3 _offset = m_currentTile.exitAnchor.position - _newTileController.entryAnchor.position; |
|
|
|
_newTileObj.transform.position += _offset; |
|
|
|
|
|
|
|
m_previousTile = m_currentTile; |
|
|
|
m_currentTile = _newTileController; |
|
|
|
|
|
|
|
} |
|
|
|
} |