-
-
Notifications
You must be signed in to change notification settings - Fork 33
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
9 changed files
with
78 additions
and
19 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
using LCVR.Input; | ||
using LCVR.Player; | ||
using UnityEngine; | ||
using UnityEngine.XR; | ||
|
||
namespace LCVR.Items; | ||
|
||
public class VRBeltBagItem : VRItem<BeltBagItem> | ||
{ | ||
private ShakeDetector shake; | ||
private ShakeDetector shakeBig; | ||
private BeltBagInventoryUI inventoryUI; | ||
|
||
private float lastShakeTime; | ||
private float lastItemDrop; | ||
private float minWaitTime = 0.3f; | ||
|
||
protected override void Awake() | ||
{ | ||
base.Awake(); | ||
|
||
shake = new ShakeDetector(transform, 0.06f, true); | ||
shakeBig = new ShakeDetector(transform, 0.1f, true); | ||
inventoryUI = FindObjectOfType<BeltBagInventoryUI>(true); | ||
|
||
shake.onShake += () => | ||
{ | ||
if (Time.realtimeSinceStartup - lastShakeTime > 0.5f) | ||
return; | ||
|
||
if (item.currentPlayerChecking != StartOfRound.Instance.localPlayerController) | ||
return; | ||
|
||
if (transform.forward.y > -0.6) | ||
return; | ||
|
||
if (Time.realtimeSinceStartup - lastItemDrop < minWaitTime) | ||
return; | ||
|
||
if (item.objectsInBag.Count < 1) | ||
return; | ||
|
||
inventoryUI.RemoveItemFromUI(item.objectsInBag.Count - 1); | ||
lastItemDrop = Time.realtimeSinceStartup; | ||
lastShakeTime = Time.realtimeSinceStartup; | ||
minWaitTime = Random.Range(0.1f, 0.3f); | ||
|
||
RoundManager.PlayRandomClip(item.bagAudio, item.grabItemInBagSFX, audibleNoiseID: -1); | ||
VRSession.VibrateController(XRNode.RightHand, 0.1f, 0.5f); | ||
}; | ||
|
||
shakeBig.onShake += () => | ||
{ | ||
lastShakeTime = Time.realtimeSinceStartup; | ||
}; | ||
} | ||
|
||
protected override void OnUpdate() | ||
{ | ||
shake.Update(); | ||
shakeBig.Update(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters