Compare commits

..

No commits in common. "9850407a1103ebb46377726048f8acefbc3f8e03" and "69a8bf6b684172f675e6d562da9fd13eb6190a19" have entirely different histories.

3 changed files with 35 additions and 38 deletions

View File

@ -37,13 +37,12 @@ public class Device_Cover : Device_Base
if (!isOpen)
{
//螺丝都拧松才能拆盖子
if (!cover_screw_Left.isInstall && !cover_screw_Right.isInstall)
{
Open();
}
}
else
else if (isOpen)
{
Close();
}
@ -55,22 +54,18 @@ public class Device_Cover : Device_Base
/// </summary>
public void Open()
{
//盖子螺丝不在动才能动盖子
if (!cover_screw_Left.isMoving && !cover_screw_Right.isMoving)
{
Debug.Log("打开盖子");
isOpen = true;
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>
@ -78,21 +73,17 @@ public class Device_Cover : Device_Base
/// </summary>
public void Close()
{
//盖子螺丝不在动才能动盖子
if (!cover_screw_Left.isMoving && !cover_screw_Right.isMoving)
{
Debug.Log("盖上盖子");
isOpen = false;
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,6 +27,12 @@ public class Tool_Screw : Tool_Base
/// </summary>
public bool hasElectricity;
/// <summary>
/// 正在移动不能操作
/// </summary>
private bool isMoving;
/// <summary>
/// 安装状态时Y的local值
/// </summary>
@ -55,10 +61,9 @@ public class Tool_Screw : Tool_Base
/// <param name="screwdriver"></param>
public void BeInstalled(Tool_Screwdriver screwdriver)
{
if (!isMoving && !screwdriver.isMoving)
if (!isMoving)
{
isMoving = true;
screwdriver.isMoving = true;
Debug.Log("开始拧紧螺丝");
//设置螺丝刀初始位置
screwdriver.transform.parent = null;
@ -78,9 +83,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);
});
});
@ -93,10 +98,9 @@ public class Tool_Screw : Tool_Base
/// <param name="screwdriver"></param>
public void BeUnInstalled(Tool_Screwdriver screwdriver)
{
if (!isMoving && !screwdriver.isMoving)
if (!isMoving)
{
isMoving = true;
screwdriver.isMoving = true;
Debug.Log("开始卸螺丝");
//设置螺丝刀初始位置
screwdriver.transform.parent = null;
@ -116,9 +120,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,6 +16,7 @@ public class Tool_Screwdriver : Tool_Base
{
if (!screw.isInstall)
{
isMoving = true;
screw.BeInstalled(this);
}
}
@ -28,6 +29,7 @@ public class Tool_Screwdriver : Tool_Base
{
if (screw.isInstall)
{
isMoving = true;
screw.BeUnInstalled(this);
}
}