This commit is contained in:
陈向学 2024-08-23 09:50:02 +08:00
parent f4beaae9c5
commit 724d542812
7 changed files with 87 additions and 79 deletions

View File

@ -240,7 +240,7 @@ GameObject:
- component: {fileID: 4139865883083994037}
- component: {fileID: 4800734424466799504}
m_Layer: 0
m_Name: "ND_\u4E07\u7528\u8868_02"
m_Name: "\u6863\u4F4D"
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
@ -528,7 +528,7 @@ GameObject:
- component: {fileID: 6774997958504205085}
- component: {fileID: 4316715026652588437}
m_Layer: 0
m_Name: "ND_\u4E07\u7528\u8868_04"
m_Name: "\u9ED1\u63D2\u5934"
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
@ -874,7 +874,7 @@ GameObject:
- component: {fileID: 4926728448107073058}
- component: {fileID: 2203297996672072483}
m_Layer: 0
m_Name: "ND_\u4E07\u7528\u8868_03"
m_Name: "\u7EA2\u63D2\u5934"
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0

View File

@ -285,7 +285,7 @@ MonoBehaviour:
id:
isInstall: 1
installPos: {fileID: 2576541080142119082}
hasElectricity: 0
hasElectricity: 1
initPostionY: 0.0256958
--- !u!114 &2576541079962278358
MonoBehaviour:
@ -910,7 +910,7 @@ MonoBehaviour:
id:
isInstall: 1
installPos: {fileID: 2576541080266261661}
hasElectricity: 0
hasElectricity: 1
initPostionY: 0.0256958
--- !u!114 &2576541080661371199
MonoBehaviour:
@ -1369,7 +1369,7 @@ MonoBehaviour:
id:
isInstall: 1
installPos: {fileID: 2576541079990510656}
hasElectricity: 0
hasElectricity: 1
initPostionY: 0.0256958
--- !u!114 &2576541080516725976
MonoBehaviour:
@ -1662,7 +1662,7 @@ MonoBehaviour:
id:
isInstall: 1
installPos: {fileID: 2576541080447090660}
hasElectricity: 0
hasElectricity: 1
initPostionY: 0.0256958
--- !u!114 &2576541080325731228
MonoBehaviour:
@ -2376,7 +2376,7 @@ MonoBehaviour:
id:
isInstall: 1
installPos: {fileID: 2576541080224064224}
hasElectricity: 0
hasElectricity: 1
initPostionY: 0.0256958
--- !u!1 &2537738450205131575
GameObject:
@ -3635,7 +3635,7 @@ MonoBehaviour:
id:
isInstall: 1
installPos: {fileID: 2576541081758559536}
hasElectricity: 0
hasElectricity: 1
initPostionY: 0.0256958
--- !u!114 &2576541081429723931
MonoBehaviour:
@ -4382,7 +4382,7 @@ MonoBehaviour:
id:
isInstall: 1
installPos: {fileID: 2576541081645226417}
hasElectricity: 0
hasElectricity: 1
initPostionY: 0.0256958
--- !u!114 &2576541080545036941
MonoBehaviour:
@ -4847,7 +4847,7 @@ MonoBehaviour:
id:
isInstall: 1
installPos: {fileID: 2576541080183327174}
hasElectricity: 0
hasElectricity: 1
initPostionY: 0.0256958
--- !u!1 &3932947889739227106
GameObject:
@ -5765,7 +5765,7 @@ MonoBehaviour:
id:
isInstall: 1
installPos: {fileID: 2576541079818901621}
hasElectricity: 0
hasElectricity: 1
initPostionY: 0.0256958
--- !u!1 &4627208948562638019
GameObject:
@ -5886,7 +5886,7 @@ MonoBehaviour:
id:
isInstall: 1
installPos: {fileID: 2576541080163564030}
hasElectricity: 0
hasElectricity: 1
initPostionY: 0.0256958
--- !u!114 &2576541080794005321
MonoBehaviour:
@ -6789,7 +6789,7 @@ MonoBehaviour:
id:
isInstall: 1
installPos: {fileID: 2576541079818547023}
hasElectricity: 0
hasElectricity: 1
initPostionY: 0.0256958
--- !u!114 &2576541080767639298
MonoBehaviour:
@ -7791,7 +7791,7 @@ MonoBehaviour:
id:
isInstall: 1
installPos: {fileID: 2576541081608891598}
hasElectricity: 0
hasElectricity: 1
initPostionY: 0.0256958
--- !u!114 &2576541079857287480
MonoBehaviour:
@ -8167,7 +8167,7 @@ MonoBehaviour:
id:
isInstall: 1
installPos: {fileID: 2576541081575823058}
hasElectricity: 0
hasElectricity: 1
initPostionY: 0.0256958
--- !u!114 &2576541080334431883
MonoBehaviour:
@ -9551,7 +9551,7 @@ MonoBehaviour:
id:
isInstall: 1
installPos: {fileID: 2576541081300379520}
hasElectricity: 0
hasElectricity: 1
initPostionY: 0.02220154
--- !u!1 &7847778419808227353
GameObject:
@ -9838,7 +9838,7 @@ MonoBehaviour:
id:
isInstall: 1
installPos: {fileID: 2576541081225681401}
hasElectricity: 0
hasElectricity: 1
initPostionY: 0.02220154
--- !u!114 &2576541080563400542
MonoBehaviour:
@ -10925,7 +10925,7 @@ MonoBehaviour:
id:
isInstall: 1
installPos: {fileID: 2576541080299287560}
hasElectricity: 0
hasElectricity: 1
initPostionY: 0.0256958
--- !u!1 &8963846282716106637
GameObject:

View File

@ -20,12 +20,14 @@ public class Multimeter_pen : MonoBehaviour, IPointerClickHandler
{
if(eventData.button== PointerEventData.InputButton.Left)
{
//左键点选中
Debug.Log("选中"+ id+"笔");
//选中
isChose = true;
}
else if(eventData.button == PointerEventData.InputButton.Right)
{
//右键点放下
Debug.Log("放开" + id + "笔");
//取消选中
isChose = false;

View File

@ -59,10 +59,10 @@ public class Device_DirectAccessElectricEnergyMeteringDevice : Device_Base
cover.transform.localPosition = new Vector3(0.0001220703f, -0.1388763f, -0.2485413f);
//左螺丝拧下
cover.cover_screw_Left.isInstall = false;
cover.cover_screw_Left.transform.localPosition = new Vector3(0.06128693f, -0.03405334f, -0.1012321f);
cover.cover_screw_Left.transform.localPosition = new Vector3(cover.cover_screw_Left.transform.localPosition.x, cover.cover_screw_Left.initPostionY-0.03f, cover.cover_screw_Left.transform.localPosition.z);
//右螺丝拧下
cover.cover_screw_Right.isInstall = false;
cover.cover_screw_Right.transform.localPosition = new Vector3(-0.06129074f, -0.03405334f, -0.1012321f);
cover.cover_screw_Right.transform.localPosition = new Vector3(cover.cover_screw_Right.transform.localPosition.x, cover.cover_screw_Right.initPostionY-0.03f, cover.cover_screw_Right.transform.localPosition.z);
//左封印被剪开
cover.cover_seal_Left.isCut = true;
cover.cover_seal_Left.gameObject.SetActive(false);
@ -71,15 +71,15 @@ public class Device_DirectAccessElectricEnergyMeteringDevice : Device_Base
cover.cover_seal_Right.gameObject.SetActive(false);
//左固定螺丝拧下
fix_screw_left.isInstall = false;
fix_screw_left.transform.localPosition = new Vector3(0.06592941f, 0.03107117f, -0.1094047f);
fix_screw_left.transform.localPosition = new Vector3(fix_screw_left.transform.localPosition.x, fix_screw_left.initPostionY-0.03f, fix_screw_left.transform.localPosition.z);
//右固定螺丝拧下
fix_screw_right.isInstall = false;
fix_screw_right.transform.localPosition = new Vector3(-0.06737137f, 0.03107117f, -0.1094047f);
fix_screw_right.transform.localPosition = new Vector3(fix_screw_right.transform.localPosition.x, fix_screw_right.initPostionY-0.03f, fix_screw_right.transform.localPosition.z);
//接线螺丝全部拧下
jieXian_screws.ForEach(a =>
{
a.isInstall = false;
a.transform.localPosition = new Vector3(a.transform.localPosition.x, 0.005695801f, a.transform.localPosition.z);
a.transform.localPosition = new Vector3(a.transform.localPosition.x, a.initPostionY-0.03f, a.transform.localPosition.z);
});
}
}

View File

@ -3,6 +3,7 @@ using System.Collections.Generic;
using Unity.VisualScripting;
using Unity.VisualScripting.Antlr3.Runtime;
using UnityEngine;
using static UnityEngine.EventSystems.EventTrigger;
/// <summary>
/// 计量柜
@ -30,6 +31,11 @@ public class Device_MeasuringCabinet : Device_Base
/// </summary>
public List<Tool_Line> jieXian_screws;
/// <summary>
/// 电能表碰撞
/// </summary>
public BoxCollider dianCollider;
private void Awake()
{
//添加开关切换回调
@ -107,4 +113,57 @@ public class Device_MeasuringCabinet : Device_Base
}
});
}
private void Update()
{
//是否可以触发能表的拆卸或安装电
if (meteringDevice == null)
{
dianCollider.enabled = true;
}
else
{
//电能表固定螺丝拆掉了,线拆掉了
if (!meteringDevice.fix_screw_left.isInstall && !meteringDevice.fix_screw_right.isInstall && jieXian_screws.TrueForAll(a => !a.isConnected))
{
dianCollider.enabled = true;
}
else
{
dianCollider.enabled = false;
}
}
//安装或拆除电能表
if (Input.GetMouseButtonDown(0))
{
if (Physics.Raycast(Camera.main.ScreenPointToRay(Input.mousePosition), out RaycastHit hit))
{
if (hit.collider == dianCollider)
{
if (meteringDevice == null)
{
//安装电能表
if (LiveSceneManager.Instance.currentTool != null && LiveSceneManager.Instance.currentTool.GetComponent<Device_DirectAccessElectricEnergyMeteringDevice>() != null)
{
meteringDevice = LiveSceneManager.Instance.currentTool.GetComponent<Device_DirectAccessElectricEnergyMeteringDevice>();
meteringDevice.Add();
//接线关联螺丝
SetLineScrew();
//刷新带电状态
CheckHasElectricity();
}
}
else
{
//拆下电能表
meteringDevice.Remove();
//情况接线关联螺丝
ClearLineScrew();
}
}
}
}
}
}

View File

@ -14,61 +14,8 @@ public class SiteManager : MonoBehaviour
/// 机柜
/// </summary>
public Device_MeasuringCabinet measuringCabinet;
/// <summary>
/// 电能表碰撞
/// </summary>
public BoxCollider dianCollider;
private void Awake()
{
instance = this;
}
private void Update()
{
//使能电能表碰撞
if (measuringCabinet.meteringDevice == null)
{
dianCollider.enabled = true;
}
else
{
//电能表固定螺丝拆掉了,线拆掉了
if (!measuringCabinet.meteringDevice.fix_screw_left.isInstall && !measuringCabinet.meteringDevice.fix_screw_right.isInstall && measuringCabinet.jieXian_screws.TrueForAll(a=>!a.isConnected))
{
dianCollider.enabled = true;
}
else
{
dianCollider.enabled = false;
}
}
if (Input.GetMouseButtonDown(0))
{
if(Physics.Raycast(Camera.main.ScreenPointToRay(Input.mousePosition),out RaycastHit hit))
{
if(hit.collider== dianCollider)
{
if (measuringCabinet.meteringDevice==null)
{
//安装电能表
if(LiveSceneManager.Instance.currentTool!=null && LiveSceneManager.Instance.currentTool.GetComponent<Device_DirectAccessElectricEnergyMeteringDevice>()!=null)
{
measuringCabinet.meteringDevice = LiveSceneManager.Instance.currentTool.GetComponent<Device_DirectAccessElectricEnergyMeteringDevice>();
measuringCabinet.meteringDevice.Add();
//接线关联螺丝
measuringCabinet.SetLineScrew();
}
}
else
{
//拆下电能表
measuringCabinet.meteringDevice.Remove();
//情况接线关联螺丝
measuringCabinet.ClearLineScrew();
}
}
}
}
}
}

View File

@ -17,8 +17,8 @@ public class Tool_Multimeter : Tool_Base
/// µ²Î»
/// </summary>
public Multimeter_dangwei dangWei;
public Transform redPen;
public Transform blackPen;
public Multimeter_pen redPen;
public Multimeter_pen blackPen;
/// <summary>
/// Çл»µ²Î»