CultivationOfBrewing/Assets/Scripts/Project/ProjectBase/RayClliderManager.cs

52 lines
1.4 KiB
C#

using HighlightPlus;
using UnityEngine;
using UnityEngine.Playables;
public class RayClliderManager : MonoBehaviour
{
public PlayableDirector TuoChe_PlayableDirector;
public Animator Gengtian_animator;
public HighlightEffect TuoChe_highlightEffect;
public bool TuoChe_enabled;
// Start is called before the first frame update
void Start()
{
Gengtian_animator.enabled = false;
if (Bootstrap.Instance != null)
Bootstrap.Instance.eventCenter.AddEventListener<bool>(Enum_EventType.Íϳµ, TuoCheEnabled);
}
private void TuoCheEnabled(bool value)
{
TuoChe_enabled = value;
}
// Update is called once per frame
void Update()
{
if (Input.GetMouseButtonDown(0) && TuoChe_enabled)
{
Ray ray = Camera.main.ScreenPointToRay(Input.mousePosition);
RaycastHit hit;
bool raycast = Physics.Raycast(ray, out hit);
if (raycast)
{
if (hit.collider.gameObject.name.Equals("Íϳµ"))
{
Gengtian_animator.enabled = true;
TuoChe_highlightEffect.highlighted = false;
TuoChe_PlayableDirector.Play();
}
}
}
}
private void OnDisable()
{
if (Bootstrap.Instance != null)
Bootstrap.Instance.eventCenter.RemoveEventListener<bool>(Enum_EventType.Íϳµ, TuoCheEnabled);
}
}