This commit is contained in:
parent
443139d785
commit
f97495d712
|
@ -10104,7 +10104,7 @@ MonoBehaviour:
|
|||
FireSpeed: 20
|
||||
explodePrefab: {fileID: 1000013462590818, guid: ecdd96beb7f93494880c052dfccf9dc1,
|
||||
type: 3}
|
||||
Camera: {fileID: 0}
|
||||
camera: {fileID: 0}
|
||||
RawImage: {fileID: 6102700022742998670, guid: b2cb817bb62743a4194cd9d89f07e27d,
|
||||
type: 3}
|
||||
crosshair: {fileID: 0}
|
||||
|
|
|
@ -120,7 +120,7 @@ public class LaserFireControlPlatformManger : MonoBehaviour
|
|||
/// <summary>
|
||||
/// 十字准星架视角
|
||||
/// </summary>
|
||||
public Camera Camera;
|
||||
public Camera camera;
|
||||
/// <summary>
|
||||
/// 十字准星架视角UI显示
|
||||
/// </summary>
|
||||
|
@ -137,12 +137,23 @@ public class LaserFireControlPlatformManger : MonoBehaviour
|
|||
/// 点击空白处碰撞器
|
||||
/// </summary>
|
||||
public GameObject Detection;
|
||||
|
||||
/// <summary>
|
||||
/// 摄像机视角开关
|
||||
/// </summary>
|
||||
public bool isplaser = true;
|
||||
/// <summary>
|
||||
/// 激光火炮打击时间
|
||||
/// </summary>
|
||||
public static float lasertime;
|
||||
/// <summary>
|
||||
/// 判断物体是否在相机里面
|
||||
/// </summary>
|
||||
public bool ispcamera;
|
||||
void Start()
|
||||
{
|
||||
equipmentCommon = GetComponent<EquipmentCommon>();
|
||||
laserFireControlPlatformMangers.Add(this);
|
||||
Camera = transform.GetChild(1).GetComponent<Camera>();
|
||||
camera = transform.GetChild(1).GetComponent<Camera>();
|
||||
//weaponitemones = Newtonsoft.Json.JsonConvert.DeserializeObject<Weaponitemone>(msg);
|
||||
//FillInTheData(weaponitemones);//测试写入
|
||||
// 订阅布尔值变化事件
|
||||
|
@ -184,9 +195,9 @@ public class LaserFireControlPlatformManger : MonoBehaviour
|
|||
// Front = true;
|
||||
// }
|
||||
//}
|
||||
if (UIBootstrap.Instance.GetRoleByIDPracticeId(GlobalFlag.practiceSeatId)!="0"&&Input.GetMouseButtonDown(0))
|
||||
if (UIBootstrap.Instance.GetRoleByIDPracticeId(GlobalFlag.practiceSeatId) != "0" && Input.GetMouseButtonDown(0))
|
||||
{
|
||||
Ray ray=Camera.main.ScreenPointToRay(Input.mousePosition);
|
||||
Ray ray = Camera.main.ScreenPointToRay(Input.mousePosition);
|
||||
RaycastHit hit;
|
||||
if (Physics.Raycast(ray, out hit))
|
||||
{
|
||||
|
@ -194,7 +205,7 @@ public class LaserFireControlPlatformManger : MonoBehaviour
|
|||
{
|
||||
return;
|
||||
}
|
||||
if (hit.transform.gameObject.tag == "AttackTarget"&&hit.transform.gameObject.name == "激光火控平台(Clone)")
|
||||
if (hit.transform.gameObject.tag == "AttackTarget" && hit.transform.gameObject.name == "激光火控平台(Clone)")
|
||||
{
|
||||
Transform canvas = GameObject.Find("Canvas").transform;
|
||||
if (canvas)
|
||||
|
@ -203,9 +214,9 @@ public class LaserFireControlPlatformManger : MonoBehaviour
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 开启暂停激光发射武器
|
||||
|
@ -254,16 +265,20 @@ public class LaserFireControlPlatformManger : MonoBehaviour
|
|||
{
|
||||
while (true)
|
||||
{
|
||||
yield return new WaitForSeconds(timepiece);
|
||||
if (timepiece!=0)
|
||||
yield return new WaitForSeconds(lasertime);
|
||||
if (lasertime != 0)
|
||||
{
|
||||
Laserattack();
|
||||
//Laserattack();
|
||||
}
|
||||
}
|
||||
}
|
||||
void LateUpdate()
|
||||
{
|
||||
|
||||
if (Receivingdistance > 0 && isplaser == true)
|
||||
{
|
||||
camera.farClipPlane = Receivingdistance;
|
||||
isplaser = false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
@ -282,7 +297,7 @@ public class LaserFireControlPlatformManger : MonoBehaviour
|
|||
{
|
||||
case "储能间隔时间:":
|
||||
StorageIntervalTime = weaponitemone[i].para_value;
|
||||
timepiece = float.Parse(StorageIntervalTime);
|
||||
lasertime = float.Parse(StorageIntervalTime);
|
||||
break;
|
||||
case "毁伤目标累积作用时间:":
|
||||
CumulativeActionTimeOfDamageTarget = weaponitemone[i].para_value;
|
||||
|
@ -306,10 +321,9 @@ public class LaserFireControlPlatformManger : MonoBehaviour
|
|||
/// </summary>
|
||||
public void Laserattack()
|
||||
{
|
||||
if (Receivingdistance > 0 && targetPoint!=null)
|
||||
if (Receivingdistance > 0 && targetPoint != null)
|
||||
{
|
||||
Collider[] colliders = Physics.OverlapSphere(transform.position, Receivingdistance);//检查是否在打击的范围内
|
||||
Debug.LogError("范围打击距离:" + Receivingdistance);
|
||||
for (int i = 0; i < colliders.Length; i++)
|
||||
{
|
||||
if (colliders[i].gameObject.tag == "WRJ")
|
||||
|
@ -328,17 +342,17 @@ public class LaserFireControlPlatformManger : MonoBehaviour
|
|||
{
|
||||
Debug.LogError("角度没有问题进来了" + InterferenceAngle);
|
||||
|
||||
if (Receivingposin==null)
|
||||
if (Receivingposin == null)
|
||||
{
|
||||
//if (Random.value>0.5f)
|
||||
//{
|
||||
Receivingposin = unmannedAerialVehicle.transform;
|
||||
Debug.LogError("接收无人机的位置" + Receivingposin.position);
|
||||
var nowData = GetSyncData();
|
||||
_ = SyncCreateRoom.SendMessageAsync(string.Format("send2room {0}", nowData));
|
||||
isLasings = true;
|
||||
CastRayAndRender();
|
||||
break;
|
||||
Receivingposin = unmannedAerialVehicle.transform;
|
||||
Debug.LogError("接收无人机的位置" + Receivingposin.position);
|
||||
var nowData = GetSyncData();
|
||||
_ = SyncCreateRoom.SendMessageAsync(string.Format("send2room {0}", nowData));
|
||||
isLasings = true;
|
||||
CastRayAndRender();
|
||||
break;
|
||||
//}
|
||||
//else
|
||||
//{
|
||||
|
@ -358,9 +372,9 @@ public class LaserFireControlPlatformManger : MonoBehaviour
|
|||
}
|
||||
}
|
||||
|
||||
private string GetSyncData1()
|
||||
private string GetSyncData1()
|
||||
{
|
||||
return string.Format("{0},{1},{2},{3}" + equipmentCommon.deviceID, Receivingposin.position.x+3,Receivingposin.position.y+3,Receivingposin.position.z);
|
||||
return string.Format("{0},{1},{2},{3}" + equipmentCommon.deviceID, Receivingposin.position.x + 3, Receivingposin.position.y + 3, Receivingposin.position.z);
|
||||
}
|
||||
|
||||
|
||||
|
@ -371,11 +385,10 @@ public class LaserFireControlPlatformManger : MonoBehaviour
|
|||
{
|
||||
if (targetPoint != null)
|
||||
{
|
||||
LaserModer.transform.DOLookAt(targetPoint.position, 1.5f).OnComplete(() =>
|
||||
LaserModer.transform.DOLookAt(targetPoint.position,0.5f).OnComplete(() =>
|
||||
{
|
||||
|
||||
isLasing = false;
|
||||
//CastRayAndRender();
|
||||
|
||||
});
|
||||
//var nowData = GetSyncData();
|
||||
//_ = SyncCreateRoom.SendMessageAsync(string.Format("send2room {0}", nowData));
|
||||
|
@ -389,11 +402,47 @@ public class LaserFireControlPlatformManger : MonoBehaviour
|
|||
/// 十字准星架视角
|
||||
/// </summary>
|
||||
public void Crosshair()
|
||||
{
|
||||
{
|
||||
if (targetPoint != null)
|
||||
{
|
||||
Camera.transform.DOLookAt(targetPoint.position, 1.5f).SetEase(Ease.Linear);
|
||||
//isLasing = false;
|
||||
camera.transform.DOLookAt(targetPoint.position,0.5f).SetEase(Ease.Linear).OnComplete(() =>
|
||||
{
|
||||
Debug.LogError("看向进来了");
|
||||
Launchanattack();
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
/// <summary>
|
||||
/// 激光显示
|
||||
/// </summary>
|
||||
public void Launchanattack()
|
||||
{
|
||||
if (targetPoint != null)
|
||||
{
|
||||
Vector3 pos = camera.WorldToViewportPoint(targetPoint.position);
|
||||
ispcamera = (pos.x > 0 && pos.x < 1 && pos.y > 0 && pos.y < 1 && pos.z > 0);
|
||||
if (ispcamera)
|
||||
{
|
||||
Debug.LogError("出现在摄像机视角里面了");
|
||||
Vector3 cector = targetPoint.position - transform.position;
|
||||
float angle = Vector3.Angle(cector, transform.forward);
|
||||
if (float.Parse(InterferenceAngle) > angle)
|
||||
{
|
||||
Debug.Log("角度合适进行打击");
|
||||
var nowData = GetSyncData();
|
||||
_ = SyncCreateRoom.SendMessageAsync(string.Format("send2room {0}", nowData));
|
||||
CastRayAndRender();
|
||||
}
|
||||
else
|
||||
{
|
||||
Debug.LogError("超出了角度不进行攻击");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
Debug.LogError("飞机不在摄像机范围内");
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -406,14 +455,14 @@ public class LaserFireControlPlatformManger : MonoBehaviour
|
|||
if (InnerLaserlineRenderer)
|
||||
{
|
||||
InnerLaserlineRenderer.SetPosition(0, LaserPoint.transform.position); // 设置线段起点为物体位置
|
||||
InnerLaserlineRenderer.SetPosition(1, Receivingposin.position); // 设置线段终点为目标点
|
||||
InnerLaserlineRenderer.SetPosition(1, targetPoint.position); // 设置线段终点为目标点
|
||||
}
|
||||
if (OuterLaserlineRenderer)
|
||||
{
|
||||
OuterLaserlineRenderer.SetPosition(0, LaserPoint.transform.position); // 设置线段起点为物体位置
|
||||
OuterLaserlineRenderer.SetPosition(1, Receivingposin.position); // 设置线段终点为目标点
|
||||
OuterLaserlineRenderer.SetPosition(1, targetPoint.position); // 设置线段终点为目标点
|
||||
}
|
||||
StrikeDrone(Receivingposin);
|
||||
StrikeDrone(targetPoint);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
@ -429,46 +478,7 @@ public class LaserFireControlPlatformManger : MonoBehaviour
|
|||
StartCoroutine(LaserExtinction());
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// 激光打击位置未打中
|
||||
/// </summary>
|
||||
public void Lasering()
|
||||
{
|
||||
if (targetPoint != null)
|
||||
{
|
||||
targetPoint.position = new Vector3(targetPoint.position.x + 5, targetPoint.position.y, transform.position.z);
|
||||
LaserModer.transform.DOLookAt(targetPoint.position, 0.5f);
|
||||
//CastRayAndRender1();
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// 十字准星架为打中视角
|
||||
/// </summary>
|
||||
public void Crosshair1()
|
||||
{
|
||||
if (targetPoint != null)
|
||||
{
|
||||
targetPoint.position = new Vector3(targetPoint.position.x + 5, targetPoint.position.y, transform.position.z);
|
||||
Camera.transform.DOLookAt(targetPoint.position, 0.1f).SetEase(Ease.Linear);
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// 激光显示为打中
|
||||
/// </summary>
|
||||
public void CastRayAndRender1()
|
||||
{
|
||||
if (InnerLaserlineRenderer)
|
||||
{
|
||||
InnerLaserlineRenderer.SetPosition(0, LaserPoint.transform.position); // 设置线段起点为物体位置
|
||||
InnerLaserlineRenderer.SetPosition(1, Receivingposin.position); // 设置线段终点为目标点
|
||||
}
|
||||
if (OuterLaserlineRenderer)
|
||||
{
|
||||
InnerLaserlineRenderer.SetPosition(0, LaserPoint.transform.position); // 设置线段起点为物体位置
|
||||
InnerLaserlineRenderer.SetPosition(1, Receivingposin.position); // 设置线段终点为目标点
|
||||
}
|
||||
StartCoroutine(LaserExtinction());
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 销毁单体无人机
|
||||
|
@ -519,7 +529,7 @@ public class LaserFireControlPlatformManger : MonoBehaviour
|
|||
/// 单个无人机被销毁
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
protected string GetSyncDis(UnmannedAerialVehicle unmannedAerialVehicle)
|
||||
protected string GetSyncDis(UnmannedAerialVehicle unmannedAerialVehicle)
|
||||
{
|
||||
return string.Format("{0},{1},{2}", "DroneWasDestroyed", unmannedAerialVehicle.unmannedAerialVehicleManage.equipmentCommon.deviceID, unmannedAerialVehicle.serialNumber);
|
||||
}
|
||||
|
@ -539,7 +549,7 @@ public class LaserFireControlPlatformManger : MonoBehaviour
|
|||
OuterLaserlineRenderer.SetPosition(0, LaserPoint.transform.position); // 设置线段起点为物体位置
|
||||
OuterLaserlineRenderer.SetPosition(1, LaserPoint.transform.position); // 设置线段终点为目标点
|
||||
}
|
||||
isLasings = false;
|
||||
isLasing = false;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
@ -551,10 +561,10 @@ public class LaserFireControlPlatformManger : MonoBehaviour
|
|||
/// <returns></returns>
|
||||
protected string GetSyncData()
|
||||
{
|
||||
|
||||
Debug.Log("目标点位..:" + Receivingposin.position);
|
||||
return string.Format("{0},{1},{2},{3},{4}", "Lasing", equipmentCommon.deviceID, Receivingposin.position.x, Receivingposin.position.y, Receivingposin.position.z);
|
||||
|
||||
|
||||
Debug.Log("目标点位..:" + targetPoint.position);
|
||||
return string.Format("{0},{1},{2},{3},{4}", "Lasing", equipmentCommon.deviceID, targetPoint.position.x, targetPoint.position.y, targetPoint.position.z);
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
|
|
@ -118,6 +118,10 @@ public class RadarManger : MonoBehaviour
|
|||
/// 渲染小地图摄像机
|
||||
/// </summary>
|
||||
public Camera Mincamera;
|
||||
/// <summary>
|
||||
/// 计时火炮蓄能时间
|
||||
/// </summary>
|
||||
public float radartime;
|
||||
void Start()
|
||||
{
|
||||
Mincamera = GameObject.Find("Minimap Camera").GetComponent<Camera>();
|
||||
|
@ -163,7 +167,7 @@ public class RadarManger : MonoBehaviour
|
|||
while (true)
|
||||
{
|
||||
//Debug.Log("Timer fired at: " + Time.time);
|
||||
yield return new WaitForSeconds(interval); // 等待一段时间后继续执行
|
||||
yield return new WaitForSeconds(5); // 等待一段时间后继续执行
|
||||
//RetrievalUAV();
|
||||
}
|
||||
}
|
||||
|
@ -186,9 +190,11 @@ public class RadarManger : MonoBehaviour
|
|||
{
|
||||
if (equipmentCommon.isPlayer && timerCoroutine != null)
|
||||
{
|
||||
|
||||
StopCoroutine(timerCoroutine);
|
||||
timerCoroutine = null;
|
||||
isTimerRunning = false;
|
||||
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
|
@ -299,20 +305,26 @@ public class RadarManger : MonoBehaviour
|
|||
UnmannedAerialVehicle unmannedAerialVehicle = colliders2[i].GetComponent<UnmannedAerialVehicle>();
|
||||
if (unmannedAerialVehicle)
|
||||
{
|
||||
LaserFireControlPlatformManger laserFireControlPlatformManger = LaserFireControlPlatformManger.laserFireControlPlatformMangers.Find(x => (x != null && x.isLasing == false));
|
||||
if (laserFireControlPlatformManger)
|
||||
radartime += Time.deltaTime;
|
||||
if (radartime>=LaserFireControlPlatformManger.lasertime)
|
||||
{
|
||||
laserFireControlPlatformManger.isLasing=true;
|
||||
//Debug.Log(laserFireControlPlatformManger.transform.name + "攻击无人机: " + unmannedAerialVehicle.transform.name);
|
||||
laserFireControlPlatformManger.targetPoint = unmannedAerialVehicle.transform;
|
||||
laserFireControlPlatformManger.Crosshair();
|
||||
laserFireControlPlatformManger.Lasing();
|
||||
Debug.Log("今来了");
|
||||
LaserFireControlPlatformManger laserFireControlPlatformManger = LaserFireControlPlatformManger.laserFireControlPlatformMangers.Find(x => (x != null && x.isLasing == false));
|
||||
radartime = 0;
|
||||
if (laserFireControlPlatformManger)
|
||||
{
|
||||
laserFireControlPlatformManger.isLasing = true;
|
||||
//Debug.Log(laserFireControlPlatformManger.transform.name + "攻击无人机: " + unmannedAerialVehicle.transform.name);
|
||||
laserFireControlPlatformManger.targetPoint = unmannedAerialVehicle.transform;
|
||||
laserFireControlPlatformManger.Crosshair();
|
||||
laserFireControlPlatformManger.Lasing();
|
||||
}
|
||||
}
|
||||
number++;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue