test commit
This commit is contained in:
@@ -0,0 +1,39 @@
|
||||
using UnityEngine;
|
||||
using UnityEngine.InputSystem;
|
||||
|
||||
public class HeldInteractions : MonoBehaviour
|
||||
{
|
||||
[Header("Flashlight")]
|
||||
public GameObject Flashlight;
|
||||
public AudioSource FlashlightToggleSfx;
|
||||
public InputActionProperty FlashlightAction;
|
||||
[Header("Misc")]
|
||||
public GameObject Map;
|
||||
public InputActionProperty MapAction;
|
||||
|
||||
public bool OffHandFree => !Map.activeSelf;
|
||||
|
||||
bool justToggledLight;
|
||||
|
||||
private void Update()
|
||||
{
|
||||
var toggledMap = MapAction.action.WasPressedThisFrame();
|
||||
if (toggledMap) {
|
||||
Map.SetActive(!Map.activeSelf);
|
||||
}
|
||||
|
||||
var lightThreshold = 0.9f;
|
||||
var toggledLight = FlashlightAction.action.ReadValue<float>();
|
||||
if (toggledLight > lightThreshold && !justToggledLight) {
|
||||
justToggledLight = true;
|
||||
|
||||
Flashlight.SetActive(!Flashlight.activeSelf);
|
||||
|
||||
FlashlightToggleSfx.Stop();
|
||||
FlashlightToggleSfx.pitch = Random.Range(0.9f, 1.1f);
|
||||
FlashlightToggleSfx.Play();
|
||||
}
|
||||
if (toggledLight < lightThreshold)
|
||||
justToggledLight = false;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,2 @@
|
||||
fileFormatVersion: 2
|
||||
guid: aee63ebffe4d5fc498e51cc149510cb0
|
||||
@@ -0,0 +1,41 @@
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
|
||||
public class NearbyVignette : MonoBehaviour
|
||||
{
|
||||
public static NearbyVignette Instance;
|
||||
|
||||
public AudioSource Sound;
|
||||
public GameObject Vignette;
|
||||
|
||||
float showTime;
|
||||
float soundCooldown;
|
||||
|
||||
private void Awake()
|
||||
{
|
||||
Instance = this;
|
||||
}
|
||||
|
||||
private void Update()
|
||||
{
|
||||
if (Time.time < showTime)
|
||||
{
|
||||
Vignette.SetActive(true);
|
||||
} else
|
||||
{
|
||||
Vignette.SetActive(false);
|
||||
}
|
||||
}
|
||||
|
||||
public static void Show()
|
||||
{
|
||||
if (!Instance) return;
|
||||
|
||||
if (Time.time > Instance.soundCooldown)
|
||||
{
|
||||
Instance.soundCooldown = Time.time + 5;
|
||||
Instance.Sound.Play();
|
||||
}
|
||||
Instance.showTime = Time.time + 0.5f;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,2 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 2e55849e0e0aa1f488092a409e164aae
|
||||
@@ -0,0 +1,101 @@
|
||||
using UnityEngine;
|
||||
using UnityEngine.InputSystem;
|
||||
using UnityEngine.SceneManagement;
|
||||
using UnityEngine.XR.Interaction.Toolkit.Locomotion.Movement;
|
||||
|
||||
public class Player : MonoBehaviour
|
||||
{
|
||||
public static Player Instance;
|
||||
|
||||
public HeldInteractions HeldInteractions;
|
||||
|
||||
public Camera Camera;
|
||||
|
||||
[Header("Components")]
|
||||
public Spookys spookys;
|
||||
|
||||
[Header("Toggles")]
|
||||
public bool SpookyImages = true;
|
||||
|
||||
[Header("Collect Interaction")]
|
||||
public AudioSource CollectSound;
|
||||
public Transform CollectInteractor;
|
||||
public Transform CollectLocation;
|
||||
public float CollectGrabRange = 4;
|
||||
public float CollectRange = 2;
|
||||
|
||||
[Header("Anchors")]
|
||||
public Transform CustardAnchor;
|
||||
|
||||
[Header("Speeds")]
|
||||
public float WalkSpeed = 5;
|
||||
public float RunSpeed = 7.05f;
|
||||
|
||||
[Header("Movement")]
|
||||
public ContinuousMoveProvider MoveProvider;
|
||||
|
||||
[Header("Input")]
|
||||
public InputActionProperty CollectAction;
|
||||
public InputActionProperty RunAction;
|
||||
|
||||
[HideInInspector] public Transform Collecting;
|
||||
|
||||
[HideInInspector] public bool running = false;
|
||||
[HideInInspector] public bool collecting = false;
|
||||
|
||||
private void Awake()
|
||||
{
|
||||
Instance = this;
|
||||
}
|
||||
|
||||
private void Start()
|
||||
{
|
||||
spookys.enabled = SpookyImages;
|
||||
}
|
||||
|
||||
private void Update()
|
||||
{
|
||||
running = RunAction.action.ReadValue<float>() > 0.9f;
|
||||
collecting = CollectAction.action.ReadValue<float>() > 0.5f && HeldInteractions.OffHandFree;
|
||||
|
||||
MoveProvider.moveSpeed = (running) ? RunSpeed : WalkSpeed;
|
||||
}
|
||||
|
||||
public bool InRangeForCollectGrab(GameObject who)
|
||||
{
|
||||
return Vector3.Distance(who.transform.position, CollectInteractor.position) < CollectGrabRange;
|
||||
}
|
||||
|
||||
public bool InRangeForCollect(GameObject who)
|
||||
{
|
||||
return Vector3.Distance(who.transform.position, CollectLocation.position) < CollectRange;
|
||||
}
|
||||
|
||||
public void PlayCollectSound()
|
||||
{
|
||||
CollectSound.Stop();
|
||||
CollectSound.pitch = Random.Range(0.9f, 1.1f);
|
||||
CollectSound.Play();
|
||||
}
|
||||
|
||||
private void OnDrawGizmos()
|
||||
{
|
||||
if (CollectInteractor)
|
||||
{
|
||||
Gizmos.color = Color.pink;
|
||||
Gizmos.DrawLine(CollectInteractor.position, CollectInteractor.position + CollectInteractor.forward * CollectGrabRange);
|
||||
Gizmos.color = Color.white;
|
||||
}
|
||||
if (CollectLocation)
|
||||
{
|
||||
Gizmos.color = Color.purple;
|
||||
Gizmos.DrawWireSphere(CollectLocation.position, CollectRange);
|
||||
Gizmos.color = Color.white;
|
||||
}
|
||||
}
|
||||
|
||||
public void Kill()
|
||||
{
|
||||
SceneManager.LoadScene("Dead");
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,2 @@
|
||||
fileFormatVersion: 2
|
||||
guid: a3ee49617d057da48bed853744a85542
|
||||
@@ -0,0 +1,22 @@
|
||||
using UnityEngine;
|
||||
using UnityEngine.XR.Interaction.Toolkit.Locomotion.Movement;
|
||||
|
||||
public class PlayerFootsteps : MonoBehaviour
|
||||
{
|
||||
public ContinuousMoveProvider ContinuousMoveProvider;
|
||||
public AudioSource AudioSource;
|
||||
public float MaxVolume = 0.75f;
|
||||
|
||||
void Update()
|
||||
{
|
||||
if (!Player.Instance) return;
|
||||
|
||||
var input = ContinuousMoveProvider.leftHandMoveInput.ReadValue(); // fuck you, the actual game does it like this too.
|
||||
if (Mathf.Abs(input.x) + Mathf.Abs(input.y) > 0.1f)
|
||||
AudioSource.volume = Mathf.Lerp(AudioSource.volume, MaxVolume, Time.deltaTime * 20f);
|
||||
else
|
||||
AudioSource.volume = Mathf.Lerp(AudioSource.volume, 0, Time.deltaTime * 20f);
|
||||
|
||||
AudioSource.pitch = (Player.Instance.running) ? 1.5f : 1;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,2 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 561bbb499a68fb9438d8ffd25cf11325
|
||||
Reference in New Issue
Block a user