Exemplo n.º 1
0
    //protected virtual void Update()
    //{
    //    if (rumbling && interactableItem.AttachedHand != null)
    //    {
    //        interactableItem.AttachedHand.TriggerHapticPulse(500);
    //    }
    //}

    protected virtual void OnCollisionEnter(Collision collision)
    {
        if (!isActiveAndEnabled)
        {
            return;
        }

        var enemy       = collision.gameObject;
        var enemyHealth = enemy.GetComponent <EnemyHealth>();

        if (enemyHealth)
        {
            float damage = (collision.relativeVelocity.magnitude) * mDamageScale;
            enemyHealth.TakeDamage(damage);
            GetComponent <WeaponHealth>().TakeDamage(damage);

            if (interactableItem == null)
            {
                interactableItem = GetComponent <NewtonVR.NVRInteractableItem>();
            }
            if (interactableItem != null)
            {
                if (interactableItem.AttachedHand != null)
                {
                    rumbling = true;

                    interactableItem.AttachedHand.TriggerHapticPulse(1000, NewtonVR.NVRButtons.Touchpad);
                }
            }
        }
    }
Exemplo n.º 2
0
        protected virtual void Attach(NVRAttachPoint point)
        {
            point.Attached(this);

            AttachedItem  = point.Item;
            AttachedPoint = point;
        }
Exemplo n.º 3
0
        protected virtual void Attach(NVRAttachPoint point)
        {
            point.Attached(this);

            AttachedItem = point.Item;
            AttachedPoint = point;
        }
Exemplo n.º 4
0
    // Called in Update every frame while being held by a second hand
    // DON'T LET GO JACK ;(
    public override void OnSecondHandHold(NewtonVR.NVRInteractableItem nvrIItem)
    {
        float distBetweenHands = Vector3.Distance(nvrIItem.AttachedHands[0].transform.position, nvrIItem.AttachedHands[1].transform.position);

        AdjustBlendShapes(distBetweenHands);

        // Stretch Weapon
        ScaleModelToPositions(gameObject, nvrIItem.AttachedHands[0].transform.position, nvrIItem.AttachedHands[1].transform.position);
    }
    // Called in Update every frame while being held by a second hand
    // DON'T LET GO JACK ;(
    public virtual void OnSecondHandHold(NewtonVR.NVRInteractableItem nvrIItem)
    {
        // Stretch Enemy
        StretchModelToPositions(enemyModelTransform, nvrIItem.AttachedHands[0].transform.position, nvrIItem.AttachedHands[1].transform.position);

        // Stretch Weapon
        if (spawnedWeapon)
        {
            ScaleModelToPositions(spawnedWeapon, nvrIItem.AttachedHands[0].transform.position, nvrIItem.AttachedHands[1].transform.position);
        }
    }
Exemplo n.º 6
0
        protected virtual void Detach()
        {
            if (AttachedPoint)
            {
                AttachedPoint.Detached(this);
            }

            AttachedItem       = null;
            AttachedPoint      = null;
            IsTryingToAttach   = false;
            TryingToAttachItem = null;
        }
Exemplo n.º 7
0
        protected virtual void Awake()
        {
            IsAttached = false;

            Item = FindNVRItem(this.gameObject);
            if (Item == null)
            {
                Debug.LogError("No NVRInteractableItem found on this object. " + this.gameObject.name, this.gameObject);
            }

            AttachPointMapper.Register(this.GetComponent<Collider>(), this);
        }
Exemplo n.º 8
0
        protected virtual void Awake()
        {
            IsAttached = false;

            Item = FindNVRItem(this.gameObject);
            if (Item == null)
            {
                Debug.LogError("No NVRInteractableItem found on this object. " + this.gameObject.name, this.gameObject);
            }

            AttachPointMapper.Register(this.GetComponent <Collider>(), this);
        }
Exemplo n.º 9
0
        protected virtual void Awake()
        {
            IsAttached = false;

            Item = FindNVRItem(this.gameObject);
            if (Item == null)
            {
                Debug.LogError("No NVRInteractableItem found on this object. " + this.gameObject.name, this.gameObject);
            }

            // In case of collider not existing in the same entity, then allow user to assign one for this attach point
            //Collider thisCollider = (ThisCollider != null) ? ThisCollider: this.GetComponent<Collider>();
            //AttachPointMapper.Register(thisCollider, this);
        }
Exemplo n.º 10
0
        protected virtual void Detach()
        {
            OnDetach(AttachedPoint);
            AttachedPoint.Detached(this);

            if (SetKinematicWhenAttached)
            {
                AttachedItem.Rigidbody.isKinematic = _itemKinematicStatePreAttach;
            }
            // AttachedItem.EndInteraction();

            AttachedItem  = null;
            AttachedPoint = null;
        }
Exemplo n.º 11
0
    // Use this for initialization
    void Start()
    {
        leftController                = SteamVR_Controller.GetDeviceIndex(SteamVR_Controller.DeviceRelation.Leftmost);
        leftController                = SteamVR_Controller.GetDeviceIndex(SteamVR_Controller.DeviceRelation.Rightmost);
        rightControlStickOrigin       = transform.FindChild("RightControlStickReference");
        leftControlStickOrigin        = transform.FindChild("LeftControlStickReference");
        rightControlStickPosition     = transform.FindChild("RightControlStick");
        leftControlStickPosition      = transform.FindChild("LeftControlStick");
        rightInteractableControlStick = transform.FindChild("RightControlStick").GetComponent <NewtonVR.NVRInteractableItem>();
        leftInteractableControlStick  = transform.FindChild("LeftControlStick").GetComponent <NewtonVR.NVRInteractableItem>();

        desiredYRotation = transform.parent.rotation.eulerAngles.y;

        Debug.Log(transform.parent.name);
    }
Exemplo n.º 12
0
        private NVRInteractableItem FindNVRItem(GameObject gameobject)
        {
            NVRInteractableItem item = gameobject.GetComponent <NVRInteractableItem>();

            if (item != null)
            {
                return(item);
            }

            if (gameobject.transform.parent != null)
            {
                return(FindNVRItem(gameobject.transform.parent.gameObject));
            }

            return(null);
        }
    // Called once one hand lets go. Aka only 1 hand is left holding on
    public virtual void OnSecondHandReleased(NewtonVR.NVRHand handStillHolding, NewtonVR.NVRInteractableItem nvrIItem)
    {
        // End interaction with Enemy
        handStillHolding.EndInteraction(nvrIItem);

        // Enable weapon Colliders until ready to be used
        foreach (Collider c in spawnedWeapon.GetComponentsInChildren <Collider>())
        {
            c.enabled = true;
        }

        // Start Interaction with Weapon
        handStillHolding.BeginInteraction(spawnedWeapon.GetComponent <NewtonVR.NVRInteractable>());

        // Destroy Enemy
        Destroy(gameObject);
    }
Exemplo n.º 14
0
    IEnumerator ScanUpward()
    {
        burgerDetectionArea.transform.localPosition = startPoint;
        List <GameObject> ingredients = new List <GameObject> ();
        float             secondsSinceLastIngredient = 0;
        bool       foundNewIngredients = false;
        GameObject firstPlacard        = orderPlacards[0];
        var        deltaTime           = 0.008f;

        do
        {
            foundNewIngredients = false;
            Bounds     bounds     = burgerDetectionArea.GetComponent <Renderer>().bounds;
            Collider[] foundItems = Physics.OverlapBox(bounds.center, bounds.extents, burgerDetectionArea.transform.rotation);
            foreach (Collider foundItem in foundItems)
            {
                Ingredient foundIngredient = foundItem.GetComponent <Ingredient>();
                if (foundIngredient && !ingredients.Contains(foundIngredient.gameObject))
                {
                    NewtonVR.NVRInteractableItem nvri = foundIngredient.GetComponent <NewtonVR.NVRInteractableItem>();
                    if (nvri.AttachedHand == null)
                    {
                        foundNewIngredients = true;
                        ingredients.Add(foundIngredient.gameObject);
                        Debug.Log("Found ingredient: " + foundIngredient.ingredientName, foundIngredient.gameObject);
                    }
                }
            }
            if (foundNewIngredients)
            {
                secondsSinceLastIngredient = 0;
            }
            else
            {
                secondsSinceLastIngredient += deltaTime;
            }
            burgerDetectionArea.transform.localPosition = burgerDetectionArea.transform.localPosition + movementPerSecond * deltaTime;
        } while(secondsSinceLastIngredient < 0.05f);
        transform.localPosition = startPoint;
        ingredients.TrimExcess();
        if (ingredients.Capacity != 0)
        {
            FinalizeBurger(transform.parent.gameObject, ingredients);
        }
        yield return(null);
    }
Exemplo n.º 15
0
        protected virtual void Attach(NVRAttachPoint point)
        {
            OnAttach(point);
            point.Attached(this);

            AttachedItem  = point.Item;
            AttachedPoint = point;

            if (SnapToAttachPoint)
            {
                AttachedItem.transform.position = transform.position + (AttachedItem.transform.position - AttachedPoint.transform.position);
            }
            _itemKinematicStatePreAttach = AttachedItem.Rigidbody.isKinematic;
            if (SetKinematicWhenAttached)
            {
                AttachedItem.Rigidbody.isKinematic = true;
            }
        }
Exemplo n.º 16
0
        protected virtual void OnTriggerStay(Collider col)
        {
            if (IsAttached == false && CanAttach == true)
            {
                NVRAttachPoint point = AttachPointMapper.GetAttachPoint(col);
                if (point != null && point.IsAttached == false)
                {
                    float distance = Vector3.Distance(point.transform.position, this.transform.position);

                    if (distance < AttachRange)
                    {
                        Attach(point);
                    }
                    else
                    {
                        point.PullTowards(this);
                    }

                    IsTryingToAttach   = true;
                    TryingToAttachItem = col.gameObject.GetComponentInParent <NVRInteractableItem> ();
                }
            }
        }
Exemplo n.º 17
0
    IEnumerator CheckForPlacard()
    {
        while (true)
        {
            if (placardsInArea > 0)
            {
                bool unattachedBunFound = false;
                for (int i = 0; i < orderPlacards.Count; i++)
                {
                    NewtonVR.NVRInteractableItem nvri = orderPlacards[i].GetComponent <NewtonVR.NVRInteractableItem>();
                    if (nvri != null && nvri.AttachedHand == null)
                    {
                        unattachedBunFound = true;
                        break;
                    }
                }
                if (!unattachedBunFound)
                {
                    yield return(new WaitForSeconds(placardDetectionInterval));

                    continue;
                }
                placardResidentSeconds += placardDetectionInterval;
                if (placardResidentSeconds >= timeUntilOrderComplete)
                {
                    yield return(ScanUpward());

                    placardResidentSeconds = 0;
                }
            }
            else if (placardResidentSeconds > 0)
            {
                placardResidentSeconds = 0;
            }
            yield return(new WaitForSeconds(placardDetectionInterval));
        }
    }
Exemplo n.º 18
0
 protected virtual void Detach()
 {
     AttachedPoint.Detached(this);
     AttachedItem  = null;
     AttachedPoint = null;
 }
Exemplo n.º 19
0
 protected virtual void Start()
 {
     interactableItem = GetComponent <NewtonVR.NVRInteractableItem>();
 }
Exemplo n.º 20
0
 protected virtual void Detach()
 {
     AttachedPoint.Detached(this);
     AttachedItem = null;
     AttachedPoint = null;
 }
Exemplo n.º 21
0
 // Use this for initialization
 void Start()
 {
     stringOrigin       = stringBone.transform.localPosition;
     stringCollider     = stringBone.GetComponent <Collider>();
     interactableString = stringBone.GetComponent <NewtonVR.NVRInteractableItem>();
 }
Exemplo n.º 22
0
 // Called once one hand lets go. Aka only 1 hand is left holding on
 public override void OnSecondHandReleased(NewtonVR.NVRHand handStillHolding, NewtonVR.NVRInteractableItem nvrIItem)
 {
     Destroy(this);
 }
Exemplo n.º 23
0
 // Use this for initialization
 void Start()
 {
     i = GetComponent <NewtonVR.NVRInteractableItem> ();
     r = GetComponent <Rigidbody> ();
     e = GetComponent <Explo> ();
 }
Exemplo n.º 24
0
 protected virtual void OnTriggerExit(Collider col)
 {
     IsTryingToAttach   = false;
     TryingToAttachItem = null;
 }