Exemple #1
0
 void resetHand(VirtualHandInfo hand)
 {
     hand.state     = VirtualHandState.Open;
     hand.hand.type = AffectType.Virtual;
     if (hand.target != null)
     {
         Rigidbody rig = hand.target.GetComponent <Rigidbody> ();
         rig.isKinematic = false;
         rig.useGravity  = true;
         hand.target.transform.parent = world;
     }
     hand.target = null;
 }
Exemple #2
0
    void updateHand(VirtualHandInfo hi)
    {
        VirtualHandState state  = hi.state;
        Affect           hand   = hi.hand;
        CommonButton     button = hi.button;
        GameObject       target = hi.target;

        if (state == VirtualHandState.Open)
        {
            if (hand.triggerOngoing)
            {
                state = VirtualHandState.Touching;
            }
            else
            {
            }
        }
        else if (hi.state == VirtualHandState.Touching)
        {
            if (!hand.triggerOngoing)
            {
                // Change state to open
                state  = VirtualHandState.Open;
                target = null;
            }
            else
            {
                if (button.GetPress() && target == null && !hand.ongoingTriggers [0].GetComponent <Interactive>().isHeavy)
                {
                    target = hand.ongoingTriggers [0].gameObject;

                    JackHook jackHook = target.GetComponent <JackHook> ();
                    if (jackHook == null)
                    {
                        SnapTarget snap = target.GetComponent <SnapTarget> ();

                        if (snap != null && snap.state == FAFVR.SnapTargetState.Locked)
                        {
                            state  = VirtualHandState.Open;
                            target = null;
                        }
                        else
                        {
                            if (snap != null)
                            {
                                snap.setState(FAFVR.SnapTargetState.Holding);
                            }

                            TireIron ti = target.GetComponent <TireIron> ();
                            if (ti != null)
                            {
                                ti.SetStatus(TireIronStatus.OneHandHolding);
                            }
                            Rigidbody rig = target.GetComponent <Rigidbody> ();
                            rig.isKinematic         = true;
                            rig.useGravity          = false;
                            target.transform.parent = hand.gameObject.transform;
                            state = VirtualHandState.Holding;
                        }
                    }
                    else
                    {
                        if (jackHook.state == JackHookState.Open)
                        {
                            Rigidbody rig = target.GetComponent <Rigidbody> ();
                            rig.isKinematic         = true;
                            rig.useGravity          = false;
                            target.transform.parent = hand.gameObject.transform;
                            state = VirtualHandState.Holding;
                            jackHook.SetState(JackHookState.Holding);
                            jackHook.isRotating = false;
                        }
                        else if (jackHook.state == JackHookState.Connecting)
                        {
                            jackHook.isRotating = true;
                        }
                        else
                        {
                            jackHook.isRotating = false;
                        }
                    }
                }
            }
        }
        else if (hi.state == VirtualHandState.Holding)
        {
            if (target == null)
            {
                state = VirtualHandState.Open;
            }
            else
            {
                SnapTarget snap = target.GetComponent <SnapTarget> ();
                if (snap != null && snap.state == FAFVR.SnapTargetState.Locked)
                {
                    target.transform.parent = world;
                    target = null;
                    state  = VirtualHandState.Open;
                }
                else if (!button.GetPress() && target != null)
                {
                    Rigidbody rig = target.GetComponent <Rigidbody> ();
                    rig.isKinematic         = false;
                    rig.useGravity          = true;
                    target.transform.parent = world;

                    state = VirtualHandState.Open;

                    snap = target.GetComponent <SnapTarget> ();

                    if (snap != null)
                    {
                        snap.setState(FAFVR.SnapTargetState.Open);
                    }

                    if (target.GetComponent <JackHook> () != null)
                    {
                        target.GetComponent <JackHook> ().state = JackHookState.Open;
                    }
                    target = null;
                }
            }
        }

        hi.state  = state;
        hi.target = target;
    }