修改数据格式,添加接受逻辑

This commit is contained in:
YangHua 2023-11-20 18:35:43 +08:00
parent bbd6889f3e
commit cddd9c869a
2 changed files with 51 additions and 33 deletions

View File

@ -17,10 +17,10 @@ public class GameManager : MonoBehaviour
public TenkokuModule tenkokuModule; public TenkokuModule tenkokuModule;
public System.Collections.Generic.List<ModelInfo> modelsInfo = new System.Collections.Generic.List<ModelInfo>(); public System.Collections.Generic.List<ModelInfo> modelsInfo = new System.Collections.Generic.List<ModelInfo>();
public Transform dviceContent; public Transform dviceContent;
public GameObject wrjDrag; public DragController wrjDrag;
public GameObject ldDrag; public DragController ldDrag;
public GameObject hpDrag; public DragController hpDrag;
public GameObject wxdDrag; public DragController wxdDrag;
public GameObject Teacher; public GameObject Teacher;
public GameObject student; public GameObject student;
// Start is called before the first frame update // Start is called before the first frame update
@ -55,8 +55,8 @@ public class GameManager : MonoBehaviour
{ {
for (int i = 0; i < UIBootstrap.Instance.GetDeviceByName("蜂群无人机").device_count; i++) for (int i = 0; i < UIBootstrap.Instance.GetDeviceByName("蜂群无人机").device_count; i++)
{ {
GameObject wrj = Instantiate(wrjDrag, dviceContent); DragController wrj = Instantiate(wrjDrag, dviceContent);
wrj.GetComponent<DragController>().deviceID = UIBootstrap.Instance.GetDeviceByName("蜂群无人机").id; wrj.deviceID = UIBootstrap.Instance.GetDeviceByName("蜂群无人机").id;
} }
} }
} }
@ -67,24 +67,24 @@ public class GameManager : MonoBehaviour
{ {
for (int i = 0; i < UIBootstrap.Instance.GetDeviceByName("探测雷达").device_count; i++) for (int i = 0; i < UIBootstrap.Instance.GetDeviceByName("探测雷达").device_count; i++)
{ {
GameObject ld = Instantiate(ldDrag, dviceContent); DragController ld = Instantiate(ldDrag, dviceContent);
ld.GetComponent<DragController>().deviceID = UIBootstrap.Instance.GetDeviceByName("探测雷达").id; ld.deviceID = UIBootstrap.Instance.GetDeviceByName("探测雷达").id;
} }
} }
if (UIBootstrap.Instance.GetDeviceByName("激光火控平台").device_count > 0) if (UIBootstrap.Instance.GetDeviceByName("激光火控平台").device_count > 0)
{ {
for (int i = 0; i < UIBootstrap.Instance.GetDeviceByName("激光火控平台").device_count; i++) for (int i = 0; i < UIBootstrap.Instance.GetDeviceByName("激光火控平台").device_count; i++)
{ {
GameObject hp = Instantiate(hpDrag, dviceContent); DragController hp = Instantiate(hpDrag, dviceContent);
hp.GetComponent<DragController>().deviceID = UIBootstrap.Instance.GetDeviceByName("激光火控平台").id; hp.deviceID = UIBootstrap.Instance.GetDeviceByName("激光火控平台").id;
} }
} }
if (UIBootstrap.Instance.GetDeviceByName("地面无线电干扰").device_count > 0) if (UIBootstrap.Instance.GetDeviceByName("地面无线电干扰").device_count > 0)
{ {
for (int i = 0; i < UIBootstrap.Instance.GetDeviceByName("地面无线电干扰").device_count; i++) for (int i = 0; i < UIBootstrap.Instance.GetDeviceByName("地面无线电干扰").device_count; i++)
{ {
GameObject wxd = Instantiate(wxdDrag, dviceContent); DragController wxd = Instantiate(wxdDrag, dviceContent);
wxd.GetComponent<DragController>().deviceID = UIBootstrap.Instance.GetDeviceByName("地面无线电干扰").id; wxd.deviceID = UIBootstrap.Instance.GetDeviceByName("地面无线电干扰").id;
} }
} }
} }
@ -112,6 +112,7 @@ public class GameManager : MonoBehaviour
yield return new WaitForSeconds(0.5f); yield return new WaitForSeconds(0.5f);
Debug.Log(msg); Debug.Log(msg);
string[] data = msg.Split(','); string[] data = msg.Split(',');
switch (data[0]) switch (data[0])
{ {
case "online": case "online":
@ -131,6 +132,20 @@ public class GameManager : MonoBehaviour
{ {
UnmannedAerialVehicleManage.unmannedAerialVehicleManages[i].isStartRehearsing = true; UnmannedAerialVehicleManage.unmannedAerialVehicleManages[i].isStartRehearsing = true;
} }
break;
case "无人机List":
GameObject wrj = Instantiate(wrjDrag.model);
wrj.transform.position = new Vector3(float.Parse(data[1]), float.Parse(data[2]), float.Parse(data[3]));
wrj.transform.eulerAngles = new Vector3(float.Parse(data[4]), float.Parse(data[5]), float.Parse(data[6]));
break;
case "地面无线电干扰":
break;
case "探测雷达":
break;
case "激光火控平台":
break; break;
case "Stop": case "Stop":
GlobalFlag.isStartRehearsing = false; GlobalFlag.isStartRehearsing = false;

View File

@ -169,7 +169,8 @@ public class UnmannedAerialVehicleManage : MonoBehaviour
/// </summary> /// </summary>
public void modeSwitch(int patternCut) public void modeSwitch(int patternCut)
{ {
switch (patternCut) { switch (patternCut)
{
case 0://待机 case 0://待机
pattern = Pattern.; pattern = Pattern.;
break; break;
@ -216,13 +217,14 @@ public class UnmannedAerialVehicleManage : MonoBehaviour
{ {
if (equipmentCommon) if (equipmentCommon)
{ {
string msg = $"send2room {equipmentCommon.equipmentType}+{transform.position.ToString().Replace(" ","")}+{transform.eulerAngles.ToString().Replace(" ", "")}"; string msg = $"send2room {equipmentCommon.equipmentType}+{transform.position.ToString().Replace(" ", "")}+{transform.eulerAngles.ToString().Replace(" ", "").Replace("(", "").Replace(")", "")}";
Debug.Log(msg); Debug.Log(msg);
_ = SyncCreateRoom.SendMessageAsync(msg); _ = SyncCreateRoom.SendMessageAsync(msg);
} }
for (int i = 0; i < weaponitemone.Count; i++) for (int i = 0; i < weaponitemone.Count; i++)
{ {
switch (weaponitemone[i].para_name) { switch (weaponitemone[i].para_name)
{
case "续航时间:": case "续航时间:":
batteryLife = weaponitemone[i].para_value; batteryLife = weaponitemone[i].para_value;
break; break;
@ -287,7 +289,8 @@ public class UnmannedAerialVehicleManage : MonoBehaviour
/// <param name="number"></param> /// <param name="number"></param>
public void Formation(int number) public void Formation(int number)
{ {
switch (number) { switch (number)
{
case 1: case 1:
GenerateFormation(); GenerateFormation();
break; break;