Compare commits

...

2 Commits

Author SHA1 Message Date
yulong b468d289e4 Merge branch 'master' of http://git.umayle.com:2023/yulong/NewN_UAVPlane 2024-01-22 14:47:47 +08:00
yulong eb55cac44a 4565 2024-01-22 14:47:41 +08:00
24 changed files with 288 additions and 12 deletions

View File

@ -1 +1 @@
192.168.1.5:48888
192.168.97.15:48888

View File

@ -1 +1 @@
192.168.1.5
192.168.97.15

View File

@ -0,0 +1,99 @@
using AdamSync;
using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.Events;
using UnityEngine.Networking;
using static InterfaceManager;
public class Backpack : MonoBehaviour
{
public UnityEvent oneClickEvent;//unity事件
public UnityEvent doubleClickEvent;//unity事件
public float time;
public float lascktime;
public float itemtime = 0.2f;
public int count;
public bool isCount = true;
public Mastermanagement mastermanagement;
public string Id;
void Start()
{
}
void Update()
{
if (Input.GetMouseButtonDown(1))
{
time = 0.2f;
if (Time.realtimeSinceStartup - lascktime < itemtime)
{
count = 2;
}
else
{
count = 1;
}
}
if (Input.GetMouseButtonUp(1))
{
isCount = false;
lascktime = Time.realtimeSinceStartup;
}
if (!isCount)
{
time -= Time.deltaTime;
if (time <= 0)
{
if (count == 2)
{
OnRay();
doubleClickEvent?.Invoke();
}
else
{
oneClickEvent?.Invoke();
}
isCount = true;
}
}
}
private void OnRay()
{
Ray ray = Camera.main.ScreenPointToRay(Input.mousePosition);
RaycastHit hit;
if (Physics.Raycast(ray, out hit, 1000))
{
if (hit.collider.gameObject.tag == "AttackTarget")
{
mastermanagement.Onobj(hit.collider.gameObject);
mastermanagement.Remove(hit.collider.gameObject);
Id = hit.collider.gameObject.GetComponent<EquipmentCommon>().deviceID;
Deletedevice();
}
}
}
private void Deletedevice()
{
if (string.IsNullOrEmpty(Id))
{
return;
}
string nowData = string.Format("{0},{1}", "SetToBeDestroyedTwo", Id);
_ = SyncCreateRoom.SendMessageAsync(string.Format("send2room {0}", nowData));
WWWForm headers = new WWWForm();
headers.AddField("id", Id);
StartCoroutine(PostString(Url_Deletepracticedevicedetail, headers, data =>
{
Id = null;
Debug.Log(data);
}));
}
}

View File

@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 13182b39a85857f4f833a669ab1e3daf
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,77 @@
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using UnityEngine;
public class Mastermanagement : MonoBehaviour
{
public List<DragController> dragControllers = new List<DragController>();//用于存UI元素
public List<GameObject> weapongames = new List<GameObject>();//用于存储场景中的物体
void Awake()
{
}
void Start()
{
StartCoroutine(WaitGetAllDevice());
}
private IEnumerator WaitGetAllDevice()
{
yield return new WaitForSeconds(0.01f);
weapongames = DeviceManager.Instance.GetPlayerDecive1();
if (weapongames != null)
{
for (int i = 0; i < weapongames.Count; i++)
{
Noobj(weapongames[i]);
}
}
}
void Update()
{
}
//初始化场景的设备
public void Noobj(GameObject game)
{
for (int i = 0; i < dragControllers.Count; i++)
{
if (dragControllers[i].gameObject.name == game.name)
{
dragControllers[i].gameObject.SetActive(false);
}
}
}
//判断链表的名字是否有相等的
public void Onobj(GameObject game)
{
for (int i = 0; i < dragControllers.Count; i++)
{
if (dragControllers[i].gameObject.name == game.name)
{
dragControllers[i].gameObject.SetActive(true);
}
}
}
//给列表添加游戏物体
public void OnAdd(GameObject obj)
{
if (!weapongames.Contains(obj))
{
weapongames.Add(obj);
}
}
//给游戏删除物体
public void Remove(GameObject obj)
{
if (weapongames.Contains(obj))
{
weapongames.Remove(obj);
Destroy(obj);
}
}
}

View File

@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: f60413c586ad1224eacda56f97097b97
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -38,7 +38,7 @@ RenderSettings:
m_ReflectionIntensity: 1
m_CustomReflection: {fileID: 0}
m_Sun: {fileID: 1113159741}
m_IndirectSpecularColor: {r: 0.1623278, g: 0.30647233, b: 0.67099607, a: 1}
m_IndirectSpecularColor: {r: 0.16234788, g: 0.30616665, b: 0.6691998, a: 1}
m_UseRadianceAmbientProbe: 0
--- !u!157 &3
LightmapSettings:
@ -6652,6 +6652,7 @@ MonoBehaviour:
isPlayer: 0
isThinck: 0
wrjModel: 0
mastermanagement: {fileID: 0}
--- !u!224 &138577124 stripped
RectTransform:
m_CorrespondingSourceObject: {fileID: 1586417955185665353, guid: 18a1ad49a084edc44b006d5905c6d928,
@ -6671,6 +6672,8 @@ GameObject:
- component: {fileID: 147647009}
- component: {fileID: 147647008}
- component: {fileID: 147647012}
- component: {fileID: 147647013}
- component: {fileID: 147647014}
m_Layer: 5
m_Name: Canvas
m_TagString: Untagged
@ -6780,6 +6783,44 @@ MonoBehaviour:
m_EditorClassIdentifier:
secne1: {fileID: 284678593}
secne2: {fileID: 1862065805184089352}
--- !u!114 &147647013
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 147647007}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: f60413c586ad1224eacda56f97097b97, type: 3}
m_Name:
m_EditorClassIdentifier:
dragControllers: []
weapongames: []
--- !u!114 &147647014
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 147647007}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 13182b39a85857f4f833a669ab1e3daf, type: 3}
m_Name:
m_EditorClassIdentifier:
oneClickEvent:
m_PersistentCalls:
m_Calls: []
doubleClickEvent:
m_PersistentCalls:
m_Calls: []
time: 0
lascktime: 0
itemtime: 0.2
count: 0
isCount: 1
mastermanagement: {fileID: 147647013}
--- !u!1 &150755764
GameObject:
m_ObjectHideFlags: 0
@ -49404,6 +49445,7 @@ MonoBehaviour:
- {fileID: 609129006}
- {fileID: 745447508}
- {fileID: 1213021907}
mastermanagement: {fileID: 147647013}
--- !u!4 &1436809530
Transform:
m_ObjectHideFlags: 0
@ -63570,7 +63612,7 @@ MonoBehaviour:
m_PreInfinity: 2
m_PostInfinity: 2
m_RotationOrder: 4
randSeed: 256023359
randSeed: -1014665484
isDoingTransition: 0
minimumHeight: 0
--- !u!114 &1820978574

View File

@ -93,6 +93,22 @@ public class DeviceManager : MonoSingleton<DeviceManager>
}
return temp.Count;
}
/// <summary>
/// 获取所以当前玩家的设备
/// </summary>
/// <returns></returns>
public List<GameObject> GetPlayerDecive1()
{
List<GameObject> temp = new List<GameObject>();
for (int i = 0; i < devices.Count; i++)
{
if (devices[i] != null && devices[i].isPlayer)
{
temp.Add(devices[i].gameObject);
}
}
return temp;
}
/// <summary>
/// 获取光学无人机和自杀式无人机

View File

@ -19,6 +19,12 @@ public class DragController : MonoBehaviour, IBeginDragHandler, IEndDragHandler,
public WRJModel wrjModel = WRJModel.;
public Mastermanagement mastermanagement;
void Start()
{
mastermanagement = GameObject.Find("Canvas").GetComponent<Mastermanagement>();
}
public void OnBeginDrag(PointerEventData eventData)
{
if (isDragWRJ)
@ -59,8 +65,11 @@ public class DragController : MonoBehaviour, IBeginDragHandler, IEndDragHandler,
model.GetComponent<EquipmentCommon>().FillInTheData(temp);
if (!isDragWRJ)
{
transform.SetAsLastSibling();
transform.localScale = Vector3.zero;
//transform.SetAsLastSibling();
//transform.localScale = Vector3.zero;
model.name = gameObject.name;
mastermanagement.OnAdd(model);
gameObject.SetActive(false);
}
}
if (DragManager.Instance != null)

View File

@ -35,9 +35,9 @@ public class GameManager : MonoSingleton<GameManager>
public DragController[] wrjDrags;
public Mastermanagement mastermanagement;
// Start is called before the first frame update
// Start is called before the first frame update
private void Awake()
{
SyncCreateRoom.getroomusersRequset += OnGetRoomUsers;
@ -60,7 +60,7 @@ public class GameManager : MonoSingleton<GameManager>
wrjCount = diTemp.device_count;
for (int i = 0; i < wrjDrags.Length; i++)
{
wrjDrags[i].isPlayer = true;
wrjDrags[i].isPlayer = true;
wrjDrags[i].deviceID = UIBootstrap.Instance.GetDeviceByName("蜂群无人机").id;
}
}
@ -89,6 +89,7 @@ public class GameManager : MonoSingleton<GameManager>
{
DragController ld = Instantiate(ldDrag, dviceContent);
ld.deviceID = UIBootstrap.Instance.GetDeviceByName("探测雷达").id;
mastermanagement.dragControllers.Add(ld);
}
}
if (UIBootstrap.Instance.GetDeviceByName("激光火控平台").device_count > 0)
@ -97,6 +98,7 @@ public class GameManager : MonoSingleton<GameManager>
{
DragController hp = Instantiate(hpDrag, dviceContent);
hp.deviceID = UIBootstrap.Instance.GetDeviceByName("激光火控平台").id;
mastermanagement.dragControllers.Add(hp);
}
}
if (UIBootstrap.Instance.GetDeviceByName("地面无线电干扰").device_count > 0)
@ -105,6 +107,7 @@ public class GameManager : MonoSingleton<GameManager>
{
DragController wxd = Instantiate(wxdDrag, dviceContent);
wxd.deviceID = UIBootstrap.Instance.GetDeviceByName("地面无线电干扰").id;
mastermanagement.dragControllers.Add(wxd);
}
}
if (UIBootstrap.Instance.GetDeviceByName("微波武器").device_count > 0)
@ -113,6 +116,7 @@ public class GameManager : MonoSingleton<GameManager>
{
DragController wxd = Instantiate(wbDrag, dviceContent);
wxd.deviceID = UIBootstrap.Instance.GetDeviceByName("微波武器").id;
mastermanagement.dragControllers.Add(wxd);
}
}
if (UIBootstrap.Instance.GetDeviceByName("频谱探测").device_count > 0)
@ -121,6 +125,7 @@ public class GameManager : MonoSingleton<GameManager>
{
DragController wxd = Instantiate(ppDrag, dviceContent);
wxd.deviceID = UIBootstrap.Instance.GetDeviceByName("频谱探测").id;
mastermanagement.dragControllers.Add(wxd);
}
}
}

View File

@ -134,6 +134,10 @@ public static class InterfaceManager
/// 查询房间作战日志
/// </summary>
public static string Url_Querypracticelog { get => IpAddress + "/Handler/Practice.ashx?action=querypracticelog&PracticeId="; }
/// <summary>
/// 删除设备
/// </summary>
public static string Url_delete { get => IpAddress + "/Handler/Thinkingfile.ashx?action=deletedevice"; }
#endregion

View File

@ -303,7 +303,9 @@ public class EquipmentCommon : MonoBehaviour
Bao.SetActive(true);
Destroy(transform.gameObject);
break;
case "SetToBeDestroyedTwo"://设备被收回
Destroy(transform.gameObject);
break;
default:
break;
}

View File

@ -215,7 +215,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.GetComponent<LaserFireControlPlatformManger>())
{
Transform canvas = GameObject.Find("Canvas").transform;
if (canvas)

View File

@ -140,7 +140,7 @@ public class TerrestrialRadioInterferenceManger : MonoBehaviour
{
return;
}
if (hit.transform.tag == "AttackTarget" && hit.transform.gameObject.name == "地面无线电干扰(Clone)")
if (hit.transform.tag == "AttackTarget" && hit.transform.GetComponent<TerrestrialRadioInterferenceManger>())
{
Conversionfrequency.Instance.terrestrialRadioInterferenceManger = hit.transform.GetComponent<TerrestrialRadioInterferenceManger>();
Conversionfrequency.Instance.transform.position = Camera.main.WorldToScreenPoint(hit.point);