diff --git a/T3-Unity/Assets/Mapbox/Examples/6_ZoomableMap/Scripts/SpawnOnMap.cs b/T3-Unity/Assets/Mapbox/Examples/6_ZoomableMap/Scripts/SpawnOnMap.cs deleted file mode 100644 index 0b7042f68a8fd114a934c68ca454645cc3232340..0000000000000000000000000000000000000000 --- a/T3-Unity/Assets/Mapbox/Examples/6_ZoomableMap/Scripts/SpawnOnMap.cs +++ /dev/null @@ -1,55 +0,0 @@ -namespace Mapbox.Examples -{ - using UnityEngine; - using Mapbox.Utils; - using Mapbox.Unity.Map; - using Mapbox.Unity.MeshGeneration.Factories; - using Mapbox.Unity.Utilities; - using System.Collections.Generic; - - public class SpawnOnMap : MonoBehaviour - { - [SerializeField] - AbstractMap _map; - - [SerializeField] - [Geocode] - string[] _locationStrings; - Vector2d[] _locations; - - [SerializeField] - float _spawnScale = 100f; - - [SerializeField] - GameObject _markerPrefab; - - List<GameObject> _spawnedObjects; - - void Start() - { - _locations = new Vector2d[_locationStrings.Length]; - _spawnedObjects = new List<GameObject>(); - for (int i = 0; i < _locationStrings.Length; i++) - { - var locationString = _locationStrings[i]; - _locations[i] = Conversions.StringToLatLon(locationString); - var instance = Instantiate(_markerPrefab); - instance.transform.localPosition = _map.GeoToWorldPosition(_locations[i], true); - instance.transform.localScale = new Vector3(_spawnScale, _spawnScale, _spawnScale); - _spawnedObjects.Add(instance); - } - } - - private void Update() - { - int count = _spawnedObjects.Count; - for (int i = 0; i < count; i++) - { - var spawnedObject = _spawnedObjects[i]; - var location = _locations[i]; - spawnedObject.transform.localPosition = _map.GeoToWorldPosition(location, true); - spawnedObject.transform.localScale = new Vector3(_spawnScale, _spawnScale, _spawnScale); - } - } - } -} \ No newline at end of file diff --git a/T3-Unity/Assets/Prefabs/Waypoint.prefab b/T3-Unity/Assets/Prefabs/Waypoint.prefab index 9c72163c19472f5523629aa3714d2f54dd603b86..72b6597b02c91cb7e64fa08e13b496e819234a5c 100644 --- a/T3-Unity/Assets/Prefabs/Waypoint.prefab +++ b/T3-Unity/Assets/Prefabs/Waypoint.prefab @@ -9,6 +9,7 @@ GameObject: serializedVersion: 6 m_Component: - component: {fileID: 901362092215755284} + - component: {fileID: 23660658557325912} m_Layer: 0 m_Name: Waypoint m_TagString: wp @@ -25,13 +26,50 @@ Transform: m_GameObject: {fileID: 901362092215755285} m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} m_LocalPosition: {x: 0, y: 0, z: 0} - m_LocalScale: {x: 2, y: 1, z: 2} + m_LocalScale: {x: 2, y: 2, z: 2} m_Children: - {fileID: 901362092661596065} - {fileID: 8516574415075833833} m_Father: {fileID: 0} m_RootOrder: 0 m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} +--- !u!23 &23660658557325912 +MeshRenderer: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 901362092215755285} + m_Enabled: 1 + m_CastShadows: 0 + m_ReceiveShadows: 0 + m_DynamicOccludee: 1 + m_MotionVectors: 1 + m_LightProbeUsage: 1 + m_ReflectionProbeUsage: 1 + m_RenderingLayerMask: 1 + m_RendererPriority: 0 + m_Materials: + - {fileID: 0} + m_StaticBatchInfo: + firstSubMesh: 0 + subMeshCount: 0 + m_StaticBatchRoot: {fileID: 0} + m_ProbeAnchor: {fileID: 0} + m_LightProbeVolumeOverride: {fileID: 0} + m_ScaleInLightmap: 1 + m_PreserveUVs: 0 + m_IgnoreNormalsForChartDetection: 0 + m_ImportantGI: 0 + m_StitchLightmapSeams: 0 + m_SelectedEditorRenderState: 3 + m_MinimumChartSize: 4 + m_AutoUVMaxDistance: 0.5 + m_AutoUVMaxAngle: 89 + m_LightmapParameters: {fileID: 0} + m_SortingLayerID: 0 + m_SortingLayer: 0 + m_SortingOrder: 0 --- !u!1 &901362092661596070 GameObject: m_ObjectHideFlags: 0 @@ -50,7 +88,7 @@ GameObject: m_Icon: {fileID: 0} m_NavMeshLayer: 0 m_StaticEditorFlags: 0 - m_IsActive: 0 + m_IsActive: 1 --- !u!4 &901362092661596065 Transform: m_ObjectHideFlags: 0 diff --git a/T3-Unity/Assets/Scenes/Map_Tests1.unity b/T3-Unity/Assets/Scenes/Map_Tests1.unity index 826abd567cf50d7f1b54feae346a1e3b70a87151..18cdcdb53eded8f09cf0fed6de74dd613303c041 100644 --- a/T3-Unity/Assets/Scenes/Map_Tests1.unity +++ b/T3-Unity/Assets/Scenes/Map_Tests1.unity @@ -38,7 +38,7 @@ RenderSettings: m_ReflectionIntensity: 1 m_CustomReflection: {fileID: 0} m_Sun: {fileID: 170076734} - m_IndirectSpecularColor: {r: 0.44657844, g: 0.49641222, b: 0.57481694, a: 1} + m_IndirectSpecularColor: {r: 0.44657874, g: 0.49641258, b: 0.5748172, a: 1} m_UseRadianceAmbientProbe: 0 --- !u!157 &3 LightmapSettings: @@ -1711,6 +1711,8 @@ MonoBehaviour: m_EditorClassIdentifier: panSpeed: 1 referenceCamera: {fileID: 534669904} + minZoom: 14 + maxZoom: 16 _zoomSpeed: 0.25 _useDegreeMethod: 0 _mapManager: {fileID: 703254553} @@ -1726,6 +1728,25 @@ MonoBehaviour: m_Script: {fileID: 11500000, guid: cd961b1c9541a4cee99686069ecce852, type: 3} m_Name: m_EditorClassIdentifier: +--- !u!114 &703254555 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 703254551} + m_Enabled: 0 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: dcf32ea2cc0514b569329f6b6b68f9b4, type: 3} + m_Name: + m_EditorClassIdentifier: + _map: {fileID: 703254553} + _locations: [] + _spawnScale: 1 + _markerPrefab: {fileID: 901362092215755285, guid: 18761a72aa6233c4bb4bd29dd401981e, + type: 3} + _spawnedObjects: [] + parent: {fileID: 1041475211} --- !u!1 &729711190 GameObject: m_ObjectHideFlags: 0 @@ -1982,9 +2003,9 @@ MonoBehaviour: m_Name: m_EditorClassIdentifier: mat: {fileID: 2100000, guid: b4d771525b9636c4b9bf6a1640d82f46, type: 2} - linesParent: {fileID: 0} - _startObject: {fileID: 0} - _finishObject: {fileID: 0} + linesParent: {fileID: 488440634} + _startObject: {x: 0, y: 0, z: 0} + _finishObject: {x: 0, y: 0, z: 0} --- !u!1 &927176943 GameObject: m_ObjectHideFlags: 0 @@ -2536,11 +2557,8 @@ MonoBehaviour: m_Script: {fileID: 11500000, guid: 46bc6c53f411bc84882c76fe1694830a, type: 3} m_Name: m_EditorClassIdentifier: - coordonnee1: - coordonnee2: _prefab: {fileID: 901362092215755284, guid: 18761a72aa6233c4bb4bd29dd401981e, type: 3} _prefabs_parent: {fileID: 1041475211} - infoJson: {fileID: 0} --- !u!4 &1041475211 Transform: m_ObjectHideFlags: 0 @@ -2549,7 +2567,7 @@ Transform: m_PrefabAsset: {fileID: 0} m_GameObject: {fileID: 1041475209} m_LocalRotation: {x: -0, y: -0, z: -0, w: 1} - m_LocalPosition: {x: -92.10596, y: 21.066406, z: 31.054688} + m_LocalPosition: {x: 0, y: 0, z: 0} m_LocalScale: {x: 1, y: 1, z: 1} m_Children: [] m_Father: {fileID: 1160038181} @@ -2704,7 +2722,7 @@ Transform: m_PrefabAsset: {fileID: 0} m_GameObject: {fileID: 1160038180} m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} - m_LocalPosition: {x: 82.63281, y: 77.359375, z: -41.15625} + m_LocalPosition: {x: 0, y: 0, z: 0} m_LocalScale: {x: 1, y: 1, z: 1} m_Children: - {fileID: 1041475211} diff --git a/T3-Unity/Assets/Scripts/GameManager.cs b/T3-Unity/Assets/Scripts/GameManager.cs index 64da76e9511dbfd8f6ff26836b1d286e7d2493eb..636ed8802857542f6a2b1aa0243ad3b313e70b8d 100644 --- a/T3-Unity/Assets/Scripts/GameManager.cs +++ b/T3-Unity/Assets/Scripts/GameManager.cs @@ -87,7 +87,7 @@ namespace Scripts } - GameObject.Find("GameManager").GetComponent<RouteTracer>().enabled = true; + //GameObject.Find("GameManager").GetComponent<RouteTracer>().enabled = true; } } diff --git a/T3-Unity/Assets/Scripts/IA/Runners.cs b/T3-Unity/Assets/Scripts/IA/Runners.cs index c596cdf530c51f057c58280afb8eb64a078a02d1..f18b3d06b39c35be2bee7aa2f02b15849777a698 100644 --- a/T3-Unity/Assets/Scripts/IA/Runners.cs +++ b/T3-Unity/Assets/Scripts/IA/Runners.cs @@ -2,17 +2,23 @@ { using UnityEngine; using Scripts.Waypoints; + using Mapbox.Utils; + using Mapbox.Unity.Map; public class Runners : MonoBehaviour { public float speed = 10f; + private AbstractMap _map; - private Transform target; + private Vector3 target; private int waypointIndex = 0; void Start() { - target = WaypointsFactory.getInstance().getWp()[0]; + _map = GameObject.Find("Map").GetComponent<AbstractMap>(); + + Debug.Log("JE SUIS CREE !"); + target = _map.GeoToWorldPosition(WaypointsFactory.getInstance().getWp()[0]); float vitesse = (float.Parse(RunnersFactory.getInstance().getRandom().Next(75, 125).ToString()) / 100f) * 10f; speed = vitesse; @@ -20,10 +26,10 @@ private void Update() { - Vector3 dir = target.position - transform.position; + Vector3 dir = target - transform.position; transform.Translate(dir.normalized * speed * Time.deltaTime, Space.World); - if (Vector3.Distance(transform.position, target.position) <= 0.3f) //Marge d'erreur + if (Vector3.Distance(transform.position, target) <= 0.3f) //Marge d'erreur { GetNextWaypoint(); } @@ -31,6 +37,7 @@ private void GetNextWaypoint() { + Debug.Log(target.ToString()); if (waypointIndex >= WaypointsFactory.getInstance().getWp().Count - 1) { Destroy(gameObject); @@ -38,7 +45,7 @@ } waypointIndex++; - target = WaypointsFactory.getInstance().getWp()[waypointIndex]; + target = _map.GeoToWorldPosition(WaypointsFactory.getInstance().getWp()[waypointIndex]); } } } \ No newline at end of file diff --git a/T3-Unity/Assets/Scripts/IA/RunnersFactory.cs b/T3-Unity/Assets/Scripts/IA/RunnersFactory.cs index ff3de5e323e650afd056bb023d0c04dfc7a9d2f8..0e18c7e81b0940346b5b5817ab5defe8dda54c30 100644 --- a/T3-Unity/Assets/Scripts/IA/RunnersFactory.cs +++ b/T3-Unity/Assets/Scripts/IA/RunnersFactory.cs @@ -2,6 +2,7 @@ { using UnityEngine; using Scripts.Waypoints; + using Mapbox.Unity.Map; public class RunnersFactory : MonoBehaviour { @@ -10,17 +11,16 @@ public Runners copy; private System.Random rdn; private static RunnersFactory instance; + private AbstractMap _map; void Start() { + _map = GameObject.Find("Map").GetComponent<AbstractMap>(); instance = this; rdn = new System.Random(); for (int i = 0; i < nbJoueur; i++) { - Instantiate(copy, - new Vector3(WaypointsFactory.getInstance().getWp()[0].transform.position.x, - WaypointsFactory.getInstance().getWp()[0].transform.position.y, - WaypointsFactory.getInstance().getWp()[0].transform.position.z), + Instantiate(copy, _map.GeoToWorldPosition(WaypointsFactory.getInstance().getWp()[0]), new Quaternion(0, 0, 0, 0), parent); } } diff --git a/T3-Unity/Assets/Scripts/Map/QuadTreeCameraMovement.cs b/T3-Unity/Assets/Scripts/Map/QuadTreeCameraMovement.cs index e65ed16195ad693a233478957b388ac3fd4b5490..9272c7e65c4b63ceb1ce7d58d909ceceb2fbc714 100644 --- a/T3-Unity/Assets/Scripts/Map/QuadTreeCameraMovement.cs +++ b/T3-Unity/Assets/Scripts/Map/QuadTreeCameraMovement.cs @@ -15,6 +15,8 @@ // Champs publiques [SerializeField] [Range(1, 20)] public float panSpeed = 1.0f; [SerializeField] public Camera referenceCamera; + public int minZoom = 14; + public int maxZoom = 16; // Champs privés private float _trueSpeed; @@ -147,7 +149,7 @@ // { var zoom = Mathf.Max(0.0f, Mathf.Min(_mapManager.Zoom + zoomFactor * _zoomSpeed, 21.0f)); //Debug.Log("zoom = "+zoom); - if (14 < zoom && zoom < 16) + if (minZoom < zoom && zoom < maxZoom) { if (Math.Abs(zoom - _mapManager.Zoom) > 0f) { diff --git a/T3-Unity/Assets/Scripts/Routes/RouteTracer.cs b/T3-Unity/Assets/Scripts/Routes/RouteTracer.cs index be11bad239ada7b0f42a3ca2e92cf75c24367b1b..4328eac134cef3df6749512fee081e2c2a6aa983 100644 --- a/T3-Unity/Assets/Scripts/Routes/RouteTracer.cs +++ b/T3-Unity/Assets/Scripts/Routes/RouteTracer.cs @@ -5,6 +5,8 @@ using UnityEngine; using Scripts.Waypoints; using Scripts.IA; + using Mapbox.Utils; + using Mapbox.Unity.Map; //! @authors MrWarzo //! Wakestufou @@ -17,15 +19,17 @@ public Transform linesParent; //!< @b GameObject contenant tout les morceaux de ligne. // Champs privés - private List<Transform> _waypoints; //!< Liste de tout les waypoints par lesquels la ligne doit passer. - [SerializeField] Transform _startObject; //!< @b GameObject de début de la ligne. - [SerializeField] Transform _finishObject; //!< @b GameObject de fin de la ligne. + private List<GameObject> _waypoints; //!< Liste de tout les waypoints par lesquels la ligne doit passer. + [SerializeField] Vector3 _startObject; //!< @b GameObject de début de la ligne. + [SerializeField] Vector3 _finishObject; //!< @b GameObject de fin de la ligne. + private AbstractMap _map; //! @brief Se lance au lancement du script. //! @details Initialise une coroutine sur @b CreateLine(). private void Start() { - StartCoroutine(CreateLine()); + _map = GameObject.Find("Map").GetComponent<AbstractMap>(); + CreateLine(); } //! @brief Création d'une ligne entre deux @b GameObject @@ -33,43 +37,25 @@ //! Lance ensuite la fonction @b DrawLine(Vector3, Vector3, Color, float) avec en paramètre des couples de cette liste de manière à tracer une ligne complète suivant les étapes entre le départ et l'arrivée. //! Une fois la ligne entière terminée, active la @b IA.RunnersFactory puis arrête la coroutine. //! @return @eIEnumerator Permet d'assigner un délai à la répétition de la coroutine. - IEnumerator CreateLine() + void CreateLine() { - yield return new WaitUntil(() => WaypointsFactory.getInstance().getTest() == false); - Debug.Log(WaypointsFactory.getInstance().getTest()); - _waypoints = WaypointsFactory.getInstance().getWp(); - - _startObject = GameObject.FindGameObjectWithTag("start_wp").transform; - _finishObject = GameObject.FindGameObjectWithTag("end_wp").transform; + _waypoints = SpawnOnMap.getInstance().getSpawnedObject(); for (int i = 0; i < _waypoints.Count - 1; i++) { - if (i == 0) - { - _startObject = GameObject.FindGameObjectWithTag("start_wp").transform; - _finishObject = _waypoints[i + 1]; - } - else if (i == _waypoints.Count - 2) - { - _startObject = _waypoints[i]; - _finishObject = GameObject.FindGameObjectWithTag("end_wp").transform; - } - else - { - _startObject = _waypoints[i]; - _finishObject = _waypoints[i + 1]; - } - DrawLine(_startObject.transform.position, _finishObject.transform.position, Color.cyan, 1f); + _startObject = _waypoints[i].transform.position; + _finishObject = _waypoints[i + 1].transform.position; + DrawLine(_startObject, _finishObject, Color.cyan, 1f); } GameObject.Find("Player").transform.position = new Vector3( - (float)((GameObject.FindGameObjectWithTag("start_wp").transform.position.x + GameObject.FindGameObjectWithTag("end_wp").transform.position.x) / 2d), + (float)((_waypoints[0].transform.position.x + _waypoints[_waypoints.Count - 1].transform.position.x) / 2d), GameObject.Find("Player").transform.position.y, - (float)((GameObject.FindGameObjectWithTag("start_wp").transform.position.z + GameObject.FindGameObjectWithTag("end_wp").transform.position.z) / 2d) + (float)((_waypoints[0].transform.position.z + _waypoints[_waypoints.Count - 1].transform.position.z) / 2d)// + 19f ); @@ -98,8 +84,8 @@ lr.endColor = color; lr.startWidth = width; lr.endWidth = width; - lr.SetPosition(0, start); - lr.SetPosition(1, end); + lr.SetPosition(0, start + Vector3.up); + lr.SetPosition(1, end + Vector3.up); } } } \ No newline at end of file diff --git a/T3-Unity/Assets/Scripts/Waypoints/SpawnOnMap.cs b/T3-Unity/Assets/Scripts/Waypoints/SpawnOnMap.cs new file mode 100644 index 0000000000000000000000000000000000000000..2e77e8818455d113c3e82328b7cae22f63b7f796 --- /dev/null +++ b/T3-Unity/Assets/Scripts/Waypoints/SpawnOnMap.cs @@ -0,0 +1,101 @@ +namespace Scripts.Waypoints +{ + using UnityEngine; + using Mapbox.Utils; + using Mapbox.Unity.Map; + using Mapbox.Unity.MeshGeneration.Factories; + using Mapbox.Unity.Utilities; + using System.Collections.Generic; + using Scripts.Routes; + using Scripts.Map; + + public class SpawnOnMap : MonoBehaviour + { + [SerializeField] + AbstractMap _map; + + [SerializeField] + [Geocode] + Vector2d[] _locations; + + [SerializeField] + float _spawnScale = 1f; + + [SerializeField] + GameObject _markerPrefab; + + public List<GameObject> _spawnedObjects; + + public Transform parent; + private float _zoom; + private static SpawnOnMap instance; + + void Start() + { + instance = this; + List<Vector2d> Waypoints = new List<Vector2d>(WaypointsFactory.getInstance().getWp()); + _locations = new Vector2d[Waypoints.Count]; + _spawnedObjects = new List<GameObject>(); + for (int i = 0; i < _locations.Length; i++) + { + _locations[i] = Waypoints[i]; + var instance = Instantiate(_markerPrefab, parent); + instance.transform.localPosition = _map.GeoToWorldPosition(_locations[i], true); + instance.transform.localScale = new Vector3(_spawnScale, _spawnScale, _spawnScale); + _spawnedObjects.Add(instance); + } + //GameObject.Find("Map").GetComponent<QuadTreeCameraMovement>().enabled = true; + //_cam = GameObject.Find("GameManager").GetComponent<QuadTreeCameraMovement>(); + //_cam.enabled = true; + //_cam.minZoom = 0; + _zoom = _map.Zoom; + } + + private void Update() + { + int count = _spawnedObjects.Count; + for (int i = 0; i < count; i++) + { + var spawnedObject = _spawnedObjects[i]; + var location = _locations[i]; + spawnedObject.transform.localPosition = _map.GeoToWorldPosition(location, true); + spawnedObject.transform.localScale = new Vector3(_spawnScale, _spawnScale, _spawnScale); + } + + if (VerifVisible()) + { + GameObject.Find("GameManager").GetComponent<RouteTracer>().enabled = true; + //this.enabled = false; + } else if (_zoom <= 2) + { + GameObject.Find("GameManager").GetComponent<RouteTracer>().enabled = true; + //this.enabled = false; + } + else + { + _zoom--; + _map.UpdateMap(_map.CenterLatitudeLongitude, _zoom); + } + } + + private bool VerifVisible() + { + bool verif = true; + for (int i = 0; i<_spawnedObjects.Count; i++) + { + if (!_spawnedObjects[i].GetComponent<Renderer>().isVisible) verif = false; + } + return verif; + } + + public List<GameObject> getSpawnedObject() + { + return _spawnedObjects; + } + + public static SpawnOnMap getInstance() + { + return instance; + } + } +} \ No newline at end of file diff --git a/T3-Unity/Assets/Mapbox/Examples/6_ZoomableMap/Scripts/SpawnOnMap.cs.meta b/T3-Unity/Assets/Scripts/Waypoints/SpawnOnMap.cs.meta similarity index 100% rename from T3-Unity/Assets/Mapbox/Examples/6_ZoomableMap/Scripts/SpawnOnMap.cs.meta rename to T3-Unity/Assets/Scripts/Waypoints/SpawnOnMap.cs.meta diff --git a/T3-Unity/Assets/Scripts/Waypoints/WaypointsFactory.cs b/T3-Unity/Assets/Scripts/Waypoints/WaypointsFactory.cs index 83b539597fb63f8b4f134ed05d400db9e5653b97..dc302faf19881d073eb04814453c6e38d0f6b356 100644 --- a/T3-Unity/Assets/Scripts/Waypoints/WaypointsFactory.cs +++ b/T3-Unity/Assets/Scripts/Waypoints/WaypointsFactory.cs @@ -6,8 +6,6 @@ using Mapbox.Utils; using Mapbox.Directions; using Mapbox.Unity; - using UnityEngine.UI; - using Mapbox.Json; using Mapbox.Utils.JsonConverters; using Mapbox.Unity.Map; @@ -15,10 +13,9 @@ public class WaypointsFactory : MonoBehaviour { - public static List<Transform> points; - public string coordonnee1; - public string coordonnee2; - private const string JSON_FILE = "test.json"; + public static List<Vector2d> points; + private string coordonnee1; + private string coordonnee2; public Transform _prefab; public Transform _prefabs_parent; private AbstractMap abstractmap; @@ -29,7 +26,6 @@ Vector2d[] _coordinates; DirectionResource _directionResource; - public Text infoJson; private DirectionsResponse DirectionResourceResultat; private bool test = true; @@ -38,7 +34,7 @@ instance = this; map = GameObject.Find("Map"); abstractmap = map.GetComponent<AbstractMap>(); - points = new List<Transform>(); + points = new List<Vector2d>(); coordonnee1 = ""; coordonnee2 = ""; _directions = MapboxAccess.Instance.Directions; @@ -60,7 +56,7 @@ return test; } - public List<Transform> getWp() + public List<Vector2d> getWp() { return points; } @@ -78,8 +74,6 @@ { DirectionResourceResultat = res; var data = JsonConvert.SerializeObject(res, Formatting.Indented, JsonConverters.Converters); - //infoJson.text = res.Routes[0].Legs[0].Steps[0].Intersections[0].Location.ToString(); - System.IO.File.WriteAllText(Application.dataPath + "\\" + JSON_FILE, data); test = false; } @@ -102,15 +96,8 @@ else { Route(); - /* - dynamic array = JsonConvert.DeserializeObject<string>(JSON_FILE); - foreach (var item in array) - { - Thread.Sleep(1); - infoJson.text = item.routes + "|" + item.legs; - //Debug.Log(item.routes + item.legs); - }*/ yield return new WaitUntil(() => test == false); + PlacementWaypoint(abstractmap.WorldToGeoPosition(GameObject.FindGameObjectWithTag("start_wp").transform.position)); foreach (var val in DirectionResourceResultat.Routes[0].Legs[0].Steps) { @@ -119,19 +106,15 @@ PlacementWaypoint(inter.Location); } } - } + PlacementWaypoint(abstractmap.WorldToGeoPosition(GameObject.FindGameObjectWithTag("end_wp").transform.position)); + map.GetComponent<SpawnOnMap>().enabled = true; + } } void PlacementWaypoint(Vector2d coordonnesPoints) { - points.Add(Instantiate(_prefab, new Vector3(abstractmap.GeoToWorldPosition(coordonnesPoints).x, 1, abstractmap.GeoToWorldPosition(coordonnesPoints).z), new Quaternion(0, 0, 0, 0), _prefabs_parent) as Transform); - /*points = new Transform[transform.childCount]; - for (int i = 0; i <1; i++) - { - Transform newGameObj = Instantiate(_prefab, new Vector3(0, 0, 0), new Quaternion(0, 0, 0, 0)) as Transform; - points[i] = transform.GetChild(i); - }*/ + points.Add(coordonnesPoints); } } } \ No newline at end of file diff --git a/T3-Unity/Assets/SpawnOnMap.cs b/T3-Unity/Assets/SpawnOnMap.cs new file mode 100644 index 0000000000000000000000000000000000000000..2b006e38b98ff9349056d7cc312c51d2a50cf775 --- /dev/null +++ b/T3-Unity/Assets/SpawnOnMap.cs @@ -0,0 +1,18 @@ +using System.Collections; +using System.Collections.Generic; +using UnityEngine; + +public class SpawnOnMap : MonoBehaviour +{ + // Start is called before the first frame update + void Start() + { + + } + + // Update is called once per frame + void Update() + { + + } +} diff --git a/T3-Unity/Assets/SpawnOnMap.cs.meta b/T3-Unity/Assets/SpawnOnMap.cs.meta new file mode 100644 index 0000000000000000000000000000000000000000..34a5156ffbd3c7bb87342c4eed261da0740cb820 --- /dev/null +++ b/T3-Unity/Assets/SpawnOnMap.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 7d9134162b20552469fd194b70715021 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/T3-Unity/Assets/test.json b/T3-Unity/Assets/test.json deleted file mode 100644 index cb14f22f0d5dbfa6a3e8bacbd91b95ac0fa6bb04..0000000000000000000000000000000000000000 --- a/T3-Unity/Assets/test.json +++ /dev/null @@ -1,1069 +0,0 @@ -{ - "routes": [ - { - "legs": [ - { - "steps": [ - { - "intersections": [ - { - "out": 0, - "entry": [ - true - ], - "bearings": [ - 252 - ], - "location": [ - 7.745167, - 48.571364 - ] - }, - { - "out": 1, - "entry": [ - false, - true - ], - "bearings": [ - 72, - 254 - ], - "location": [ - 7.744899, - 48.571307 - ], - "in": 0 - }, - { - "out": 1, - "entry": [ - false, - true - ], - "bearings": [ - 79, - 260 - ], - "location": [ - 7.742773, - 48.570948 - ], - "in": 0 - }, - { - "out": 1, - "entry": [ - false, - true - ], - "bearings": [ - 85, - 272 - ], - "location": [ - 7.740545, - 48.570839 - ], - "in": 0 - } - ], - "geometry": "_rmgHivgn@Ht@d@fEJ`ADj@Hz@Dv@Dl@Dx@BfA@dB?dB@b@@ZAzBAXAPERKVuApD", - "maneuver": { - "bearing_after": 252, - "type": "depart", - "modifier": null, - "bearing_before": 0, - "Location": [ - 7.745167, - 48.571364 - ], - "instruction": "Drive west on Rue de la Corderie." - }, - "duration": 40.337, - "distance": 509.439, - "name": "Rue de la Corderie", - "mode": "driving" - }, - { - "intersections": [ - { - "out": 1, - "entry": [ - false, - true - ], - "bearings": [ - 126, - 289 - ], - "location": [ - 7.738597, - 48.57139 - ], - "in": 0 - } - ], - "geometry": "ermgHgmfn@GZALAJ?JBNBHBJDD", - "maneuver": { - "bearing_after": 289, - "type": "fork", - "modifier": "slight left", - "bearing_before": 306, - "Location": [ - 7.738597, - 48.57139 - ], - "instruction": "Keep left to take Rue du Kuehlager." - }, - "duration": 5.647, - "distance": 45.0, - "name": "Rue du Kuehlager", - "mode": "driving" - }, - { - "intersections": [ - { - "out": 1, - "entry": [ - false, - true - ], - "bearings": [ - 60, - 201 - ], - "location": [ - 7.738045, - 48.571355 - ], - "in": 0 - }, - { - "out": 1, - "entry": [ - false, - true - ], - "bearings": [ - 21, - 183 - ], - "location": [ - 7.73796, - 48.571207 - ], - "in": 0 - }, - { - "out": 1, - "entry": [ - false, - true - ], - "bearings": [ - 2, - 164 - ], - "location": [ - 7.737924, - 48.570533 - ], - "in": 0 - } - ], - "geometry": "_rmgHyifn@HFFDJBF?j@BrABJAHAFCBCBI?G@S", - "maneuver": { - "bearing_after": 201, - "type": "continue", - "modifier": "slight left", - "bearing_before": 240, - "Location": [ - 7.738045, - 48.571355 - ], - "instruction": "Bear left to stay on Rue du Kuehlager." - }, - "duration": 20.734, - "distance": 127.0, - "name": "Rue du Kuehlager", - "mode": "driving" - }, - { - "intersections": [ - { - "out": 0, - "entry": [ - true, - false - ], - "bearings": [ - 84, - 300 - ], - "location": [ - 7.738172, - 48.570328 - ], - "in": 1 - }, - { - "out": 0, - "entry": [ - true, - false - ], - "bearings": [ - 86, - 264 - ], - "location": [ - 7.739587, - 48.570433 - ], - "in": 1 - }, - { - "out": 0, - "entry": [ - true, - false - ], - "bearings": [ - 87, - 266 - ], - "location": [ - 7.739912, - 48.570448 - ], - "in": 1 - }, - { - "out": 0, - "entry": [ - true, - false - ], - "bearings": [ - 84, - 270 - ], - "location": [ - 7.741345, - 48.570464 - ], - "in": 1 - }, - { - "out": 0, - "entry": [ - true, - false - ], - "bearings": [ - 66, - 262 - ], - "location": [ - 7.742174, - 48.57053 - ], - "in": 1 - }, - { - "out": 0, - "entry": [ - true, - false - ], - "bearings": [ - 80, - 246 - ], - "location": [ - 7.742453, - 48.570611 - ], - "in": 1 - }, - { - "out": 0, - "entry": [ - true, - false - ], - "bearings": [ - 71, - 252 - ], - "location": [ - 7.745524, - 48.571137 - ], - "in": 1 - }, - { - "out": 0, - "entry": [ - true, - false - ], - "bearings": [ - 77, - 254 - ], - "location": [ - 7.746503, - 48.571334 - ], - "in": 1 - } - ], - "geometry": "qkmgHqjfn@S{GAa@A]A{@?mA?uCEsAGoAOw@IqAKsAQiBWkCUsBSuAQuASmBOcBIiA", - "maneuver": { - "bearing_after": 84, - "type": "turn", - "modifier": "slight left", - "bearing_before": 120, - "Location": [ - 7.738172, - 48.570328 - ], - "instruction": "Bear left onto M 1004." - }, - "duration": 48.923, - "distance": 693.0, - "name": "", - "mode": "driving" - }, - { - "intersections": [ - { - "out": 0, - "entry": [ - true, - false - ], - "bearings": [ - 86, - 258 - ], - "location": [ - 7.747366, - 48.571463 - ], - "in": 1 - }, - { - "out": 0, - "entry": [ - true, - false - ], - "bearings": [ - 79, - 266 - ], - "location": [ - 7.747759, - 48.571481 - ], - "in": 1 - }, - { - "out": 0, - "entry": [ - true, - false - ], - "bearings": [ - 79, - 260 - ], - "location": [ - 7.750054, - 48.571763 - ], - "in": 1 - }, - { - "out": 0, - "entry": [ - true, - false - ], - "bearings": [ - 79, - 259 - ], - "location": [ - 7.750814, - 48.571861 - ], - "in": 1 - }, - { - "out": 0, - "entry": [ - true, - false - ], - "bearings": [ - 93, - 268 - ], - "location": [ - 7.752739, - 48.571999 - ], - "in": 1 - }, - { - "out": 0, - "entry": [ - true, - false - ], - "bearings": [ - 96, - 275 - ], - "location": [ - 7.753712, - 48.571956 - ], - "in": 1 - }, - { - "out": 0, - "entry": [ - true, - false - ], - "bearings": [ - 95, - 276 - ], - "location": [ - 7.754008, - 48.571934 - ], - "in": 1 - }, - { - "out": 0, - "entry": [ - true, - false - ], - "bearings": [ - 103, - 281 - ], - "location": [ - 7.754873, - 48.571845 - ], - "in": 1 - }, - { - "out": 0, - "entry": [ - true, - false - ], - "bearings": [ - 102, - 283 - ], - "location": [ - 7.755001, - 48.571826 - ], - "in": 1 - }, - { - "out": 0, - "entry": [ - true, - false - ], - "bearings": [ - 101, - 282 - ], - "location": [ - 7.755157, - 48.571804 - ], - "in": 1 - }, - { - "out": 0, - "entry": [ - true, - false - ], - "bearings": [ - 101, - 281 - ], - "location": [ - 7.755292, - 48.571787 - ], - "in": 1 - }, - { - "out": 0, - "entry": [ - true, - false - ], - "bearings": [ - 96, - 281 - ], - "location": [ - 7.755804, - 48.571721 - ], - "in": 1 - } - ], - "geometry": "srmgHadhn@CmA_@iFW_FSwCAOOaCGuBAyB@cADsB?I@M?G@E?G@WBcAJgBBYD_@@YJuA@O?EBm@", - "maneuver": { - "bearing_after": 86, - "type": "off ramp", - "modifier": "slight right", - "bearing_before": 78, - "Location": [ - 7.747366, - 48.571463 - ], - "instruction": "Take the exit." - }, - "duration": 129.478, - "distance": 649.0, - "name": "", - "mode": "driving" - }, - { - "intersections": [ - { - "out": 1, - "entry": [ - false, - true - ], - "bearings": [ - 276, - 346 - ], - "location": [ - 7.756061, - 48.571703 - ], - "in": 0 - }, - { - "out": 1, - "entry": [ - false, - true - ], - "bearings": [ - 166, - 344 - ], - "location": [ - 7.756012, - 48.571837 - ], - "in": 0 - }, - { - "out": 1, - "entry": [ - false, - true - ], - "bearings": [ - 164, - 346 - ], - "location": [ - 7.755869, - 48.572174 - ], - "in": 0 - }, - { - "out": 1, - "entry": [ - false, - true - ], - "bearings": [ - 166, - 346 - ], - "location": [ - 7.755703, - 48.572605 - ], - "in": 0 - }, - { - "out": 1, - "entry": [ - false, - true - ], - "bearings": [ - 166, - 346 - ], - "location": [ - 7.755569, - 48.572954 - ], - "in": 0 - } - ], - "geometry": "ctmgHkzin@QDIBaAZwA`@cAXQD", - "maneuver": { - "bearing_after": 346, - "type": "turn", - "modifier": "left", - "bearing_before": 96, - "Location": [ - 7.756061, - 48.571703 - ], - "instruction": "Turn left onto Route de Vienne." - }, - "duration": 34.511, - "distance": 153.0, - "name": "Route de Vienne", - "mode": "driving" - }, - { - "intersections": [ - { - "out": 0, - "entry": [ - true, - false - ], - "bearings": [ - 37, - 166 - ], - "location": [ - 7.755538, - 48.573035 - ], - "in": 1 - }, - { - "out": 0, - "entry": [ - true, - false - ], - "bearings": [ - 86, - 217 - ], - "location": [ - 7.755655, - 48.573138 - ], - "in": 1 - }, - { - "out": 0, - "entry": [ - true, - false - ], - "bearings": [ - 103, - 282 - ], - "location": [ - 7.756367, - 48.57309 - ], - "in": 1 - }, - { - "out": 0, - "entry": [ - true, - false - ], - "bearings": [ - 102, - 283 - ], - "location": [ - 7.756527, - 48.573066 - ], - "in": 1 - }, - { - "out": 0, - "entry": [ - true, - false - ], - "bearings": [ - 102, - 282 - ], - "location": [ - 7.756808, - 48.573025 - ], - "in": 1 - }, - { - "out": 0, - "entry": [ - true, - false - ], - "bearings": [ - 93, - 281 - ], - "location": [ - 7.759193, - 48.572713 - ], - "in": 1 - }, - { - "out": 0, - "entry": [ - true, - false - ], - "bearings": [ - 98, - 268 - ], - "location": [ - 7.760009, - 48.572708 - ], - "in": 1 - }, - { - "out": 0, - "entry": [ - true, - false - ], - "bearings": [ - 95, - 275 - ], - "location": [ - 7.761091, - 48.572621 - ], - "in": 1 - }, - { - "out": 0, - "entry": [ - true, - false - ], - "bearings": [ - 92, - 275 - ], - "location": [ - 7.761945, - 48.572574 - ], - "in": 1 - }, - { - "out": 0, - "entry": [ - true, - false - ], - "bearings": [ - 93, - 272 - ], - "location": [ - 7.762388, - 48.572563 - ], - "in": 1 - } - ], - "geometry": "o|mgHcwin@IIIMCKAUNkB@O@OFw@D[x@_M@kAAwALaCBuADcBBgA@gA?O?O", - "maneuver": { - "bearing_after": 102, - "type": "turn", - "modifier": "right", - "bearing_before": 346, - "Location": [ - 7.755538, - 48.573035 - ], - "instruction": "Turn right to take the ramp." - }, - "duration": 82.846, - "distance": 522.0, - "name": "Avenue du Rhin", - "mode": "driving" - }, - { - "intersections": [ - { - "out": 0, - "entry": [ - true, - false - ], - "bearings": [ - 153, - 273 - ], - "location": [ - 7.762465, - 48.57256 - ], - "in": 1 - }, - { - "out": 0, - "entry": [ - true, - false - ], - "bearings": [ - 155, - 333 - ], - "location": [ - 7.762503, - 48.572511 - ], - "in": 1 - } - ], - "geometry": "oymgHmbkn@HEHIFEFA", - "maneuver": { - "bearing_after": 155, - "type": "turn", - "modifier": "right", - "bearing_before": 93, - "Location": [ - 7.762465, - 48.57256 - ], - "instruction": "Turn right." - }, - "duration": 6.886, - "distance": 23.0, - "name": "", - "mode": "driving" - }, - { - "intersections": [ - { - "out": 0, - "entry": [ - true, - false - ], - "bearings": [ - 202, - 337 - ], - "location": [ - 7.762593, - 48.572375 - ], - "in": 1 - }, - { - "out": 1, - "entry": [ - false, - true - ], - "bearings": [ - 36, - 266 - ], - "location": [ - 7.762478, - 48.572239 - ], - "in": 0 - }, - { - "out": 1, - "entry": [ - false, - true - ], - "bearings": [ - 99, - 324 - ], - "location": [ - 7.762205, - 48.572248 - ], - "in": 0 - }, - { - "out": 0, - "entry": [ - true, - false - ], - "bearings": [ - 0, - 167 - ], - "location": [ - 7.762057, - 48.572458 - ], - "in": 1 - } - ], - "geometry": "kxmgHeckn@J?DBDHBF@N@PAJCFCHGHKDQBE?G?", - "maneuver": { - "bearing_after": 324, - "type": "continue", - "modifier": "uturn", - "bearing_before": 157, - "Location": [ - 7.762593, - 48.572375 - ], - "instruction": "Make a right U-turn." - }, - "duration": 16.48, - "distance": 75.0, - "name": "", - "mode": "driving" - }, - { - "intersections": [ - { - "out": 1, - "entry": [ - false, - true - ], - "bearings": [ - 180, - 338 - ], - "location": [ - 7.762057, - 48.572531 - ], - "in": 0 - } - ], - "geometry": "iymgH{_kn@UJILCHGPEPMlA", - "maneuver": { - "bearing_after": 338, - "type": "turn", - "modifier": "slight left", - "bearing_before": 0, - "Location": [ - 7.762057, - 48.572531 - ], - "instruction": "Bear left toward P 1 Centre commercial." - }, - "duration": 12.685, - "distance": 69.933, - "name": "", - "mode": "driving" - }, - { - "intersections": [ - { - "out": 0, - "entry": [ - true - ], - "bearings": [ - 105 - ], - "location": [ - 7.761308, - 48.572845 - ], - "in": 0 - } - ], - "geometry": "i{mgHe{jn@??", - "maneuver": { - "bearing_after": 0, - "type": "arrive", - "modifier": null, - "bearing_before": 285, - "Location": [ - 7.761308, - 48.572845 - ], - "instruction": "You have arrived at your destination." - }, - "duration": 0.0, - "distance": 0.0, - "name": "", - "mode": "driving" - } - ], - "summary": "M 1004, Avenue du Rhin", - "duration": 398.526, - "distance": 2866.371, - "annotation": null - } - ], - "geometry": "_rmgHivgn@vAlONlKEfDgB|EDlBpDVZo@g@_XyDo_@iBw\\x@qWkGfBYy@zA_T\\oSb@W\\bA{@d@_AtC", - "duration": 398.526, - "distance": 2866.371, - "weight": 623.91, - "weight_name": "auto" - } - ], - "waypoints": [ - { - "name": "Rue de la Corderie", - "location": [ - 7.745167, - 48.571364 - ] - }, - { - "name": "", - "location": [ - 7.761308, - 48.572845 - ] - } - ], - "code": "Ok" -} \ No newline at end of file