Browse Source

Fixed routes completely

Marcel Zickler 3 years ago
parent
commit
9ee18e7b50

+ 1 - 0
Assembly-CSharp.csproj

@@ -296,6 +296,7 @@
      <Compile Include="Assets\Scripts\Routes\Route.cs" />
      <Compile Include="Assets\Scripts\Routes\RouteManager.cs" />
      <Compile Include="Assets\Scripts\Routes\Turn.cs" />
+     <Compile Include="Assets\Scripts\Routes\TurnDirectionMapper.cs" />
      <Compile Include="Assets\Scripts\Sensors\ANT\HrReceiver.cs" />
      <Compile Include="Assets\Scripts\Sensors\ANT\PowerMeterReceiver.cs" />
      <Compile Include="Assets\Scripts\Sensors\ANT\SpeedSensorReceiver.cs" />

+ 18 - 0
Assets/Prefabs/Roads/Road_Junction.prefab

@@ -144,6 +144,7 @@ GameObject:
   m_Component:
   - component: {fileID: 1682435362963659099}
   - component: {fileID: 1929101100484375460}
+  - component: {fileID: 4268401987894089247}
   m_Layer: 0
   m_Name: Road_Junction
   m_TagString: Untagged
@@ -184,6 +185,23 @@ MonoBehaviour:
   m_EditorClassIdentifier: 
   comingFrom: 4
   goingTo: 4
+  junctionData:
+    north: {fileID: 5649092369451393666}
+    east: {fileID: 8161612656808989192}
+    south: {fileID: 4150568125881694722}
+--- !u!65 &4268401987894089247
+BoxCollider:
+  m_ObjectHideFlags: 0
+  m_CorrespondingSourceObject: {fileID: 0}
+  m_PrefabInstance: {fileID: 0}
+  m_PrefabAsset: {fileID: 0}
+  m_GameObject: {fileID: 6779282248948444977}
+  m_Material: {fileID: 0}
+  m_IsTrigger: 1
+  m_Enabled: 1
+  serializedVersion: 2
+  m_Size: {x: 20, y: 6, z: 20}
+  m_Center: {x: 0, y: 3, z: 0}
 --- !u!1 &7717470968696966125
 GameObject:
   m_ObjectHideFlags: 0

+ 113 - 108
Assets/Scenes/MainScene.unity

@@ -100343,16 +100343,6 @@ PrefabInstance:
       propertyPath: m_LocalEulerAnglesHint.z
       value: 0
       objectReference: {fileID: 0}
-    - target: {fileID: 5908241662424435614, guid: 8b8f51b9ab677d14789d28c0522c7e4c,
-        type: 3}
-      propertyPath: goingTo
-      value: 2
-      objectReference: {fileID: 0}
-    - target: {fileID: 5908241662424435614, guid: 8b8f51b9ab677d14789d28c0522c7e4c,
-        type: 3}
-      propertyPath: comingFrom
-      value: 0
-      objectReference: {fileID: 0}
     - target: {fileID: 6779282248948444977, guid: 8b8f51b9ab677d14789d28c0522c7e4c,
         type: 3}
       propertyPath: m_Name
@@ -131895,18 +131885,6 @@ Transform:
     type: 3}
   m_PrefabInstance: {fileID: 1074948672}
   m_PrefabAsset: {fileID: 0}
---- !u!114 &549215465 stripped
-MonoBehaviour:
-  m_CorrespondingSourceObject: {fileID: 5908241662424435614, guid: 8b8f51b9ab677d14789d28c0522c7e4c,
-    type: 3}
-  m_PrefabInstance: {fileID: 48593010}
-  m_PrefabAsset: {fileID: 0}
-  m_GameObject: {fileID: 0}
-  m_Enabled: 1
-  m_EditorHideFlags: 0
-  m_Script: {fileID: 11500000, guid: 7bc613422f424ecbab70286630638b48, type: 3}
-  m_Name: 
-  m_EditorClassIdentifier: 
 --- !u!4 &549701974 stripped
 Transform:
   m_CorrespondingSourceObject: {fileID: 412702, guid: 7b30b5ba44201104fba4e71a527b6905,
@@ -237160,6 +237138,18 @@ Transform:
     type: 3}
   m_PrefabInstance: {fileID: 986831717}
   m_PrefabAsset: {fileID: 0}
+--- !u!114 &987259120 stripped
+MonoBehaviour:
+  m_CorrespondingSourceObject: {fileID: 1929101100484375460, guid: f1b4cbd2f891a5c46aedca9958dc3ed1,
+    type: 3}
+  m_PrefabInstance: {fileID: 624490147}
+  m_PrefabAsset: {fileID: 0}
+  m_GameObject: {fileID: 0}
+  m_Enabled: 1
+  m_EditorHideFlags: 0
+  m_Script: {fileID: 11500000, guid: ad8f054f47e6472581c773771c181bc4, type: 3}
+  m_Name: 
+  m_EditorClassIdentifier: 
 --- !u!1001 &988650480
 PrefabInstance:
   m_ObjectHideFlags: 0
@@ -239853,6 +239843,18 @@ PrefabInstance:
       objectReference: {fileID: 0}
     m_RemovedComponents: []
   m_SourcePrefab: {fileID: 100100000, guid: f9c5e344bb1131f4f83e34b3f8cae927, type: 3}
+--- !u!114 &1003356207 stripped
+MonoBehaviour:
+  m_CorrespondingSourceObject: {fileID: 1929101100484375460, guid: f1b4cbd2f891a5c46aedca9958dc3ed1,
+    type: 3}
+  m_PrefabInstance: {fileID: 1447897012}
+  m_PrefabAsset: {fileID: 0}
+  m_GameObject: {fileID: 0}
+  m_Enabled: 1
+  m_EditorHideFlags: 0
+  m_Script: {fileID: 11500000, guid: ad8f054f47e6472581c773771c181bc4, type: 3}
+  m_Name: 
+  m_EditorClassIdentifier: 
 --- !u!1001 &1003723173
 PrefabInstance:
   m_ObjectHideFlags: 0
@@ -299479,18 +299481,6 @@ Transform:
     type: 3}
   m_PrefabInstance: {fileID: 579390416}
   m_PrefabAsset: {fileID: 0}
---- !u!114 &1261825046 stripped
-MonoBehaviour:
-  m_CorrespondingSourceObject: {fileID: 5908241662424435614, guid: 8b8f51b9ab677d14789d28c0522c7e4c,
-    type: 3}
-  m_PrefabInstance: {fileID: 1917596212}
-  m_PrefabAsset: {fileID: 0}
-  m_GameObject: {fileID: 0}
-  m_Enabled: 1
-  m_EditorHideFlags: 0
-  m_Script: {fileID: 11500000, guid: 7bc613422f424ecbab70286630638b48, type: 3}
-  m_Name: 
-  m_EditorClassIdentifier: 
 --- !u!1001 &1261836580
 PrefabInstance:
   m_ObjectHideFlags: 0
@@ -312530,6 +312520,18 @@ Transform:
     type: 3}
   m_PrefabInstance: {fileID: 1318038323}
   m_PrefabAsset: {fileID: 0}
+--- !u!114 &1318096299 stripped
+MonoBehaviour:
+  m_CorrespondingSourceObject: {fileID: 1929101100484375460, guid: f1b4cbd2f891a5c46aedca9958dc3ed1,
+    type: 3}
+  m_PrefabInstance: {fileID: 1444958998}
+  m_PrefabAsset: {fileID: 0}
+  m_GameObject: {fileID: 0}
+  m_Enabled: 1
+  m_EditorHideFlags: 0
+  m_Script: {fileID: 11500000, guid: ad8f054f47e6472581c773771c181bc4, type: 3}
+  m_Name: 
+  m_EditorClassIdentifier: 
 --- !u!1001 &1318320385
 PrefabInstance:
   m_ObjectHideFlags: 0
@@ -365180,6 +365182,18 @@ Transform:
     type: 3}
   m_PrefabInstance: {fileID: 1545577087}
   m_PrefabAsset: {fileID: 0}
+--- !u!114 &1546069026 stripped
+MonoBehaviour:
+  m_CorrespondingSourceObject: {fileID: 5908241662424435614, guid: 8b8f51b9ab677d14789d28c0522c7e4c,
+    type: 3}
+  m_PrefabInstance: {fileID: 932570561}
+  m_PrefabAsset: {fileID: 0}
+  m_GameObject: {fileID: 0}
+  m_Enabled: 1
+  m_EditorHideFlags: 0
+  m_Script: {fileID: 11500000, guid: 7bc613422f424ecbab70286630638b48, type: 3}
+  m_Name: 
+  m_EditorClassIdentifier: 
 --- !u!4 &1546145600 stripped
 Transform:
   m_CorrespondingSourceObject: {fileID: 1121772855208284805, guid: a8075fecadfce7c4abe277fb835ca5c5,
@@ -378450,6 +378464,18 @@ Transform:
     type: 3}
   m_PrefabInstance: {fileID: 1598556458}
   m_PrefabAsset: {fileID: 0}
+--- !u!114 &1598958500 stripped
+MonoBehaviour:
+  m_CorrespondingSourceObject: {fileID: 1929101100484375460, guid: f1b4cbd2f891a5c46aedca9958dc3ed1,
+    type: 3}
+  m_PrefabInstance: {fileID: 810294905}
+  m_PrefabAsset: {fileID: 0}
+  m_GameObject: {fileID: 0}
+  m_Enabled: 1
+  m_EditorHideFlags: 0
+  m_Script: {fileID: 11500000, guid: ad8f054f47e6472581c773771c181bc4, type: 3}
+  m_Name: 
+  m_EditorClassIdentifier: 
 --- !u!1001 &1598967586
 PrefabInstance:
   m_ObjectHideFlags: 0
@@ -431593,18 +431619,6 @@ Transform:
     type: 3}
   m_PrefabInstance: {fileID: 1839022487}
   m_PrefabAsset: {fileID: 0}
---- !u!114 &1839307290 stripped
-MonoBehaviour:
-  m_CorrespondingSourceObject: {fileID: 5908241662424435614, guid: 8b8f51b9ab677d14789d28c0522c7e4c,
-    type: 3}
-  m_PrefabInstance: {fileID: 656569659}
-  m_PrefabAsset: {fileID: 0}
-  m_GameObject: {fileID: 0}
-  m_Enabled: 1
-  m_EditorHideFlags: 0
-  m_Script: {fileID: 11500000, guid: 7bc613422f424ecbab70286630638b48, type: 3}
-  m_Name: 
-  m_EditorClassIdentifier: 
 --- !u!1001 &1839507940
 PrefabInstance:
   m_ObjectHideFlags: 0
@@ -449331,33 +449345,36 @@ MonoBehaviour:
     to: 2
   - turn: {fileID: 18472990}
     from: 0
-    to: 3
-  - turn: {fileID: 1998860976}
-    from: 1
-    to: 3
-  - turn: {fileID: 549215465}
-    from: 1
     to: 2
-  - turn: {fileID: 1839307290}
+  - turn: {fileID: 1248160490}
     from: 0
     to: 1
-  - turn: {fileID: 2129671049}
-    from: 3
-    to: 1
-  - turn: {fileID: 1248160490}
+  - turn: {fileID: 1496827268}
     from: 3
     to: 2
-  - turn: {fileID: 2110517520}
+  - turn: {fileID: 946838796}
     from: 0
     to: 1
-  - turn: {fileID: 946838796}
+  - turn: {fileID: 987259120}
     from: 3
     to: 0
-  - turn: {fileID: 1496827268}
+  - turn: {fileID: 1546069026}
     from: 2
+    to: 1
+  - turn: {fileID: 1598958500}
+    from: 3
     to: 0
-  - turn: {fileID: 99796066}
+  - turn: {fileID: 1318096299}
     from: 2
+    to: 3
+  - turn: {fileID: 1976143583}
+    from: 1
+    to: 2
+  - turn: {fileID: 2049304755}
+    from: 0
+    to: 3
+  - turn: {fileID: 99796066}
+    from: 1
     to: 0
   - turn: {fileID: 1264150695}
     from: 2
@@ -449367,23 +449384,23 @@ MonoBehaviour:
     to: 0
   - turn: {fileID: 1997061101}
     from: 2
+    to: 3
+  - turn: {fileID: 1003356207}
+    from: 1
     to: 0
-  - turn: {fileID: 1261825046}
+  - turn: {fileID: 1356213784}
     from: 2
-    to: 1
-  - turn: {fileID: 1171525601}
-    from: 3
     to: 0
-  - turn: {fileID: 2099722422}
+  - turn: {fileID: 1951792574}
     from: 2
-    to: 3
+    to: 1
   - turn: {fileID: 1344655401}
-    from: 1
-    to: 3
-  - turn: {fileID: 1951792574}
-    from: 1
+    from: 3
+    to: 1
+  - turn: {fileID: 2099722422}
+    from: 3
     to: 2
-  - turn: {fileID: 1356213784}
+  - turn: {fileID: 1171525601}
     from: 0
     to: 2
 --- !u!1001 &1915533873
@@ -465122,6 +465139,18 @@ PrefabInstance:
       objectReference: {fileID: 2100000, guid: c29d9dff2056b1543bbb70ec32427a62, type: 2}
     m_RemovedComponents: []
   m_SourcePrefab: {fileID: 100100000, guid: 77dd7072ed0a2784d87c474eb9a288b7, type: 3}
+--- !u!114 &1976143583 stripped
+MonoBehaviour:
+  m_CorrespondingSourceObject: {fileID: 5908241662424435614, guid: 8b8f51b9ab677d14789d28c0522c7e4c,
+    type: 3}
+  m_PrefabInstance: {fileID: 1265029174}
+  m_PrefabAsset: {fileID: 0}
+  m_GameObject: {fileID: 0}
+  m_Enabled: 1
+  m_EditorHideFlags: 0
+  m_Script: {fileID: 11500000, guid: 7bc613422f424ecbab70286630638b48, type: 3}
+  m_Name: 
+  m_EditorClassIdentifier: 
 --- !u!1001 &1976533212
 PrefabInstance:
   m_ObjectHideFlags: 0
@@ -469299,18 +469328,6 @@ PrefabInstance:
       objectReference: {fileID: 0}
     m_RemovedComponents: []
   m_SourcePrefab: {fileID: 100100000, guid: 827ae48cedbbd6543817a37cb59dab8d, type: 3}
---- !u!114 &1998860976 stripped
-MonoBehaviour:
-  m_CorrespondingSourceObject: {fileID: 5908241662424435614, guid: 8b8f51b9ab677d14789d28c0522c7e4c,
-    type: 3}
-  m_PrefabInstance: {fileID: 1584873890}
-  m_PrefabAsset: {fileID: 0}
-  m_GameObject: {fileID: 0}
-  m_Enabled: 1
-  m_EditorHideFlags: 0
-  m_Script: {fileID: 11500000, guid: 7bc613422f424ecbab70286630638b48, type: 3}
-  m_Name: 
-  m_EditorClassIdentifier: 
 --- !u!1001 &1998903899
 PrefabInstance:
   m_ObjectHideFlags: 0
@@ -482121,6 +482138,18 @@ Transform:
     type: 3}
   m_PrefabInstance: {fileID: 2049214230}
   m_PrefabAsset: {fileID: 0}
+--- !u!114 &2049304755 stripped
+MonoBehaviour:
+  m_CorrespondingSourceObject: {fileID: 1929101100484375460, guid: f1b4cbd2f891a5c46aedca9958dc3ed1,
+    type: 3}
+  m_PrefabInstance: {fileID: 635680401}
+  m_PrefabAsset: {fileID: 0}
+  m_GameObject: {fileID: 0}
+  m_Enabled: 1
+  m_EditorHideFlags: 0
+  m_Script: {fileID: 11500000, guid: ad8f054f47e6472581c773771c181bc4, type: 3}
+  m_Name: 
+  m_EditorClassIdentifier: 
 --- !u!1001 &2049671502
 PrefabInstance:
   m_ObjectHideFlags: 0
@@ -496478,18 +496507,6 @@ Transform:
     type: 3}
   m_PrefabInstance: {fileID: 2110482206}
   m_PrefabAsset: {fileID: 0}
---- !u!114 &2110517520 stripped
-MonoBehaviour:
-  m_CorrespondingSourceObject: {fileID: 5908241662424435614, guid: 8b8f51b9ab677d14789d28c0522c7e4c,
-    type: 3}
-  m_PrefabInstance: {fileID: 1851158714}
-  m_PrefabAsset: {fileID: 0}
-  m_GameObject: {fileID: 0}
-  m_Enabled: 1
-  m_EditorHideFlags: 0
-  m_Script: {fileID: 11500000, guid: 7bc613422f424ecbab70286630638b48, type: 3}
-  m_Name: 
-  m_EditorClassIdentifier: 
 --- !u!1001 &2110617714
 PrefabInstance:
   m_ObjectHideFlags: 0
@@ -501092,18 +501109,6 @@ Transform:
     type: 3}
   m_PrefabInstance: {fileID: 2129457292}
   m_PrefabAsset: {fileID: 0}
---- !u!114 &2129671049 stripped
-MonoBehaviour:
-  m_CorrespondingSourceObject: {fileID: 5908241662424435614, guid: 8b8f51b9ab677d14789d28c0522c7e4c,
-    type: 3}
-  m_PrefabInstance: {fileID: 1723130835}
-  m_PrefabAsset: {fileID: 0}
-  m_GameObject: {fileID: 0}
-  m_Enabled: 1
-  m_EditorHideFlags: 0
-  m_Script: {fileID: 11500000, guid: 7bc613422f424ecbab70286630638b48, type: 3}
-  m_Name: 
-  m_EditorClassIdentifier: 
 --- !u!1001 &2131074549
 PrefabInstance:
   m_ObjectHideFlags: 0

+ 1 - 0
Assets/Scripts/Pools/Pool.cs

@@ -46,6 +46,7 @@ namespace Pools
                 item = inactive.Dequeue();
             }
 
+            item.transform.SetPositionAndRotation(Vector3.zero, Quaternion.Euler(Vector3.zero));
             item.SetActive(true);
             active.Add(item);
             return item;

+ 0 - 65
Assets/Scripts/Roads/CrossingExtras.cs

@@ -18,71 +18,6 @@ namespace Roads
         public Transform south;
     }
 
-    public enum RoadDirection
-    {
-        West,
-        North,
-        East,
-        South,
-        None
-    }
-
-    public enum TurnDirection
-    {
-        Right,
-        Left,
-        Straight
-    }
-
-    static class TurnDirectionMapper
-    {
-        private static readonly Dictionary<RoadDirection, TurnDirection> fromSouth =
-            new Dictionary<RoadDirection, TurnDirection>
-            {
-                {RoadDirection.East, TurnDirection.Right},
-                {RoadDirection.West, TurnDirection.Left}
-            };
-
-        private static readonly Dictionary<RoadDirection, TurnDirection> fromNorth =
-            new Dictionary<RoadDirection, TurnDirection>
-            {
-                {RoadDirection.East, TurnDirection.Left},
-                {RoadDirection.West, TurnDirection.Right}
-            };
-
-        private static readonly Dictionary<RoadDirection, TurnDirection> fromWest =
-            new Dictionary<RoadDirection, TurnDirection>
-            {
-                {RoadDirection.North, TurnDirection.Left},
-                {RoadDirection.South, TurnDirection.Right}
-            };
-
-        private static readonly Dictionary<RoadDirection, TurnDirection> fromEast =
-            new Dictionary<RoadDirection, TurnDirection>
-            {
-                {RoadDirection.North, TurnDirection.Right},
-                {RoadDirection.South, TurnDirection.Left}
-            };
-
-        public static TurnDirection GetTurnDirection(RoadDirection from, RoadDirection to)
-        {
-            TurnDirection direction;
-            switch (from)
-            {
-                case RoadDirection.West:
-                    return fromWest.TryGetValue(to, out direction) ? direction : TurnDirection.Straight;
-                case RoadDirection.North:
-                    return fromNorth.TryGetValue(to, out direction) ? direction : TurnDirection.Straight;
-                case RoadDirection.East:
-                    return fromEast.TryGetValue(to, out direction) ? direction : TurnDirection.Straight;
-                case RoadDirection.South:
-                    return fromSouth.TryGetValue(to, out direction) ? direction : TurnDirection.Straight;
-                default:
-                    return TurnDirection.Straight;
-            }
-        }
-    }
-
     public class CrossingExtras : Turn
     {
         public CrossingData crossingData;

+ 101 - 2
Assets/Scripts/Roads/JunctionExtras.cs

@@ -1,13 +1,112 @@
-using Routes;
+using System;
+using JetBrains.Annotations;
+using Routes;
 using UnityEngine;
 
 namespace Roads
 {
+    [Serializable]
+    public struct JunctionData
+    {
+        [SerializeField]
+        private Transform north;
+        [SerializeField]
+        private Transform east;
+        [SerializeField]
+        private Transform south;
+
+        [CanBeNull]
+        public Transform GetEast(float yRotation)
+        {
+            var rotation = (int) yRotation;
+            switch (rotation)
+            {
+                case 0:
+                    return east;
+                case 90:
+                    return north;
+                case 270:
+                    return south;
+                default:
+                    return null;
+            }
+        }
+
+        [CanBeNull]
+        public Transform GetNorth(float yRotation)
+        {
+            var rotation = (int) yRotation;
+            switch (rotation)
+            {
+                case 0:
+                    return north;
+                case 180:
+                    return south;
+                case 270:
+                    return east;
+                default:
+                    return null;
+            } 
+        }
+
+        [CanBeNull]
+        public Transform GetSouth(float yRotation)
+        {
+            var rotation = (int) yRotation;
+            switch (rotation)
+            {
+                case 0:
+                    return south;
+                case 90:
+                    return east;
+                case 180:
+                    return north;
+                default:
+                    return null;
+            } 
+        }
+
+        [CanBeNull]
+        public Transform GetWest(float yRotation)
+        {
+            var rotation = (int) yRotation;
+            switch (rotation)
+            {
+                case 90:
+                    return south;
+                case 180:
+                    return east;
+                case 270:
+                    return north;
+                default:
+                    return null;
+            } 
+        }
+        
+    }
+    
     public class JunctionExtras : Turn
     {
+        public JunctionData junctionData;
+        
         protected override Transform RoadDirectionToTransform(RoadDirection position)
         {
-            throw new System.NotImplementedException();
+            var rotation = transform.rotation.eulerAngles.y;
+            switch (position)
+            {
+                case RoadDirection.North:
+                    return junctionData.GetNorth(rotation);
+                case RoadDirection.West:
+                    return junctionData.GetWest(rotation);
+                case RoadDirection.East:
+                    return junctionData.GetEast(rotation);
+                case RoadDirection.South:
+                    return junctionData.GetSouth(rotation);
+                case RoadDirection.None:
+                    throw new ArgumentException("RoadDirection.None not allowed for adding arrows");
+                default:
+                    throw new ArgumentOutOfRangeException(nameof(position), position, "Wrong Argument for AddArrows");
+            }
         }
     }
 }

+ 2 - 4
Assets/Scripts/Routes/Route.cs

@@ -41,7 +41,6 @@ namespace Routes
 
         private int visibleLength;
         private int visibleStart;
-        private Transform bicycle;
 
         private int VisibleStart => Math.Max(0, visibleStart - 1);
 
@@ -52,7 +51,6 @@ namespace Routes
             var routeManager = GetComponentInParent<RouteManager>();
             visibleStart = 0;
             visibleLength = routeManager.visibleLength;
-            bicycle = routeManager.bicycle;
 
             items.ForEach((item) => item.turn.OnTriggerExitBicycle = NextTurn);
             UpdateRouteItems();
@@ -67,10 +65,10 @@ namespace Routes
 
         private void UpdateRouteItems()
         {
-            for (var i = 0; i < items.Count; i++)
+            for (var i = 0; i < VisibleEnd; i++)
             {
                 var item = items[i];
-                if (i >= VisibleStart && i < VisibleEnd)
+                if (i >= VisibleStart)
                 {
                     item.Apply();
                 }

+ 36 - 5
Assets/Scripts/Routes/Turn.cs

@@ -9,6 +9,22 @@ using Valve.VR.InteractionSystem;
 
 namespace Routes
 {
+    public enum RoadDirection
+    {
+        West,
+        North,
+        East,
+        South,
+        None
+    }
+
+    public enum TurnDirection
+    {
+        Right,
+        Left,
+        Straight
+    }
+
     public abstract class Turn : MonoBehaviour
     {
         public RoadDirection comingFrom;
@@ -19,12 +35,15 @@ namespace Routes
         private bool arrowPoolAvailable;
         private TurnDirection turnDirection;
         private List<GameObject> usedArrows = new List<GameObject>();
+
+        private Collider trigger;
         public Action OnTriggerExitBicycle { get; set; }
 
         private void Awake()
         {
             arrowPool = FindObjectsOfType<Pool>().FirstOrDefault(o => o.CompareTag("ArrowPool"));
             arrowPoolAvailable = arrowPool != null;
+            trigger = GetComponent<Collider>();
             if (!arrowPoolAvailable) Debug.LogWarning("Arrow Pool not found");
         }
 
@@ -33,15 +52,18 @@ namespace Routes
             UpdateArrows();
         }
 
-        protected abstract Transform RoadDirectionToTransform(RoadDirection position);
+        [CanBeNull] protected abstract Transform RoadDirectionToTransform(RoadDirection position);
 
-        private void AddArrows(RoadDirection position, GameObject arrows)
+        private bool AddArrows(RoadDirection position, GameObject arrows)
         {
-            if (!arrowPoolAvailable) return;
+            Debug.Log($"---{gameObject.name}--- adding arrows at {position}");
             var t = RoadDirectionToTransform(position);
+            if (t == null) return false;
+            Debug.Log($"  Transform for position => {t.gameObject.name}");
 
             SetRotation(arrows, position);
             arrows.transform.position = t.position;
+            return true;
         }
 
         private void SetRotation(GameObject arrows, RoadDirection position)
@@ -128,7 +150,6 @@ namespace Routes
             var usedArrowIndex = 0;
             foreach (var position in items.Where(i => i != comingFrom && i != goingTo))
             {
-                
                 GameObject arrows;
                 if (usedArrowIndex < usedArrows.Count)
                 {
@@ -140,9 +161,18 @@ namespace Routes
                     arrows = arrowPool.GetItem();
                     usedArrows.Add(arrows);
                 }
-                AddArrows(position, arrows);
+
+                var used = AddArrows(position, arrows);
+                if (!used)
+                {
+                    // ReSharper disable once PossibleNullReferenceException
+                    arrowPool.ReturnToPool(arrows);
+                    usedArrows.Remove(arrows);
+                    continue;
+                }
                 usedArrowIndex++;
             }
+            trigger.enabled = true;
         }
 
         private void OnTriggerExit(Collider other)
@@ -150,6 +180,7 @@ namespace Routes
             if (other.CompareTag("bike"))
             {
                 OnTriggerExitBicycle();
+                trigger.enabled = false;
             }
         }
 

+ 53 - 0
Assets/Scripts/Routes/TurnDirectionMapper.cs

@@ -0,0 +1,53 @@
+using System.Collections.Generic;
+
+namespace Routes
+{
+     static class TurnDirectionMapper
+    {
+        private static readonly Dictionary<RoadDirection, TurnDirection> fromSouth =
+            new Dictionary<RoadDirection, TurnDirection>
+            {
+                {RoadDirection.East, TurnDirection.Right},
+                {RoadDirection.West, TurnDirection.Left}
+            };
+
+        private static readonly Dictionary<RoadDirection, TurnDirection> fromNorth =
+            new Dictionary<RoadDirection, TurnDirection>
+            {
+                {RoadDirection.East, TurnDirection.Left},
+                {RoadDirection.West, TurnDirection.Right}
+            };
+
+        private static readonly Dictionary<RoadDirection, TurnDirection> fromWest =
+            new Dictionary<RoadDirection, TurnDirection>
+            {
+                {RoadDirection.North, TurnDirection.Left},
+                {RoadDirection.South, TurnDirection.Right}
+            };
+
+        private static readonly Dictionary<RoadDirection, TurnDirection> fromEast =
+            new Dictionary<RoadDirection, TurnDirection>
+            {
+                {RoadDirection.North, TurnDirection.Right},
+                {RoadDirection.South, TurnDirection.Left}
+            };
+
+        public static TurnDirection GetTurnDirection(RoadDirection from, RoadDirection to)
+        {
+            TurnDirection direction;
+            switch (from)
+            {
+                case RoadDirection.West:
+                    return fromWest.TryGetValue(to, out direction) ? direction : TurnDirection.Straight;
+                case RoadDirection.North:
+                    return fromNorth.TryGetValue(to, out direction) ? direction : TurnDirection.Straight;
+                case RoadDirection.East:
+                    return fromEast.TryGetValue(to, out direction) ? direction : TurnDirection.Straight;
+                case RoadDirection.South:
+                    return fromSouth.TryGetValue(to, out direction) ? direction : TurnDirection.Straight;
+                default:
+                    return TurnDirection.Straight;
+            }
+        }
+    }
+}

+ 3 - 0
Assets/Scripts/Routes/TurnDirectionMapper.cs.meta

@@ -0,0 +1,3 @@
+fileFormatVersion: 2
+guid: a4d4c9491ca4488284bbb205a88527a2
+timeCreated: 1609754527

+ 1 - 1
ProjectSettings/QualitySettings.asset

@@ -95,7 +95,7 @@ QualitySettings:
     skinWeights: 2
     textureQuality: 0
     anisotropicTextures: 1
-    antiAliasing: 2
+    antiAliasing: 0
     softParticles: 0
     softVegetation: 1
     realtimeReflectionProbes: 1