|
@@ -37,27 +37,28 @@ public class PlayerController : MonoBehaviour
|
|
|
public GameObject DatePicker;
|
|
|
Camera camera;
|
|
|
public Toggle projection;
|
|
|
+ public GameObject Locations;
|
|
|
|
|
|
public enum Mode { RealTime = 0, History = 1, Stop = 2 };
|
|
|
public static Mode active_mode = Mode.Stop;
|
|
|
int mode = 0;
|
|
|
//public GameObject Time;
|
|
|
|
|
|
- static Client client;
|
|
|
+ Client client;
|
|
|
+ static EditorController editor;
|
|
|
|
|
|
DateTimePicker Date;
|
|
|
|
|
|
- public List<GameObject> maps;
|
|
|
+ //public List<GameObject> maps;
|
|
|
static bool starting = false; // флаг остановки
|
|
|
public static Dictionary<uint, bool> end_send = new Dictionary<uint, bool>(); // флаги завершения загрузки
|
|
|
Dictionary<uint, MarkerMoving> moving = new Dictionary<uint, MarkerMoving>(); // флаги начала движения
|
|
|
float interpolationPeriod = 0.1f;
|
|
|
- float time_realtime = 0;
|
|
|
+ //float time_realtime = 0;
|
|
|
float time_draw = 0;
|
|
|
public static List<User> users = new List<User>();
|
|
|
public static bool users_load = false;
|
|
|
public static bool beacons_load = false;
|
|
|
- uint location_id = 1;
|
|
|
public static List<Location> locations;
|
|
|
public static List<Marker> markers;
|
|
|
|
|
@@ -68,6 +69,7 @@ public class PlayerController : MonoBehaviour
|
|
|
{
|
|
|
DebugHelper.ActivateConsole();
|
|
|
client = Client.instance;
|
|
|
+ editor = GameObject.Find("Canvas").transform.GetChild(3).GetComponent<EditorController>();
|
|
|
camera = Camera.main;
|
|
|
markers = new List<Marker>();
|
|
|
locations = new List<Location>();
|
|
@@ -78,6 +80,9 @@ public class PlayerController : MonoBehaviour
|
|
|
locations.Add(new Location { id = 25, name = "25" });
|
|
|
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);
|
|
|
|
|
|
DropdownCompany.options.Add(new Dropdown.OptionData("Тайшет"));
|
|
|
DropdownCompany.options.Add(new Dropdown.OptionData("Тестовая"));
|
|
@@ -124,33 +129,6 @@ public class PlayerController : MonoBehaviour
|
|
|
client.SendGetUsers((uint) active_company + 1);
|
|
|
}
|
|
|
|
|
|
- if (active_location != DropdownLocation.value)
|
|
|
- {
|
|
|
- maps.ElementAt(active_location).SetActive(false);
|
|
|
- maps.ElementAt(DropdownLocation.value).SetActive(true);
|
|
|
- active_location = DropdownLocation.value;
|
|
|
- switch (DropdownLocation.value)
|
|
|
- {
|
|
|
- case 0:
|
|
|
- location_id = 1;
|
|
|
- break;
|
|
|
- case 1:
|
|
|
- location_id = 22;
|
|
|
- break;
|
|
|
- case 2:
|
|
|
- location_id = 25;
|
|
|
- break;
|
|
|
- }
|
|
|
-
|
|
|
- foreach (var b in Beacons)
|
|
|
- {
|
|
|
- Destroy(b.beacon);
|
|
|
- Destroy(b.button);
|
|
|
- }
|
|
|
- Beacons = new List<Beacon>();
|
|
|
- client.BeaconsRequest((uint)locations[DropdownLocation.value].id);
|
|
|
- }
|
|
|
-
|
|
|
time_draw += Time.deltaTime;
|
|
|
if (time_draw >= interpolationPeriod)
|
|
|
{
|
|
@@ -191,7 +169,7 @@ public class PlayerController : MonoBehaviour
|
|
|
{
|
|
|
if (m.toggle.isOn)
|
|
|
{
|
|
|
- client.CoordinatesRequest(0, 0, 1, location_id, m.acc_id);
|
|
|
+ client.CoordinatesRequest(0, 0, 1, (uint)locations[active_location].id, m.acc_id);
|
|
|
end_send[m.acc_id] = false;
|
|
|
}
|
|
|
}
|
|
@@ -230,12 +208,7 @@ public class PlayerController : MonoBehaviour
|
|
|
WorkerMarker(u, Color.green);
|
|
|
}
|
|
|
|
|
|
- if (beacons_load)
|
|
|
- {
|
|
|
- beacons_load = false;
|
|
|
- foreach (var b in Beacons)
|
|
|
- AddBeacon(b);
|
|
|
- }
|
|
|
+ LoadMaps(client, DropdownLocation, Locations);
|
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
@@ -345,7 +318,7 @@ public class PlayerController : MonoBehaviour
|
|
|
{
|
|
|
if (m.toggle.isOn)
|
|
|
{
|
|
|
- client.CoordinatesRequest(time_start.Ticks, time_end.Ticks, 1, location_id, m.acc_id);
|
|
|
+ client.CoordinatesRequest(time_start.Ticks, time_end.Ticks, 1, (uint)locations[active_location].id, m.acc_id);
|
|
|
end_send[m.acc_id] = false;
|
|
|
}
|
|
|
}
|
|
@@ -439,16 +412,14 @@ public class PlayerController : MonoBehaviour
|
|
|
/// Отображение маяков
|
|
|
/// </summary>
|
|
|
/// <param name="b"></param>
|
|
|
- public void AddBeacon(Beacon b)
|
|
|
+ public static void AddBeacon(Beacon b)
|
|
|
{
|
|
|
var beacon = Instantiate(Resources.Load("GameObjects/Beacon", typeof(GameObject))) as GameObject;
|
|
|
beacon.transform.position = new Vector3(b.x/100, 0.5f, b.y/100);
|
|
|
beacon.name = $"BeaconButton_{b.id}";
|
|
|
- beacon.GetComponent<BeaconController>().move = false;
|
|
|
beacon.GetComponent<BeaconController>().info = false;
|
|
|
beacon.transform.SetParent(GameObject.Find("Beacons").transform);
|
|
|
- var canvas = beacon.transform.GetChild(0);
|
|
|
- canvas.transform.GetChild(0).transform.GetChild(0).GetComponent<Text>().text = $"{b.id}\nuuid={b.uuid}\nmajor={b.major}\nminor={b.minor}";
|
|
|
+ beacon.transform.GetChild(0).GetChild(0).GetChild(0).GetComponent<Text>().text = $"{b.id}\nuuid={b.uuid}\nmajor={b.major}\nminor={b.minor}";
|
|
|
|
|
|
b.beacon = beacon;
|
|
|
}
|
|
@@ -463,5 +434,37 @@ public class PlayerController : MonoBehaviour
|
|
|
//if (Input.GetKeyDown(KeyCode.BackQuote))
|
|
|
DebugHelper.DrawConsole();
|
|
|
}
|
|
|
+
|
|
|
+ public static void LoadMaps(Client client, Dropdown DropdownLocation, GameObject Locations)
|
|
|
+ {
|
|
|
+ if (active_location != DropdownLocation.value)
|
|
|
+ {
|
|
|
+ Locations.transform.GetChild(active_location).gameObject.SetActive(false);
|
|
|
+ Locations.transform.GetChild(DropdownLocation.value).gameObject.SetActive(true);
|
|
|
+ active_location = DropdownLocation.value;
|
|
|
+
|
|
|
+ foreach (var b in Beacons)
|
|
|
+ {
|
|
|
+ Destroy(b.beacon);
|
|
|
+ Destroy(b.panel_button);
|
|
|
+ }
|
|
|
+ Beacons = new List<Beacon>();
|
|
|
+
|
|
|
+ if (ModeController.editor == true && DropdownLocation.value != DropdownLocation.options.Count - 1) client.BeaconsRequest((uint)locations[DropdownLocation.value].id);
|
|
|
+ if(ModeController.editor == false) client.BeaconsRequest((uint)locations[DropdownLocation.value].id);
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ if (beacons_load)
|
|
|
+ {
|
|
|
+ beacons_load = false;
|
|
|
+ foreach (var b in Beacons)
|
|
|
+ {
|
|
|
+ //if (ModeController.editor == false) AddBeacon(b);
|
|
|
+ //if (ModeController.editor == true)
|
|
|
+ editor.AddBeacon(b);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|
|
|
|