using System; using System.Collections; using System.Collections.Generic; using DragonLi.Core; using UnityEngine; public class PullHand : MonoBehaviour { public Collider selfCollider; public Bow bow; private bool _inArrowArea = false; private bool _isPulling = false; public void Start() { MRInput.Ins.RegisterClickRrightTrigger(() => { // 钩弦 if (!_isPulling && _inArrowArea) { // Debug.Log("钩弦"); selfCollider.enabled = false; _isPulling = true; // 生成箭矢 bow.CreateArrowInHand(); } }); MRInput.Ins.RegisterCancelRightTrigger(() => { // 松弦 if (_isPulling && bow != null) { // Debug.Log("松弦"); _isPulling = false; _inArrowArea = false; // 射出箭矢 bow.ShootArrow(); CoroutineTaskManager.Instance.WaitSecondTodo(() => { selfCollider.enabled = true; }, 0.5f); } }); MRInput.Ins.RegisterHoldPressRightTrigger(() => { // 拉弓 if (_isPulling && bow != null) { // Debug.Log("拉弓"); bow.Pull(transform); // _nowArrow.Move(transform); } }); } private void Update() { if (Input.GetMouseButtonDown(0)) { bow.CreateArrowInHand(); bow.Pull(transform); } if (Input.GetMouseButtonUp(0)) { bow.ShootArrow(); CoroutineTaskManager.Instance.WaitSecondTodo(() => { selfCollider.enabled = true; }, 0.5f); } } void OnTriggerEnter(Collider other) { Debug.Log("进入弓弦区域"); _inArrowArea = true; bow = other.gameObject.GetComponent(); } void OnTriggerExit(Collider other) { Debug.Log("离开弓弦区域"); _inArrowArea = false; bow = null; } }