using System; using System.Collections.Generic; using UnityEngine; public class VRTouchMgr { public VRTouchMgr() { this.m_hand[0] = new VRTouchMgr.Hand(VRTouchMgr.EHand.Left); this.m_hand[1] = new VRTouchMgr.Hand(VRTouchMgr.EHand.Right); } public void Clear() { this.m_hand[0].Clear(); this.m_hand[1].Clear(); } public void FrameStart() { for (int i = 0; i < 2; i++) { this.m_hand[i].FrameStart(); } } public void FrameEnd() { for (int i = 0; i < 2; i++) { this.m_hand[i].FrameEnd(); } } public bool GetBehaviorTouchDown(VRTouchMgr.EHand f_eHand, VRTouchMgr.ETouchPos f_checkPos, VRTouchMgr.ETouchBehavior f_checkBeh, int f_nMaidNo = 0) { return this.m_hand[(int)f_eHand].GetBehaviorTouchDown(f_checkPos, f_checkBeh, f_nMaidNo); } public bool GetBehaviorTouch(VRTouchMgr.EHand f_eHand, VRTouchMgr.ETouchPos f_checkPos, VRTouchMgr.ETouchBehavior f_checkBeh, int f_nMaidNo = 0) { return this.m_hand[(int)f_eHand].GetBehaviorTouch(f_checkPos, f_checkBeh, f_nMaidNo); } public bool GetBehaviorTouchOrGrab(VRTouchMgr.EHand f_eHand, VRTouchMgr.ETouchPos f_checkPos, int f_nMaidNo = 0) { return this.m_hand[(int)f_eHand].GetBehaviorTouchOrGrab(f_checkPos, f_nMaidNo); } private VRTouchMgr.Hand[] m_hand = new VRTouchMgr.Hand[2]; public enum ETouchPos { 無し, 頭頂部, 髪の毛, 胸, お腹, 手, お尻, 腿, リボン, スカ\u30FCト, MAX } public enum ETouchBehavior { 無し, 触る, 掴む, MAX } public class State { public VRTouchMgr.ETouchBehavior behBef; public VRTouchMgr.ETouchBehavior behNow; } public enum EHand { Non = -1, Left, Right, MAX } private class Hand { public Hand(VRTouchMgr.EHand f_HandSide) { if (f_HandSide == VRTouchMgr.EHand.Left) { this.m_vr_obj = GameMain.Instance.OvrMgr.ovr_obj.left_controller; } else if (f_HandSide == VRTouchMgr.EHand.Right) { this.m_vr_obj = GameMain.Instance.OvrMgr.ovr_obj.right_controller; } this.m_CtrlBtn = this.m_vr_obj.controller_buttons; this.m_vr_obj.grip_collider.ClearColliderList(); this.m_listCollider = this.m_vr_obj.grip_collider.collider_list; } public void Clear() { if (this.m_vr_obj != null) { this.m_vr_obj.grip_collider.ClearColliderList(); } } public void FrameStart() { foreach (KeyValuePair> keyValuePair in this.m_dicState) { foreach (KeyValuePair keyValuePair2 in keyValuePair.Value) { keyValuePair2.Value.behNow = VRTouchMgr.ETouchBehavior.無し; } } VRTouchMgr.ETouchBehavior behNow = VRTouchMgr.ETouchBehavior.触る; if (this.m_CtrlBtn != null && this.m_CtrlBtn.GetPress(AVRControllerButtons.BTN.TRIGGER)) { behNow = VRTouchMgr.ETouchBehavior.掴む; } OvrMgr.OvrObject ovr_obj = GameMain.Instance.OvrMgr.ovr_obj; List listCollider = this.m_listCollider; foreach (GameObject gameObject in listCollider) { if (!(gameObject == null)) { if (gameObject.layer == 19) { bool flag = false; VRTouchMgr.ETouchPos key = VRTouchMgr.ETouchPos.無し; if (gameObject.name == "OvrTouchHit_Bip01 Spine_SCL_" || gameObject.name == "OvrGrabHit_Bip01 Spine0a_SCL_") { flag = true; key = VRTouchMgr.ETouchPos.お腹; } else if (gameObject.name == "OvrTouchHit_Mune_L_sub" || gameObject.name == "OvrTouchHit_Mune_R_sub") { flag = true; key = VRTouchMgr.ETouchPos.胸; } else if (gameObject.name == "OvrTouchHit_Bip01 Head") { flag = true; key = VRTouchMgr.ETouchPos.頭頂部; } else if (gameObject.name == "OvrTouchHit_Bip01 L Hand" || gameObject.name == "OvrTouchHit_Bip01 R Hand") { flag = true; key = VRTouchMgr.ETouchPos.手; } else if (gameObject.name == "OvrTouchHit_Bip01 Pelvis_SCL_") { flag = true; key = VRTouchMgr.ETouchPos.お尻; } if (flag) { Maid componentInParent = gameObject.GetComponentInParent(); int activeSlotNo = componentInParent.ActiveSlotNo; Dictionary dictionary; if (!this.m_dicState.TryGetValue(activeSlotNo, out dictionary)) { Dictionary dictionary2 = new Dictionary(); this.m_dicState[activeSlotNo] = dictionary2; dictionary = dictionary2; } VRTouchMgr.State state; if (!dictionary.TryGetValue(key, out state)) { VRTouchMgr.State state2 = new VRTouchMgr.State(); dictionary[key] = state2; state = state2; } state.behNow = behNow; } } } } } public void FrameEnd() { foreach (KeyValuePair> keyValuePair in this.m_dicState) { foreach (KeyValuePair keyValuePair2 in keyValuePair.Value) { keyValuePair2.Value.behBef = keyValuePair2.Value.behNow; } } } private bool GetState(int f_nMaidNo, VRTouchMgr.ETouchPos f_checkPos, out VRTouchMgr.State f_outState) { f_outState = null; Dictionary dictionary; return this.m_dicState.TryGetValue(f_nMaidNo, out dictionary) && dictionary.TryGetValue(f_checkPos, out f_outState); } public bool GetBehaviorTouchDown(VRTouchMgr.ETouchPos f_checkPos, VRTouchMgr.ETouchBehavior f_checkBeh, int f_nMaidNo = 0) { VRTouchMgr.State state; return this.GetState(f_nMaidNo, f_checkPos, out state) && (state.behNow == f_checkBeh && state.behBef != state.behNow); } public bool GetBehaviorTouch(VRTouchMgr.ETouchPos f_checkPos, VRTouchMgr.ETouchBehavior f_checkBeh, int f_nMaidNo = 0) { VRTouchMgr.State state; return this.GetState(f_nMaidNo, f_checkPos, out state) && state.behNow == f_checkBeh; } public bool GetBehaviorTouchOrGrab(VRTouchMgr.ETouchPos f_checkPos, int f_nMaidNo = 0) { VRTouchMgr.State state; return this.GetState(f_nMaidNo, f_checkPos, out state) && (state.behNow == VRTouchMgr.ETouchBehavior.触る || state.behNow == VRTouchMgr.ETouchBehavior.掴む); } private AVRControllerButtons m_CtrlBtn; private List m_listCollider; private Dictionary> m_dicState = new Dictionary>(); private OvrMgr.OvrObject.Controller m_vr_obj; } }