From 545caed8639199d3fdcd574a3ae5652fb1951a60 Mon Sep 17 00:00:00 2001
From: Jordan <jordan.pereira@etu.unistra.fr>
Date: Wed, 15 Dec 2021 12:22:03 +0100
Subject: [PATCH] Systeme tracage de route

---
 T3-Unity/Assets/Prefabs/Waypoint.prefab | 14 ++++----
 T3-Unity/Assets/Scenes/Map_Tests.unity  | 47 ++++++++++++++++++++++---
 T3-Unity/Assets/Scripts/GameManager.cs  | 18 +++++++---
 3 files changed, 63 insertions(+), 16 deletions(-)

diff --git a/T3-Unity/Assets/Prefabs/Waypoint.prefab b/T3-Unity/Assets/Prefabs/Waypoint.prefab
index 623d107..df3bb7d 100644
--- a/T3-Unity/Assets/Prefabs/Waypoint.prefab
+++ b/T3-Unity/Assets/Prefabs/Waypoint.prefab
@@ -11,7 +11,7 @@ GameObject:
   - component: {fileID: 901362092215755284}
   m_Layer: 0
   m_Name: Waypoint
-  m_TagString: Untagged
+  m_TagString: wp
   m_Icon: {fileID: 0}
   m_NavMeshLayer: 0
   m_StaticEditorFlags: 0
@@ -90,7 +90,7 @@ MeshRenderer:
   m_RenderingLayerMask: 1
   m_RendererPriority: 0
   m_Materials:
-  - {fileID: 2100000, guid: 27f1e34ec9273454ebc5ea9db98eb833, type: 2}
+  - {fileID: 2100000, guid: b4d771525b9636c4b9bf6a1640d82f46, type: 2}
   m_StaticBatchInfo:
     firstSubMesh: 0
     subMeshCount: 0
@@ -234,7 +234,7 @@ MonoBehaviour:
   m_OnCullStateChanged:
     m_PersistentCalls:
       m_Calls: []
-  m_text: START
+  m_text: 
   m_isRightToLeft: 0
   m_fontAsset: {fileID: 11400000, guid: 8f586378b4e144a9851e7b34d9b748ee, type: 2}
   m_sharedMaterial: {fileID: 2180264, guid: 8f586378b4e144a9851e7b34d9b748ee, type: 2}
@@ -303,13 +303,13 @@ MonoBehaviour:
   m_margin: {x: 7.599061, y: 0.41759348, z: 7.2742157, w: 0}
   m_textInfo:
     textComponent: {fileID: 4496217386513608057}
-    characterCount: 5
+    characterCount: 0
     spriteCount: 0
     spaceCount: 0
-    wordCount: 1
+    wordCount: 0
     linkCount: 0
-    lineCount: 1
-    pageCount: 1
+    lineCount: 0
+    pageCount: 0
     materialCount: 1
   m_isUsingLegacyAnimationComponent: 0
   m_isVolumetricText: 0
diff --git a/T3-Unity/Assets/Scenes/Map_Tests.unity b/T3-Unity/Assets/Scenes/Map_Tests.unity
index 8a3ab59..ab9e9fb 100644
--- a/T3-Unity/Assets/Scenes/Map_Tests.unity
+++ b/T3-Unity/Assets/Scenes/Map_Tests.unity
@@ -800,15 +800,30 @@ MonoBehaviour:
   m_PrefabInstance: {fileID: 0}
   m_PrefabAsset: {fileID: 0}
   m_GameObject: {fileID: 703254551}
-  m_Enabled: 1
+  m_Enabled: 0
   m_EditorHideFlags: 0
   m_Script: {fileID: 11500000, guid: cb9f22c201ea92c4ba4e0ccff8264b5b, type: 3}
   m_Name: 
   m_EditorClassIdentifier: 
   _map: {fileID: 703254553}
-  _locationStrings: []
-  _spawnScale: 100
-  _markerPrefab: {fileID: 2852985419580513409, guid: d0fa0a2d49f4ee44ebe2ec530d3cdf33,
+  _locationStrings:
+  - 48.858875, 2.320115
+  - 48.858494, 2.319832
+  - 48.858076, 2.319521
+  - 48.857702, 2.319244
+  - 48.858875, 2.320115
+  - 48.85736, 2.318761
+  - 48.857167, 2.318199
+  - 48.85736, 2.318761
+  - 48.857461, 2.31826
+  - 48.857673, 2.318417
+  - 48.858006, 2.318436
+  - 48.858006, 2.318436
+  - 48.858246, 2.318614
+  - 48.858743, 2.318983
+  - 48.858691, 2.319461
+  _spawnScale: 5
+  _markerPrefab: {fileID: 5106668611982552037, guid: 6a798f905f6b7dd4ea45b512de8e4537,
     type: 3}
 --- !u!1 &758898508
 GameObject:
@@ -886,6 +901,7 @@ GameObject:
   m_Component:
   - component: {fileID: 817057768}
   - component: {fileID: 817057767}
+  - component: {fileID: 817057769}
   m_Layer: 0
   m_Name: GameManager
   m_TagString: Untagged
@@ -906,10 +922,14 @@ MonoBehaviour:
   m_Name: 
   m_EditorClassIdentifier: 
   waypoints:
-  - {fileID: 2852985419580513409, guid: d0fa0a2d49f4ee44ebe2ec530d3cdf33, type: 3}
+  - {fileID: 2042676738254883600, guid: adcf133badada334581b9bd798be23cd, type: 3}
   - {fileID: 5106668611982552037, guid: 6a798f905f6b7dd4ea45b512de8e4537, type: 3}
   map: {fileID: 703254553}
   canvas: {fileID: 2056313312}
+  test: 0
+  objA: {fileID: 0}
+  objB: {fileID: 0}
+  nbWaypoint: 0
   locked: 0
 --- !u!4 &817057768
 Transform:
@@ -925,6 +945,23 @@ Transform:
   m_Father: {fileID: 0}
   m_RootOrder: 5
   m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
+--- !u!114 &817057769
+MonoBehaviour:
+  m_ObjectHideFlags: 0
+  m_CorrespondingSourceObject: {fileID: 0}
+  m_PrefabInstance: {fileID: 0}
+  m_PrefabAsset: {fileID: 0}
+  m_GameObject: {fileID: 817057766}
+  m_Enabled: 0
+  m_EditorHideFlags: 0
+  m_Script: {fileID: 11500000, guid: cd798a14eb5ec2f429324eab724cb025, type: 3}
+  m_Name: 
+  m_EditorClassIdentifier: 
+  objA: {fileID: 0}
+  objB: {fileID: 0}
+  rayLength: 20
+  mat: {fileID: 2100000, guid: b4d771525b9636c4b9bf6a1640d82f46, type: 2}
+  test: 0
 --- !u!1 &1255026297
 GameObject:
   m_ObjectHideFlags: 0
diff --git a/T3-Unity/Assets/Scripts/GameManager.cs b/T3-Unity/Assets/Scripts/GameManager.cs
index b857b69..ecc928a 100644
--- a/T3-Unity/Assets/Scripts/GameManager.cs
+++ b/T3-Unity/Assets/Scripts/GameManager.cs
@@ -3,14 +3,18 @@ using System.Collections.Generic;
 using UnityEngine;
 using Mapbox.Unity.Map;
 using Mapbox.Examples;
+using System;
 
 public class GameManager : MonoBehaviour
 {
     public GameObject[] waypoints;
     public AbstractMap map;
     public Canvas canvas;
-
-    private bool locked = false;
+    [SerializeField] int test = 0;
+    [SerializeField] Transform objA;
+    [SerializeField] Transform objB;
+    [SerializeField] int nbWaypoint = 0;
+    [SerializeField] bool locked = false;
     private Vector3 offset;
     private Plane _yPlane;
 
@@ -23,16 +27,22 @@ public class GameManager : MonoBehaviour
     // Update is called once per frame
     void Update()
     {
-        if (Input.GetKeyDown(KeyCode.Mouse0) && locked)
+        if (Input.GetKeyDown(KeyCode.Mouse0) && locked && nbWaypoint < 2)
         {
             Ray ray = Camera.main.ScreenPointToRay(Input.mousePosition);
 
             float enter = 0.0f;
             if (_yPlane.Raycast(ray, out enter))
             {
-                Instantiate(waypoints[0], ray.GetPoint(enter), new Quaternion(0, 0, 0, 0));
+                Instantiate(waypoints[nbWaypoint], ray.GetPoint(enter) + Vector3.up, new Quaternion(0, 0, 0, 0));
+                nbWaypoint++;
             }
         }
+
+        if (GameObject.FindGameObjectWithTag("start_wp") != null && GameObject.FindGameObjectWithTag("end_wp") != null)
+        {
+            GameObject.Find("GameManager").GetComponent<RouteTracer>().enabled = true;
+        }
     }
 
     // Lock la map
-- 
GitLab