Compare commits

...

3 Commits

Author SHA1 Message Date
YangHua 19049e6860 12121 2024-03-27 23:08:53 +08:00
YangHua 4c944a7444 Merge branch 'master' of http://git.umayle.com:2023/yulong/NewN_UAVPlane 2024-03-27 20:49:00 +08:00
YangHua 8eac208ce0 212 2024-03-27 20:48:54 +08:00
4 changed files with 60 additions and 40 deletions

View File

@ -321,7 +321,7 @@ public class GameManager : MonoSingleton<GameManager>
} }
break; break;
case "StartDeduction": case "StartDeduction":
CheckRoomState(); CheckRoomState("state=1");
break; break;
case "蜂群无人机": case "蜂群无人机":
SpawnDevice(wrjDrag.prefabItem, data); SpawnDevice(wrjDrag.prefabItem, data);
@ -342,19 +342,16 @@ public class GameManager : MonoSingleton<GameManager>
SpawnDevice(wbDrag.prefabItem, data); SpawnDevice(wbDrag.prefabItem, data);
break; break;
case "Stop": case "Stop":
GlobalFlag.isStartRehearsing = false; CheckRoomState("state=0");
for (int i = 0; i < DeviceManager.Instance.devices.Count; i++)
{
DeviceManager.Instance.devices[i].isStartRehearsing = false;
}
break; break;
case "EndDeduction": case "EndDeduction":
GlobalFlag.isStartRehearsing = false; CheckRoomState("state=0");
for (int i = 0; i < DeviceManager.Instance.devices.Count; i++) //GlobalFlag.isStartRehearsing = false;
{ //for (int i = 0; i < DeviceManager.Instance.devices.Count; i++)
DeviceManager.Instance.devices[i].isStartRehearsing = false; //{
} // DeviceManager.Instance.devices[i].isStartRehearsing = false;
//}
break; break;
case "offline": case "offline":
@ -374,11 +371,14 @@ public class GameManager : MonoSingleton<GameManager>
} }
public async void CheckRoomState() public async void CheckRoomState(string state)
{ {
RoomState roomState = await AsyncWebReq.Post<RoomState>(Url_UpdateRoomState + GlobalFlag.roomID + "&state=1", null); RoomState roomState = await AsyncWebReq.Post<RoomState>(Url_UpdateRoomState + GlobalFlag.roomID +"&" + state, null);
if (roomState.message == "success") if (roomState.message == "success")
{ {
if(state == "state=1")
{
GlobalFlag.isStartRehearsing = true; GlobalFlag.isStartRehearsing = true;
for (int i = 0; i < DeviceManager.Instance.devices.Count; i++) for (int i = 0; i < DeviceManager.Instance.devices.Count; i++)
{ {
@ -390,6 +390,15 @@ public class GameManager : MonoSingleton<GameManager>
//currentSpt.GetComponent<Camera>().cullingMask &= ~(1 << 15); //currentSpt.GetComponent<Camera>().cullingMask &= ~(1 << 15);
} }
} }
else
{
GlobalFlag.isStartRehearsing = false;
for (int i = 0; i < DeviceManager.Instance.devices.Count; i++)
{
DeviceManager.Instance.devices[i].isStartRehearsing = false;
}
}
}
} }

View File

@ -125,7 +125,7 @@ public class UnmannedAerialVehicle : MonoBehaviour
+ "编号" + serialNumber + "子无人机" + "自杀式攻击自爆了"; + "编号" + serialNumber + "子无人机" + "自杀式攻击自爆了";
UploadLog(_log); UploadLog(_log);
} }
if(explodePrefab&&transform) if (explodePrefab && transform)
{ {
GameObject Bao = Instantiate(explodePrefab, transform); GameObject Bao = Instantiate(explodePrefab, transform);
Bao.transform.localPosition = Vector3.zero; Bao.transform.localPosition = Vector3.zero;
@ -258,14 +258,14 @@ public class UnmannedAerialVehicle : MonoBehaviour
Vector3 _v3 = attackTarget.position; Vector3 _v3 = attackTarget.position;
transform.DOLookAt(_v3, 0.1f).OnComplete(() => transform.DOLookAt(_v3, 0.1f).OnComplete(() =>
{ {
if (wrjModel == WRJModel.) //if (wrjModel == WRJModel.光学无人机)
{ //{
Debug.Log("光学无人机攻击"); // //Debug.Log("光学无人机攻击");
StopCoroutine(RangedAttack()); // //StopCoroutine(RangedAttack());
StartCoroutine(RangedAttack()); // //StartCoroutine(RangedAttack());
} //}
else //else
{ //{
string nowData = GetSyncData(attackTarget); string nowData = GetSyncData(attackTarget);
Debug.Log(nowData); Debug.Log(nowData);
MyNetMQClient.instance.Send(nowData); MyNetMQClient.instance.Send(nowData);
@ -280,7 +280,7 @@ public class UnmannedAerialVehicle : MonoBehaviour
// //BeAssaulted("没有攻击到目标"); // //BeAssaulted("没有攻击到目标");
//} //}
}); });
} //}
}); });
} }
} }

View File

@ -491,7 +491,13 @@ public class UnmannedAerialVehicleManage : MonoBehaviour
private bool GetAttackTarget(GameObject c)
{
if (Vector3.Distance(transform.position, c.transform.position) < 500f)
return true;
else
return false;
}
/// <summary> /// <summary>
/// 攻击打击 /// 攻击打击
@ -501,27 +507,31 @@ public class UnmannedAerialVehicleManage : MonoBehaviour
//if (isEngagedTarget) return; //if (isEngagedTarget) return;
//if (wrjModel == WRJModel.电子侦察无人机 || wrjModel == WRJModel.光学无人机) //if (wrjModel == WRJModel.电子侦察无人机 || wrjModel == WRJModel.光学无人机)
List<GameObject> allColliders = GameObject.FindGameObjectsWithTag("AttackTarget").ToList().FindAll(GetAttackTarget);
if (wrjModel == WRJModel.) if (wrjModel == WRJModel.)
{ {
List<Collider> allColliders = Physics.OverlapSphere(transform.position,500).ToList(); // 检索范围内的所有碰撞体 //List<Collider> allColliders = Physics.OverlapSphere(transform.position,500).ToList(); // 检索范围内的所有碰撞体
for (int i = 0; i < allColliders.Count; i++) for (int i = 0; i < allColliders.Count; i++)
{ {
attackColliders1.Add(allColliders[i]); if (!attackColliders1.Contains(allColliders[i].GetComponent<Collider>()))
attackColliders1.Add(allColliders[i].GetComponent<Collider>());
} }
} }
else if (wrjModel == WRJModel.) else if (wrjModel == WRJModel.)
{ {
List<Collider> allColliders = Physics.OverlapSphere(transform.position,500).ToList(); // 检索范围内的所有碰撞体 //List<Collider> allColliders = Physics.OverlapSphere(transform.position, 500).ToList(); // 检索范围内的所有碰撞体
//List<GameObject> allColliders = GameObject.FindGameObjectsWithTag("AttackTarget").ToList().FindAll(GetAttackTarget);
for (int i = 0; i < allColliders.Count; i++) for (int i = 0; i < allColliders.Count; i++)
{ {
if (allColliders[i].gameObject.tag == "AttackTarget" && !allColliders[i].isTrigger && !attackColliders1.Contains(allColliders[i])) if (!allColliders[i].GetComponent<Collider>().isTrigger && !attackColliders1.Contains(allColliders[i].GetComponent<Collider>()))
{ {
Vector3 pos = gxWRJCamera.WorldToViewportPoint(allColliders[i].transform.position); Vector3 pos = gxWRJCamera.WorldToViewportPoint(allColliders[i].transform.position);
bool ispcamera = (pos.x > 0 && pos.x < 1 && pos.y > 0 && pos.y < 1 && pos.z > 0); bool ispcamera = (pos.x > 0 && pos.x < 1 && pos.y > 0 && pos.y < 1 && pos.z > 0);
if (ispcamera) if (ispcamera)
{ {
attackColliders1.Add(allColliders[i]); if (!attackColliders1.Contains(allColliders[i].GetComponent<Collider>()))
attackColliders1.Add(allColliders[i].GetComponent<Collider>());
} }
} }
} }

View File

@ -58,6 +58,7 @@ public class RadioAngleView : MonoBehaviour
} }
private void Update() private void Update()
{ {
if (!GlobalFlag.isStartRehearsing) return;
if (typeWRJ != WRJModel.) return; if (typeWRJ != WRJModel.) return;
targets = GameObject.FindGameObjectsWithTag("AttackTarget").ToList().FindAll(GetQualifiedEquipment); targets = GameObject.FindGameObjectsWithTag("AttackTarget").ToList().FindAll(GetQualifiedEquipment);
if (targets.Count == 0) return; if (targets.Count == 0) return;