private void Awake()
    {
        lastMessage = new Message_ExtLight(false, false, false, networkUID);
        strobeLight = GetComponentInChildren <StrobeLightController>();
        VRInteractable navObject = FindInteractableWithName("Navigation Lights");

        if (navObject == null)
        {
            navObject = FindInteractableWithName("Nav Lights");
        }
        VRInteractable landingObject = FindInteractableWithName("Landing Lights");

        if (navObject != null)
        {
            navLever = navObject.gameObject.GetComponent <VRLever>();
            Debug.Log("Got navlight lever");
        }
        else
        {
            Debug.Log("Could not get navlight lever");
        }
        if (landingObject != null)
        {
            landingLever = landingObject.gameObject.GetComponent <VRLever>();
            Debug.Log("Got landing lever");
        }
        else
        {
            Debug.Log("Could not get landing lever");
        }
    }
Пример #2
0
    // destroy self and spawn pfx and sfx objects that will stick around to do fx stuff after i'm gone
    private void BreakSelf(Stimulus breakStim)
    {
        Debug.Log(gameObject + ", breaking self!");

        if (breakSFX != null)
        {
            GameObject sfx = (GameObject)Instantiate(breakSFX.gameObject, transform.position, transform.rotation) as GameObject;
            Destroy(sfx, 30f);

            RandomizedSFX rsfx = sfx.GetComponent <RandomizedSFX>();
            rsfx.PlaySFX();
        }

        if (breakPFX != null)
        {
            GameObject pfx = (GameObject)Instantiate(breakPFX, transform.position, transform.rotation) as GameObject;
            Destroy(pfx, 60f);
        }

        VRInteractable interactable = this.gameObject.GetComponent <VRInteractable>();

        if (interactable != null)
        {
            interactable.GetDropped(false);
        }


        Destroy(this.gameObject);
    }
Пример #3
0
 /// <summary>
 /// Stop hovering over this object indefinitely.
 /// </summary>
 /// <param name="interactable">The hover-locked VRInteractable to stop hovering over indefinitely.</param>
 /// <seealso cref="HoverLock"/>
 public void HoverUnlock(VRInteractable interactable)
 {
     if (hoveringInteractable == interactable)
     {
         hoverLocked = false;
     }
 }
Пример #4
0
 void OnStopInteractWith(VRInteractable interactable)
 {
     if (acquireTargetType == AcquireHoverTargetType.RayCast && VRPlayer.Instance.IsUsingSimulator)
     {
         acquirePoint.localPosition = Vector3.zero;
     }
 }
Пример #5
0
    private IEnumerator DrawButton()
    {
        // I ripped this from marsh's code soooooooooooooooooooo
        Log("Ripping off multiplayer");
        Transform ScenarioDisplay = GameObject.Find("InteractableCanvas").transform.GetChild(0).GetChild(6).GetChild(0).GetChild(1);

        if (ScenarioDisplay.name != "ScenarioDisplay")
        {
            Log($"ScenarioDisplay was wrong ({ScenarioDisplay.name}), trying other method");
            ScenarioDisplay = GameObject.Find("InteractableCanvas").transform.GetChild(0).GetChild(8).GetChild(0).GetChild(1);
            Log($"ScenarioDisplay now == {ScenarioDisplay.name}");
        }
        Transform mpButton = Instantiate(ScenarioDisplay.GetChild(9).gameObject, ScenarioDisplay).transform;

        Log("Multiplayer Button" + mpButton.name);
        mpButton.gameObject.SetActive(true);
        mpButton.name = "MPButton";
        mpButton.GetComponent <RectTransform>().localPosition = new Vector3(601, -325);
        mpButton.GetComponent <RectTransform>().sizeDelta     = new Vector2(70, 206.7f);
        mpButton.GetComponentInChildren <Text>().text         = "QL";
        mpButton.GetComponent <Image>().color    = Color.cyan;
        mpButton.GetComponent <Button>().onClick = new Button.ButtonClickedEvent();
        VRInteractable mpInteractable = mpButton.GetComponent <VRInteractable>();

        mpInteractable.interactableName = "QuickLoad";
        UnityAction UA = new UnityAction(StartLoad);

        mpInteractable.OnInteract = new UnityEvent();
        mpInteractable.OnInteract.AddListener(UA);
        yield return(null);
    }
Пример #6
0
    // Doing raycasting in Update instead of FixedUpdate because it's a costly procedure
    void Update()
    {
        _ray = new Ray(this.transform.position, this.transform.forward);

        if (Physics.Raycast(_ray, out _hit, _rayLength, _raycastMask))
        {
            if (_isGazeActive == false)
            {
                _isGazeActive         = true;
                _previousInteractable = null;
            }
            //find the interactable
            _interactable = _hit.collider.gameObject.GetComponent <VRInteractable> ();
            //only activate enter event if it's the first time looking at it
            if (_previousInteractable != _interactable)
            {
                _previousInteractable = _interactable;
                _interactable.enter();
            }
            //if input is pressed, activate event
            if (Input.GetAxis("Submit") == 1)
            {
                _interactable.input();
            }
        }
        else
        {
            //only activate leave event if it's the first time looking away
            if (_isGazeActive)
            {
                _interactable.leave();
                _isGazeActive = false;
            }
        }
    }
Пример #7
0
    // tracks currentInteractable as the wand passes through qualifying objects
    void OnTriggerEnter(Collider other)
    {
        VRInteractable collidedInteractable = CodeTools.GetComponentFromNearestAncestor <VRInteractable>(other.gameObject);

        if (collidedInteractable != null)
        {
            // if we don't already have this interactable on our list of ones we're selecting, then add it
            if (!currentSelection.Contains(collidedInteractable))
            {
                currentSelection.Add(collidedInteractable);
            }

            if (currentInteractable != null)
            {
                if (collidedInteractable != currentInteractable)
                {
                    Debug.Log(this + " just selected " + collidedInteractable.gameObject + ", but my currentInteractable is " + currentInteractable.gameObject + ", probably you just pushed the current interactable through something else.");
                }
            }
        }
        else
        {
//            if (other.gameObject != null)
//              Debug.Log("WandController collided with a non-VRInteractable object, so ignoring it; it's "+ other.gameObject);
        }
    }
Пример #8
0
        public override void Run()
        {
            Debug.Log("Creating Gear Stuck Up FlightWarning");


            SetHUDWarningText($"-[ GEAR FAILURE ]-");
            StartWarning();
            running = true;

            GameObject currentVehicle = VTOLAPI.instance.GetPlayersVehicleGameObject();

            gear = currentVehicle.GetComponentInChildren <GearAnimator>();

            GearAnimator.GearStates gearState = gear.GetCurrentState();
            if (gearState == GearAnimator.GearStates.Extended)
            {
                Color red = new Color();
                gear.statusLight.SetColor(red);
                gear.ExtendImmediate();
                foreach (VRInteractable interactable in currentVehicle.GetComponentsInChildren <VRInteractable>())
                {
                    if (interactable.name == "GearInteractable")
                    {
                        interactable.OnInteract.AddListener(stopFailure);
                        gearInteractable = interactable;
                        break;
                    }
                }

                StartCoroutine(FlashLightsRed());
            }
        }
Пример #9
0
 void OnStartInteractWith(VRInteractable interactable)
 {
     if (acquireTargetType == AcquireHoverTargetType.RayCast && VRPlayer.Instance.IsUsingSimulator)
     {
         acquirePoint.localPosition = acquirePoint.parent.InverseTransformPoint(interactable.transform.position);
     }
 }
Пример #10
0
 private void Awake()
 {
     mInteractable = GetComponent <VRInteractable>();
     if (mInteractable != null)
     {
         mInteractable.OnInteractionStartEvent.AddListener(OnButtonClick);
     }
 }
Пример #11
0
 private void Awake()
 {
     mInteractable = GetComponent <VRInteractable>();
     startPosition = transform.localPosition;
     startRotation = transform.localRotation;
     mInteractable.OnInteractionStartEvent.AddListener(OnStartInteracting);
     mInteractable.OnInteractionFinishedEvent.AddListener(OnStopInteracting);
 }
Пример #12
0
 /// <summary>
 /// Stop hovering over this object indefinitely.
 /// </summary>
 /// <param name="interactable">The hover-locked VRInteractable to stop hovering over indefinitely.</param>
 /// <seealso cref="HoverLock"/>
 public void HoverUnlock(VRInteractable interactable)
 {
     VRHandDebugLog("HoverUnlock " + interactable);
     if (hoveringInteractable == interactable)
     {
         hoverLocked = false;
     }
 }
Пример #13
0
 public void UpdateRotation(float newSpeed)
 {
     currentObjectInteractable = currentGameObj.GetComponent <VRInteractable>();
     if (currentObjectInteractable == null)
     {
         Debug.Log("Debug: no object selected");
         return;
     }
     currentObjectInteractable.ChangeRotation(newSpeed, currentAxis);
 }
Пример #14
0
 void Awake()
 {
     mImage        = GetComponent <Image>();
     mInteractable = GetComponent <VRInteractable>();
     mImage.color  = normalColor;
     mInteractable.OnHoveredInEvent.AddListener(OnHoverIn);
     mInteractable.OnHoveredOutEvent.AddListener(OnHoverOut);
     mInteractable.OnInteractionStartEvent.AddListener(InteractingStart);
     mInteractable.OnInteractionFinishedEvent.AddListener(InteractionStop);
 }
 private void Awake()
 {
     if (mSlider != null)
     {
         mSlider.OnReachLeftPolar.AddListener(OnReachLeft);
         mSlider.OnReachRightPolar.AddListener(OnReachRight);
     }
     mInteractable = GetComponent <VRInteractable>();
     mInteractable.OnInteractionStartEvent.AddListener(OnStartInteracting);
     mInteractable.OnInteractionFinishedEvent.AddListener(OnStopInteracting);
 }
Пример #16
0
    // this is called by an interactable when it decides to pair with this controller
    public bool PairWithInteractable(VRInteractable interactable)
    {
        if (currentInteractable != null)
        {
            Debug.LogError("Can't pair with " + interactable.gameObject + " because I'm already paired with " + currentInteractable);
            return(false);
        }

        currentInteractable = interactable;
        return(true);
    }
Пример #17
0
    // this is called by an interactable when it decides to unpair with this controller
    public bool UnpairWithInteractable(VRInteractable interactable)
    {
        if (currentInteractable != interactable)
        {
            Debug.LogError("Can't unpair from " + interactable.gameObject + " because I'm not paired with it, I'm paired with " + currentInteractable.gameObject);
            return(false);
        }

        currentInteractable = null;
        return(true);
    }
 private void Awake()
 {
     mInteractable = GetComponent <VRInteractable>();
     startPosition = transform.localPosition;
     startRotation = transform.localRotation;
     mInteractable.OnInteractionStartEvent.AddListener(OnStartInteracting);
     mInteractable.OnInteractionFinishedEvent.AddListener(OnStopInteracting);
     if (backtoStartPosition)
     {
         GetComponent <Rigidbody>().isKinematic = true;
     }
 }
Пример #19
0
    // tracks currentInteractable as the wand passes through qualifying objects
    void OnTriggerStay(Collider other)
    {
        VRInteractable collidedInteractable = CodeTools.GetComponentFromNearestAncestor <VRInteractable>(other.gameObject);

        if (collidedInteractable != null)
        {
            if (!currentSelection.Contains(collidedInteractable))
            {
                Debug.LogError(this.gameObject + " wand is OnTriggerStay() colliding with " + collidedInteractable.gameObject + " but it's not on the currentSelection list, but it should be!");
            }
        }
    }
    private void Awake()
    {
        mInteractable = GetComponent <VRInteractable>();
        if (mInteractable != null)
        {
            mInteractable.OnInteractionStartEvent.AddListener(OnStartInteracting);
            mInteractable.OnInteractionFinishedEvent.AddListener(OnStopInteracting);
        }

        fullOpenDirection  = Vector3.Cross(fullOpenPosition - door.position, doorOpenDirection);
        fullCloseDirection = Vector3.Cross(fullClosePosition - door.position, doorOpenDirection);
    }
Пример #21
0
 /// <summary>
 /// Switch to another hovering object which can be null
 /// </summary>
 /// <param name="target"></param>
 void SwitchHoveringObject(VRInteractable target)
 {
     if (target != currentHoveringObject)
     {
         if (currentHoveringObject != null)
         {
             currentHoveringObject.OnHoveredOut(this);
         }
         currentHoveringObject = target;
         if (currentHoveringObject != null)
         {
             currentHoveringObject.OnHoveredIn(this);
         }
     }
 }
    void Awake()
    {
        if (highlightTarget == null)
        {
            highlightTarget = transform;
        }
        mInteractable = GetComponent <VRInteractable>();
        mInteractable.OnHoveredInEvent.AddListener(OnHoverIn);
        mInteractable.OnHoveredOutEvent.AddListener(OnHoverOut);
        mInteractable.OnInteractionStartEvent.AddListener(InteractingStart);
        mInteractable.OnInteractionFinishedEvent.AddListener(InteractingStop);

        renderers     = highlightTarget.GetComponentsInChildren <MeshRenderer>(true);
        materialCache = renderers.ToDictionary <MeshRenderer, MeshRenderer, Material[]>(r => r, r => r.materials);
    }
Пример #23
0
    void OnTriggerExit(Collider other)
    {
        VRInteractable newInteractable = other.gameObject.GetComponent <VRInteractable>();

        if (newInteractable == null)
        {
            return;
        }

        if (currentInteractable != null)
        {
            if (currentInteractable == newInteractable)
            {
                currentInteractable = null;
            }
        }
    }
Пример #24
0
    void UpdateHovering()
    {
        if (hoverLocked)
        {
            return;
        }

        float          closestDistance     = float.MaxValue;
        VRInteractable closestInteractable = null;

        // Pick the closest hovering
        Collider[] overlappingColliders = Physics.OverlapSphere(hoverSphereTransform.position, hoverSphereRadius, hoverLayerMask.value);
        foreach (Collider collider in overlappingColliders)
        {
            VRInteractable contacting = collider.GetComponentInParent <VRInteractable>();

            // Yeah, it's null, skip
            if (contacting == null)
            {
                continue;
            }

            // Can't hover over the object if it's attached
            if (attachedObjects.FindIndex(l => l.attachedObject == contacting.gameObject) != -1)
            {
                continue;
            }

            // Occupied by another hand, so we can't touch it
            if (otherHand && otherHand.hoveringInteractable == contacting)
            {
                continue;
            }

            // Best candidate so far...
            float distance = Vector3.Distance(contacting.transform.position, transform.position);
            if (distance < closestDistance)
            {
                closestDistance     = distance;
                closestInteractable = contacting;
            }
        }

        // Hover on this one
        hoveringInteractable = closestInteractable;
    }
Пример #25
0
 void SwitchInteractingObject(VRInteractable target)
 {
     if (target != currentInteractingObject)
     {
         if (currentInteractingObject != null)
         {
             OnStopInteractWith(currentInteractingObject);
             currentInteractingObject.OnInteractionFinished(this);
         }
         currentInteractingObject = target;
         if (currentInteractingObject != null)
         {
             OnStartInteractWith(currentInteractingObject);
             currentInteractingObject.OnInteractionStart(this);
         }
     }
 }
Пример #26
0
    // tracks currentInteractable as the wand passes through qualifying objects
    void OnTriggerExit(Collider other)
    {
        VRInteractable collidedInteractable = CodeTools.GetComponentFromNearestAncestor <VRInteractable>(other.gameObject);

        if (collidedInteractable == null)
        {
            return;
        }

        if (currentSelection.Contains(collidedInteractable))
        {
            currentSelection.Remove(collidedInteractable);
        }
        else
        {
            Debug.LogError(this.gameObject + " wand called OnTriggerExit() with " + collidedInteractable.gameObject + " but it's not on the currentSelection list, but it should be!");
        }
    }
Пример #27
0
	/// <summary>
	/// Stop hovering over this object indefinitely.
	/// </summary>
	/// <param name="interactable">The hover-locked VRInteractable to stop hovering over indefinitely.</param>
	/// <seealso cref="HoverLock"/>
	public void HoverUnlock( VRInteractable interactable )
	{
		if ( hoveringInteractable == interactable )
		{
			hoverLocked = false;
		}
	}
Пример #28
0
	/// <summary>
	/// Continue to hover over this object indefinitely, whether or not the VRHand moves out of its interaction trigger volume.
	/// </summary>
	/// <param name="interactable">The VRInteractable to hover over indefinitely.</param>
	/// <seealso cref="HoverUnlock"/>
	public void HoverLock( VRInteractable interactable )
	{
		hoverLocked = true;
		hoveringInteractable = interactable;
	}
	/// <summary>
	/// Continue to hover over this object indefinitely, whether or not the VRHand moves out of its interaction trigger volume.
	/// </summary>
	/// <param name="interactable">The VRInteractable to hover over indefinitely.</param>
	/// <seealso cref="HoverUnlock"/>
	public void HoverLock( VRInteractable interactable )
	{
		VRHandDebugLog( "HoverLock " + interactable );
		hoverLocked = true;
		hoveringInteractable = interactable;
	}
	/// <summary>
	/// Stop hovering over this object indefinitely.
	/// </summary>
	/// <param name="interactable">The hover-locked VRInteractable to stop hovering over indefinitely.</param>
	/// <seealso cref="HoverLock"/>
	public void HoverUnlock( VRInteractable interactable )
	{
		VRHandDebugLog( "HoverUnlock " + interactable );
		if ( hoveringInteractable == interactable )
		{
			hoverLocked = false;
		}
	}