소스 검색

Правка отображения маяков

Виктор Шейко 4 년 전
부모
커밋
3e962815ea

+ 63 - 0
Assets/Scripts/Components/WallCreate.cs

@@ -0,0 +1,63 @@
+using System;
+using System.Collections;
+using System.Collections.Generic;
+using UnityEngine;
+
+public class WallCreate : MonoBehaviour
+{
+    public float Height = 1f;
+    public int Rounding = 1;
+    public bool move = false;
+    public bool BoxColliderEnabled = true;
+    //GameObject cursor_end;
+
+    private Vector3 screenPoint;
+    private Vector3 offset;
+    private Vector3 curScreenPoint;
+    private Vector3 curPosition;
+
+    // Start is called before the first frame update
+    void Start()
+    {
+       // gameObject.GetComponent<BoxCollider>().enabled = BoxColliderEnabled;
+        //cursor_end = transform.GetChild(6).gameObject;
+    }
+
+    // Update is called once per frame
+    void Update()
+    {
+        // if (gameObject.GetComponent<BoxCollider>().enabled != BoxColliderEnabled) gameObject.GetComponent<BoxCollider>().enabled = BoxColliderEnabled;
+    
+    }
+
+    void OnMouseDown()
+    {
+        //Debug.Log(StagesEditorController.indexCursor);
+        
+        screenPoint = Camera.main.WorldToScreenPoint(gameObject.transform.position);
+        offset = gameObject.transform.position - Camera.main.ScreenToWorldPoint(new Vector3(Input.mousePosition.x, Input.mousePosition.y, screenPoint.z));
+
+    }
+
+    // Перемещение
+    void OnMouseDrag()
+    {
+        curScreenPoint = new Vector3(Input.mousePosition.x, Input.mousePosition.y, screenPoint.z);
+        curPosition = Camera.main.ScreenToWorldPoint(curScreenPoint) + offset;
+        var x = (float)Math.Round(curPosition.x, Rounding);
+        var z = (float)Math.Round(curPosition.z, Rounding);
+        //transform.position = new Vector3(x, Height, z);
+        //gameObject.GetComponent<BoxCollider>().size = new Vector3(x, Height, z);
+        var pos = new Vector3(x, transform.localScale.y / 2f, z);
+        transform.position = pos;
+        //LocationController.Cube(gameObject, );
+        AddWall(pos);
+    }
+
+    void AddWall(Vector3 pos)
+    {
+        var wall = Instantiate(Resources.Load("GameObjects/Pole", typeof(GameObject))) as GameObject;
+        wall.transform.position = pos;
+
+    }
+}

+ 1 - 1
Assets/Scripts/Controllers/AuthorizationController.cs

@@ -32,7 +32,7 @@ public class AuthorizationController : MonoBehaviour
         {//SceneManager.LoadScene("Location");
             transform.gameObject.SetActive(false);
             client.SendGetUsers((uint)WorkerController.active_company + 1);
-            client.BeaconsRequest((uint)WorkerController.active_location);
+            client.BeaconsRequest((uint)WorkerController.locations[WorkerController.active_location].id);
         }
         if(error) Error.SetActive(true);
     }

+ 93 - 0
Assets/Scripts/Controllers/WallsController.cs

@@ -0,0 +1,93 @@
+using System;
+using System.Collections;
+using System.Collections.Generic;
+using System.Linq;
+using UnityEngine;
+using UnityEngine.UI;
+
+public class WallsController : MonoBehaviour
+{
+    //public Button ButtonWall;
+    //public Button ButtonRoom;
+    //public Button ButtonDel;
+    public GameObject Cursor;
+    public int Rounding = 1;
+    public List<GameObject> Walls = new List<GameObject>();
+    
+    enum Tools { Wall, Room, Del, Cursor};
+    Tools tools = Tools.Cursor;
+
+    private Vector3 screenPoint;
+    private Vector3 offset;
+    private Vector3 curScreenPoint;
+    private Vector3 curPosition;
+
+    bool new_well = false;
+
+    // Start is called before the first frame update
+    void Start()
+    {
+        
+    }
+
+    // Update is called once per frame
+    void Update()
+    {
+       
+    }
+
+    public void WallCreate()
+    {
+        tools = Tools.Wall;
+        Cursor.SetActive(true);
+
+        var last =  Walls.LastOrDefault();
+        if(last != null)last.GetComponent<Room>().BoxColliderEnabled = false;
+    }
+
+
+    public void RoomCreate()
+    {
+        tools = Tools.Room;
+
+        var Cube = Instantiate(Resources.Load("GameObjects/Cube", typeof(GameObject))) as GameObject;
+        Cube.AddComponent<Room>();
+        Cube.transform.position = new Vector3(0.5f, 0.5f, 0.5f);
+        new_well = true;
+        Walls.Add(Cube);
+        Cursor.SetActive(false);
+    }
+
+    public void Delete()
+    {
+        tools = Tools.Del;
+    }
+
+    void Editor()
+    {
+        switch (tools)
+        {
+            case Tools.Room:
+                var Cube = Instantiate(Resources.Load("GameObjects/Cube", typeof(GameObject))) as GameObject;
+                Cube.AddComponent<Room>();
+                Walls.Add(Cube);
+                break;
+        }
+    }
+
+    //void OnMouseDown()
+    //{
+    //    //Debug.Log(StagesEditorController.indexCursor);
+    //    switch (tools)
+    //    {
+    //        case Tools.Room:
+    //            screenPoint = Camera.main.WorldToScreenPoint(gameObject.transform.position);
+    //            offset = gameObject.transform.position - Camera.main.ScreenToWorldPoint(new Vector3(Input.mousePosition.x, Input.mousePosition.y, screenPoint.z));
+    //            break;
+    //    }
+
+    //}
+
+    // Перемещение
+
+}

+ 7 - 4
Assets/Scripts/Controllers/WorkerController.cs

@@ -60,6 +60,7 @@ public class WorkerController : MonoBehaviour
     public static bool users_load = false;
     public static bool beacons_load = false;
     uint location_id = 1;
+    public static  List<Location> locations = new List<Location>();
 
     //List<bool> StartStop = new List<bool>();
 
@@ -69,9 +70,11 @@ public class WorkerController : MonoBehaviour
         DebugHelper.ActivateConsole();
 
         Date = DatePicker.GetComponent<DateTimePicker>();
-        DropdownLocation.options.Add(new Dropdown.OptionData("1 Братск"));
-        DropdownLocation.options.Add(new Dropdown.OptionData("22 Офис Ижевск"));
-        DropdownLocation.options.Add(new Dropdown.OptionData("25"));
+        locations.Add(new Location { id = 1, name = "1 Братск" });
+        locations.Add(new Location { id = 22, name = "22 Офис Ижевск" });
+        locations.Add(new Location { id = 25, name = "1 Братск" });
+        foreach(var l in locations)
+        DropdownLocation.options.Add(new Dropdown.OptionData(l.name));
 
         DropdownCompany.options.Add(new Dropdown.OptionData("Тайшет"));
         DropdownCompany.options.Add(new Dropdown.OptionData("Тестовая"));
@@ -142,7 +145,7 @@ public class WorkerController : MonoBehaviour
                 Destroy(b.button);
             }
             Beacons = new List<Beacon>();
-            client.BeaconsRequest((uint) active_location);
+            client.BeaconsRequest((uint)locations[DropdownLocation.value].id);
         }
 
         foreach (var m in markers)

+ 13 - 0
Assets/Scripts/Models/Location.cs

@@ -0,0 +1,13 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+
+    public class Location
+    {
+    public int id { get; set; }
+    public string name { get; set; }
+    }
+