Example #1
0
    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)]);
            }
        }
    }
Example #2
0
    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);
    }
Example #3
0
 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;
 }
Example #4
0
    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);
    }
Example #6
0
 private void OnTouchDown()
 {
     m_interactionsPressed |= XperAction.Touch;
     m_interactionsDown    |= XperAction.Touch;
     m_touched              = true;
 }
Example #7
0
 private void OnGripButton()
 {
     m_interactionsDown &= ~XperAction.Grip;
     m_interactionsUp   &= ~XperAction.Grip;
 }
Example #8
0
 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));
 }
Example #10
0
 public bool InteractionDown(XperAction action)
 {
     return((m_interactionsDown & action) == action);
 }
Example #11
0
 private void OnTouchPress()
 {
     m_interactionsDown &= ~XperAction.TouchPress;
     m_interactionsUp   &= ~XperAction.TouchPress;
 }
Example #12
0
 private void OnTouchPressDown()
 {
     m_interactionsPressed |= XperAction.TouchPress;
     m_interactionsDown    |= XperAction.TouchPress;
 }
Example #13
0
    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);
    }
Example #14
0
    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;
        }
    }
Example #15
0
 private void OnTouchUp()
 {
     m_interactionsPressed &= ~XperAction.Touch;
     m_interactionsUp      |= XperAction.Touch;
     m_touched              = false;
 }
Example #16
0
 private void OnTriggerButtonDown()
 {
     m_interactionsPressed |= XperAction.Trigger;
     m_interactionsDown    |= XperAction.Trigger;
 }
Example #17
0
 private void OnTriggerButtonUp()
 {
     m_interactionsPressed &= ~XperAction.Trigger;
     m_interactionsUp      |= XperAction.Trigger;
 }
Example #18
0
 private void OnTouchPressUp()
 {
     m_interactionsPressed &= ~XperAction.TouchPress;
     m_interactionsUp      |= XperAction.TouchPress;
 }
Example #19
0
 private void OnTriggerButton()
 {
     m_interactionsDown &= ~XperAction.Trigger;
     m_interactionsUp   &= ~XperAction.Trigger;
 }
Example #20
0
 public bool IsInteractionPressed(XperAction action)
 {
     return((m_interactionsPressed & action) == action);
 }
Example #21
0
 private void OnGripButtonDown()
 {
     m_interactionsPressed |= XperAction.Grip;
     m_interactionsDown    |= XperAction.Grip;
 }
Example #22
0
 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);
    }