diff --git a/Assets/Scripts/CXX/Tools/Tool_TestPen.cs b/Assets/Scripts/CXX/Tools/Tool_TestPen.cs index 648f9dd..c94355e 100644 --- a/Assets/Scripts/CXX/Tools/Tool_TestPen.cs +++ b/Assets/Scripts/CXX/Tools/Tool_TestPen.cs @@ -14,6 +14,10 @@ public class Tool_TestPen : Tool_Base /// private bool isFlicker; private float time; + /// + /// 是否回到手里 + /// + private float backToHandTime; private void Update() { @@ -21,7 +25,7 @@ public class Tool_TestPen : Tool_Base return; - if (Input.GetMouseButtonDown(0)) + if (Input.GetMouseButtonDown(0) && !isMoving) { //点击螺丝验电 Ray tmpray = Camera.main.ScreenPointToRay(Input.mousePosition); @@ -62,6 +66,19 @@ public class Tool_TestPen : Tool_Base time = 0; } } + + //收回手中 + if(backToHandTime>0) + { + backToHandTime -= Time.deltaTime; + if (backToHandTime <= 0) + { + if (!isMoving) + { + base.ReBackHead(); + } + } + } } /// /// 执行验电操作 @@ -73,6 +90,8 @@ public class Tool_TestPen : Tool_Base { if (device_base.deviceType == DeviceType.计量柜_插座) { + isMoving = true; + backToHandTime = 3f; var tmp = ((Device_Socket)device_base); //位置移动 base.hand_out_action?.Invoke(); @@ -84,14 +103,15 @@ public class Tool_TestPen : Tool_Base isFlicker = tmp.hasElectricity; screem.materials[0].color = isFlicker ? Color.red : Color.white; int index = (triggerAction == null ? 0 : triggerAction.Invoke($"{triggerName}+{device_base.triggerName}", true)); - base.hand_back_action?.Invoke(); + isMoving = false; + backToHandTime = 3f; base.CallScoreAction(null, $"{triggerName}+{device_base.triggerName}"); }); } else if (device_base.deviceType == DeviceType.计量柜_柜门) { var tmp = ((Device_CabinetDoor)device_base); - + backToHandTime = 3f; //位置移动 base.hand_out_action?.Invoke(); transform.parent = null; @@ -102,7 +122,8 @@ public class Tool_TestPen : Tool_Base isFlicker = tmp.hasElectricity; screem.materials[0].color = isFlicker ? Color.red : Color.white; int index = (triggerAction == null ? 0 : triggerAction.Invoke($"{triggerName}+{device_base.triggerName}", true)); - base.hand_back_action?.Invoke(); + isMoving = false; + backToHandTime = 3f; base.CallScoreAction(null, $"{triggerName}+{device_base.triggerName}"); }); } @@ -119,6 +140,8 @@ public class Tool_TestPen : Tool_Base { if (tool_base.toolType == ToolType.螺丝) { + isMoving = true; + backToHandTime = 3f; var tmp = ((Tool_Screw)tool_base); base.hand_out_action?.Invoke(); //位置移动 @@ -129,12 +152,11 @@ public class Tool_TestPen : Tool_Base Debug.Log("螺丝 已验电"); isFlicker = tmp.hasElectricity; screem.materials[0].color = isFlicker ? Color.red : Color.white; - base.hand_back_action?.Invoke(); + isMoving = false; + backToHandTime = 3f; base.CallScoreAction(null, $"{triggerName}+{tool_base.triggerName}"); }); } } } - - }