验电笔回手里

This commit is contained in:
陈向学 2024-09-02 13:19:38 +08:00
parent f565e6554b
commit 5d752987aa
1 changed files with 29 additions and 7 deletions

View File

@ -14,6 +14,10 @@ public class Tool_TestPen : Tool_Base
/// </summary>
private bool isFlicker;
private float time;
/// <summary>
/// ÊÇ·ñ»Øµ½ÊÖÀï
/// </summary>
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();
}
}
}
}
/// <summary>
/// 执行验电操作
@ -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}");
});
}
}
}
}