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

View File

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

View File

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