Виктор Шейко 4 years ago
parent
commit
1191ad6c8f
1 changed files with 5 additions and 4 deletions
  1. 5 4
      Assets/Scripts/Models/Zone.cs

+ 5 - 4
Assets/Scripts/Models/Zone.cs

@@ -56,7 +56,7 @@ public class Zone
     {
         int read = 5;
         var location = PlayerController.locations[PlayerController.locations_index[PlayerController.active_location]];
-        location.zones = new List<Zone>();
+        var zones = new List<Zone>();
         while (read < bytedata.Length)
         {
             var id = BitConverter.ToUInt32(bytedata, read);
@@ -67,10 +67,11 @@ public class Zone
             var lid = BitConverter.ToUInt32(bytedata, read + 20);
             Debug.Log($"zone received id {id} x1 {x1} z1 {z1} x2 {x2} z2 {z2} location {lid}");
             read += 24;
-
-            location.zones.Add(new Zone { id = id, location_id = location.id, name = $"Зона {location.zones.Count + 1}", start_height = x1, start_width = z1, end_height = x2, end_width = z2 });
+            
+            zones.Add(new Zone { id = id, location_id = location.id, name = $"Зона {zones.Count + 1}", start_height = x1, start_width = z1, end_height = x2, end_width = z2 });
         }
-
+        location.zones = zones;
+        Debug.Log($"location {location.id} zones count {zones.Count}");
         PlayerController.load_location_elements[location.id].zones = true;
     }