123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162 |
- using System;
- using UnityEngine;
- using UnityEngine.Events;
- using UnityEngine.UI;
- public class VRDecideMiniGameHand : MonoBehaviour
- {
- public static VRDecideMiniGameHand Create(Vector3 WorldPos, Quaternion Qt)
- {
- if (VRDecideMiniGameHand.m_Instance != null)
- {
- VRDecideMiniGameHand.m_Instance.transform.position = WorldPos;
- VRDecideMiniGameHand.m_Instance.transform.rotation = Qt;
- return VRDecideMiniGameHand.m_Instance;
- }
- VRDecideMiniGameHand vrdecideMiniGameHand = UnityEngine.Object.FindObjectOfType<VRDecideMiniGameHand>();
- if (!vrdecideMiniGameHand)
- {
- string path = "SceneVRCommunication/Tablet/MiniGameDecideHand";
- UnityEngine.Object original = Resources.Load(path);
- GameObject gameObject = UnityEngine.Object.Instantiate(original, WorldPos, Qt) as GameObject;
- vrdecideMiniGameHand = gameObject.GetComponent<VRDecideMiniGameHand>();
- }
- else
- {
- GameObject gameObject = vrdecideMiniGameHand.gameObject;
- }
- return vrdecideMiniGameHand;
- }
- public Text textCountDown
- {
- get
- {
- return this.m_TextCountDown;
- }
- }
- private void Awake()
- {
- if (VRDecideMiniGameHand.m_Instance != null)
- {
- UnityEngine.Object.DestroyImmediate(base.gameObject);
- return;
- }
- VRDecideMiniGameHand.m_Instance = this;
- }
- private void Start()
- {
- this.m_ControllerR = GameMain.Instance.OvrMgr.ovr_obj.right_controller.controller;
- this.m_ControllerL = GameMain.Instance.OvrMgr.ovr_obj.left_controller.controller;
- }
- private void Update()
- {
- if (!this.m_IsUpdate)
- {
- return;
- }
- if (!this.m_ControllerL || !this.m_ControllerR)
- {
- this.m_ControllerR = GameMain.Instance.OvrMgr.ovr_obj.right_controller.controller;
- this.m_ControllerL = GameMain.Instance.OvrMgr.ovr_obj.left_controller.controller;
- if (!this.m_ControllerL || !this.m_ControllerR)
- {
- return;
- }
- }
- bool press = this.m_ControllerR.VRControllerButtons.GetPress(AVRControllerButtons.BTN.TRIGGER);
- bool press2 = this.m_ControllerL.VRControllerButtons.GetPress(AVRControllerButtons.BTN.TRIGGER);
- float deltaTime = Time.deltaTime;
- if (press && press2)
- {
- this.m_TotalGrabTime = 0f;
- }
- else if (press)
- {
- this.m_TotalGrabTime += deltaTime;
- }
- else if (press2)
- {
- this.m_TotalGrabTime += deltaTime;
- }
- else
- {
- this.m_TotalGrabTime = 0f;
- }
- if (press2 != press)
- {
- this.m_TextCountDown.gameObject.SetActive(true);
- this.m_ImageManual.gameObject.SetActive(true);
- float num = this.m_MaxGrabTime - this.m_TotalGrabTime;
- num += 1f;
- this.m_TextCountDown.text = ((int)num).ToString();
- }
- else
- {
- this.m_TextCountDown.gameObject.SetActive(false);
- this.m_ImageManual.gameObject.SetActive(true);
- }
- if (this.m_TotalGrabTime > this.m_MaxGrabTime)
- {
- this.m_IsUpdate = false;
- if (press2)
- {
- this.m_Callback(this.m_ControllerL);
- }
- else
- {
- this.m_Callback(this.m_ControllerR);
- }
- }
- }
- public void StartDecideHand(UnityAction<AVRController> callback)
- {
- if (GameMain.Instance.VRDeviceTypeID == GameMain.VRDeviceType.RIFT_TOUCH)
- {
- this.m_ImageManual.sprite = this.m_SpriteStartOculus;
- }
- else if (GameMain.Instance.VRDeviceTypeID == GameMain.VRDeviceType.VIVE)
- {
- this.m_ImageManual.sprite = this.m_SpriteStartHTC;
- }
- UICanvasFade component = base.GetComponent<UICanvasFade>();
- component.FadeIn();
- this.m_IsUpdate = true;
- this.m_Callback = null;
- this.m_Callback = callback;
- }
- private static VRDecideMiniGameHand m_Instance;
- [SerializeField]
- [Tooltip("カウントダウン用テキストUI")]
- private Text m_TextCountDown;
- [SerializeField]
- [Tooltip("説明用イメージUI")]
- private Image m_ImageManual;
- [SerializeField]
- [Tooltip("説明用イメージ(HTC)")]
- private Sprite m_SpriteStartHTC;
- [SerializeField]
- [Tooltip("説明用イメージ(Oculus)")]
- private Sprite m_SpriteStartOculus;
- private AVRController m_ControllerR;
- private AVRController m_ControllerL;
- private float m_TotalGrabTime;
- private float m_MaxGrabTime = 3f;
- private UnityAction<AVRController> m_Callback;
- private bool m_IsUpdate;
- }
|