Bladeren bron

Load list location

Виктор Шейко 4 jaren geleden
bovenliggende
commit
4aeb6ca8ff

+ 77 - 120
Assets/Scenes/Player.unity

@@ -35887,130 +35887,18 @@ Transform:
   m_Father: {fileID: 0}
   m_RootOrder: 9
   m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
---- !u!1 &1749655164
+--- !u!1 &1749655164 stripped
 GameObject:
-  m_ObjectHideFlags: 0
-  m_CorrespondingSourceObject: {fileID: 0}
-  m_PrefabInstance: {fileID: 0}
-  m_PrefabAsset: {fileID: 0}
-  serializedVersion: 6
-  m_Component:
-  - component: {fileID: 1749655170}
-  - component: {fileID: 1749655169}
-  - component: {fileID: 1749655168}
-  - component: {fileID: 1749655167}
-  - component: {fileID: 1749655165}
-  - component: {fileID: 1749655166}
-  m_Layer: 0
-  m_Name: Plane
-  m_TagString: Untagged
-  m_Icon: {fileID: 0}
-  m_NavMeshLayer: 0
-  m_StaticEditorFlags: 0
-  m_IsActive: 1
---- !u!114 &1749655165
-MonoBehaviour:
-  m_ObjectHideFlags: 0
-  m_CorrespondingSourceObject: {fileID: 0}
-  m_PrefabInstance: {fileID: 0}
-  m_PrefabAsset: {fileID: 0}
-  m_GameObject: {fileID: 1749655164}
-  m_Enabled: 0
-  m_EditorHideFlags: 0
-  m_Script: {fileID: 11500000, guid: 0febc06224d0d394db577c9bc070104a, type: 3}
-  m_Name: 
-  m_EditorClassIdentifier: 
---- !u!114 &1749655166
-MonoBehaviour:
-  m_ObjectHideFlags: 0
-  m_CorrespondingSourceObject: {fileID: 0}
-  m_PrefabInstance: {fileID: 0}
-  m_PrefabAsset: {fileID: 0}
-  m_GameObject: {fileID: 1749655164}
-  m_Enabled: 1
-  m_EditorHideFlags: 0
-  m_Script: {fileID: 11500000, guid: 8b779eb081cbdad4fa144fa9769068cb, type: 3}
-  m_Name: 
-  m_EditorClassIdentifier: 
-  activeScript: 1
-  horizontalSpeed: 1
-  verticalSpeed: 1
-  panel: {fileID: 1749655164}
---- !u!64 &1749655167
-MeshCollider:
-  m_ObjectHideFlags: 0
-  m_CorrespondingSourceObject: {fileID: 0}
-  m_PrefabInstance: {fileID: 0}
-  m_PrefabAsset: {fileID: 0}
-  m_GameObject: {fileID: 1749655164}
-  m_Material: {fileID: 0}
-  m_IsTrigger: 0
-  m_Enabled: 1
-  serializedVersion: 4
-  m_Convex: 0
-  m_CookingOptions: 30
-  m_Mesh: {fileID: 10209, guid: 0000000000000000e000000000000000, type: 0}
---- !u!23 &1749655168
-MeshRenderer:
-  m_ObjectHideFlags: 0
-  m_CorrespondingSourceObject: {fileID: 0}
-  m_PrefabInstance: {fileID: 0}
-  m_PrefabAsset: {fileID: 0}
-  m_GameObject: {fileID: 1749655164}
-  m_Enabled: 1
-  m_CastShadows: 1
-  m_ReceiveShadows: 1
-  m_DynamicOccludee: 1
-  m_MotionVectors: 1
-  m_LightProbeUsage: 1
-  m_ReflectionProbeUsage: 1
-  m_RayTracingMode: 2
-  m_RenderingLayerMask: 1
-  m_RendererPriority: 0
-  m_Materials:
-  - {fileID: 10303, guid: 0000000000000000f000000000000000, type: 0}
-  m_StaticBatchInfo:
-    firstSubMesh: 0
-    subMeshCount: 0
-  m_StaticBatchRoot: {fileID: 0}
-  m_ProbeAnchor: {fileID: 0}
-  m_LightProbeVolumeOverride: {fileID: 0}
-  m_ScaleInLightmap: 1
-  m_ReceiveGI: 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!33 &1749655169
-MeshFilter:
-  m_ObjectHideFlags: 0
-  m_CorrespondingSourceObject: {fileID: 0}
-  m_PrefabInstance: {fileID: 0}
+  m_CorrespondingSourceObject: {fileID: 8852303336717192637, guid: c4e9ee15f918acf409df4ff7eac28986,
+    type: 3}
+  m_PrefabInstance: {fileID: 8852303337391985601}
   m_PrefabAsset: {fileID: 0}
-  m_GameObject: {fileID: 1749655164}
-  m_Mesh: {fileID: 10209, guid: 0000000000000000e000000000000000, type: 0}
---- !u!4 &1749655170
+--- !u!4 &1749655170 stripped
 Transform:
-  m_ObjectHideFlags: 0
-  m_CorrespondingSourceObject: {fileID: 0}
-  m_PrefabInstance: {fileID: 0}
+  m_CorrespondingSourceObject: {fileID: 8852303336717192515, guid: c4e9ee15f918acf409df4ff7eac28986,
+    type: 3}
+  m_PrefabInstance: {fileID: 8852303337391985601}
   m_PrefabAsset: {fileID: 0}
-  m_GameObject: {fileID: 1749655164}
-  m_LocalRotation: {x: -0, y: 1, z: -0, w: 0}
-  m_LocalPosition: {x: 5.5467515, y: -0.80844223, z: 1.3548162}
-  m_LocalScale: {x: 1, y: 1, z: 1}
-  m_Children: []
-  m_Father: {fileID: 1692975093}
-  m_RootOrder: 0
-  m_LocalEulerAnglesHint: {x: 0, y: 180, z: 0}
 --- !u!1 &1753594913
 GameObject:
   m_ObjectHideFlags: 0
@@ -50647,6 +50535,75 @@ GameObject:
   m_NavMeshLayer: 0
   m_StaticEditorFlags: 0
   m_IsActive: 1
+--- !u!1001 &8852303337391985601
+PrefabInstance:
+  m_ObjectHideFlags: 0
+  serializedVersion: 2
+  m_Modification:
+    m_TransformParent: {fileID: 1692975093}
+    m_Modifications:
+    - target: {fileID: 8852303336717192515, guid: c4e9ee15f918acf409df4ff7eac28986,
+        type: 3}
+      propertyPath: m_LocalPosition.x
+      value: 5.5467515
+      objectReference: {fileID: 0}
+    - target: {fileID: 8852303336717192515, guid: c4e9ee15f918acf409df4ff7eac28986,
+        type: 3}
+      propertyPath: m_LocalPosition.y
+      value: -0.80844223
+      objectReference: {fileID: 0}
+    - target: {fileID: 8852303336717192515, guid: c4e9ee15f918acf409df4ff7eac28986,
+        type: 3}
+      propertyPath: m_LocalPosition.z
+      value: 1.3548162
+      objectReference: {fileID: 0}
+    - target: {fileID: 8852303336717192515, guid: c4e9ee15f918acf409df4ff7eac28986,
+        type: 3}
+      propertyPath: m_LocalRotation.x
+      value: -0
+      objectReference: {fileID: 0}
+    - target: {fileID: 8852303336717192515, guid: c4e9ee15f918acf409df4ff7eac28986,
+        type: 3}
+      propertyPath: m_LocalRotation.y
+      value: 1
+      objectReference: {fileID: 0}
+    - target: {fileID: 8852303336717192515, guid: c4e9ee15f918acf409df4ff7eac28986,
+        type: 3}
+      propertyPath: m_LocalRotation.z
+      value: -0
+      objectReference: {fileID: 0}
+    - target: {fileID: 8852303336717192515, guid: c4e9ee15f918acf409df4ff7eac28986,
+        type: 3}
+      propertyPath: m_LocalRotation.w
+      value: 0
+      objectReference: {fileID: 0}
+    - target: {fileID: 8852303336717192515, guid: c4e9ee15f918acf409df4ff7eac28986,
+        type: 3}
+      propertyPath: m_RootOrder
+      value: 0
+      objectReference: {fileID: 0}
+    - target: {fileID: 8852303336717192515, guid: c4e9ee15f918acf409df4ff7eac28986,
+        type: 3}
+      propertyPath: m_LocalEulerAnglesHint.x
+      value: 0
+      objectReference: {fileID: 0}
+    - target: {fileID: 8852303336717192515, guid: c4e9ee15f918acf409df4ff7eac28986,
+        type: 3}
+      propertyPath: m_LocalEulerAnglesHint.y
+      value: 180
+      objectReference: {fileID: 0}
+    - target: {fileID: 8852303336717192515, guid: c4e9ee15f918acf409df4ff7eac28986,
+        type: 3}
+      propertyPath: m_LocalEulerAnglesHint.z
+      value: 0
+      objectReference: {fileID: 0}
+    - target: {fileID: 8852303336717192637, guid: c4e9ee15f918acf409df4ff7eac28986,
+        type: 3}
+      propertyPath: m_Name
+      value: Plane
+      objectReference: {fileID: 0}
+    m_RemovedComponents: []
+  m_SourcePrefab: {fileID: 100100000, guid: c4e9ee15f918acf409df4ff7eac28986, type: 3}
 --- !u!222 &9192370379611238542
 CanvasRenderer:
   m_ObjectHideFlags: 0

+ 25 - 16
Assets/Scripts/Controllers/PlayerController.cs

@@ -56,6 +56,8 @@ public class PlayerController : MonoBehaviour
     static bool starting = false; // флаг остановки
     public static Dictionary<uint, bool> end_send = new Dictionary<uint, bool>(); // флаги завершения загрузки
     Dictionary<uint, MarkerMoving> moving = new Dictionary<uint, MarkerMoving>(); // флаги начала движения
+    public static Dictionary<uint, Load> load_location_elements = new Dictionary<uint, Load>(); // флаги загрузки элементов локации
+    public static bool load_location = false;
     float interpolationPeriod = 0.1f;
     //float time_realtime = 0;
     float time_draw = 0;
@@ -78,12 +80,12 @@ public class PlayerController : MonoBehaviour
         locations = new List<Location>();
 
         Date = DatePicker.GetComponent<DateTimePicker>();
-        locations.Add(new Location { id = 1, name = "1 Братск" });
-        locations.Add(new Location { id = 22, name = "22 Офис Ижевск" });
-        locations.Add(new Location { id = 25, name = "25" });
-        locations.Add(new Location { id = 26, name = "26 Братское (вагрант)" });
-        foreach (var l in locations)
-            DropdownLocation.options.Add(new Dropdown.OptionData(l.name));
+        //locations.Add(new Location { id = 1, name = "1 Братск" });
+        //locations.Add(new Location { id = 22, name = "22 Офис Ижевск" });
+        //locations.Add(new Location { id = 25, name = "25" });
+        //locations.Add(new Location { id = 26, name = "26 Братское (вагрант)" });
+        //foreach (var l in locations)
+        //    DropdownLocation.options.Add(new Dropdown.OptionData(l.name));
 
         //for (int i = 0; i < Locations.transform.childCount; i++)
         //    maps.Add(Locations.transform.GetChild(i).gameObject);
@@ -93,15 +95,22 @@ public class PlayerController : MonoBehaviour
         DropdownCompany.options.Add(new Dropdown.OptionData("Братское"));
 
         //Client.LocationsRequest();
-    }
-
-    public static Dictionary<uint, Load> load_location = new Dictionary<uint, Load>();
+    }    
 
     public static int active_location = -1;
     public static int active_company = -1;
     // Update is called once per frame
     void Update()
     {
+        if (load_location)
+        {
+            load_location = false;
+            foreach (var l in locations)
+                DropdownLocation.options.Add(new Dropdown.OptionData($"{l.id} {l.name}"));
+            DropdownLocation.value = 1;
+        }
+
+
         if (DropdownMode.value != mode)
             СhangeMode();
 
@@ -391,7 +400,7 @@ public class PlayerController : MonoBehaviour
 
     public static void LoadMaps(Dropdown DropdownLocation, GameObject Locations)
     {
-        if (active_location != DropdownLocation.value && AuthorizationController.success)
+        if (active_location != DropdownLocation.value && AuthorizationController.success && locations.Any())
         {
             if (active_location >= 0) Locations.transform.GetChild(active_location).gameObject.SetActive(false);
             Locations.transform.GetChild(DropdownLocation.value).gameObject.SetActive(true);
@@ -509,35 +518,35 @@ public class PlayerController : MonoBehaviour
             location.Load();
         }
 
-        if (load_location[location.id].walls)
+        if (load_location_elements[location.id].walls)
         {
             var walls = new GameObject();
             walls.name = "Walls";
             walls.transform.SetParent(Location.transform);
 
-            load_location[location.id].walls = false;
+            load_location_elements[location.id].walls = false;
             foreach (var w in location.walls)
             {
                 var wall = WallCreate.AddWall(new Vector3(w.start_height, WallCreate.WallHeight / 2, w.start_width), new Vector3(w.end_height, WallCreate.WallHeight, w.end_width));
                 wall.transform.SetParent(walls.transform);
             }
         }
-        if (load_location[location.id].beacons)
+        if (load_location_elements[location.id].beacons)
         {
             var beacons = new GameObject();
             beacons.name = "Beacons";
             beacons.transform.SetParent(Location.transform);
 
-            load_location[location.id].walls = false;
+            load_location_elements[location.id].walls = false;
 
         }
-        if (load_location[location.id].zones)
+        if (load_location_elements[location.id].zones)
         {
             var zones = new GameObject();
             zones.name = "Zones";
             zones.transform.SetParent(Location.transform);
 
-            load_location[location.id].walls = false;
+            load_location_elements[location.id].walls = false;
             WallCreate.AddZone(Dialog, gameObject, ZonesScroll);
         }
     }

+ 1 - 0
Assets/Scripts/Models/Load.cs

@@ -7,6 +7,7 @@ using System.Threading.Tasks;
 
 public class Load
 {
+    public bool location { get; set; }
     public bool walls { get; set; }
     public bool beacons { get; set; }
     public bool zones { get; set; }

+ 11 - 1
Assets/Scripts/Models/Location.cs

@@ -6,7 +6,7 @@ using System.Threading.Tasks;
 using UnityEngine;
 
 public class Location
-    {
+{
     public uint id { get; set; }
     public string name { get; set; }
     public List<Wall> walls { get; set; }
@@ -14,6 +14,7 @@ public class Location
     public GameObject plane { get; set; }
     public string texture_url { get; set; }
     public List<Zone> zones { get; set; }
+    public GameObject location { get; set; }
 
     public void Save()
     {
@@ -37,6 +38,8 @@ public class Location
 
     public static void ReceiveFromServer(byte[] bytedata)
     {
+        PlayerController.locations = new List<Location>();
+
         int read = 5;
         while (read < bytedata.Length)
         {
@@ -53,7 +56,14 @@ public class Location
             var name = Encoding.UTF8.GetString(bytedata, read + 32 + lenimg, lenname);
             read += (32 + lenimg + lenname);
             Debug.Log($"location received read {read} id {id} x {x} y {y} scalex {scalex} scalez {scalez} posx {posx} posz {posz} lenimg {lenimg} img {img} lenname {lenname} name {name}");
+
+            GameObject plane = UnityEngine.Object.Instantiate(Resources.Load("GameObjects/Plane", typeof(GameObject))) as GameObject;
+            plane.transform.position = new Vector3(posx, 0.01f, posz);
+            plane.transform.localScale = new Vector3(scalex, WallCreate.WallHeight, scalez);
+
+            PlayerController.locations.Add(new Location { id = id, name = name, texture_url = img, plane = plane });
         }
+        PlayerController.load_location = true;
     }
 }
 

+ 1 - 1
Assets/Scripts/Models/Wall.cs

@@ -73,7 +73,7 @@ public class Wall
             location.walls.Add(new Wall { id = id, location_id = lid, start_height = x1, start_width = z1, end_height = x2, end_width = z2 });
         }
 
-        PlayerController.load_location[location.id].walls = true;
+        PlayerController.load_location_elements[location.id].walls = true;
     }
 
     public static void LoadByLocationId(uint locId)

+ 1 - 1
Assets/Scripts/Models/Zone.cs

@@ -71,7 +71,7 @@ public class Zone
             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 });
         }
 
-        PlayerController.load_location[location.id].zones = true;
+        PlayerController.load_location_elements[location.id].zones = true;
     }
 
     public static void LoadByLocationId(uint locId)