80 lines
1.9 KiB
C#
80 lines
1.9 KiB
C#
using DG.Tweening;
|
|
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using UnityEngine;
|
|
|
|
/// <summary>
|
|
/// 螺丝
|
|
/// </summary>
|
|
public class Tool_Screw : Tool_Base
|
|
{
|
|
/// <summary>
|
|
/// 标识
|
|
/// </summary>
|
|
public string id;
|
|
|
|
/// <summary>
|
|
/// 是否已拧紧
|
|
/// </summary>
|
|
public bool isInstall;
|
|
/// <summary>
|
|
/// 上螺丝位置
|
|
/// </summary>
|
|
public Transform installPos;
|
|
|
|
/// <summary>
|
|
/// 螺丝拧紧时的位置
|
|
/// </summary>
|
|
private float localYInstallValue;
|
|
/// <summary>
|
|
/// 螺丝拧松时的位置
|
|
/// </summary>
|
|
private float localYUnInstallValue;
|
|
|
|
|
|
|
|
/// <summary>
|
|
/// 被拧紧
|
|
/// </summary>
|
|
/// <param name="screwdriver"></param>
|
|
public void BeInstalled(Tool_Screwdriver screwdriver)
|
|
{
|
|
//设置螺丝刀初始位置
|
|
screwdriver.transform.position = installPos.position;
|
|
//动画
|
|
transform.DOLocalMoveY(localYInstallValue, 1)
|
|
.OnUpdate(() =>
|
|
{
|
|
transform.RotateAroundLocal(Vector3.up, 1);
|
|
screwdriver.transform.position = installPos.position;
|
|
})
|
|
.OnComplete(() =>
|
|
{
|
|
Debug.Log("螺丝已拧紧");
|
|
isInstall = true;
|
|
});
|
|
}
|
|
|
|
/// <summary>
|
|
/// 被拧送
|
|
/// </summary>
|
|
/// <param name="screwdriver"></param>
|
|
public void BeUnInstalled(Tool_Screwdriver screwdriver)
|
|
{
|
|
//设置螺丝刀初始位置
|
|
screwdriver.transform.position = installPos.position;
|
|
//动画
|
|
transform.DOLocalMoveY(localYUnInstallValue, 1)
|
|
.OnUpdate(() =>
|
|
{
|
|
transform.RotateAroundLocal(Vector3.up, 1);
|
|
screwdriver.transform.position = installPos.position;
|
|
})
|
|
.OnComplete(() =>
|
|
{
|
|
Debug.Log("螺丝已拧松");
|
|
isInstall = false;
|
|
});
|
|
}
|
|
}
|