Files
PrinceOfGlory/Assets/Scripts/HandCatch/CatchManager.cs
kridoo 6019406bc8 1
2025-11-19 23:51:17 +08:00

77 lines
1.8 KiB
C#

using System.Collections;
using System.Collections.Generic;
using BigSpace.Logic;
using BigSpace.XRCore.Event;
using UnityEngine;
public class CatchManager : MonoBehaviour
{
public Transform attachPoint;
public Transform chuiziPoint;
public bool start;
public GrabItem m_currentItem;
private Collider m_collider;
public bool Start
{
get => start;
set
{
start = value;
if (value == false && m_currentItem != null)
{
SetCurrentItem(null);
}
}
}
private void Awake()
{
m_collider = GetComponent<Collider>();
GlobalEventMgr.Listen(GameEvent.EventChangeScence, GameDataManage_EventChangeScence);
}
public void SetStart(bool value)
{
Start = value;
}
public void SetEnd(bool value)
{
Start = value;
}
public void SetCurrentItem(GrabItem item)
{
if(item == null)
m_currentItem.OnReset(this.name);
m_currentItem = item;
m_collider.enabled = item ==null? true:false;
}
public void SetParent(Transform transform)
{
//if (transform.tag == "ChuiZi")
//{
// transform.position = chuiziPoint.position;
// transform.eulerAngles = chuiziPoint.eulerAngles;
// transform.SetParent(chuiziPoint);
//}
//else
//{
transform.position = attachPoint.position;
transform.SetParent(attachPoint);
//}
}
//Çл»³¡¾°É¾³ýÊÖÉÏÎïÌå
void GameDataManage_EventChangeScence()
{
foreach (Transform child in attachPoint)
{
Destroy(child.gameObject);
}
start = true;
m_collider.enabled = true ;
}
}