private void Awake() { s_singleton = this; XperItem[] items = Enum.GetValues(typeof(XperItem)) as XperItem[]; XperAction[] types = Enum.GetValues(typeof(XperAction)) as XperAction[]; List <XperAction> flagedTypes = new List <XperAction>(); foreach (XperItem item in items) { flagedTypes.Clear(); foreach (XperAction type in types) { XperAction tmp = AttributionsOf(item); bool hasFlag = (((int)tmp == -1) || ((tmp & type) > 0)); if (hasFlag) { flagedTypes.Add(type); } } if (flagedTypes.Count > 0) { m_xperFirstIntroduced.Add(item, flagedTypes[UnityEngine.Random.Range(0, flagedTypes.Count)]); } } }
static public bool Allows(XperItem item, XperAction type, XperRange range) { bool validAction = (s_singleton.AttributionsOf(item) & type) == type; bool validRange = (s_singleton.RangeModeOf(item) & range) == range; return(validAction && validRange); }
public XperEntry(XperAction type, XperRange range, XperItem item) { m_type = type; m_item = item; m_range = range; m_timeOfEntry = Time.time; m_introducedFirst = XperManager.FirstInteractionIntroduced(item); m_height = StageManager.stageHeight; }
private void OnTouch() { m_interactionsDown &= ~XperAction.Touch; m_interactionsUp &= ~XperAction.Touch; m_touchPosition = m_controller.GetAxis(Valve.VR.EVRButtonId.k_EButton_Axis0); if (m_previouslyTouched) { m_touchDelta = m_touchPosition - m_previousTouchPosition; } }
static public bool IsSimpleAction(XperAction action) { if ((action & XperAction.Trigger) == XperAction.Trigger) { return(true); } if ((action & XperAction.TouchPress) == XperAction.TouchPress) { return(true); } if ((action & XperAction.Grip) == XperAction.Grip) { return(true); } return(false); }
private void OnTouchDown() { m_interactionsPressed |= XperAction.Touch; m_interactionsDown |= XperAction.Touch; m_touched = true; }
private void OnGripButton() { m_interactionsDown &= ~XperAction.Grip; m_interactionsUp &= ~XperAction.Grip; }
private void OnGripButtonUp() { m_interactionsPressed &= ~XperAction.Grip; m_interactionsUp |= XperAction.Grip; }
private bool CheckWandAction(ViveWand wand, XperAction action, XperRange range) { return(wand.IsInteractionPressed(action) && XperManager.Allows(m_itemType, action, range)); }
public bool InteractionDown(XperAction action) { return((m_interactionsDown & action) == action); }
private void OnTouchPress() { m_interactionsDown &= ~XperAction.TouchPress; m_interactionsUp &= ~XperAction.TouchPress; }
private void OnTouchPressDown() { m_interactionsPressed |= XperAction.TouchPress; m_interactionsDown |= XperAction.TouchPress; }
public XperAction AttributionsOf(XperItem item) { XperAction res = 0; switch (item) { case XperItem.Erlenmeyer: res = m_erlenmeyerAttributions; break; case XperItem.Becher: res = m_becherAttributions; break; case XperItem.WaterTap: res = m_waterTapAttributions; break; case XperItem.PipetteTap: res = m_pipetteTapAttributions; break; case XperItem.Tube: res = m_tubeAttributions; break; case XperItem.CogWheel: res = m_cogWheelAttributions; break; case XperItem.AgitatorButton: res = m_agitatorButtonAttributions; break; case XperItem.HodPane: res = m_hodPaneAttributions; break; case XperItem.Cork: res = m_corkAttributions; break; case XperItem.Agitator: res = m_agitatorAttributions; break; case XperItem.Match: res = m_matchAttributions; break; case XperItem.MatchBox: res = m_matchBoxAttributions; break; case XperItem.Spatula: res = m_spatulaAttributions; break; case XperItem.InstructorButton: res = m_instructorButtonAttributions; break; case XperItem.Pen: res = m_markerAttributions; break; case XperItem.PenCork: res = m_markerCorkAttributions; break; } return(res); }
public void SetAttributionsOf(XperItem item, XperAction type) { switch (item) { case XperItem.Erlenmeyer: m_erlenmeyerAttributions = type; break; case XperItem.Becher: m_becherAttributions = type; break; case XperItem.WaterTap: m_waterTapAttributions = type; break; case XperItem.PipetteTap: m_pipetteTapAttributions = type; break; case XperItem.Tube: m_tubeAttributions = type; break; case XperItem.CogWheel: m_cogWheelAttributions = type; break; case XperItem.AgitatorButton: m_agitatorButtonAttributions = type; break; case XperItem.HodPane: m_hodPaneAttributions = type; break; case XperItem.Cork: m_corkAttributions = type; break; case XperItem.Agitator: m_agitatorAttributions = type; break; case XperItem.Match: m_matchAttributions = type; break; case XperItem.MatchBox: m_matchBoxAttributions = type; break; case XperItem.Spatula: m_spatulaAttributions = type; break; case XperItem.InstructorButton: m_instructorButtonAttributions = type; break; case XperItem.Pen: m_markerAttributions = type; break; case XperItem.PenCork: m_markerCorkAttributions = type; break; } }
private void OnTouchUp() { m_interactionsPressed &= ~XperAction.Touch; m_interactionsUp |= XperAction.Touch; m_touched = false; }
private void OnTriggerButtonDown() { m_interactionsPressed |= XperAction.Trigger; m_interactionsDown |= XperAction.Trigger; }
private void OnTriggerButtonUp() { m_interactionsPressed &= ~XperAction.Trigger; m_interactionsUp |= XperAction.Trigger; }
private void OnTouchPressUp() { m_interactionsPressed &= ~XperAction.TouchPress; m_interactionsUp |= XperAction.TouchPress; }
private void OnTriggerButton() { m_interactionsDown &= ~XperAction.Trigger; m_interactionsUp &= ~XperAction.Trigger; }
public bool IsInteractionPressed(XperAction action) { return((m_interactionsPressed & action) == action); }
private void OnGripButtonDown() { m_interactionsPressed |= XperAction.Grip; m_interactionsDown |= XperAction.Grip; }
public bool InteractionUp(XperAction action) { return((m_interactionsUp & action) == action); }
private bool InteractsWithWand(out ViveWand interactionWand, out XperAction mode, out XperRange range) { int wandCount = ViveWand.wandCount; XperAction activationMode = 0; XperRange activationRange = 0; ViveWand gripingWand = null; m_isAtRangeOfWand = false; List <ViveWand> wands = new List <ViveWand>(); for (int i = 0; i < wandCount; i++) { wands.Add(ViveWand.Wand(i)); } if (m_interactionWand && wands.Contains(m_interactionWand)) { if (wands[0] != m_interactionWand) { int indexOfInteractionWand = wands.IndexOf(m_interactionWand); ViveWand tmp = wands[0]; wands[0] = m_interactionWand; wands[indexOfInteractionWand] = tmp; } } foreach (ViveWand wand in wands) { if (!wand || !wand.gameObject.activeSelf) { continue; } if (!wand.upToDate) { wand.ForceUpdate(); } XperAction[] actions = Enum.GetValues(typeof(XperAction)) as XperAction[]; XperRange[] ranges = Enum.GetValues(typeof(XperRange)) as XperRange[]; foreach (XperRange tmpRange in ranges) { foreach (XperAction tmpAction in actions) { bool isAtRangeOfTestedWand = CheckAtRange(wand, tmpRange); m_isAtRangeOfWand |= isAtRangeOfTestedWand; if ((isAtRangeOfTestedWand || hasFocus) && CheckWandAction(wand, tmpAction, tmpRange)) { activationMode = tmpAction; activationRange = tmpRange; gripingWand = wand; break; } } if (gripingWand) { break; } } if (gripingWand) { break; } } range = activationRange; interactionWand = gripingWand; mode = activationMode; return(gripingWand != null); }