Marcel Zickler %!s(int64=3) %!d(string=hai) anos
pai
achega
e0247ae399

+ 5 - 38
Assets/Editor/RouteEditor.cs

@@ -9,6 +9,7 @@ using UnityEditor;
 using UnityEngine;
 using UnityEngine.Rendering;
 using UnityEngine.Rendering.UI;
+using Object = UnityEngine.Object;
 
 
 [CustomEditor(typeof(Route))]
@@ -120,16 +121,11 @@ public class RoutesEditor : UnityEditor.Editor
                 SwitchSelectionMode();
             }
 
-            /*if (GUILayout.Button("Clear", GUILayout.Width(56)))
+            if (GUILayout.Button("Clear", GUILayout.Width(56)))
             {
                 Clear();
-            }*/
-
-            if (GUILayout.Button("Invert", GUILayout.Width(56)))
-            {
-                Invert();
             }
-
+            
             GUILayout.FlexibleSpace();
             EditorGUILayout.EndHorizontal();
             for (var i = 0; i < list.arraySize; i++)
@@ -149,41 +145,12 @@ public class RoutesEditor : UnityEditor.Editor
 
         EditorGUILayout.EndFoldoutHeaderGroup();
     }
+    
 
-    private void Invert()
+    private void Clear()
     {
         var items = serializedObject.FindProperty("items");
-        var size = items.arraySize;
-
-        var start = serializedObject.FindProperty("start");
-        var finish = serializedObject.FindProperty("finish");
-
-        var oldStart = start.objectReferenceValue;
-        start.objectReferenceValue = finish.objectReferenceValue;
-        finish.objectReferenceValue = oldStart;
-        
-        var inverted = new List<JunctionExtras>();
-
-        for (int i = size - 1; i >= 0; i--)
-        {
-            var item = (JunctionExtras) items.GetArrayElementAtIndex(i).objectReferenceValue;
-            inverted.Add(item);
-        }
-
         items.ClearArray();
-
-        for (int i = 0; i < inverted.Count; i++)
-        {
-            items.InsertArrayElementAtIndex(i);
-            inverted[i].comingFrom = RoadDirectionHelper.OppositeOf(inverted[i].comingFrom);
-            inverted[i].goingTo = RoadDirectionHelper.OppositeOf(inverted[i].goingTo);
-            items.GetArrayElementAtIndex(i).objectReferenceValue = inverted[i];
-        }
-    }
-
-    private void Clear()
-    {
-        throw new NotImplementedException();
     }
 
     private void SwitchSelectionMode()

+ 2 - 3
Assets/Plotting/.idea/workspace.xml

@@ -1,9 +1,7 @@
 <?xml version="1.0" encoding="UTF-8"?>
 <project version="4">
   <component name="ChangeListManager">
-    <list default="true" id="ee646045-196c-400d-a2b8-69533432d097" name="Default Changelist" comment="">
-      <change beforePath="$PROJECT_DIR$/../../.idea/.idea.VR Cycling/.idea/indexLayout.xml" beforeDir="false" afterPath="$PROJECT_DIR$/../../.idea/.idea.VR Cycling/.idea/indexLayout.xml" afterDir="false" />
-    </list>
+    <list default="true" id="ee646045-196c-400d-a2b8-69533432d097" name="Default Changelist" comment="" />
     <option name="SHOW_DIALOG" value="false" />
     <option name="HIGHLIGHT_CONFLICTS" value="true" />
     <option name="HIGHLIGHT_NON_ACTIVE_CHANGELIST" value="false" />
@@ -71,6 +69,7 @@
       <workItem from="1609929396953" duration="1851000" />
       <workItem from="1610104231320" duration="1600000" />
       <workItem from="1610563608926" duration="62000" />
+      <workItem from="1620708746836" duration="19000" />
     </task>
     <servers />
   </component>

A diferenza do arquivo foi suprimida porque é demasiado grande
+ 558 - 316
Assets/Scenes/MainScene.unity


+ 37 - 3
Assets/Scripts/Routes/RouteManager.cs

@@ -1,4 +1,5 @@
-using Controller.Bicycle;
+using System.Linq;
+using Controller.Bicycle;
 using UnityEngine;
 
 namespace Routes
@@ -24,15 +25,48 @@ namespace Routes
             routes[selectedRoute].OnStartEntered += OnOnStartEntered;
             routes[selectedRoute].OnFinishPassed += OnOnFinishPassed;
 
+            PlaceBike();
+        }
+
+        private void PlaceBike()
+        {
+            var firstTurnPos = routes[selectedRoute].items.First().turn.transform.position;
 
             var startTransform = routes[selectedRoute].start.gameObject.transform;
             var startRotationEuler = startTransform.rotation.eulerAngles;
+
+            var difStartFirstTurn = firstTurnPos - startTransform.position;
+            Vector3 bikeDirection = Vector3.zero;
+            Vector3 bikeRotation = Vector3.zero;
+
+            if (difStartFirstTurn.x > 1)
+            {
+                bikeDirection = startTransform.right;
+                bikeRotation = new Vector3(0, -90, 0);
+            }
+            else if (difStartFirstTurn.z > 1)
+            {
+                bikeDirection = startTransform.forward;
+                bikeRotation = new Vector3(0, -180, 0);
+            }
+            else if (difStartFirstTurn.x < -1)
+            {
+                bikeDirection = -startTransform.right;
+                bikeRotation = new Vector3(0, 90, 0);
+            }
+            else if (difStartFirstTurn.z < -1)
+            {
+                bikeDirection = -startTransform.forward;
+                bikeRotation = new Vector3(0, 180, 0);
+            }
+
             bicycleGameObject = bicycle.gameObject;
             bicycleGameObject.transform.SetPositionAndRotation(
-                startTransform.position + startTransform.right * 12,
-                Quaternion.Euler(startRotationEuler + new Vector3(0, -90, 0)));
+                startTransform.position + bikeDirection * 12,
+                Quaternion.Euler(startRotationEuler + bikeRotation));
         }
 
+
         private void OnOnFinishPassed()
         {
             //bicycle.enabled = false;

Algúns arquivos non se mostraron porque demasiados arquivos cambiaron neste cambio