This commit is contained in:
陈向学 2024-08-29 18:49:53 +08:00
parent f8bf4bd5a7
commit b968dadcaa
3 changed files with 38 additions and 35 deletions

View File

@ -37,12 +37,13 @@ public class Device_Cover : Device_Base
if (!isOpen) if (!isOpen)
{ {
//螺丝都拧松才能拆盖子
if (!cover_screw_Left.isInstall && !cover_screw_Right.isInstall) if (!cover_screw_Left.isInstall && !cover_screw_Right.isInstall)
{ {
Open(); Open();
} }
} }
else if (isOpen) else
{ {
Close(); Close();
} }
@ -53,6 +54,9 @@ public class Device_Cover : Device_Base
/// 打开盖子 /// 打开盖子
/// </summary> /// </summary>
public void Open() public void Open()
{
//盖子螺丝不在动才能动盖子
if (!cover_screw_Left.isMoving && !cover_screw_Right.isMoving)
{ {
Debug.Log("打开盖子"); Debug.Log("打开盖子");
isOpen = true; isOpen = true;
@ -67,11 +71,15 @@ public class Device_Cover : Device_Base
int result = (triggerAction == null ? 0 : triggerAction.Invoke(triggerName, true)); int result = (triggerAction == null ? 0 : triggerAction.Invoke(triggerName, true));
}); });
} }
}
/// <summary> /// <summary>
/// 盖上盖子 /// 盖上盖子
/// </summary> /// </summary>
public void Close() public void Close()
{
//盖子螺丝不在动才能动盖子
if (!cover_screw_Left.isMoving && !cover_screw_Right.isMoving)
{ {
Debug.Log("盖上盖子"); Debug.Log("盖上盖子");
isOpen = false; isOpen = false;
@ -86,4 +94,5 @@ public class Device_Cover : Device_Base
int result = (triggerAction == null ? 0 : triggerAction.Invoke(triggerName, true)); int result = (triggerAction == null ? 0 : triggerAction.Invoke(triggerName, true));
}); });
} }
}
} }

View File

@ -27,12 +27,6 @@ public class Tool_Screw : Tool_Base
/// </summary> /// </summary>
public bool hasElectricity; public bool hasElectricity;
/// <summary>
/// 正在移动不能操作
/// </summary>
private bool isMoving;
/// <summary> /// <summary>
/// 安装状态时Y的local值 /// 安装状态时Y的local值
/// </summary> /// </summary>
@ -61,9 +55,10 @@ public class Tool_Screw : Tool_Base
/// <param name="screwdriver"></param> /// <param name="screwdriver"></param>
public void BeInstalled(Tool_Screwdriver screwdriver) public void BeInstalled(Tool_Screwdriver screwdriver)
{ {
if (!isMoving) if (!isMoving && !screwdriver.isMoving)
{ {
isMoving = true; isMoving = true;
screwdriver.isMoving = true;
Debug.Log("开始拧紧螺丝"); Debug.Log("开始拧紧螺丝");
//设置螺丝刀初始位置 //设置螺丝刀初始位置
screwdriver.transform.parent = null; screwdriver.transform.parent = null;
@ -83,9 +78,9 @@ public class Tool_Screw : Tool_Base
Debug.Log("螺丝已拧紧"); Debug.Log("螺丝已拧紧");
isInstall = true; isInstall = true;
isMoving = false; isMoving = false;
screwdriver.isMoving = false;
installAction?.Invoke(true); installAction?.Invoke(true);
screwdriver.ReBackHead(); screwdriver.ReBackHead();
screwdriver.isMoving = false;
CallScoreAction(true); CallScoreAction(true);
}); });
}); });
@ -98,9 +93,10 @@ public class Tool_Screw : Tool_Base
/// <param name="screwdriver"></param> /// <param name="screwdriver"></param>
public void BeUnInstalled(Tool_Screwdriver screwdriver) public void BeUnInstalled(Tool_Screwdriver screwdriver)
{ {
if (!isMoving) if (!isMoving && !screwdriver.isMoving)
{ {
isMoving = true; isMoving = true;
screwdriver.isMoving = true;
Debug.Log("开始卸螺丝"); Debug.Log("开始卸螺丝");
//设置螺丝刀初始位置 //设置螺丝刀初始位置
screwdriver.transform.parent = null; screwdriver.transform.parent = null;
@ -120,9 +116,9 @@ public class Tool_Screw : Tool_Base
Debug.Log("螺丝已拧松"); Debug.Log("螺丝已拧松");
isInstall = false; isInstall = false;
isMoving = false; isMoving = false;
screwdriver.isMoving = false;
installAction?.Invoke(false); installAction?.Invoke(false);
screwdriver.ReBackHead(); screwdriver.ReBackHead();
screwdriver.isMoving = false;
CallScoreAction(false); CallScoreAction(false);
}); });
}); });

View File

@ -16,7 +16,6 @@ public class Tool_Screwdriver : Tool_Base
{ {
if (!screw.isInstall) if (!screw.isInstall)
{ {
isMoving = true;
screw.BeInstalled(this); screw.BeInstalled(this);
} }
} }
@ -29,7 +28,6 @@ public class Tool_Screwdriver : Tool_Base
{ {
if (screw.isInstall) if (screw.isInstall)
{ {
isMoving = true;
screw.BeUnInstalled(this); screw.BeUnInstalled(this);
} }
} }