示例#1
0
    private static void ProcessGrabIVBottleEvent(RPCVariable rpcVariable)
    {
        try {
            // decode variable
            var grabberSUID = (int)rpcVariable.floatValues[0];
            var IVBottleID  = (int)rpcVariable.floatValues[1];

            var targetBlackBoard = SyncVRNurseBlackboard.FindBlackBoard(grabberSUID);
            var targetIVBottle   = IVBottle.FindIVBottle(IVBottleID);

            // set the blackboard values
            targetBlackBoard.grabIVBottleID    = targetIVBottle.id;
            targetBlackBoard.grabActionTrigger = true;
        }
        catch (System.Exception e)
        {
            Debug.LogError(e.Message);
        }
    }
示例#2
0
    protected override IEnumerator NodeRunning()
    {
        _state = State.running;

        var nurseBB = blackboard as SyncVRNurseBlackboard;

        // set animation
        nurseBB.animator.SetTrigger("grab");
        nurseBB.grabActionTrigger = false;

        // wait till animation end or has another antion break this one
        const float ASSUME_GRAB_TIME = 2f;
        var         endTime          = Time.time + ASSUME_GRAB_TIME;

        while (Time.time < endTime)
        {
            yield return(null);

            if (nurseBB.hasAction)
            {
                break;
            }
        }

        // attached the bottle
        var bottle = IVBottle.FindIVBottle(nurseBB.grabIVBottleID);

        if (bottle && nurseBB.handAnchorPoint)
        {
            bottle.isOnGrab = true;
            bottle.transform.SetParent(transform);
            bottle.transform.localPosition = Vector3.zero;
        }

        if (nurseBB.hasAction)
        {
            _state = State.fail;
        }
        else
        {
            _state = State.success;
        }
    }