123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233 |
- 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<int, Dictionary<VRTouchMgr.ETouchPos, VRTouchMgr.State>> keyValuePair in this.m_dicState)
- {
- foreach (KeyValuePair<VRTouchMgr.ETouchPos, VRTouchMgr.State> 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<GameObject> 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<Maid>();
- int activeSlotNo = componentInParent.ActiveSlotNo;
- Dictionary<VRTouchMgr.ETouchPos, VRTouchMgr.State> dictionary;
- if (!this.m_dicState.TryGetValue(activeSlotNo, out dictionary))
- {
- Dictionary<VRTouchMgr.ETouchPos, VRTouchMgr.State> dictionary2 = new Dictionary<VRTouchMgr.ETouchPos, VRTouchMgr.State>();
- 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<int, Dictionary<VRTouchMgr.ETouchPos, VRTouchMgr.State>> keyValuePair in this.m_dicState)
- {
- foreach (KeyValuePair<VRTouchMgr.ETouchPos, VRTouchMgr.State> 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<VRTouchMgr.ETouchPos, VRTouchMgr.State> 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<GameObject> m_listCollider;
- private Dictionary<int, Dictionary<VRTouchMgr.ETouchPos, VRTouchMgr.State>> m_dicState = new Dictionary<int, Dictionary<VRTouchMgr.ETouchPos, VRTouchMgr.State>>();
- private OvrMgr.OvrObject.Controller m_vr_obj;
- }
- }
|