Joshua Reason 1 year ago
parent
commit
9361f04bfe
20 changed files with 97 additions and 14 deletions
  1. BIN
      Assets/Data/Tiles/Bend_Left.asset
  2. BIN
      Assets/Data/Tiles/Bend_Left_01.asset
  3. +0
    -0
      Assets/Data/Tiles/Bend_Left_01.asset.meta
  4. BIN
      Assets/Data/Tiles/Bend_Left_02.asset
  5. +8
    -0
      Assets/Data/Tiles/Bend_Left_02.asset.meta
  6. BIN
      Assets/Data/Tiles/Final.asset
  7. +8
    -0
      Assets/Data/Tiles/Final.asset.meta
  8. BIN
      Assets/Data/Tiles/Straight_01.asset
  9. BIN
      Assets/Data/Tiles/Straight_02.asset
  10. +8
    -0
      Assets/Data/Tiles/Straight_02.asset.meta
  11. BIN
      Assets/Prefab/FinalTile_01.prefab
  12. +7
    -0
      Assets/Prefab/FinalTile_01.prefab.meta
  13. BIN
      Assets/Prefab/Freg_wRignDance.prefab
  14. +7
    -0
      Assets/Prefab/Freg_wRignDance.prefab.meta
  15. BIN
      Assets/Prefab/Tile_01_obstacle 1.prefab
  16. +7
    -0
      Assets/Prefab/Tile_01_obstacle 1.prefab.meta
  17. BIN
      Assets/Prefab/Tile_02_obstacle 1.prefab
  18. +7
    -0
      Assets/Prefab/Tile_02_obstacle 1.prefab.meta
  19. BIN
      Assets/Scenes/Main.unity
  20. +18
    -8
      Assets/Scripts/Route/TileManager.cs

BIN
Assets/Data/Tiles/Bend_Left.asset (Stored with Git LFS) View File

size 502

BIN
Assets/Data/Tiles/Bend_Left_01.asset (Stored with Git LFS) View File

size 505

Assets/Data/Tiles/Bend_Left.asset.meta → Assets/Data/Tiles/Bend_Left_01.asset.meta View File


BIN
Assets/Data/Tiles/Bend_Left_02.asset (Stored with Git LFS) View File

size 505

+ 8
- 0
Assets/Data/Tiles/Bend_Left_02.asset.meta View File

@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: fcc2d51be6341b64b8709e5259b7b848
NativeFormatImporter:
externalObjects: {}
mainObjectFileID: 11400000
userData:
assetBundleName:
assetBundleVariant:

BIN
Assets/Data/Tiles/Final.asset (Stored with Git LFS) View File

size 497

+ 8
- 0
Assets/Data/Tiles/Final.asset.meta View File

@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: aa439551c5f028748be734246632e9e2
NativeFormatImporter:
externalObjects: {}
mainObjectFileID: 11400000
userData:
assetBundleName:
assetBundleVariant:

BIN
Assets/Data/Tiles/Straight_01.asset (Stored with Git LFS) View File

size 503 size 503

BIN
Assets/Data/Tiles/Straight_02.asset (Stored with Git LFS) View File

size 503

+ 8
- 0
Assets/Data/Tiles/Straight_02.asset.meta View File

@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 27840c40339e676429a2e06442fbfe0d
NativeFormatImporter:
externalObjects: {}
mainObjectFileID: 11400000
userData:
assetBundleName:
assetBundleVariant:

BIN
Assets/Prefab/FinalTile_01.prefab (Stored with Git LFS) View File

size 295968

+ 7
- 0
Assets/Prefab/FinalTile_01.prefab.meta View File

@ -0,0 +1,7 @@
fileFormatVersion: 2
guid: 1355850619fff884dbb97b93633e5a70
PrefabImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

BIN
Assets/Prefab/Freg_wRignDance.prefab (Stored with Git LFS) View File

size 62995

+ 7
- 0
Assets/Prefab/Freg_wRignDance.prefab.meta View File

@ -0,0 +1,7 @@
fileFormatVersion: 2
guid: 3b9cec4f3f93f0245ae7b60bcdf4d150
PrefabImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

BIN
Assets/Prefab/Tile_01_obstacle 1.prefab (Stored with Git LFS) View File

size 24328

+ 7
- 0
Assets/Prefab/Tile_01_obstacle 1.prefab.meta View File

@ -0,0 +1,7 @@
fileFormatVersion: 2
guid: cae8ccb1101be9644bb467f4ec9c13f2
PrefabImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

BIN
Assets/Prefab/Tile_02_obstacle 1.prefab (Stored with Git LFS) View File

size 18580

+ 7
- 0
Assets/Prefab/Tile_02_obstacle 1.prefab.meta View File

@ -0,0 +1,7 @@
fileFormatVersion: 2
guid: 431e89a7d14485749b7ba6abb00ecbe3
PrefabImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

BIN
Assets/Scenes/Main.unity (Stored with Git LFS) View File

size 65336

+ 18
- 8
Assets/Scripts/Route/TileManager.cs View File

@ -10,6 +10,9 @@ public class TileManager : MonoBehaviour
[SerializeField] [SerializeField]
private int trackTiles = 10; private int trackTiles = 10;
[SerializeField]
private TileData m_finalTile;
private int m_bendProfile = 0; private int m_bendProfile = 0;
@ -30,10 +33,10 @@ public class TileManager : MonoBehaviour
for (int i = 0; i < trackTiles; i++) for (int i = 0; i < trackTiles; i++)
{ {
SpawnRandomTile();
SpawnTile();
} }
SpawnTile(m_finalTile);
} }
// Update is called once per frame // Update is called once per frame
@ -58,23 +61,30 @@ 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; 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; m_bendProfile += (int)_selectedTile.tileType;
var _newTileObj = Instantiate(_selectedTile.prefab); var _newTileObj = Instantiate(_selectedTile.prefab);
_newTileObj.transform.forward = m_currentTile.exitAnchor.transform.forward; _newTileObj.transform.forward = m_currentTile.exitAnchor.transform.forward;
var _newTileController = _newTileObj.GetComponent<TileController>();
var _newTileController = _newTileObj.GetComponentInChildren<TileController>();
Vector3 _offset = m_currentTile.exitAnchor.position - _newTileController.entryAnchor.position; Vector3 _offset = m_currentTile.exitAnchor.position - _newTileController.entryAnchor.position;
_newTileObj.transform.position += _offset; _newTileObj.transform.position += _offset;

Loading…
Cancel
Save