135 lines
3.0 KiB
C#
135 lines
3.0 KiB
C#
using System.Globalization;
|
|
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using Pico.Platform;
|
|
using UnityEngine;
|
|
using System;
|
|
using DG.Tweening;
|
|
using DragonLi.Core;
|
|
using UnityEngine.XR.Interaction.Toolkit;
|
|
using TrackedPoseDriver = UnityEngine.SpatialTracking.TrackedPoseDriver;
|
|
|
|
public class RightHand : MonoBehaviour
|
|
{
|
|
public TrackedPoseDriver tracked;
|
|
|
|
private HandState _cachePlayerState;
|
|
|
|
// 射线
|
|
public LayerMask layerMask;
|
|
public Transform ray;
|
|
|
|
[Tooltip("手模型")] public GameObject hand;
|
|
public GameObject[] gems;
|
|
|
|
public GameObject gemKeyHand;
|
|
|
|
public GameObject skillet;
|
|
public GameObject skilletEx;
|
|
|
|
public GameObject hit;
|
|
|
|
public RaycastHit handlingHit;
|
|
|
|
private int _cacheTargetId = -1;
|
|
|
|
private Vector3 _curPos;
|
|
private bool _isStartTrigger;
|
|
|
|
public bool isTrigger;
|
|
|
|
public bool _isOpenLine = false;
|
|
|
|
private Collider _collider = null;
|
|
|
|
public Collider selfCollider
|
|
{
|
|
get
|
|
{
|
|
if (_collider == null)
|
|
{
|
|
_collider = GetComponentInChildren<Collider>();
|
|
}
|
|
return _collider;
|
|
}
|
|
}
|
|
|
|
public void Start()
|
|
{
|
|
tracked.enabled = true;
|
|
selfCollider.enabled = true;
|
|
GameManager.Ins.playerRightHand=this;
|
|
MRInput.Ins.RegisterClickRrightTrigger(ClickRrightTrigger);
|
|
Init();
|
|
}
|
|
|
|
public void Init()
|
|
{
|
|
|
|
|
|
}
|
|
|
|
public void Update()
|
|
{
|
|
if (Input.GetKeyDown(KeyCode.Space))
|
|
{
|
|
|
|
}
|
|
|
|
#if UNITY_EDITOR
|
|
Transform camera = GameLocal.Ins.MRCamera.transform;
|
|
transform.position = camera.position + camera.forward * 0.5f + camera.right * 0.2f + camera.up * -0.1f;
|
|
transform.rotation = camera.rotation;
|
|
#endif
|
|
|
|
ray.gameObject.SetActive(_isOpenLine);
|
|
isTrigger = MRInput.Ins.pressRightTrigger;
|
|
if (isTrigger&& !_isStartTrigger)
|
|
{
|
|
_isStartTrigger = true;
|
|
_curPos = transform.position;
|
|
}
|
|
else
|
|
{
|
|
_isStartTrigger = false;
|
|
}
|
|
// 射线检测
|
|
if (_isOpenLine)
|
|
{
|
|
if (Physics.Raycast(transform.position, transform.forward, out handlingHit, 100F, layerMask))
|
|
{
|
|
hit = handlingHit.collider.gameObject;
|
|
}
|
|
else
|
|
{
|
|
hit = null;
|
|
}
|
|
}
|
|
|
|
}
|
|
|
|
public void ClickRrightTrigger()
|
|
{
|
|
if(hit==null)
|
|
return;
|
|
if (hit.tag == "TreeUI"|| hit.tag == "TreePoint")
|
|
{
|
|
TreeTask.Ins.CheckPoint(handlingHit.point,hit);
|
|
}
|
|
|
|
//石板任务检测
|
|
BronzeBlock bronzeBlock = hit.GetComponent<BronzeBlock>();
|
|
if (bronzeBlock != null)
|
|
{
|
|
bronzeBlock.OnClickRotate();
|
|
return;
|
|
}
|
|
}
|
|
|
|
public void ChangeHand()
|
|
{
|
|
hand.SetActive(true);
|
|
_isOpenLine = true;
|
|
}
|
|
}
|