位置实时推送
This commit is contained in:
parent
6ad2acd75a
commit
ec803964b4
|
@ -406,7 +406,7 @@ MonoBehaviour:
|
|||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 144713087}
|
||||
m_Enabled: 1
|
||||
m_Enabled: 0
|
||||
m_EditorHideFlags: 0
|
||||
m_Script: {fileID: 11500000, guid: 014683e72ff868e4c9c0d3eec7d87a26, type: 3}
|
||||
m_Name:
|
||||
|
@ -653,6 +653,11 @@ PrefabInstance:
|
|||
propertyPath: m_Name
|
||||
value: "\u5730\u9762\u65E0\u7EBF\u7535\u5E72\u6270"
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 625513913607457920, guid: 121324ce722bdb944a7cc1c7c3a5077f,
|
||||
type: 3}
|
||||
propertyPath: m_IsActive
|
||||
value: 0
|
||||
objectReference: {fileID: 0}
|
||||
m_RemovedComponents: []
|
||||
m_SourcePrefab: {fileID: 100100000, guid: 121324ce722bdb944a7cc1c7c3a5077f, type: 3}
|
||||
--- !u!114 &480997535 stripped
|
||||
|
@ -908,6 +913,11 @@ PrefabInstance:
|
|||
propertyPath: m_Name
|
||||
value: "\u63A2\u6D4B\u96F7\u8FBE"
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 3977472425108262603, guid: 2b2524df6b4053a4aa08b1f5fe4d62f5,
|
||||
type: 3}
|
||||
propertyPath: m_IsActive
|
||||
value: 0
|
||||
objectReference: {fileID: 0}
|
||||
m_RemovedComponents: []
|
||||
m_SourcePrefab: {fileID: 100100000, guid: 2b2524df6b4053a4aa08b1f5fe4d62f5, type: 3}
|
||||
--- !u!1 &954663048
|
||||
|
@ -1302,6 +1312,11 @@ PrefabInstance:
|
|||
propertyPath: m_Name
|
||||
value: "\u65E0\u4EBA\u673AList"
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 6865737300552731157, guid: 8425122cf585dcc47bbf3eff95ecf176,
|
||||
type: 3}
|
||||
propertyPath: m_IsActive
|
||||
value: 1
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 6865737300552731159, guid: 8425122cf585dcc47bbf3eff95ecf176,
|
||||
type: 3}
|
||||
propertyPath: m_LocalPosition.x
|
||||
|
@ -1848,6 +1863,11 @@ PrefabInstance:
|
|||
propertyPath: m_Name
|
||||
value: "\u6FC0\u5149\u706B\u63A7\u5E73\u53F0"
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 7615181139496386322, guid: 7abae14e48a106d4c8120d0eba515162,
|
||||
type: 3}
|
||||
propertyPath: m_IsActive
|
||||
value: 0
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 7615181139496386328, guid: 7abae14e48a106d4c8120d0eba515162,
|
||||
type: 3}
|
||||
propertyPath: m_LocalPosition.x
|
||||
|
@ -1922,6 +1942,11 @@ PrefabInstance:
|
|||
propertyPath: m_Name
|
||||
value: "\u6FC0\u5149\u706B\u63A7\u5E73\u53F0"
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 7615181139496386322, guid: 7abae14e48a106d4c8120d0eba515162,
|
||||
type: 3}
|
||||
propertyPath: m_IsActive
|
||||
value: 0
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 7615181139496386328, guid: 7abae14e48a106d4c8120d0eba515162,
|
||||
type: 3}
|
||||
propertyPath: m_LocalPosition.x
|
||||
|
|
|
@ -104,7 +104,7 @@ public class GameManager : MonoBehaviour
|
|||
|
||||
private void Update()
|
||||
{
|
||||
if (Input.GetMouseButtonDown(1))
|
||||
if (UIBootstrap.Instance.GetRoleByIDPracticeId(GlobalFlag.practiceSeatId) == "0"&&Input.GetMouseButtonDown(1))
|
||||
{
|
||||
Ray ray = Camera.main.ScreenPointToRay(Input.mousePosition);
|
||||
RaycastHit hitInfo;
|
||||
|
|
|
@ -22,6 +22,22 @@ namespace AdamSync
|
|||
}
|
||||
}
|
||||
|
||||
private void Update()
|
||||
{
|
||||
if (Input.GetMouseButtonDown(1))
|
||||
{
|
||||
Ray ray = Camera.main.ScreenPointToRay(Input.mousePosition);
|
||||
RaycastHit hitInfo;
|
||||
if (Physics.Raycast(ray, out hitInfo, 1000))
|
||||
{
|
||||
if (hitInfo.collider.tag == "WRJ")
|
||||
{
|
||||
UnmannedAerialVehicleUI.Instance.unmannedAerialVehicleManage = hitInfo.collider.GetComponent<UnmannedAerialVehicleManage>();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private IEnumerator SendMsg()
|
||||
{
|
||||
while (true)
|
||||
|
|
|
@ -21,7 +21,7 @@ namespace Assets.Zion.Scripts.Adam
|
|||
|
||||
private void Update()
|
||||
{
|
||||
if (Input.GetMouseButtonDown(1))
|
||||
if (UIBootstrap.Instance.GetRoleByIDPracticeId(GlobalFlag.practiceSeatId) == "0" && Input.GetMouseButtonDown(1))
|
||||
{
|
||||
Ray ray = Camera.main.ScreenPointToRay(Input.mousePosition);
|
||||
RaycastHit hitInfo;
|
||||
|
|
|
@ -21,13 +21,35 @@ public class EquipmentCommon : MonoBehaviour
|
|||
/// </summary>
|
||||
public static List<EquipmentCommon> equipmentCommons = new List<EquipmentCommon>();
|
||||
public string equipmentType = "";
|
||||
private bool _isStartRehearsing = false;
|
||||
|
||||
/// <summary>
|
||||
/// 设备唯一ID
|
||||
/// </summary>
|
||||
public string deviceID;
|
||||
public bool isPlayer = false;
|
||||
/// <summary>
|
||||
/// 是否是本人创建的设备
|
||||
/// </summary>
|
||||
public bool isPlayer
|
||||
{
|
||||
get { return _isPlayer; }
|
||||
set
|
||||
{
|
||||
if (_isPlayer != value)
|
||||
{
|
||||
_isPlayer = value;
|
||||
OnActivationIsPlayer?.Invoke(_isPlayer);
|
||||
}
|
||||
}
|
||||
}
|
||||
public event System.Action<bool> OnActivationIsPlayer;
|
||||
private bool _isPlayer = false;
|
||||
|
||||
|
||||
// 布尔值变化时触发的事件
|
||||
public event System.Action<bool> OnActivationChanged;
|
||||
|
||||
|
||||
private bool _isStartRehearsing = false;
|
||||
// 属性绑定布尔值,并在值变化时触发事件
|
||||
public bool isStartRehearsing
|
||||
{
|
||||
|
@ -48,20 +70,23 @@ public class EquipmentCommon : MonoBehaviour
|
|||
equipmentCommons.Add(this);
|
||||
// 订阅布尔值变化事件
|
||||
OnActivationChanged += OnActivationChangedHandler;
|
||||
//
|
||||
OnActivationIsPlayer += OnActivationChangedIsPlayer;
|
||||
}
|
||||
void OnActivationChangedIsPlayer(bool newValue)
|
||||
{
|
||||
if(newValue&& equipmentType== "无人机List"&& isOnlyOne)
|
||||
{
|
||||
isOnlyOne = false;
|
||||
StartCoroutine(SendMsg());
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// 导条 暂停开始控制
|
||||
/// </summary>
|
||||
/// <param name="newValue"></param>
|
||||
void OnActivationChangedHandler(bool newValue)
|
||||
{
|
||||
if (equipmentCommon)
|
||||
{
|
||||
//string msg = $"send2room {equipmentCommon.equipmentType}+{transform.position.ToString().Replace(" ", "").Replace("(", "").Replace(")", "")}+{transform.eulerAngles.ToString().Replace(" ", "").Replace("(", "").Replace(")", "")}";
|
||||
//Debug.Log(msg);
|
||||
//_ = SyncCreateRoom.SendMessageAsync(msg);
|
||||
}
|
||||
switch (equipmentType)
|
||||
{
|
||||
case "激光火控平台":
|
||||
|
@ -88,21 +113,16 @@ public class EquipmentCommon : MonoBehaviour
|
|||
public char replaceInfo;
|
||||
public Dictionary<string, string> replaceInfoDic = new Dictionary<string, string>();
|
||||
|
||||
//public void ResultsInfo(bool b, string s)
|
||||
//{
|
||||
// Debug.Log(s);
|
||||
// ReturnDeviceID result = JsonConvert.DeserializeObject<ReturnDeviceID>(s);
|
||||
// Debug.Log(result.data);
|
||||
//}
|
||||
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// 物体生成时接受数据
|
||||
/// </summary>
|
||||
/// <param name="weaponitemone"></param>
|
||||
public void FillInTheData(List<List_paraItem> weaponitemone)
|
||||
{
|
||||
if (!isPlayer) return;
|
||||
if (equipmentCommon)
|
||||
//向其他的单位发送创建信息
|
||||
if (isPlayer&& equipmentCommon)//但是是由我自主创建的时候发送一次 且只发送一次
|
||||
{
|
||||
string paraListJson = JsonConvert.SerializeObject(weaponitemone);
|
||||
replaceInfoDic.Add("PracticeId", GlobalFlag.roomID);
|
||||
|
@ -117,7 +137,8 @@ public class EquipmentCommon : MonoBehaviour
|
|||
_ = SyncCreateRoom.SendMessageAsync(msg);
|
||||
}));
|
||||
}
|
||||
|
||||
|
||||
//填入数据
|
||||
switch (equipmentType)
|
||||
{
|
||||
case "激光火控平台":
|
||||
|
@ -142,6 +163,39 @@ public class EquipmentCommon : MonoBehaviour
|
|||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
//位置实时传送
|
||||
private string latestData = "";
|
||||
private bool isOnlyOne = true;
|
||||
public IEnumerator SendMsg()
|
||||
{
|
||||
while (true)
|
||||
{
|
||||
yield return new WaitForSeconds(0.01f);
|
||||
|
||||
var nowData = GetSyncData();
|
||||
if (!nowData.Equals(latestData))
|
||||
{
|
||||
latestData = nowData;
|
||||
Debug.Log(latestData);
|
||||
_ = SyncCreateRoom.SendMessageAsync(string.Format("WRJ {0}", nowData));
|
||||
}
|
||||
}
|
||||
}
|
||||
protected string GetSyncData()
|
||||
{
|
||||
return string.Format("{0},{1},{2},{3},{4},{5},{6}", equipmentCommon.deviceID, transform.position.x, transform.position.y, transform.position.z, transform.eulerAngles.x, transform.eulerAngles.y, transform.eulerAngles.z);
|
||||
}
|
||||
|
||||
|
||||
private void Update()
|
||||
{
|
||||
if (Input.GetKeyDown(KeyCode.T))
|
||||
{
|
||||
isPlayer = !isPlayer;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public enum SelectedSide
|
||||
|
|
|
@ -143,7 +143,7 @@ public class UnmannedAerialVehicleManage : MonoBehaviour
|
|||
// Update is called once per frame
|
||||
void Update()
|
||||
{
|
||||
if (isStartRehearsing && isStartRehearsing && pattern == Pattern.攻击)
|
||||
if (isStartRehearsing && equipmentCommon.isPlayer && pattern == Pattern.攻击)
|
||||
{
|
||||
if (airRoute)
|
||||
{
|
||||
|
@ -440,10 +440,8 @@ public class UnmannedAerialVehicleManage : MonoBehaviour
|
|||
isMove = true;
|
||||
}
|
||||
|
||||
private void OnMouseEnter()
|
||||
{
|
||||
UnmannedAerialVehicleUI.Instance.unmannedAerialVehicleManage = transform.GetComponent<UnmannedAerialVehicleManage>();
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
public enum Pattern
|
||||
{
|
||||
|
|
Loading…
Reference in New Issue