|
@@ -33,7 +33,7 @@ public class EditorController : MonoBehaviour
|
|
|
public static GameObject NewLocation;
|
|
|
public static GameObject plane;
|
|
|
|
|
|
- public List<Beacon> Beacons = new List<Beacon>();
|
|
|
+ public Dictionary<uint, List<Beacon>> Beacons = new Dictionary<uint, List<Beacon>>();
|
|
|
|
|
|
PlayerController player;
|
|
|
ModeController mode;
|
|
@@ -172,19 +172,28 @@ public class EditorController : MonoBehaviour
|
|
|
{
|
|
|
//SceneManager.LoadScene("Location");
|
|
|
tools.CursorOff();
|
|
|
- if (!Name.text.Equals("")) {
|
|
|
+ if (!Name.text.Equals(""))
|
|
|
+ {
|
|
|
//var location = new Location { id = 0, name = Name.text, beacons = Beacons, zones = WallCreate.Zones, walls = WallCreate.Walls, texture_url = Image.text, plane = plane, location = NewLocation};
|
|
|
Location location;
|
|
|
- if (EditLocation.id != 0)
|
|
|
+ if (EditLocation.id != 0) location = EditLocation;
|
|
|
+ else location = new Location { id = 0, plane = plane, location = NewLocation };
|
|
|
+
|
|
|
+ location.name = Name.text;
|
|
|
+ location.texture_url = Image.text;
|
|
|
+ if (WallCreate.Walls.ContainsKey(EditLocation.id)) location.walls.AddRange(WallCreate.Walls[EditLocation.id]);
|
|
|
+ if (WallCreate.Zones.ContainsKey(EditLocation.id)) location.zones.AddRange(WallCreate.Zones[EditLocation.id]);
|
|
|
+ if (Beacons.ContainsKey(EditLocation.id))
|
|
|
{
|
|
|
- location = EditLocation;
|
|
|
- location.name = Name.text;
|
|
|
- location.texture_url = Image.text;
|
|
|
- if (WallCreate.Walls.ContainsKey(EditLocation.id)) location.walls.AddRange(WallCreate.Walls[EditLocation.id]);
|
|
|
- if (WallCreate.Zones.ContainsKey(EditLocation.id)) location.zones.AddRange(WallCreate.Zones[EditLocation.id]);
|
|
|
- location.beacons.AddRange(Beacons);
|
|
|
+ foreach(var b in Beacons[EditLocation.id])
|
|
|
+ {
|
|
|
+ var go = b.beacon;
|
|
|
+ b.x = go.transform.position.x;
|
|
|
+ b.y = go.transform.position.z;
|
|
|
+ b.z = go.transform.position.y;
|
|
|
+ }
|
|
|
+ location.beacons.AddRange(Beacons[EditLocation.id]);
|
|
|
}
|
|
|
- else location = location = new Location { id = 0, name = Name.text, beacons = Beacons, zones = WallCreate.Zones[EditLocation.id], walls = WallCreate.Walls[EditLocation.id], texture_url = Image.text, plane = plane, location = NewLocation };
|
|
|
|
|
|
player.DropdownLocation.options.Last().text = location.name;
|
|
|
|
|
@@ -227,10 +236,12 @@ public class EditorController : MonoBehaviour
|
|
|
location.Save();
|
|
|
mode.Switch();
|
|
|
}
|
|
|
- else {
|
|
|
+ else
|
|
|
+ {
|
|
|
Dialog.SetActive(true);
|
|
|
Dialog.transform.GetChild(0).GetComponent<Text>().text = "Введите название локации";
|
|
|
- Dialog.transform.GetChild(2).GetComponent<Button>().onClick.AddListener(() => {
|
|
|
+ Dialog.transform.GetChild(2).GetComponent<Button>().onClick.AddListener(() =>
|
|
|
+ {
|
|
|
Dialog.SetActive(false);
|
|
|
});
|
|
|
}
|
|
@@ -245,7 +256,7 @@ public class EditorController : MonoBehaviour
|
|
|
public void AddBeacon(PlayerController player, Beacon b = null)
|
|
|
{
|
|
|
//PanelBeaconEdit.SetActive(true);
|
|
|
- var location = player.locations[player.locations_index[player.active_location]].location;
|
|
|
+ var location = player.locations[player.locations_index[player.active_location]];
|
|
|
|
|
|
var beacon = Instantiate(Resources.Load("GameObjects/Beacon", typeof(GameObject))) as GameObject;
|
|
|
if (ModeController.editor) beacon.GetComponent<BeaconController>().mode = BeaconController.Mode.Editor;
|
|
@@ -259,7 +270,7 @@ public class EditorController : MonoBehaviour
|
|
|
beacon.GetComponent<BeaconController>().id = $"{b.id}";
|
|
|
if (b.enabled == false) beacon.GetComponent<Renderer>().material.color = Color.grey;
|
|
|
}
|
|
|
- beacon.transform.SetParent(location.transform.GetChild(3).transform);
|
|
|
+ beacon.transform.SetParent(location.location.transform.GetChild(3).transform);
|
|
|
var name_beacon = $"Маяк {b?.id.ToString() ?? Beacons.Count.ToString()}";
|
|
|
PanelBeaconEdit.transform.GetChild(0).GetComponent<Text>().text = name_beacon;
|
|
|
var panel_button = Instantiate(Resources.Load("GameObjects/Panel_Beacon", typeof(GameObject))) as GameObject;
|
|
@@ -272,22 +283,31 @@ public class EditorController : MonoBehaviour
|
|
|
|
|
|
//var b = new Beacon { };
|
|
|
|
|
|
+ var shader1 = Shader.Find("Outlined/Silhouetted Bumped Diffuse");
|
|
|
+ var shader2 = Shader.Find("Standard");
|
|
|
button.onClick.AddListener(() =>
|
|
|
{
|
|
|
BeaconEdit(b, name_beacon);
|
|
|
+ //b.beacon.GetComponent<Renderer>().material.shader = shader1;
|
|
|
});
|
|
|
//var text = PanelBeaconEdit.transform.GetChild(0).GetComponent<Text>().text = "";
|
|
|
//var uuid = PanelBeaconEdit.transform.GetChild(1).GetComponent<InputField>().text = "";
|
|
|
- if (b == null) b = new Beacon();
|
|
|
- var button_ok = PanelBeaconEdit.transform.GetChild(7).transform.GetChild(0).GetComponent<Button>();
|
|
|
- button_ok.onClick.AddListener(() =>
|
|
|
+ if (b == null)
|
|
|
{
|
|
|
+ b = new Beacon();
|
|
|
+ b.location_id = location.id;
|
|
|
b.id = Convert.ToUInt32(4000000000 + Beacons.Count);
|
|
|
+ b.enabled = true;
|
|
|
+ }
|
|
|
+
|
|
|
+ var button_ok = PanelBeaconEdit.transform.GetChild(7).transform.GetChild(0).GetComponent<Button>();
|
|
|
+ button_ok.onClick.AddListener(() =>
|
|
|
+ {
|
|
|
b.uuid = PanelBeaconEdit.transform.GetChild(2).GetComponent<InputField>().text;
|
|
|
b.minor = ushort.Parse(PanelBeaconEdit.transform.GetChild(3).GetComponent<InputField>().text);
|
|
|
b.major = ushort.Parse(PanelBeaconEdit.transform.GetChild(4).GetComponent<InputField>().text);
|
|
|
b.mac = PanelBeaconEdit.transform.GetChild(5).GetComponent<InputField>().text;
|
|
|
- b.enabled = PanelBeaconEdit.transform.GetChild(6).GetComponent<Toggle>().isOn;
|
|
|
+ b.enabled = PanelBeaconEdit.transform.GetChild(6).GetComponent<Toggle>().isOn;
|
|
|
|
|
|
PanelBeaconEdit.SetActive(false);
|
|
|
});
|
|
@@ -295,6 +315,7 @@ public class EditorController : MonoBehaviour
|
|
|
button_close.onClick.AddListener(() =>
|
|
|
{
|
|
|
PanelBeaconEdit.SetActive(false);
|
|
|
+ //b.beacon.GetComponent<Renderer>().material.shader = shader2;
|
|
|
});
|
|
|
|
|
|
var button_del = panel_button.transform.GetChild(2).GetComponent<Button>();
|
|
@@ -302,7 +323,7 @@ public class EditorController : MonoBehaviour
|
|
|
{
|
|
|
Destroy(beacon);
|
|
|
Destroy(panel_button);
|
|
|
- Beacons.Remove(b);
|
|
|
+ Beacons[location.id].Remove(b);
|
|
|
if (PanelBeaconEdit.activeSelf) PanelBeaconEdit.SetActive(false);
|
|
|
});
|
|
|
|
|
@@ -310,7 +331,9 @@ public class EditorController : MonoBehaviour
|
|
|
b.beacon = beacon;
|
|
|
b.panel_button = panel_button;
|
|
|
|
|
|
- Beacons.Add(b);
|
|
|
+ if (!Beacons.ContainsKey(location.id))
|
|
|
+ Beacons[location.id] = new List<Beacon>();
|
|
|
+ Beacons[location.id].Add(b);
|
|
|
|
|
|
BeaconEdit(b, name_beacon);
|
|
|
}
|
|
@@ -322,7 +345,7 @@ public class EditorController : MonoBehaviour
|
|
|
if (b != null)
|
|
|
{
|
|
|
PanelBeaconEdit.transform.GetChild(1).GetComponent<InputField>().text = b.uuid;
|
|
|
- PanelBeaconEdit.transform.GetChild(1).GetComponent<InputField>().text = b.vagrant_label.ToString();
|
|
|
+ PanelBeaconEdit.transform.GetChild(2).GetComponent<InputField>().text = b.vagrant_label.ToString();
|
|
|
PanelBeaconEdit.transform.GetChild(3).GetComponent<InputField>().text = $"{b.major}";
|
|
|
PanelBeaconEdit.transform.GetChild(4).GetComponent<InputField>().text = $"{b.major}";
|
|
|
PanelBeaconEdit.transform.GetChild(5).GetComponent<InputField>().text = b.mac;
|