Files
PrinceOfGlory/Assets/Scripts/Scene_05/TouchPlayAnimatior.cs
kridoo 6e91a0c7f0 111
2025-09-15 17:32:08 +08:00

67 lines
1.7 KiB
C#

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class TouchPlayAnimatior : MonoBehaviour
{
public HandFontSelfCtr showSelfFont;
public GrabItem grabItem;
Animator animator;
AudioSource audioSource;
//计时相关
bool isRun = false;
float waitTime = 2f;
float runTime = 0;
float showGrabItem = 1.5f; //显示里面铜具的时间
// Start is called before the first frame update
void Start()
{
audioSource = GetComponent<AudioSource>();
animator = GetComponent<Animator>();
if (grabItem != null)
grabItem.gameObject.SetActive(false);
}
private void Update()
{
if (isRun)
{
runTime += Time.deltaTime;
if (runTime >= waitTime)
{
isRun = false;
runTime = 0;
ShowFont();
//if (grabItem != null)
// grabItem.gameObject.SetActive(true);
this.gameObject.SetActive(false);
}
if (runTime >= showGrabItem) //显示里面的铜具
{
if (grabItem != null && grabItem.gameObject.activeSelf == false)
grabItem.gameObject.SetActive(true);
}
}
}
private void OnTriggerEnter(Collider other)
{
if (other.gameObject.name == "PalmBox_L" || other.gameObject.name == "PalmBox_R")
{
this.GetComponent<BoxCollider>().enabled = false;
animator.Play("Touch");
isRun = true;
if (audioSource != null)
audioSource.Play();
}
}
void ShowFont()
{
if (showSelfFont != null)
showSelfFont.PlayShowJGWFont();
}
}