This commit is contained in:
YangHua 2024-09-02 13:47:08 +08:00
commit 980e89a2b0
1 changed files with 29 additions and 7 deletions

View File

@ -14,6 +14,10 @@ public class Tool_TestPen : Tool_Base
/// </summary> /// </summary>
private bool isFlicker; private bool isFlicker;
private float time; private float time;
/// <summary>
/// ÊÇ·ñ»Øµ½ÊÖÀï
/// </summary>
private float backToHandTime;
private void Update() private void Update()
{ {
@ -21,7 +25,7 @@ public class Tool_TestPen : Tool_Base
return; return;
if (Input.GetMouseButtonDown(0)) if (Input.GetMouseButtonDown(0) && !isMoving)
{ {
//点击螺丝验电 //点击螺丝验电
Ray tmpray = Camera.main.ScreenPointToRay(Input.mousePosition); Ray tmpray = Camera.main.ScreenPointToRay(Input.mousePosition);
@ -62,6 +66,19 @@ public class Tool_TestPen : Tool_Base
time = 0; time = 0;
} }
} }
//ÊÕ»ØÊÖÖÐ
if(backToHandTime>0)
{
backToHandTime -= Time.deltaTime;
if (backToHandTime <= 0)
{
if (!isMoving)
{
base.ReBackHead();
}
}
}
} }
/// <summary> /// <summary>
/// 执行验电操作 /// 执行验电操作
@ -73,6 +90,8 @@ public class Tool_TestPen : Tool_Base
{ {
if (device_base.deviceType == DeviceType._插座) if (device_base.deviceType == DeviceType._插座)
{ {
isMoving = true;
backToHandTime = 3f;
var tmp = ((Device_Socket)device_base); var tmp = ((Device_Socket)device_base);
//位置移动 //位置移动
base.hand_out_action?.Invoke(); base.hand_out_action?.Invoke();
@ -84,14 +103,15 @@ public class Tool_TestPen : Tool_Base
isFlicker = tmp.hasElectricity; isFlicker = tmp.hasElectricity;
screem.materials[0].color = isFlicker ? Color.red : Color.white; screem.materials[0].color = isFlicker ? Color.red : Color.white;
int index = (triggerAction == null ? 0 : triggerAction.Invoke($"{triggerName}+{device_base.triggerName}", true)); 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}"); base.CallScoreAction(null, $"{triggerName}+{device_base.triggerName}");
}); });
} }
else if (device_base.deviceType == DeviceType._柜门) else if (device_base.deviceType == DeviceType._柜门)
{ {
var tmp = ((Device_CabinetDoor)device_base); var tmp = ((Device_CabinetDoor)device_base);
backToHandTime = 3f;
//位置移动 //位置移动
base.hand_out_action?.Invoke(); base.hand_out_action?.Invoke();
transform.parent = null; transform.parent = null;
@ -102,7 +122,8 @@ public class Tool_TestPen : Tool_Base
isFlicker = tmp.hasElectricity; isFlicker = tmp.hasElectricity;
screem.materials[0].color = isFlicker ? Color.red : Color.white; screem.materials[0].color = isFlicker ? Color.red : Color.white;
int index = (triggerAction == null ? 0 : triggerAction.Invoke($"{triggerName}+{device_base.triggerName}", true)); 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}"); base.CallScoreAction(null, $"{triggerName}+{device_base.triggerName}");
}); });
} }
@ -119,6 +140,8 @@ public class Tool_TestPen : Tool_Base
{ {
if (tool_base.toolType == ToolType.) if (tool_base.toolType == ToolType.)
{ {
isMoving = true;
backToHandTime = 3f;
var tmp = ((Tool_Screw)tool_base); var tmp = ((Tool_Screw)tool_base);
base.hand_out_action?.Invoke(); base.hand_out_action?.Invoke();
//位置移动 //位置移动
@ -129,12 +152,11 @@ public class Tool_TestPen : Tool_Base
Debug.Log("螺丝 已验电"); Debug.Log("螺丝 已验电");
isFlicker = tmp.hasElectricity; isFlicker = tmp.hasElectricity;
screem.materials[0].color = isFlicker ? Color.red : Color.white; 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}"); base.CallScoreAction(null, $"{triggerName}+{tool_base.triggerName}");
}); });
} }
} }
} }
} }