123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657 |
- using System.Collections;
- using System.Collections.Generic;
- using UnityEngine;
- public class SynPlayerTransform : MonoSingleton<SynPlayerTransform>
- {
- public Transform player;
- void Start()
- {
- player = OpenXRCamera.Instance.head;
- }
- // Update is called once per frame
- void Update()
- {
- transform.eulerAngles = new Vector3(0, player.eulerAngles.y, 0);
- transform.position = new Vector3(player.position.x, 0, player.position.z);
- // UILogManager.Instance.text3.text = transform.localEulerAngles.y.ToString();
- }
- /// <summary>
- /// 返回当前朝向的机柜 , False 单排机柜 1 3 5...
- /// </summary>
- /// <returns></returns>
- public bool GetOrientation()
- {
- if (Mathf.Abs(transform.localEulerAngles.y) > 90&& Mathf.Abs(transform.localEulerAngles.y)<270)
- {
- return true;
- }
- return false;
- }
- /// <summary>
- /// 判断当前在第几排机柜之间
- /// </summary>
- public int GetRowCabinets()
- {
- int row = 0;
- float rowDis = 0;
- int index = 0;
- for (int i = 0; i < MachineRoomManager.Instance.listObjes.Count; i+=MachineRoomManager.Instance.data.line*2)
- {
- float disZ = Mathf.Abs(transform.position.z - MachineRoomManager.Instance.listObjes[i].transform.position.z);
- if(rowDis>disZ)
- {
- row = index;
- rowDis = disZ;
- }
- index++;
- }
- return row;
- }
- }
|