diff --git a/Assets/Crossy Road VR/Scenes/Test/Scripts/SpawnTileScript.cs b/Assets/Crossy Road VR/Scenes/Test/Scripts/SpawnTileScript.cs
index e0ce06e..e717a38 100644
--- a/Assets/Crossy Road VR/Scenes/Test/Scripts/SpawnTileScript.cs
+++ b/Assets/Crossy Road VR/Scenes/Test/Scripts/SpawnTileScript.cs
@@ -2,6 +2,7 @@ using System.Collections;
using System.Collections.Generic;
using System.Runtime.CompilerServices;
using UnityEngine;
+using UnityEngine.UIElements;
public class SpawnTileScript : MonoBehaviour
{
@@ -17,19 +18,20 @@ public class SpawnTileScript : MonoBehaviour
}
- private void OnTriggerEnter(Collider other)
- {
- if (other.gameObject.tag == "Player")
- {
- if (_Instantiated)
- {
- GenerateTile(_Tiles[0]);
- }
- }
- }
+ //private void OnTriggerEnter(Collider other)
+ //{
+ // if (other.gameObject.tag == "Player")
+ // {
+ // if (_Instantiated)
+ // {
+ // GenerateTile(_Tiles[0]);
+ // }
+ // }
+ //}
- private void GenerateTile(GameObject tile)
+ public void GenerateTile(GameObject tile, Vector3 pos, Quaternion rot)
{
- Instantiate(tile, new Vector3(_CurrentTile.transform.position.x, _CurrentTile.transform.position.y, _CurrentTile.transform.position.z+20), _CurrentTile.transform.rotation);
+ //Instantiate(tile, new Vector3(_CurrentTile.transform.position.x, _CurrentTile.transform.position.y, _CurrentTile.transform.position.z+20), _CurrentTile.transform.rotation);
+ Instantiate(tile, pos, rot);
}
}
diff --git a/Assets/Crossy Road VR/Scenes/Test/Scripts/TileManagerScript.cs b/Assets/Crossy Road VR/Scenes/Test/Scripts/TileManagerScript.cs
new file mode 100644
index 0000000..3514db1
--- /dev/null
+++ b/Assets/Crossy Road VR/Scenes/Test/Scripts/TileManagerScript.cs
@@ -0,0 +1,104 @@
+using System.Collections.Generic;
+using System.Linq;
+using Unity.VisualScripting;
+using UnityEngine;
+
+///
+/// менеджер тайлов
+/// инициализация, создание новых, удаление, отслеживание кол-ва тайлов
+///
+public class TileManagerScript : MonoBehaviour
+{
+ ///
+ /// число тайлов, которые будут созданы
+ ///
+ [SerializeField]
+ private int _NumTile;
+
+ ///
+ /// номер текущего тайла
+ ///
+ public int CurrentTile;
+
+ //
+ [SerializeField]
+ private float _DistanceTiles;
+
+ [SerializeField]
+ private List _TilesPref = new List();
+
+ ///
+ /// поле массива тайлов
+ ///
+ private List _Tiles;
+
+ // при запуске сцены, создание новых тайлов
+ private void Awake()
+ {
+ Debug.Log($"NumTile = {_NumTile}");
+ // создание массива
+ _Tiles = new List(_NumTile);
+ Debug.Log($"_Tiles = {_Tiles.Count}");
+ // запихивание в массив тайлов null, чтобы понимать, что там пусто
+ for (int i = 0; i < _Tiles.Count; i++)
+ {
+ _Tiles[i] = null;
+ }
+ Debug.Log($"_Tiles = {_Tiles.Count}");
+ float z = (_NumTile/2) * _DistanceTiles;
+ Debug.Log($"z = {z}");
+
+ // создание тайлов назад от игрока, где i номер тайла, а z координата transfrom.position.z
+ for (int i = 0; i < _NumTile; i++)
+ {
+
+ GenerateTile(new Vector3(0, 0, z), new Quaternion(0, 0, 0, 0));
+ z -= _DistanceTiles;
+ }
+ }
+
+
+ ///
+ /// Генератор тайлов с собственным положением
+ ///
+ ///
+ ///
+ ///
+ public void GenerateTile(Vector3 pos, Quaternion rot)
+ {
+ Instantiate(_TilesPref[0], pos, rot);
+ }
+ ///
+ /// Генератор тайлов за последним
+ ///
+ public void GenerateTile()
+ {
+ Vector3 pos = _Tiles.Last().transform.position;
+ Quaternion rot = _Tiles.Last().transform.rotation;
+ Vector3 newVector = new Vector3(pos.x, pos.y, pos.z + _DistanceTiles);
+ Instantiate(_TilesPref[0], new Vector3(), rot);
+ DeleteTile();
+ }
+
+ ///
+ /// Удалитель тайлов
+ ///
+ ///
+ public void DeleteTile()
+ {
+ Destroy(_Tiles[0]);
+ _Tiles.RemoveAt(0);
+ //GenerateTile();
+ }
+
+ void Start()
+ {
+
+ }
+
+ // Update is called once per frame
+ void Update()
+ {
+
+ }
+}
diff --git a/Assets/TileManagerScript.cs.meta b/Assets/Crossy Road VR/Scenes/Test/Scripts/TileManagerScript.cs.meta
similarity index 100%
rename from Assets/TileManagerScript.cs.meta
rename to Assets/Crossy Road VR/Scenes/Test/Scripts/TileManagerScript.cs.meta
diff --git a/Assets/Crossy Road VR/Scenes/Test/Test Generate Map.unity b/Assets/Crossy Road VR/Scenes/Test/Test Generate Map.unity
index cf291dd..bb1b791 100644
--- a/Assets/Crossy Road VR/Scenes/Test/Test Generate Map.unity
+++ b/Assets/Crossy Road VR/Scenes/Test/Test Generate Map.unity
@@ -425,6 +425,10 @@ PrefabInstance:
propertyPath: m_Name
value: Floor (Black)
objectReference: {fileID: 0}
+ - target: {fileID: 8202227058476080034, guid: d113347864294f441883149abd377a24, type: 3}
+ propertyPath: m_IsActive
+ value: 0
+ objectReference: {fileID: 0}
m_RemovedComponents: []
m_RemovedGameObjects: []
m_AddedGameObjects: []
@@ -565,9 +569,11 @@ MonoBehaviour:
m_Script: {fileID: 11500000, guid: 673f57172fdd6084f8c03e4433c6967c, type: 3}
m_Name:
m_EditorClassIdentifier:
- _NumTile: 3
+ _NumTile: 6
CurrentTile: 0
- _Tiles: []
+ _DistanceTiles: 20
+ _TilesPref:
+ - {fileID: 8202227058476080034, guid: d113347864294f441883149abd377a24, type: 3}
--- !u!4 &1034189939
Transform:
m_ObjectHideFlags: 0
diff --git a/Assets/TileManagerScript.cs b/Assets/TileManagerScript.cs
deleted file mode 100644
index 8deadc1..0000000
--- a/Assets/TileManagerScript.cs
+++ /dev/null
@@ -1,42 +0,0 @@
-using System.Collections;
-using System.Collections.Generic;
-using UnityEngine;
-
-public class TileManagerScript : MonoBehaviour
-{
- [SerializeField]
- private int _NumTile = 3;
- public int CurrentTile;
-
- [SerializeField]
- private List _Tiles;
-
- // Start is called before the first frame update
-
- private void Awake()
- {
- _Tiles = new List(_NumTile);
- CurrentTile = _NumTile / 2;
-
- for (int i = 0; i < _Tiles.Count; i++)
- {
- _Tiles[i] = null;
- }
-
- for (int i = 0; i < _Tiles.Count; i++)
- {
-
- }
- }
-
- void Start()
- {
-
- }
-
- // Update is called once per frame
- void Update()
- {
-
- }
-}