using System;
using System.Collections.Generic;
using DragonLi.Core;
using UnityEngine;
using UnityEngine.XR;
///
/// 手类型
///
public enum HandType
{
Left,
Right
}
///
/// 手状态
///
public enum HandState
{
///
/// 空手
///
Empty,
///
/// 有武器
///
HaveWeapon
}
public class Player : MonoBehaviour
{
public Transform LeftHand;
public Transform RightHand;
public Transform Aim;
public GameObject rightHandPre;
public Collider Collider;
public LayerMask AimLayer;
public HandState handState = HandState.Empty;
#if UNITY_EDITOR
[DisplayOnly]
#endif
public Vector3 AimVec = Vector3.zero;
public void Start()
{
GameLocal.Ins.self = this;
CreateHands();
}
public void Update()
{
Transform mainCamera = GameLocal.Ins.MRCamera.transform;
Transform aim = GameLocal.Ins.Aim.transform;
Transform leftControl = GameLocal.Ins.MRLeftControl;
Transform rightControl = GameLocal.Ins.MRRightControl;
// 同步相机
transform.position = mainCamera.position;
transform.rotation = mainCamera.rotation;
// 同步注视点
Aim.position = aim.position;
Aim.rotation = aim.rotation;
#if !UNITY_EDITOR && UNITY_ANDROID && PICO
// 同步手柄
LeftHand.transform.position = leftControl.position;
LeftHand.transform.rotation = leftControl.rotation;
RightHand.transform.position = rightControl.position;
RightHand.transform.rotation = rightControl.rotation;
#endif
if (Input.GetKeyDown(KeyCode.Q))
{
}
// 发射射线
if (Physics.Raycast(transform.position, transform.forward, out RaycastHit handlingHit, 20f, AimLayer))
{
AimVec = handlingHit.point;
}
else
{
AimVec = Aim.position;
}
}
public void CreateHands()
{
//LeftHand leftHand = Instantiate(LeftHandPre).GetComponent();
RightHand rightHand = Instantiate(rightHandPre).GetComponent();
}
public void OnTriggerEnter(Collider other)
{
// 开始游戏
if (other.tag == "GameStartDoor")
{
Debug.Log("触碰开始");
other.gameObject.GetComponent().enabled = false;
other.gameObject.SetActive(false);
Destroy(other.gameObject);
if (GameManager.Ins.taskManager.curTaskId != 4)
{
GameManager.Ins.GameStart();
}
else
{
GameManager.Ins.StartDance();
}
}
}
}