using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using static Unity.Burst.Intrinsics.X86.Avx;
///
/// 剥线钳
///
public class Tool_WireStripper : Tool_Base
{
///
/// 开始剪封印
///
///
public void CutOpen(Device_Seal device_Seal)
{
transform.parent = null;
transform.position = device_Seal.testPosAndRot.position;
transform.eulerAngles = device_Seal.testPosAndRot.eulerAngles;
//播放动画
StopAllCoroutines();
StartCoroutine(PlayAnimi(device_Seal));
}
///
/// 剪的动画
///
///
IEnumerator PlayAnimi(Device_Seal device_Seal)
{
SkinnedMeshRenderer renderer = GetComponentInChildren();
float vlaue = 0;
//打开
while (renderer.GetBlendShapeWeight(0) < 100)
{
vlaue += (Time.deltaTime * 200);
renderer.SetBlendShapeWeight(0, vlaue);
yield return null;
}
//关闭
while (renderer.GetBlendShapeWeight(0) > 0)
{
vlaue -= (Time.deltaTime * 200);
renderer.SetBlendShapeWeight(0, vlaue);
yield return null;
}
//剪断
device_Seal.Cut();
}
private void Update()
{
if (Input.GetMouseButtonDown(0))
{
//点击螺丝验电
Ray tmpray = Camera.main.ScreenPointToRay(Input.mousePosition);
if (Physics.Raycast(tmpray, out RaycastHit hit))
{
//封印
Device_Seal ds = hit.transform.GetComponent();
if (ds != null)
{
if (GameManager.ProcessMgr.IsRightSubProcessStepsTriggerID(ds.triggerName, true) == 0)
{
CutOpen(ds);
}
}
}
}
}
}