ShanxiKnowledgeBase/SXElectricityInformationAcq.../Assets/taoruiqi/AdhesiveTape.cs

135 lines
3.6 KiB
C#

using DefaultNamespace.ProcessMode;
using DG.Tweening;
using MotionFramework;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.EventSystems;
/// <summary>
/// 없鍍스던
/// </summary>
public class AdhesiveTape : MonoBehaviour
{
[Header("없鍍스던")]
/// <summary>
/// 없鍍스던
/// </summary>
public GameObject TapeOBJ;
[Header("든窟품뙈스던")]
/// <summary>
/// 든窟품뙈스던
/// </summary>
public Material TapeMar;
[Header("든窟툭旒")]
/// <summary>
/// 든窟툭旒
/// </summary>
public BoxCollider TapeMarCol;
[Header("스던賈痰빈貫零")]
/// <summary>
/// 스던賈痰빈貫零
/// </summary>
public Transform TapeTrans;
[Header("만膠竟鯤소宮샙麟깃")]
/// <summary>
/// 만膠竟鯤소宮샙麟깃
/// </summary>
public Transform PlayerCamera;
[Header("閨왯풂돨覩迦貫零")]
/// <summary>
/// 閨왯풂돨覩迦貫零
/// </summary>
private Vector3 originalPosition;
[Header("閨왯풂돨覩迦旗瘻")]
/// <summary>
/// 閨왯풂돨覩迦旗瘻
/// </summary>
private Quaternion originalRotation;
// Start is called before the first frame update
void Start()
{
Init();
}
void Init()
{
originalPosition = TapeOBJ.transform.localPosition;
originalRotation = TapeOBJ.transform.localRotation;
TapeMar.SetFloat("_step_p1", 0);
TapeMar.SetFloat("_step_p2", 0);
TapeMar.SetFloat("_step_p3", 0);
TapeMar.SetFloat("_step_p4", 0);
TapeMar.SetFloat("_step_p5", 0);
TapeMar.SetFloat("_step_p6", 0);
}
// Update is called once per frame
void Update()
{
if (EventSystem.current.IsPointerOverGameObject())
return;
if (Input.GetMouseButtonDown(0))
{//Camera.transform.forward
Ray ray = Camera.main.ScreenPointToRay(Input.mousePosition);
RaycastHit hit;
bool raycast = Physics.Raycast(ray, out hit);
if (raycast)
{
if (hit.collider.gameObject.name == "pCylinder170")
{
TapeOBJ.gameObject.transform.SetParent(null);
TapeOBJ.gameObject.transform.SetPositionAndRotation(TapeTrans.position, TapeTrans.rotation);
StartCoroutine(Tape());
MotionEngine.GetModule<AnimationProcessManager>().HandleClick(hit.collider.gameObject.name);
}
}
}
}
/// <summary>
/// 든窟끌스던
/// </summary>
/// <returns></returns>
IEnumerator Tape()
{
yield return new WaitForSeconds(1f);
TapeMar.SetFloat("_step_p1", 1);
yield return new WaitForSeconds(1f);
TapeMar.SetFloat("_step_p2", 1);
yield return new WaitForSeconds(1f);
TapeMar.SetFloat("_step_p3", 1);
yield return new WaitForSeconds(1f);
TapeMar.SetFloat("_step_p4", 1);
yield return new WaitForSeconds(1f);
TapeMar.SetFloat("_step_p5", 1);
yield return new WaitForSeconds(1f);
TapeMar.SetFloat("_step_p6", 1);
yield return new WaitForSeconds(1f);
StartCoroutine(TapeBack());
}
/// <summary>
/// 스던럿쀼땡뺌
/// </summary>
/// <returns></returns>
IEnumerator TapeBack()
{
TapeOBJ.gameObject.transform.SetParent(PlayerCamera.transform);
yield return new WaitForSeconds(0.5f);
TapeOBJ.gameObject.transform.localPosition = originalPosition;
TapeOBJ.gameObject.transform.localRotation = originalRotation;
TapeMarCol.enabled = false;
yield return new WaitForSeconds(1f);
}
}