71 lines
2.3 KiB
C#
71 lines
2.3 KiB
C#
using DG.Tweening;
|
|
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using UnityEngine;
|
|
using static Unity.Burst.Intrinsics.X86.Avx;
|
|
|
|
/// <summary>
|
|
/// 剥线钳
|
|
/// </summary>
|
|
public class Tool_WireStripper : Tool_Base
|
|
{
|
|
/// <summary>
|
|
/// 开始剪封印
|
|
/// </summary>
|
|
/// <param name="device_Seal"></param>
|
|
public void CutOpen(Device_Seal device_Seal)
|
|
{
|
|
base.hand_out_action?.Invoke();
|
|
base.isMoving = true;
|
|
transform.parent = null;
|
|
transform.DORotate(device_Seal.testPosAndRot.eulerAngles, 0.5f);
|
|
transform.DOMove(device_Seal.testPosAndRot.position, 1).OnComplete(() =>
|
|
{
|
|
//剪
|
|
Transform left = transform.Find("剥线钳 (1)/剥线钳左");
|
|
Transform right= transform.Find("剥线钳 (1)/剥线钳右");
|
|
left.DOLocalRotate(new Vector3(-90, 15, 0), 0.5f).OnUpdate(() =>
|
|
{
|
|
right.localEulerAngles = new Vector3(left.localEulerAngles.x,-left.localEulerAngles.y, left.localEulerAngles.z);
|
|
}).OnComplete(() =>
|
|
{
|
|
left.DOLocalRotate(new Vector3(-90, 0, 0), 0.5f).OnUpdate(() =>
|
|
{
|
|
right.localEulerAngles = new Vector3(left.localEulerAngles.x, -left.localEulerAngles.y, left.localEulerAngles.z);
|
|
}).OnComplete(() =>
|
|
{
|
|
//剪断封印
|
|
device_Seal.Cut();
|
|
isMoving = false;
|
|
|
|
ReBackHead(() =>
|
|
{
|
|
int result = (triggerAction == null ? 0 : triggerAction.Invoke(device_Seal.triggerName, true));
|
|
});
|
|
});
|
|
});
|
|
});
|
|
}
|
|
|
|
private void Update()
|
|
{
|
|
if (Input.GetMouseButtonDown(0) && !isMoving)
|
|
{
|
|
//点击螺丝验电
|
|
Ray tmpray = Camera.main.ScreenPointToRay(Input.mousePosition);
|
|
if (Physics.Raycast(tmpray, out RaycastHit hit))
|
|
{
|
|
//封印
|
|
Device_Seal ds = hit.transform.GetComponent<Device_Seal>();
|
|
if (ds != null)
|
|
{
|
|
if ((triggerAction == null ? 0 : triggerAction.Invoke(ds.triggerName, false)) == 0)
|
|
{
|
|
CutOpen(ds);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|