|
@@ -26,7 +26,7 @@ public class User
|
|
public static void UsersReceive(byte[] bytedata)
|
|
public static void UsersReceive(byte[] bytedata)
|
|
{
|
|
{
|
|
var player = PlayerController.instance;
|
|
var player = PlayerController.instance;
|
|
- player.users = new Dictionary<uint, User>();
|
|
|
|
|
|
+ if(player.users==null) player.users = new Dictionary<uint, User>();
|
|
var companyId = BitConverter.ToUInt32(bytedata, 5);
|
|
var companyId = BitConverter.ToUInt32(bytedata, 5);
|
|
int read = 9;
|
|
int read = 9;
|
|
while (read < bytedata.Length)
|
|
while (read < bytedata.Length)
|
|
@@ -38,8 +38,11 @@ public class User
|
|
read += 6 + lenname;
|
|
read += 6 + lenname;
|
|
Debug.Log($"user received id {id} lenname {lenname} name {name} online {online} companyId {companyId}");
|
|
Debug.Log($"user received id {id} lenname {lenname} name {name} online {online} companyId {companyId}");
|
|
//if (companyId == Client.instance.company_id) {
|
|
//if (companyId == Client.instance.company_id) {
|
|
|
|
+ if(!player.users.ContainsKey(id)){
|
|
player.users.Add(id, new User { id = id, name_user = name, online = online != 0, company_id = companyId });
|
|
player.users.Add(id, new User { id = id, name_user = name, online = online != 0, company_id = companyId });
|
|
WorkerMarker(player.users[id], Color.green);
|
|
WorkerMarker(player.users[id], Color.green);
|
|
|
|
+ player.users[id].UserCompany();
|
|
|
|
+ }
|
|
//}
|
|
//}
|
|
}
|
|
}
|
|
player.users_load = true;
|
|
player.users_load = true;
|
|
@@ -86,8 +89,10 @@ public class User
|
|
if (u != null)
|
|
if (u != null)
|
|
{
|
|
{
|
|
var b = cmd != 0;
|
|
var b = cmd != 0;
|
|
- u.toggle_user.SetActive(b);
|
|
|
|
- u.marker.SetActive(b);
|
|
|
|
|
|
+ u.online = b;
|
|
|
|
+ //u.toggle_user.SetActive(b);
|
|
|
|
+ //u.marker.SetActive(b);
|
|
|
|
+ u.UserCompany();
|
|
}
|
|
}
|
|
else
|
|
else
|
|
{
|
|
{
|
|
@@ -141,7 +146,7 @@ public class User
|
|
public static void WorkerMarker(User user, Color color/*, GameObject WorkersList, Action<uint> BroadcastStart*/)
|
|
public static void WorkerMarker(User user, Color color/*, GameObject WorkersList, Action<uint> BroadcastStart*/)
|
|
{
|
|
{
|
|
var toggle_user = UnityEngine.Object.Instantiate(Resources.Load("GameObjects/ToggleUser", typeof(GameObject))) as GameObject;
|
|
var toggle_user = UnityEngine.Object.Instantiate(Resources.Load("GameObjects/ToggleUser", typeof(GameObject))) as GameObject;
|
|
- toggle_user.name = $"{user.id}";
|
|
|
|
|
|
+ toggle_user.name = $"user_{user.id}";
|
|
var toggle = toggle_user.transform.GetChild(0).GetComponent<Toggle>();
|
|
var toggle = toggle_user.transform.GetChild(0).GetComponent<Toggle>();
|
|
toggle.transform.GetChild(1).gameObject.GetComponent<Text>().text = $"{user.id} {user.name_user}";
|
|
toggle.transform.GetChild(1).gameObject.GetComponent<Text>().text = $"{user.id} {user.name_user}";
|
|
//toggle_user.transform.SetParent(WorkersList.transform);
|
|
//toggle_user.transform.SetParent(WorkersList.transform);
|
|
@@ -158,6 +163,10 @@ public class User
|
|
|
|
|
|
marker.GetComponent<Renderer>().material.color = color; // UnityEngine.Random.ColorHSV(0f, 1f, 1f, 1f, 0.5f, 1f);
|
|
marker.GetComponent<Renderer>().material.color = color; // UnityEngine.Random.ColorHSV(0f, 1f, 1f, 1f, 0.5f, 1f);
|
|
marker.GetComponent<LabelObjectScript>().UserId = user.id;
|
|
marker.GetComponent<LabelObjectScript>().UserId = user.id;
|
|
|
|
+ toggle.onValueChanged.AddListener(delegate
|
|
|
|
+ {
|
|
|
|
+ marker.SetActive(toggle.isOn);
|
|
|
|
+ });
|
|
|
|
|
|
var color_line = UnityEngine.Random.ColorHSV(0f, 1f, 1f, 1f, 0.5f, 1f);
|
|
var color_line = UnityEngine.Random.ColorHSV(0f, 1f, 1f, 1f, 0.5f, 1f);
|
|
var marker_line = UnityEngine.Object.Instantiate(Resources.Load("GameObjects/Line", typeof(LineRenderer))) as LineRenderer;
|
|
var marker_line = UnityEngine.Object.Instantiate(Resources.Load("GameObjects/Line", typeof(LineRenderer))) as LineRenderer;
|
|
@@ -176,6 +185,10 @@ public class User
|
|
toggle_user.transform.SetParent(player.WorkersList.transform);
|
|
toggle_user.transform.SetParent(player.WorkersList.transform);
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ /// <summary>
|
|
|
|
+ /// Запуск потока с камеры
|
|
|
|
+ /// </summary>
|
|
|
|
+ /// <param name="BroadcastStart"></param>
|
|
public void SetParam(Action<uint> BroadcastStart)
|
|
public void SetParam(Action<uint> BroadcastStart)
|
|
{
|
|
{
|
|
var camera_button = toggle_user.transform.GetChild(1).GetComponent<Button>();
|
|
var camera_button = toggle_user.transform.GetChild(1).GetComponent<Button>();
|
|
@@ -187,8 +200,52 @@ public class User
|
|
/// </summary>
|
|
/// </summary>
|
|
public void UserCompany()
|
|
public void UserCompany()
|
|
{
|
|
{
|
|
- var active = CompanyController.instance.active_location + 1 == company_id;
|
|
|
|
- toggle_user.SetActive(active);
|
|
|
|
- marker.SetActive(active);
|
|
|
|
|
|
+ var on = PlayerController.instance.DropdownMode.value == 0;
|
|
|
|
+ var active = Client.instance.company_id == company_id;
|
|
|
|
+
|
|
|
|
+ if (on)
|
|
|
|
+ {
|
|
|
|
+ toggle_user.SetActive(active && online);
|
|
|
|
+ marker.SetActive(active && online && toggle.isOn);
|
|
|
|
+ }
|
|
|
|
+ else
|
|
|
|
+ {
|
|
|
|
+ toggle_user.SetActive(active);
|
|
|
|
+ marker.SetActive(active && toggle.isOn);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ public void BroadcastStart()
|
|
|
|
+ {
|
|
|
|
+ var player = PlayerController.instance;
|
|
|
|
+ var client = Client.instance;
|
|
|
|
+ var user_broadcast = player.user_broadcast;
|
|
|
|
+ if (user_broadcast.HasValue)
|
|
|
|
+ {
|
|
|
|
+ client.ImageStreamStopSend(user_broadcast.Value);
|
|
|
|
+ var camera_button = toggle_user.transform.GetChild(1).GetComponent<Button>();
|
|
|
|
+ camera_button.GetComponent<Image>().color = Color.white;
|
|
|
|
+ broadcast = false;
|
|
|
|
+ }
|
|
|
|
+ if (user_broadcast != id)
|
|
|
|
+ {
|
|
|
|
+ client.ImageStreamStartSend(id);
|
|
|
|
+ player.user_broadcast = id;
|
|
|
|
+ var name = player.UserInfo.transform.GetChild(1).GetChild(0).GetComponent<Text>();
|
|
|
|
+ name.text = $"{id} {name_user}";
|
|
|
|
+ name.GetComponent<RectTransform>().sizeDelta = new Vector2(name.preferredWidth, 30);
|
|
|
|
+
|
|
|
|
+ var camera_button = toggle_user.transform.GetChild(1).GetComponent<Button>();
|
|
|
|
+ camera_button.GetComponent<Image>().color = Color.green;
|
|
|
|
+
|
|
|
|
+ player.UserInfo.SetActive(false);
|
|
|
|
+ broadcast = true;
|
|
|
|
+ }
|
|
|
|
+ else
|
|
|
|
+ {
|
|
|
|
+ broadcast = false;
|
|
|
|
+ player.user_broadcast = null;
|
|
|
|
+ player.UserInfo.SetActive(false);
|
|
|
|
+ }
|
|
}
|
|
}
|
|
}
|
|
}
|