带电逻辑完善,修复工具bug,拆卸安装电能表流程完善
This commit is contained in:
parent
ebf4a433ba
commit
5339727bcf
|
@ -123,8 +123,8 @@ CapsuleCollider:
|
||||||
m_Material: {fileID: 0}
|
m_Material: {fileID: 0}
|
||||||
m_IsTrigger: 0
|
m_IsTrigger: 0
|
||||||
m_Enabled: 1
|
m_Enabled: 1
|
||||||
m_Radius: 0.5
|
m_Radius: 0.2
|
||||||
m_Height: 2
|
m_Height: 1.7
|
||||||
m_Direction: 1
|
m_Direction: 1
|
||||||
m_Center: {x: 0, y: 0, z: 0}
|
m_Center: {x: 0, y: 0, z: 0}
|
||||||
--- !u!33 &7005868485670428847
|
--- !u!33 &7005868485670428847
|
||||||
|
|
|
@ -1168,7 +1168,7 @@ GameObject:
|
||||||
- component: {fileID: 4658103605771657434}
|
- component: {fileID: 4658103605771657434}
|
||||||
- component: {fileID: 2797656432174285614}
|
- component: {fileID: 2797656432174285614}
|
||||||
m_Layer: 0
|
m_Layer: 0
|
||||||
m_Name: "\u4E09\u76F8\u56DB\u7EBF\u7535\u80FD\u8868"
|
m_Name: "\u4E09\u76F8\u56DB\u7EBF\u7535\u80FD\u8868_xxx"
|
||||||
m_TagString: Untagged
|
m_TagString: Untagged
|
||||||
m_Icon: {fileID: 0}
|
m_Icon: {fileID: 0}
|
||||||
m_NavMeshLayer: 0
|
m_NavMeshLayer: 0
|
File diff suppressed because it is too large
Load Diff
|
@ -1,6 +1,6 @@
|
||||||
fileFormatVersion: 2
|
fileFormatVersion: 2
|
||||||
guid: 0ea8c75644dbff14bacec41ed2dc6efc
|
guid: 10f4454f32eb20e4298912d896f6020e
|
||||||
DefaultImporter:
|
PrefabImporter:
|
||||||
externalObjects: {}
|
externalObjects: {}
|
||||||
userData:
|
userData:
|
||||||
assetBundleName:
|
assetBundleName:
|
File diff suppressed because it is too large
Load Diff
|
@ -1,5 +1,5 @@
|
||||||
fileFormatVersion: 2
|
fileFormatVersion: 2
|
||||||
guid: a39ba73cc2686bf42b78647875bb8a23
|
guid: b89569af6fe931647be081fff26b1b94
|
||||||
DefaultImporter:
|
DefaultImporter:
|
||||||
externalObjects: {}
|
externalObjects: {}
|
||||||
userData:
|
userData:
|
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
|
@ -53,8 +53,8 @@ public class Device_Cover : Device_Base
|
||||||
{
|
{
|
||||||
Debug.Log("打开盖子");
|
Debug.Log("打开盖子");
|
||||||
isOpen = true;
|
isOpen = true;
|
||||||
transform.DOLocalMoveY(transform.localPosition.y - 0.15f, 2);
|
transform.DOLocalMoveY(-0.1388763f, 2);
|
||||||
transform.DOLocalMoveZ(transform.localPosition.z - 0.15f, 2);
|
transform.DOLocalMoveZ(-0.2485413f, 2);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
@ -64,7 +64,7 @@ public class Device_Cover : Device_Base
|
||||||
{
|
{
|
||||||
Debug.Log("盖上盖子");
|
Debug.Log("盖上盖子");
|
||||||
isOpen = false;
|
isOpen = false;
|
||||||
transform.DOLocalMoveY(transform.localPosition.y + 0.15f, 2);
|
transform.DOLocalMoveY(0.01112366f, 2);
|
||||||
transform.DOLocalMoveZ(transform.localPosition.z + 0.15f, 2);
|
transform.DOLocalMoveZ(-0.09854126f, 2);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
using DG.Tweening;
|
using DG.Tweening;
|
||||||
|
using Sirenix.Utilities;
|
||||||
using System.Collections;
|
using System.Collections;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using Unity.VisualScripting;
|
|
||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
@ -9,11 +9,6 @@ using UnityEngine;
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public class Device_DirectAccessElectricEnergyMeteringDevice : Device_Base
|
public class Device_DirectAccessElectricEnergyMeteringDevice : Device_Base
|
||||||
{
|
{
|
||||||
public static Device_DirectAccessElectricEnergyMeteringDevice instance;
|
|
||||||
/// <summary>
|
|
||||||
/// 是否已被拆除
|
|
||||||
/// </summary>
|
|
||||||
public bool isRemove;
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 铭牌
|
/// 铭牌
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
@ -24,13 +19,6 @@ public class Device_DirectAccessElectricEnergyMeteringDevice : Device_Base
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public Device_Cover cover;
|
public Device_Cover cover;
|
||||||
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// 电能表接线
|
|
||||||
/// </summary>
|
|
||||||
[Tooltip("接线")]
|
|
||||||
public List<Tool_Line> jieXian_lines;
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 电能表固定螺丝左
|
/// 电能表固定螺丝左
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
@ -39,27 +27,72 @@ public class Device_DirectAccessElectricEnergyMeteringDevice : Device_Base
|
||||||
/// 电能表固定螺丝右
|
/// 电能表固定螺丝右
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public Tool_Screw fix_screw_right;
|
public Tool_Screw fix_screw_right;
|
||||||
|
/// <summary>
|
||||||
|
/// 电能表接线螺丝
|
||||||
|
/// </summary>
|
||||||
|
public List<Tool_Screw> jieXian_screws;
|
||||||
|
|
||||||
|
|
||||||
private BoxCollider boxCollider;
|
private BoxCollider boxCollider;
|
||||||
|
|
||||||
private void Awake()
|
private void Awake()
|
||||||
{
|
{
|
||||||
instance = this;
|
|
||||||
boxCollider = GetComponent<BoxCollider>();
|
boxCollider = GetComponent<BoxCollider>();
|
||||||
|
if(UnityEngine.SceneManagement.SceneManager.GetActiveScene().name== "05_LiveScene")
|
||||||
|
{
|
||||||
|
boxCollider.enabled = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 初始化电能表状态(默认是装好的状态不用设置)
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="isIntsalledState"></param>
|
||||||
|
public void Init(bool isIntsalledState)
|
||||||
|
{
|
||||||
|
if(!isIntsalledState)
|
||||||
|
{
|
||||||
|
Debug.Log("电能表设置为拆下状态");
|
||||||
|
//盖子拆除
|
||||||
|
cover.isOpen = true;
|
||||||
|
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_Right.isInstall = false;
|
||||||
|
cover.cover_screw_Right.transform.localPosition = new Vector3(-0.06129074f, -0.03405334f, -0.1012321f);
|
||||||
|
//左封印被剪开
|
||||||
|
cover.cover_seal_Left.isCut = true;
|
||||||
|
cover.cover_seal_Left.gameObject.SetActive(false);
|
||||||
|
//右封印被剪开
|
||||||
|
cover.cover_seal_Right.isCut = true;
|
||||||
|
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_right.isInstall = false;
|
||||||
|
fix_screw_right.transform.localPosition = new Vector3(-0.06737137f, 0.03107117f, -0.1094047f);
|
||||||
|
//接线螺丝全部拧下
|
||||||
|
jieXian_screws.ForEach(a =>
|
||||||
|
{
|
||||||
|
a.isInstall = false;
|
||||||
|
a.transform.localPosition = new Vector3(a.transform.localPosition.x, 0.005695801f, a.transform.localPosition.z);
|
||||||
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 拆下电能表
|
/// 拆下电能表
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public void Remove()
|
public void Remove()
|
||||||
{
|
|
||||||
if (!isRemove)
|
|
||||||
{
|
{
|
||||||
//拆下电能表
|
//拆下电能表
|
||||||
if (!fix_screw_left.isInstall && !fix_screw_right.isInstall)
|
if (!fix_screw_left.isInstall && !fix_screw_right.isInstall)
|
||||||
{
|
{
|
||||||
isRemove = true;
|
SiteManager.instance.measuringCabinet.meteringDevice = null;
|
||||||
Debug.Log("电能表已拆除");
|
Debug.Log("电能表已拆除");
|
||||||
transform.DOLocalMove(transform.localPosition - new Vector3(0, 0.2f, 0.2f), 2).OnComplete(() =>
|
transform.DOLocalMove(transform.localPosition - new Vector3(0, 0.2f, 0.2f), 2).OnComplete(() =>
|
||||||
{
|
{
|
||||||
|
@ -67,23 +100,23 @@ public class Device_DirectAccessElectricEnergyMeteringDevice : Device_Base
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 安装电能表
|
/// 安装电能表
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public void Add()
|
public void Add()
|
||||||
{
|
{
|
||||||
if(isRemove)
|
transform.parent = SiteManager.instance.measuringCabinet.transform;
|
||||||
|
//默认是拆除的状态
|
||||||
|
Init(false);
|
||||||
|
transform.DOLocalMove(new Vector3(0.1469002f, -0.1793365f, 0.5191498f), 2).OnStart(() =>
|
||||||
{
|
{
|
||||||
gameObject.SetActive(true);
|
transform.localEulerAngles = Vector3.zero;
|
||||||
transform.DOLocalMove(transform.localPosition + new Vector3(0, 0.2f, 0.2f), 2).OnComplete(() =>
|
}).OnComplete(() =>
|
||||||
{
|
{
|
||||||
isRemove = false;
|
SiteManager.instance.measuringCabinet.meteringDevice = this;
|
||||||
|
LiveSceneManager.Instance.currentTool = null;
|
||||||
Debug.Log("电能表已安装");
|
Debug.Log("电能表已安装");
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,3 +1,4 @@
|
||||||
|
using System;
|
||||||
using System.Collections;
|
using System.Collections;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
|
@ -6,6 +7,19 @@ public class Device_Switch : Device_Base
|
||||||
{
|
{
|
||||||
public bool isOpen;
|
public bool isOpen;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 操作开关事件
|
||||||
|
/// </summary>
|
||||||
|
private Action<bool> actionBack;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 添加开关操作回调
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="actionBack"></param>
|
||||||
|
public void AddAction(Action<bool> actionBack)
|
||||||
|
{
|
||||||
|
this.actionBack= actionBack;
|
||||||
|
}
|
||||||
|
|
||||||
private void OnMouseDown()
|
private void OnMouseDown()
|
||||||
{
|
{
|
||||||
|
@ -19,5 +33,11 @@ public class Device_Switch : Device_Base
|
||||||
isOpen = true;
|
isOpen = true;
|
||||||
transform.localEulerAngles = new Vector3(0, 0, 0);
|
transform.localEulerAngles = new Vector3(0, 0, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//调用自定义事件
|
||||||
|
if (actionBack != null)
|
||||||
|
{
|
||||||
|
actionBack.Invoke(isOpen);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,5 +1,7 @@
|
||||||
using System.Collections;
|
using System.Collections;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
using Unity.VisualScripting;
|
||||||
|
using Unity.VisualScripting.Antlr3.Runtime;
|
||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
@ -8,7 +10,7 @@ using UnityEngine;
|
||||||
public class Device_MeasuringCabinet : Device_Base
|
public class Device_MeasuringCabinet : Device_Base
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 直接接入式电能计量装置
|
/// 当前机柜中安装的三相四线电能表
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public Device_DirectAccessElectricEnergyMeteringDevice meteringDevice;
|
public Device_DirectAccessElectricEnergyMeteringDevice meteringDevice;
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
@ -23,4 +25,86 @@ public class Device_MeasuringCabinet : Device_Base
|
||||||
/// ½øµç¿ª¹Ø
|
/// ½øµç¿ª¹Ø
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public Device_Switch inSwitch;
|
public Device_Switch inSwitch;
|
||||||
|
/// <summary>
|
||||||
|
/// 电能表接线
|
||||||
|
/// </summary>
|
||||||
|
public List<Tool_Line> jieXian_screws;
|
||||||
|
|
||||||
|
private void Awake()
|
||||||
|
{
|
||||||
|
//添加开关切换回调
|
||||||
|
inSwitch.AddAction(isOpen =>
|
||||||
|
{
|
||||||
|
//刷新带电状态
|
||||||
|
CheckHasElectricity();
|
||||||
|
});
|
||||||
|
|
||||||
|
//添加螺丝拆装回调
|
||||||
|
meteringDevice.jieXian_screws.ForEach(screw =>
|
||||||
|
{
|
||||||
|
screw.AddAction(isinstalled =>
|
||||||
|
{
|
||||||
|
//刷新带电状态
|
||||||
|
CheckHasElectricity();
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 清空接线的螺丝参数
|
||||||
|
/// </summary>
|
||||||
|
public void ClearLineScrew()
|
||||||
|
{
|
||||||
|
Debug.Log("清除接线关联的螺丝");
|
||||||
|
jieXian_screws.ForEach(a =>
|
||||||
|
{
|
||||||
|
a.screws.Clear();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
/// <summary>
|
||||||
|
/// 设置接线的螺丝参数
|
||||||
|
/// </summary>
|
||||||
|
public void SetLineScrew()
|
||||||
|
{
|
||||||
|
Debug.Log("接线重新关联螺丝");
|
||||||
|
jieXian_screws.ForEach(a =>
|
||||||
|
{
|
||||||
|
a.screws = meteringDevice.jieXian_screws.FindAll(b => b.gameObject.name.StartsWith(a.gameObject.name));
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 刷新电能表螺丝带电状态
|
||||||
|
/// </summary>
|
||||||
|
private void CheckHasElectricity()
|
||||||
|
{
|
||||||
|
Debug.Log("带电状态刷新");
|
||||||
|
//进线螺丝是否带电
|
||||||
|
jieXian_screws.ForEach(a =>
|
||||||
|
{
|
||||||
|
if (!inSwitch.isOpen)
|
||||||
|
{
|
||||||
|
//开关关闭不带电
|
||||||
|
a.screws.ForEach(b => b.hasElectricity = false);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
//开关打开--线接上--螺丝拧上带电
|
||||||
|
if (!a.isConnected)
|
||||||
|
{
|
||||||
|
a.screws.ForEach(b => b.hasElectricity = false);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
a.screws.ForEach(b =>
|
||||||
|
{
|
||||||
|
//安装了则带电
|
||||||
|
b.hasElectricity = b.isInstall;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,3 +1,4 @@
|
||||||
|
using Cysharp.Threading.Tasks.Triggers;
|
||||||
using System.Collections;
|
using System.Collections;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
|
@ -7,6 +8,8 @@ using UnityEngine;
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public class SiteManager : MonoBehaviour
|
public class SiteManager : MonoBehaviour
|
||||||
{
|
{
|
||||||
|
|
||||||
|
public static SiteManager instance;
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 机柜
|
/// 机柜
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
@ -15,24 +18,29 @@ public class SiteManager : MonoBehaviour
|
||||||
/// 电能表碰撞
|
/// 电能表碰撞
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public BoxCollider dianCollider;
|
public BoxCollider dianCollider;
|
||||||
|
private void Awake()
|
||||||
|
{
|
||||||
|
instance = this;
|
||||||
|
}
|
||||||
|
|
||||||
private void Update()
|
private void Update()
|
||||||
{
|
{
|
||||||
//使能电能表碰撞
|
//使能电能表碰撞
|
||||||
if (measuringCabinet.meteringDevice.isRemove)
|
if (measuringCabinet.meteringDevice == null)
|
||||||
{
|
{
|
||||||
dianCollider.enabled = true;
|
dianCollider.enabled = true;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (!measuringCabinet.meteringDevice.fix_screw_left.isInstall && !measuringCabinet.meteringDevice.fix_screw_right.isInstall)
|
//电能表固定螺丝拆掉了,线拆掉了
|
||||||
|
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;
|
dianCollider.enabled = false;
|
||||||
}
|
}
|
||||||
else
|
|
||||||
{
|
|
||||||
dianCollider.enabled = true;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Input.GetMouseButtonDown(0))
|
if (Input.GetMouseButtonDown(0))
|
||||||
|
@ -41,14 +49,23 @@ public class SiteManager : MonoBehaviour
|
||||||
{
|
{
|
||||||
if(hit.collider== dianCollider)
|
if(hit.collider== dianCollider)
|
||||||
{
|
{
|
||||||
if (measuringCabinet.meteringDevice.isRemove)
|
if (measuringCabinet.meteringDevice==null)
|
||||||
{
|
{
|
||||||
//²ðÏÂ
|
//安装电能表
|
||||||
measuringCabinet.meteringDevice.Remove();
|
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
|
else
|
||||||
{
|
{
|
||||||
//°²×°
|
//拆下电能表
|
||||||
|
measuringCabinet.meteringDevice.Remove();
|
||||||
|
//情况接线关联螺丝
|
||||||
|
measuringCabinet.ClearLineScrew();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -23,6 +23,12 @@ public class Tool_Line: Tool_Base
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public List<Tool_Screw> screws=new List<Tool_Screw>();
|
public List<Tool_Screw> screws=new List<Tool_Screw>();
|
||||||
|
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 安装状态时Y的local值
|
||||||
|
/// </summary>
|
||||||
|
public float InstallPosY;
|
||||||
|
|
||||||
protected override void OnAwake()
|
protected override void OnAwake()
|
||||||
{
|
{
|
||||||
base.OnAwake();
|
base.OnAwake();
|
||||||
|
@ -35,9 +41,11 @@ public class Tool_Line: Tool_Base
|
||||||
{
|
{
|
||||||
//取下接线
|
//取下接线
|
||||||
if(screws.TrueForAll(a=>!a.isInstall))
|
if(screws.TrueForAll(a=>!a.isInstall))
|
||||||
|
{
|
||||||
|
transform.DOLocalMoveY(InstallPosY - 2, 1).OnComplete(()=>
|
||||||
{
|
{
|
||||||
isConnected = false;
|
isConnected = false;
|
||||||
transform.DOLocalMoveY(transform.localPosition.y - 2, 1);
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -45,7 +53,7 @@ public class Tool_Line: Tool_Base
|
||||||
//装上接线
|
//装上接线
|
||||||
if (screws.TrueForAll(a => !a.isInstall))
|
if (screws.TrueForAll(a => !a.isInstall))
|
||||||
{
|
{
|
||||||
transform.DOLocalMoveY(transform.localPosition.y + 2, 1).OnComplete(() =>
|
transform.DOLocalMoveY(InstallPosY, 1).OnComplete(() =>
|
||||||
{
|
{
|
||||||
isConnected = true;
|
isConnected = true;
|
||||||
});
|
});
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
using DG.Tweening;
|
using DG.Tweening;
|
||||||
|
using System;
|
||||||
using System.Collections;
|
using System.Collections;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
|
@ -32,15 +33,15 @@ public class Tool_Screw : Tool_Base
|
||||||
private bool isMoving;
|
private bool isMoving;
|
||||||
|
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 安装状态时Y的local值
|
||||||
|
/// </summary>
|
||||||
|
public float initPostionY;
|
||||||
|
|
||||||
///// <summary>
|
/// <summary>
|
||||||
///// 螺丝拧紧时的位置
|
/// 螺丝拆装事件回调
|
||||||
///// </summary>
|
/// </summary>
|
||||||
//private float localYInstallValue;
|
private Action<bool> installAction;
|
||||||
///// <summary>
|
|
||||||
///// 螺丝拧松时的位置
|
|
||||||
///// </summary>
|
|
||||||
//private float localYUnInstallValue;
|
|
||||||
|
|
||||||
|
|
||||||
protected override void OnAwake()
|
protected override void OnAwake()
|
||||||
|
@ -49,6 +50,10 @@ public class Tool_Screw : Tool_Base
|
||||||
id = gameObject.name;
|
id = gameObject.name;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void AddAction(Action<bool> action)
|
||||||
|
{
|
||||||
|
this.installAction=action;
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 被拧紧
|
/// 被拧紧
|
||||||
|
@ -64,7 +69,7 @@ public class Tool_Screw : Tool_Base
|
||||||
screwdriver.transform.position = installPos.position;
|
screwdriver.transform.position = installPos.position;
|
||||||
screwdriver.transform.localEulerAngles = installPos.localEulerAngles;
|
screwdriver.transform.localEulerAngles = installPos.localEulerAngles;
|
||||||
//动画
|
//动画
|
||||||
transform.DOLocalMoveY(transform.localPosition.y + 0.02f, 1)
|
transform.DOLocalMoveY(initPostionY, 1)
|
||||||
.OnUpdate(() =>
|
.OnUpdate(() =>
|
||||||
{
|
{
|
||||||
transform.RotateAroundLocal(Vector3.up, 1);
|
transform.RotateAroundLocal(Vector3.up, 1);
|
||||||
|
@ -76,6 +81,7 @@ public class Tool_Screw : Tool_Base
|
||||||
Debug.Log("螺丝已拧紧");
|
Debug.Log("螺丝已拧紧");
|
||||||
isInstall = true;
|
isInstall = true;
|
||||||
isMoving = false;
|
isMoving = false;
|
||||||
|
installAction?.Invoke(true);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -94,7 +100,7 @@ public class Tool_Screw : Tool_Base
|
||||||
screwdriver.transform.position = installPos.position;
|
screwdriver.transform.position = installPos.position;
|
||||||
screwdriver.transform.localEulerAngles = installPos.localEulerAngles;
|
screwdriver.transform.localEulerAngles = installPos.localEulerAngles;
|
||||||
//动画
|
//动画
|
||||||
transform.DOLocalMoveY(transform.localPosition.y - 0.02f, 1)
|
transform.DOLocalMoveY(initPostionY - 0.02f, 1)
|
||||||
.OnUpdate(() =>
|
.OnUpdate(() =>
|
||||||
{
|
{
|
||||||
transform.RotateAroundLocal(Vector3.up, 1);
|
transform.RotateAroundLocal(Vector3.up, 1);
|
||||||
|
@ -106,6 +112,7 @@ public class Tool_Screw : Tool_Base
|
||||||
Debug.Log("螺丝已拧松");
|
Debug.Log("螺丝已拧松");
|
||||||
isInstall = false;
|
isInstall = false;
|
||||||
isMoving = false;
|
isMoving = false;
|
||||||
|
installAction?.Invoke(false);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -44,13 +44,13 @@ public class Tool_Screwdriver : Tool_Base
|
||||||
Tool_Screw ts = hit.transform.GetComponent<Tool_Screw>();
|
Tool_Screw ts = hit.transform.GetComponent<Tool_Screw>();
|
||||||
if (ts != null)
|
if (ts != null)
|
||||||
{
|
{
|
||||||
if(ts.id== "电能表盖子固定螺丝1" && !Device_DirectAccessElectricEnergyMeteringDevice.instance.cover.cover_seal_Left.isCut)
|
if(ts.id== "电能表盖子固定螺丝1" && !SiteManager.instance.measuringCabinet.meteringDevice.cover.cover_seal_Left.isCut)
|
||||||
{
|
{
|
||||||
Debug.Log("·âӡδ¼ô¶Ï");
|
Debug.Log("·âӡδ¼ô¶Ï");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ts.id == "电能表盖子固定螺丝2" && !Device_DirectAccessElectricEnergyMeteringDevice.instance.cover.cover_seal_Right.isCut)
|
if (ts.id == "电能表盖子固定螺丝2" && !SiteManager.instance.measuringCabinet.meteringDevice.cover.cover_seal_Right.isCut)
|
||||||
{
|
{
|
||||||
Debug.Log("·âӡδ¼ô¶Ï");
|
Debug.Log("·âӡδ¼ô¶Ï");
|
||||||
return;
|
return;
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
using System.Collections;
|
using System.Collections;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
|
using static Unity.Burst.Intrinsics.X86.Avx;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 验电笔
|
/// 验电笔
|
||||||
|
@ -42,7 +43,7 @@ public class Tool_TestPen : Tool_Base
|
||||||
|
|
||||||
if(isFlicker)
|
if(isFlicker)
|
||||||
{
|
{
|
||||||
time += Time.deltaTime;
|
time += Time.deltaTime*3;
|
||||||
if (time < 1)
|
if (time < 1)
|
||||||
{
|
{
|
||||||
screem.materials[0].color = Color.red;
|
screem.materials[0].color = Color.red;
|
||||||
|
@ -77,10 +78,12 @@ public class Tool_TestPen : Tool_Base
|
||||||
var tmp = ((Device_CabinetDoor)device_base);
|
var tmp = ((Device_CabinetDoor)device_base);
|
||||||
//位置移动
|
//位置移动
|
||||||
transform.position = tmp.testPosAndRot.position;
|
transform.position = tmp.testPosAndRot.position;
|
||||||
transform.eulerAngles = tmp.testPosAndRot.eulerAngles;
|
transform.localEulerAngles = tmp.testPosAndRot.localEulerAngles;
|
||||||
Debug.Log("计量柜_柜门 已验电");
|
Debug.Log("计量柜_柜门 已验电");
|
||||||
isFlicker = tmp.hasElectricity;
|
isFlicker = tmp.hasElectricity;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
screem.materials[0].color = isFlicker ? Color.red : Color.white;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
@ -94,10 +97,12 @@ public class Tool_TestPen : Tool_Base
|
||||||
var tmp = ((Tool_Screw)tool_base);
|
var tmp = ((Tool_Screw)tool_base);
|
||||||
//位置移动
|
//位置移动
|
||||||
transform.position = tmp.installPos.position;
|
transform.position = tmp.installPos.position;
|
||||||
transform.eulerAngles = tmp.installPos.eulerAngles;
|
transform.localEulerAngles = tmp.installPos.localEulerAngles;
|
||||||
Debug.Log("螺丝 已验电");
|
Debug.Log("螺丝 已验电");
|
||||||
isFlicker = tmp.hasElectricity;
|
isFlicker = tmp.hasElectricity;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
screem.materials[0].color = isFlicker ? Color.red : Color.white;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -32,14 +32,14 @@ public class Tool_WireStripper : Tool_Base
|
||||||
//´ò¿ª
|
//´ò¿ª
|
||||||
while (renderer.GetBlendShapeWeight(0) < 100)
|
while (renderer.GetBlendShapeWeight(0) < 100)
|
||||||
{
|
{
|
||||||
vlaue += (Time.deltaTime * 100);
|
vlaue += (Time.deltaTime * 200);
|
||||||
renderer.SetBlendShapeWeight(0, vlaue);
|
renderer.SetBlendShapeWeight(0, vlaue);
|
||||||
yield return null;
|
yield return null;
|
||||||
}
|
}
|
||||||
//¹Ø±Õ
|
//¹Ø±Õ
|
||||||
while (renderer.GetBlendShapeWeight(0) > 0)
|
while (renderer.GetBlendShapeWeight(0) > 0)
|
||||||
{
|
{
|
||||||
vlaue -= (Time.deltaTime * 100);
|
vlaue -= (Time.deltaTime * 200);
|
||||||
renderer.SetBlendShapeWeight(0, vlaue);
|
renderer.SetBlendShapeWeight(0, vlaue);
|
||||||
yield return null;
|
yield return null;
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,6 +6,7 @@ public class LiveSceneManager : SingletonMono<LiveSceneManager>
|
||||||
{
|
{
|
||||||
[HideInInspector]
|
[HideInInspector]
|
||||||
public FirstPersonController firstPersonController;
|
public FirstPersonController firstPersonController;
|
||||||
|
public GameObject currentTool;
|
||||||
protected override void Awake()
|
protected override void Awake()
|
||||||
{
|
{
|
||||||
base.Awake();
|
base.Awake();
|
||||||
|
|
Loading…
Reference in New Issue