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();
}
@ -54,18 +55,22 @@ public class Device_Cover : Device_Base
/// </summary>
public void Open()
{
Debug.Log("´ò¿ª¸Ç×Ó");
isOpen = true;
//盖子螺丝不在动才能动盖子
if (!cover_screw_Left.isMoving && !cover_screw_Right.isMoving)
{
Debug.Log("打开盖子");
isOpen = true;
Transform parent = cover_screw_Left.transform.parent;
cover_screw_Left.transform.parent = transform;
cover_screw_Right.transform.parent = transform;
transform.DOLocalMove(new Vector3(transform.localPosition.x, -0.1388763f, -0.2485413f), 2).OnComplete(() =>
{
cover_screw_Left.transform.parent = parent;
cover_screw_Right.transform.parent = parent;
int result = (triggerAction == null ? 0 : triggerAction.Invoke(triggerName, true));
});
Transform parent = cover_screw_Left.transform.parent;
cover_screw_Left.transform.parent = transform;
cover_screw_Right.transform.parent = transform;
transform.DOLocalMove(new Vector3(transform.localPosition.x, -0.1388763f, -0.2485413f), 2).OnComplete(() =>
{
cover_screw_Left.transform.parent = parent;
cover_screw_Right.transform.parent = parent;
int result = (triggerAction == null ? 0 : triggerAction.Invoke(triggerName, true));
});
}
}
/// <summary>
@ -73,17 +78,21 @@ public class Device_Cover : Device_Base
/// </summary>
public void Close()
{
Debug.Log("¸ÇÉϸÇ×Ó");
isOpen = false;
//盖子螺丝不在动才能动盖子
if (!cover_screw_Left.isMoving && !cover_screw_Right.isMoving)
{
Debug.Log("盖上盖子");
isOpen = false;
Transform parent = cover_screw_Left.transform.parent;
cover_screw_Left.transform.parent = transform;
cover_screw_Right.transform.parent = transform;
transform.DOLocalMove(new Vector3(transform.localPosition.x, 0.01112366f, -0.09854126f), 2).OnComplete(() =>
{
cover_screw_Left.transform.parent = parent;
cover_screw_Right.transform.parent = parent;
int result = (triggerAction == null ? 0 : triggerAction.Invoke(triggerName, true));
});
Transform parent = cover_screw_Left.transform.parent;
cover_screw_Left.transform.parent = transform;
cover_screw_Right.transform.parent = transform;
transform.DOLocalMove(new Vector3(transform.localPosition.x, 0.01112366f, -0.09854126f), 2).OnComplete(() =>
{
cover_screw_Left.transform.parent = parent;
cover_screw_Right.transform.parent = parent;
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);
}
}