//private void HitHaptics() //{ // for (int i = 1000; i > 0; i++) // { // if(i % 10 == 0) // { // HapticFeedback.HapticAmount((int)(1.5f * i), true, true); // } // } //} IEnumerator HitHaptics(float timeBetween) { for (int i = 5; i > 0; i--) { yield return(new WaitForSeconds(timeBetween)); HapticFeedback.HapticAmount((int)((200 * i) + 1000), true, false); } }
// Update is called once per frame void Update() { if (PlayerScript._deviceNonDominant.GetPressDown(SteamVR_Controller.ButtonMask.Touchpad) && !_isSettingMenuOpen) { _isSettingMenuOpen = true; _settingMenuObj.SetActive(true); HapticFeedback.HapticAmount(500, false, true); } if (_isSettingMenuOpen) { OpenSettings(); } }
void Update() { //if (_trackedObj.gameObject.activeInHierarchy) //{ // _device = SteamVR_Controller.Input((int)_trackedObj.index); //} if (PlayerScript._deviceDominant.GetPressDown(SteamVR_Controller.ButtonMask.Touchpad) && !_isInventoryOpen) { _isInventoryOpen = true; //CheckInventoryItemPlacement(); _inventoryObj.SetActive(true); //ShowInventoryItems(true); PostProcessControl.PostExposureFade(_exposureInventoryOn, _exposureFadeSpeed); //PostProcessControl.DOFFade(_focalLengthInventoryOn, _focusDistanceInventoryOn, _focalLengthFadeSpeed, _focusDistanceFadeSpeed); HapticFeedback.HapticAmount(500, true, false); PlaceItemsInInventory(false, true); CheckHandModelVisibility(); //_handModelObj.gameObject.SetActive(true); //if (_inHandObj != null) //{ // _inHandObj.SetActive(false); // _hasItemInHand = false; //} } if (_isInventoryOpen) { OpenInventory(); } //if (_hasItemInHand) //{ // _inHandObj.transform.position = Vector3.Lerp(_inHandObj.transform.position, transform.position, Time.deltaTime * 12f); // _inHandObj.transform.rotation = Quaternion.Slerp(_inHandObj.transform.rotation, transform.rotation, Time.deltaTime * 12f); //} else //{ // foreach (var slot in _inventorySlots) // { // if (slot.hasItemInHand) // { // PutInInventory(slot); // } // } //} }
private void ProgressBar() { if (PlayerScript._dominantHand.gameObject.activeInHierarchy && PlayerScript._nonDominnatHand.gameObject.activeInHierarchy) { if (_progressBarObj.fillAmount < 1) { if (PlayerScript._deviceDominant.GetPress(SteamVR_Controller.ButtonMask.Trigger) || PlayerScript._deviceDominant.GetPress(SteamVR_Controller.ButtonMask.Grip) || PlayerScript._deviceDominant.GetPress(SteamVR_Controller.ButtonMask.Touchpad) || PlayerScript._deviceDominant.GetPress(SteamVR_Controller.ButtonMask.ApplicationMenu) || PlayerScript._deviceNonDominant.GetPress(SteamVR_Controller.ButtonMask.Trigger) || PlayerScript._deviceNonDominant.GetPress(SteamVR_Controller.ButtonMask.Grip) || PlayerScript._deviceNonDominant.GetPress(SteamVR_Controller.ButtonMask.Touchpad) || PlayerScript._deviceNonDominant.GetPress(SteamVR_Controller.ButtonMask.ApplicationMenu)) { _progressBarObj.fillAmount += Time.deltaTime * .5f; if (_hapticClickTimer > 0) { _hapticClickTimer -= Time.deltaTime; } else { HapticFeedback.HapticAmount(500, true, true); } } else { if (_progressBarObj.fillAmount > 0) { _progressBarObj.fillAmount -= Time.deltaTime * .25f; } if (_progressBarObj.fillAmount <= 0) { _progressBarObj.fillAmount = 0; } } } else { if (!_isProgressBarFilled) { ProgressBarFilled(); _isProgressBarFilled = true; } } } }
public void Fire() { //print("Fired"); //shotTrail.Play(); muzzleFlash.Play(); RaycastHit hit; Ray ray = new Ray(shootPoint.transform.position, shootPoint.transform.forward); // Cast a ray that ignores triggers so we don't hit player trigger objects if (Physics.Raycast(ray, out hit, Mathf.Infinity, layerMask, QueryTriggerInteraction.Ignore)) { //if (!hit.collider.CompareTag("Enemy")) var hitPoint = hit.point; if (hit.collider.CompareTag("Destructible")) { Destructible destructible = hit.transform.GetComponent <Destructible>(); if (destructible != null) { destructible.DestroyIntoPieces(); } //AddExplosionForce(hit.point, explosionRadius, explosionForce); } else if (hit.collider.CompareTag("Enemy")) { //print("Enemy Hit: " + hit.collider.gameObject.name); //var hitDir = shootPoint.transform.position - hit.point; var hitDir = shootPoint.transform.forward; var parentObj = hit.collider.transform.parent; while (parentObj.GetComponent <Enemy>() == null) { parentObj = parentObj.transform.parent; //print("Going through while loop. Current Parent:" + parentObj.name); } //print("Enemy Hit: " + parentObj.name); Enemy enemy = parentObj.GetComponent <Enemy>(); enemy.EnemyTakeHit(_damage, hitDir, hit.collider.gameObject); //print("Enemy hit part: " + hit.collider.gameObject.name); //AddExplosionForce(hit.point, explosionRadius, explosionForce); //Collider[] colliders = Physics.OverlapSphere(hitPoint, 5f); //foreach (var col in colliders) //{ // print(col.gameObject.name); //} //print(colliders[0].gameObject.name); //if (colliders[0].transform.root.GetComponent<Enemy>() != null) //{ // colliders[0].transform.root.GetComponent<Enemy>().EnemyTakeHit(_damage); // print("Shot enemy - damage:" + _damage); //} //Enemy enemy = hit.transform.root.GetComponent<Enemy>(); //enemy.EnemyTakeHit(_damage); } else if (hit.collider.CompareTag("Rigidbody")) { AddExplosionForce(hit.point, _explosionRadius, _explosionForce, _explosionForceUp); } else { AddExplosionForce(hit.point, _explosionRadius, _explosionForce, _explosionForceUp); SpawnDecal(hit); } //_audioSource[0].PlayOneShot(clips[0]); //_audioSource[1].PlayOneShot(clips[1]); PlaySound.PlayAudio(_audioSource[0], true, -.15f, .15f); PlaySound.PlayAudio(_audioSource[1], false, 0, 0); clickSoundPlayed = false; HapticFeedback.HapticAmount(1000, true, false); //globalLowPass.GunShotLowPass(3000); //Debug.Log(hit.transform.name); gunBody.transform.localRotation = Quaternion.Euler(gunBody.transform.localRotation.x, gunBody.transform.localRotation.y, gunBody.transform.localRotation.z + recoilZAngle); } }
private void OpenSettings() { TouchpadEnabled(); if (PlayerScript._deviceNonDominant.GetPressUp(SteamVR_Controller.ButtonMask.Touchpad) && !_firstPressUp) { _firstPressUp = true; } if (PlayerScript._touchpadNonDominant.magnitude > .25f) { // Option Slot #1 - Resume if (_angleFromCenter > 210 && _angleFromCenter < 260) { _currentItem = 0; } // Option Slot #2 - Switch Hands else if (_angleFromCenter > 285 && _angleFromCenter < 335) { _currentItem = 1; } // Option Slot #3 - Graphics Settings else if (_angleFromCenter > 25 && _angleFromCenter < 75) { _currentItem = 2; } // Option Slot #3 - Quit else if (_angleFromCenter > 110 && _angleFromCenter < 160) { _currentItem = 3; } // No Option is selected else { _currentItem = -1; } } else { _currentItem = -1; } if (_currentItem != _oldItem) { if (_currentItem > -1) { foreach (var slot in _optionsSlots) { slot.optionOutline.color = _idleUIColor; slot.optionValue.color = _idleUIColor; if (slot.descriptionText != null) { slot.descriptionText.gameObject.SetActive(false); } } _optionsSlots[_currentItem].optionOutline.color = _highlightedUIColor; _optionsSlots[_currentItem].optionValue.color = _highlightedUIColor; if (_optionsSlots[_currentItem].descriptionText != null) { _optionsSlots[_currentItem].descriptionText.gameObject.SetActive(true); } HapticFeedback.HapticAmount(500, false, true); } else { foreach (var slot in _optionsSlots) { slot.optionOutline.color = _idleUIColor; if (slot.descriptionText != null) { slot.descriptionText.gameObject.SetActive(false); } } } _oldItem = _currentItem; } if (PlayerScript._deviceNonDominant.GetPressDown(SteamVR_Controller.ButtonMask.Touchpad) && _currentItem > -1 && _firstPressUp) { switch (_currentItem) { case 0: CloseInventory(); break; case 1: SwitchHands(); break; case 2: SwitchGraphics(); break; case 3: QuitApplication(); break; } //if (_optionsSlots[_currentItem]. != null) { //PutItemInHand(_inventorySlots[_currentItem]); HapticFeedback.HapticAmount(750, false, true); //_inventorySlots[_currentItem].hasItemInHand = true; //_handModelObj.SetActive(false); CloseInventory(); } //if (_inventorySlots[_currentItem].itemInHandObj != null) //{ // _inventorySlots[_currentItem].itemInHandObj.SetActive(true); // //objInHand.transform.position = transform.position; // //objInHand = itemList[currentItem].itemInHandObj; // //objInHand.SetActive(true); // _hasItemInHand = true; //} } if (PlayerScript._deviceNonDominant.GetPressDown(SteamVR_Controller.ButtonMask.Touchpad) && _firstPressUp & _currentItem == -1) { CloseInventory(); } }
public void OpenInventory() { TouchpadEnabled(); //ShowInventoryItems(false); if (PlayerScript._deviceDominant.GetPressUp(SteamVR_Controller.ButtonMask.Touchpad) && !_firstPressUp) { _firstPressUp = true; } if (PlayerScript._touchpadDominant.magnitude > .25f) { // Inventory Slot #1 if (_angleFromCenter > 275 && _angleFromCenter < 335) { _currentItem = 0; } // Inventiry Slot #2 else if (_angleFromCenter > 15 && _angleFromCenter < 75) { _currentItem = 1; } else { _currentItem = -1; } } else { _currentItem = -1; } if (_currentItem != _oldItem) { if (_currentItem > -1) { foreach (var slot in _inventorySlots) { slot.inventoryOutline.color = _idleUIColor; slot.textTag.gameObject.SetActive(false); } _inventorySlots[_currentItem].inventoryOutline.color = _highlightedUIColor; _inventorySlots[_currentItem].textTag.gameObject.SetActive(true); HapticFeedback.HapticAmount(500, true, false); _returnToFlashlightText.SetActive(false); } else { foreach (var slot in _inventorySlots) { slot.inventoryOutline.color = _idleUIColor; slot.textTag.gameObject.SetActive(false); } _returnToFlashlightText.SetActive(true); } _oldItem = _currentItem; } if (PlayerScript._deviceDominant.GetPressDown(SteamVR_Controller.ButtonMask.Touchpad) && _currentItem > -1 && _firstPressUp) { if (_inventorySlots[_currentItem].inventoryObj != null) { PutItemInHand(_inventorySlots[_currentItem]); HapticFeedback.HapticAmount(750, true, false); //_inventorySlots[_currentItem].hasItemInHand = true; //_handModelObj.SetActive(false); } CloseInventory(); //if (_inventorySlots[_currentItem].itemInHandObj != null) //{ // _inventorySlots[_currentItem].itemInHandObj.SetActive(true); // //objInHand.transform.position = transform.position; // //objInHand = itemList[currentItem].itemInHandObj; // //objInHand.SetActive(true); // _hasItemInHand = true; //} } if (PlayerScript._deviceDominant.GetPressDown(SteamVR_Controller.ButtonMask.Touchpad) && _firstPressUp & _currentItem == -1) { CloseInventory(); } }