test commit
This commit is contained in:
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 6732934a9598fba419c6098a7b9519b6
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,39 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
public class VolumetricAudio : MonoBehaviour
|
||||
{
|
||||
// old ass "pingvin mod v2" code LOL
|
||||
public float fully2DDistance = 2f;
|
||||
public float fully3DDistance = 10f;
|
||||
public AudioSource audioSource;
|
||||
|
||||
private void Awake()
|
||||
{
|
||||
if (audioSource == null)
|
||||
audioSource = GetComponent<AudioSource>();
|
||||
}
|
||||
|
||||
private void OnDrawGizmos()
|
||||
{
|
||||
Gizmos.color = new Color(1, 0, 0, 0.25f);
|
||||
Gizmos.DrawWireSphere(this.transform.position, fully3DDistance);
|
||||
Gizmos.color = new Color(0, 1, 0, 0.25f);
|
||||
Gizmos.DrawWireSphere(this.transform.position, fully2DDistance);
|
||||
Gizmos.color = Color.white;
|
||||
}
|
||||
|
||||
void Update()
|
||||
{
|
||||
if (!Camera.main)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
float distance = Vector3.Distance(Camera.main.transform.position, transform.position);
|
||||
|
||||
//audioSource.spatialBlend = Mathf.Lerp(audioSource.spatialBlend, Mathf.InverseLerp(fully2DDistance, fully3DDistance, distance), Time.deltaTime * 10f);
|
||||
audioSource.spatialBlend = Mathf.InverseLerp(fully2DDistance, fully3DDistance, distance);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,2 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 1673d1041edc561429aceac69808abdf
|
||||
@@ -0,0 +1,53 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using UnityEngine;
|
||||
using UnityEngine.SceneManagement;
|
||||
|
||||
public class CollectGamemode : MonoBehaviour
|
||||
{
|
||||
public static CollectGamemode Instance;
|
||||
|
||||
public AudioSource CollectSound;
|
||||
|
||||
public List<Custard> Custards { get; private set; } = new();
|
||||
|
||||
public int CustardAmount { get; private set; }
|
||||
public int CollectedCustard { get; private set; }
|
||||
|
||||
private void Awake()
|
||||
{
|
||||
Instance = this;
|
||||
|
||||
Custards = FindObjectsByType<Custard>().ToList();
|
||||
CustardAmount = Custards.Count;
|
||||
}
|
||||
|
||||
private void Start()
|
||||
{
|
||||
PopUps.Create($"COLLECT ALL 10\nTELETUBBY CUSTARDS");
|
||||
}
|
||||
|
||||
public void CollectCustard(Custard custard)
|
||||
{
|
||||
bool removed = Custards.Remove(custard);
|
||||
if (removed)
|
||||
{
|
||||
if (TinkyWinky.Instance)
|
||||
TinkyWinky.Instance.recentlyCollectedCustard = custard.transform.position;
|
||||
|
||||
Destroy(custard.gameObject);
|
||||
CollectedCustard++;
|
||||
|
||||
if (CollectSound)
|
||||
CollectSound.Play();
|
||||
|
||||
if (CollectedCustard >= CustardAmount)
|
||||
SceneManager.LoadScene("Orientation"); // PLACEHOLDER
|
||||
|
||||
PopUps.Create($"{CollectedCustard}/{CustardAmount}\nCUSTARDS COLLECTED");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,2 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 2dd22d2a5fc8224419947747e297c831
|
||||
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 772d5a32edd52a74b989e7770fd2a177
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,33 @@
|
||||
using UnityEngine;
|
||||
using UnityEngine.Events;
|
||||
|
||||
public class Custard : Grabbable
|
||||
{
|
||||
public UnityEvent OnCollect;
|
||||
|
||||
public override void OnPlayerCollect()
|
||||
{
|
||||
base.OnPlayerCollect();
|
||||
|
||||
if (CollectGamemode.Instance)
|
||||
CollectGamemode.Instance.CollectCustard(this);
|
||||
else
|
||||
Destroy(this.gameObject);
|
||||
|
||||
Player.Instance.PlayCollectSound();
|
||||
|
||||
if (OnCollect != null)
|
||||
OnCollect.Invoke();
|
||||
|
||||
if (DummyWinky.Instance && DummyWinky.Instance.unleashed)
|
||||
{
|
||||
float dist = Vector3.Distance(this.transform.position, DummyWinky.Instance.transform.position);
|
||||
if (dist < 100)
|
||||
{
|
||||
rb.isKinematic = true;
|
||||
rb.useGravity = false;
|
||||
this.transform.position = Vector3.MoveTowards(this.transform.position, DummyWinky.Instance.transform.position, Time.deltaTime);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,2 @@
|
||||
fileFormatVersion: 2
|
||||
guid: f3cff10c742e6df48bca14457e106872
|
||||
@@ -0,0 +1,70 @@
|
||||
using UnityEngine;
|
||||
using UnityEngine.Events;
|
||||
|
||||
public class Custard : MonoBehaviour
|
||||
{
|
||||
public UnityEvent OnCollect;
|
||||
|
||||
Rigidbody rb;
|
||||
MeshCollider collider;
|
||||
|
||||
bool wasCollecting = false;
|
||||
bool smoothing = false;
|
||||
bool lockSmoothing = false;
|
||||
bool interactedWith = false;
|
||||
|
||||
private void Awake()
|
||||
{
|
||||
collider = GetComponent<MeshCollider>();
|
||||
rb = GetComponent<Rigidbody>();
|
||||
}
|
||||
|
||||
void Update()
|
||||
{
|
||||
if (!Player.Instance) return;
|
||||
|
||||
if (Vector3.Distance(this.transform.position, Player.Instance.CustardAnchor.position) < 0.5f || lockSmoothing)
|
||||
smoothing = false;
|
||||
else
|
||||
smoothing = true;
|
||||
|
||||
if (Player.Instance.collecting && Player.Instance.InRangeForCollectGrab(gameObject))
|
||||
{
|
||||
if (!smoothing)
|
||||
lockSmoothing = true;
|
||||
|
||||
wasCollecting = true;
|
||||
interactedWith = true;
|
||||
|
||||
this.transform.position = Vector3.Lerp(this.transform.position, Player.Instance.CustardAnchor.position, (smoothing) ? Time.deltaTime * 10f : 1);
|
||||
this.transform.rotation = Quaternion.Lerp(this.transform.rotation, Player.Instance.CustardAnchor.rotation, (smoothing) ? Time.deltaTime * 10f : 1);
|
||||
|
||||
collider.enabled = false;
|
||||
rb.isKinematic = true;
|
||||
} else
|
||||
{
|
||||
lockSmoothing = false;
|
||||
|
||||
if (wasCollecting)
|
||||
{
|
||||
if (Player.Instance.InRangeForCollect(gameObject))
|
||||
{
|
||||
if (CollectGamemode.Instance)
|
||||
CollectGamemode.Instance.CollectCustard(this);
|
||||
else
|
||||
Destroy(this.gameObject);
|
||||
|
||||
Player.Instance.PlayCollectSound();
|
||||
|
||||
if (OnCollect != null)
|
||||
OnCollect.Invoke();
|
||||
}
|
||||
}
|
||||
wasCollecting = false;
|
||||
|
||||
collider.enabled = true;
|
||||
if (interactedWith)
|
||||
rb.isKinematic = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
fileFormatVersion: 2
|
||||
guid: bf88c66af797d93498a5bcee47950bd7
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 6d66547db928f61448eb289bfc899999
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,34 @@
|
||||
using NUnit.Framework;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using TMPro;
|
||||
using UnityEngine;
|
||||
using UnityEngine.AI;
|
||||
|
||||
public class DummyWinky : MonoBehaviour
|
||||
{
|
||||
public static DummyWinky Instance;
|
||||
|
||||
private void Awake()
|
||||
{
|
||||
Instance = this;
|
||||
}
|
||||
|
||||
public bool unleashed = false;
|
||||
public void Unleash()
|
||||
{
|
||||
unleashed = true;
|
||||
}
|
||||
|
||||
private void Update()
|
||||
{
|
||||
if (unleashed)
|
||||
{
|
||||
Vector3 normalized2 = (this.transform.position - Player.Instance.Camera.transform.position).normalized;
|
||||
this.transform.localScale += Vector3.one * Time.deltaTime;
|
||||
this.transform.LookAt(Player.Instance.transform.position);
|
||||
this.transform.position -= normalized2 * Time.deltaTime * 3;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,2 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 1eb97d07c3f34ae4199bf0bbcd3d4b07
|
||||
@@ -0,0 +1,555 @@
|
||||
using NUnit.Framework;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using TMPro;
|
||||
using UnityEngine;
|
||||
using UnityEngine.AI;
|
||||
using UnityEngine.Diagnostics;
|
||||
using UnityEngine.SceneManagement;
|
||||
|
||||
public class TinkyWinky : MonoBehaviour
|
||||
{
|
||||
// singleton
|
||||
public static TinkyWinky Instance;
|
||||
|
||||
// const
|
||||
private const float offscreenDotRange = 0.7f;
|
||||
private const float minDistanceForChase = 20f;
|
||||
private const float minGazeTimeForChase = 2f;
|
||||
private const float minIgnoredNearbyTimeForChase = 15f;
|
||||
private const float minGazeTimeForDeath = 6f;
|
||||
|
||||
private const float minDistanceForStalk = 100f;
|
||||
private const float maxDistanceForStalk = 200f;
|
||||
private const float keptDistanceForStalk = 30f;
|
||||
|
||||
private const float loseChaseDuration = 45f;
|
||||
private const float loseChaseDistance = 50f;
|
||||
|
||||
private const float pathRefreshInterval = 0.25f;
|
||||
|
||||
// state
|
||||
public enum States
|
||||
{
|
||||
None,
|
||||
Idle,
|
||||
Wander,
|
||||
Stalk,
|
||||
Chase
|
||||
}
|
||||
public States ActiveState { get; private set; } = States.None;
|
||||
public States NextState { get; private set; } = States.None;
|
||||
|
||||
[Header("Setup")]
|
||||
public NavMeshAgent Agent;
|
||||
public LayerMask LayerMask;
|
||||
public Vector3 RaycastOffset;
|
||||
[Header("Stats")]
|
||||
public float WalkSpeed = 3;
|
||||
public float RunSpeed = 7;
|
||||
public float KillRange = 1f;
|
||||
public Vector3 KillOffset;
|
||||
[Header("the SCARY stuff")]
|
||||
public int SprintOnlyCustardThreshold = 2;
|
||||
[Header("Visuals")]
|
||||
public Transform Model;
|
||||
public MeshRenderer MeshRenderer;
|
||||
public Texture2D ChaseFace;
|
||||
public Texture2D NormalFace;
|
||||
[Header("Audio")]
|
||||
public AudioSource FootstepSource;
|
||||
public AudioSource EhOhSource;
|
||||
public AudioSource ScreamSource;
|
||||
public float MaxFootstepVolume = 0.3f;
|
||||
|
||||
// behaviour stuff
|
||||
int custardCount => (CollectGamemode.Instance) ? CollectGamemode.Instance.CustardAmount - CollectGamemode.Instance.CollectedCustard : 99;
|
||||
List<Custard> custards => CollectGamemode.Instance.Custards ?? null;
|
||||
GameObject[] fallbackSpots;
|
||||
|
||||
float speed;
|
||||
|
||||
Vector3? targetPosition;
|
||||
[HideInInspector] public Vector3? recentlyCollectedCustard;
|
||||
|
||||
float nextStalkRefresh;
|
||||
float nextChaseRefresh;
|
||||
float nextTargetInvalidation;
|
||||
float nextTeleport;
|
||||
|
||||
float chaseDuration;
|
||||
float gazeDurationInStalk;
|
||||
float ignoredNearbyDurationInStalk;
|
||||
float gazeDurationInChase;
|
||||
|
||||
float timeSinceTooDistant;
|
||||
|
||||
bool chargeTowardPlayerInWander;
|
||||
bool angeredInStalk;
|
||||
|
||||
bool saidEhOh;
|
||||
|
||||
bool nightmare;
|
||||
|
||||
bool isOffscreen;
|
||||
|
||||
private void Awake()
|
||||
{
|
||||
Instance = this;
|
||||
}
|
||||
|
||||
private void Start()
|
||||
{
|
||||
if (DynamicTime.Instance)
|
||||
nightmare = DynamicTime.Instance.ActiveTOD == DynamicTime.TimeOfDay.Nightmare;
|
||||
|
||||
if (nightmare)
|
||||
{
|
||||
WalkSpeed = RunSpeed / 1.2f;
|
||||
MaxFootstepVolume /= 2;
|
||||
}
|
||||
|
||||
fallbackSpots = GameObject.FindGameObjectsWithTag("Fallback Spot");
|
||||
StartCoroutine(StateUpdate());
|
||||
}
|
||||
|
||||
private void LateUpdate()
|
||||
{
|
||||
isOffscreen = CheckIfOffScreen();
|
||||
}
|
||||
|
||||
private void Update()
|
||||
{
|
||||
if (Player.Instance) {
|
||||
Model.LookAt(Player.Instance.Camera.transform.position);
|
||||
Model.transform.eulerAngles = new Vector3(-90, Model.transform.eulerAngles.y, Model.transform.eulerAngles.z);
|
||||
if (Vector3.Distance(this.transform.position + KillOffset, Player.Instance.transform.position) < KillRange)
|
||||
Player.Instance.Kill();
|
||||
}
|
||||
|
||||
if (Agent.desiredVelocity.sqrMagnitude > 0.1f)
|
||||
FootstepSource.volume = Mathf.Lerp(FootstepSource.volume, 0.3f, Time.deltaTime * 20f);
|
||||
else
|
||||
FootstepSource.volume = Mathf.Lerp(FootstepSource.volume, 0f, Time.deltaTime * 20f);
|
||||
|
||||
Agent.speed = speed;
|
||||
}
|
||||
|
||||
IEnumerator StateUpdate()
|
||||
{
|
||||
while (true)
|
||||
{
|
||||
switch (ActiveState)
|
||||
{
|
||||
case States.None:
|
||||
case States.Idle:
|
||||
RequestState(States.Wander);
|
||||
break;
|
||||
case States.Wander:
|
||||
yield return WanderUpdate();
|
||||
break;
|
||||
case States.Stalk:
|
||||
yield return StalkUpdate();
|
||||
break;
|
||||
case States.Chase:
|
||||
yield return ChaseUpdate();
|
||||
break;
|
||||
}
|
||||
|
||||
if (NextState == ActiveState) NextState = States.None;
|
||||
if (NextState != States.None)
|
||||
{
|
||||
targetPosition = null;
|
||||
Agent.ResetPath();
|
||||
|
||||
chaseDuration = 0;
|
||||
gazeDurationInStalk = 0;
|
||||
gazeDurationInChase = 0;
|
||||
ignoredNearbyDurationInStalk = 0;
|
||||
|
||||
angeredInStalk = false;
|
||||
chargeTowardPlayerInWander = false;
|
||||
|
||||
timeSinceTooDistant = 0;
|
||||
|
||||
ActiveState = NextState;
|
||||
NextState = States.None;
|
||||
|
||||
if (ActiveState == States.Chase) {
|
||||
MeshRenderer.materials[0].SetTexture("_BaseMap", ChaseFace);
|
||||
ScreamSource.Play();
|
||||
|
||||
this.transform.position = GetChaseTeleportPosition();
|
||||
} else
|
||||
{
|
||||
MeshRenderer.materials[0].SetTexture("_BaseMap", NormalFace);
|
||||
}
|
||||
}
|
||||
|
||||
yield return new WaitForEndOfFrame();
|
||||
}
|
||||
}
|
||||
|
||||
IEnumerator ChaseUpdate()
|
||||
{
|
||||
if (!Player.Instance) {
|
||||
RequestState(States.Idle);
|
||||
yield break;
|
||||
}
|
||||
|
||||
float tpChance = 0; // used to be rng too
|
||||
if (nightmare)
|
||||
tpChance = (isOffscreen) ? 80 : 90;
|
||||
else
|
||||
tpChance = (isOffscreen) ? 50 : 80;
|
||||
|
||||
speed = (isOffscreen) ? RunSpeed/1.2f : RunSpeed*3;
|
||||
|
||||
if (!isOffscreen)
|
||||
NearbyVignette.Show();
|
||||
|
||||
if (Time.time > nextChaseRefresh)
|
||||
{
|
||||
if (gazeDurationInChase < 3 && Random.Range(0, 100) < tpChance && Vector3.Distance(this.transform.position + KillOffset, Player.Instance.transform.position) > KillRange * 2 && Time.time > nextTeleport)
|
||||
{
|
||||
Agent.ResetPath();
|
||||
|
||||
this.transform.position = GetChaseTeleportPosition();
|
||||
nextTeleport = Time.time + Random.Range(1f,2f);
|
||||
}
|
||||
|
||||
Agent.SetDestination(GetNavPosition(Player.Instance.transform.position));
|
||||
nextChaseRefresh = Time.time + pathRefreshInterval;
|
||||
}
|
||||
|
||||
if (!isOffscreen)
|
||||
gazeDurationInChase = Mathf.Clamp(gazeDurationInChase + Time.deltaTime, 0, 10f);
|
||||
else
|
||||
gazeDurationInChase = Mathf.Clamp(gazeDurationInChase - Time.deltaTime * 2f, 0, 10f);
|
||||
|
||||
chaseDuration += (isOffscreen) ? Time.deltaTime * 2 : Time.deltaTime;
|
||||
|
||||
if (gazeDurationInChase > minGazeTimeForDeath)
|
||||
Player.Instance.Kill();
|
||||
|
||||
if (chaseDuration >= loseChaseDuration || Vector3.Distance(this.transform.position, Player.Instance.transform.position) > loseChaseDistance)
|
||||
{
|
||||
this.transform.position = fallbackSpots[Random.Range(0, fallbackSpots.Length)].transform.position;
|
||||
RequestState(States.Idle);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
IEnumerator StalkUpdate()
|
||||
{
|
||||
if (!Player.Instance) yield break;
|
||||
|
||||
if (angeredInStalk || nightmare)
|
||||
{
|
||||
speed = (!nightmare) ? RunSpeed * 2 : RunSpeed * 3;
|
||||
|
||||
if (Time.time > nextChaseRefresh)
|
||||
{
|
||||
Agent.SetDestination(GetNavPosition(Player.Instance.transform.position));
|
||||
nextChaseRefresh = Time.time + pathRefreshInterval;
|
||||
}
|
||||
|
||||
if (PlayerDistance() <= minDistanceForChase / 1.5f) // replace back to 1.75 if range too big
|
||||
RequestState(States.Chase);
|
||||
|
||||
yield break;
|
||||
}
|
||||
|
||||
if (PlayerDistance() > minDistanceForStalk/2)
|
||||
{
|
||||
speed = RunSpeed * 4;
|
||||
if (Time.time > nextChaseRefresh)
|
||||
{
|
||||
Agent.SetDestination(GetNavPosition(Player.Instance.transform.position - Player.Instance.transform.forward * keptDistanceForStalk));
|
||||
nextChaseRefresh = Time.time + pathRefreshInterval;
|
||||
}
|
||||
|
||||
yield break;
|
||||
}
|
||||
|
||||
if (PlayerDistance() >= maxDistanceForStalk)
|
||||
{
|
||||
RequestState(States.Wander);
|
||||
yield break;
|
||||
}
|
||||
|
||||
speed = WalkSpeed * 1.5f;
|
||||
|
||||
if ((!targetPosition.HasValue || ReachedDestination()) && Time.time > nextStalkRefresh)
|
||||
{
|
||||
targetPosition = GetStalkPosition();
|
||||
Agent.SetDestination(targetPosition.Value);
|
||||
nextStalkRefresh = Time.time + Random.Range(5,10);
|
||||
}
|
||||
|
||||
if (!isOffscreen)
|
||||
{
|
||||
float multi = 1f;
|
||||
|
||||
// pure evil
|
||||
if (PlayerDistance() <= keptDistanceForStalk)
|
||||
multi += 1.5f;
|
||||
if (PlayerDistance() <= keptDistanceForStalk/2)
|
||||
multi += 1.5f;
|
||||
|
||||
gazeDurationInStalk = Mathf.Clamp(gazeDurationInStalk + Time.deltaTime * multi, 0, minGazeTimeForChase);
|
||||
|
||||
ignoredNearbyDurationInStalk = Mathf.Clamp(ignoredNearbyDurationInStalk - Time.deltaTime * 2, 0, ignoredNearbyDurationInStalk);
|
||||
if (gazeDurationInStalk > 0.5f && !saidEhOh)
|
||||
{
|
||||
saidEhOh = true;
|
||||
EhOhSource.Play();
|
||||
}
|
||||
|
||||
Agent.isStopped = true;
|
||||
}
|
||||
else {
|
||||
gazeDurationInStalk = Mathf.Clamp(gazeDurationInStalk - Time.deltaTime / 2f, 0, minGazeTimeForChase);
|
||||
if (PlayerDistance() <= keptDistanceForStalk * 1.2f)
|
||||
ignoredNearbyDurationInStalk = Mathf.Clamp(ignoredNearbyDurationInStalk + Time.deltaTime, 0, ignoredNearbyDurationInStalk);
|
||||
|
||||
Agent.isStopped = false;
|
||||
}
|
||||
|
||||
if ((gazeDurationInStalk >= minGazeTimeForChase || ignoredNearbyDurationInStalk >= minIgnoredNearbyTimeForChase) && PlayerDistance() <= minDistanceForChase * 2)
|
||||
angeredInStalk = true;
|
||||
|
||||
if (PlayerDistance() <= minDistanceForChase / 1.75f)
|
||||
RequestState(States.Chase);
|
||||
|
||||
yield break;
|
||||
}
|
||||
|
||||
IEnumerator WanderUpdate()
|
||||
{
|
||||
if (nightmare && Player.Instance || chargeTowardPlayerInWander)
|
||||
{
|
||||
speed = RunSpeed * 4;
|
||||
if (Time.time > nextChaseRefresh)
|
||||
{
|
||||
Agent.SetDestination(GetNavPosition(Player.Instance.transform.position));
|
||||
nextChaseRefresh = Time.time + pathRefreshInterval;
|
||||
}
|
||||
|
||||
if (NextState < States.Stalk)
|
||||
{
|
||||
if (isOffscreen && PlayerDistance() <= minDistanceForStalk && !chargeTowardPlayerInWander)
|
||||
RequestState(States.Stalk);
|
||||
if (!isOffscreen && PlayerDistance() <= minDistanceForChase)
|
||||
RequestState(States.Chase);
|
||||
if (PlayerDistance() <= minDistanceForChase / 1.25f)
|
||||
RequestState(States.Chase);
|
||||
}
|
||||
|
||||
yield break;
|
||||
}
|
||||
|
||||
if (Player.Instance)
|
||||
{
|
||||
// "behind u" logic stuff
|
||||
if (PlayerDistance() <= minDistanceForStalk)
|
||||
timeSinceTooDistant = 0;
|
||||
|
||||
if (PlayerDistance() > minDistanceForStalk)
|
||||
timeSinceTooDistant += Time.deltaTime;
|
||||
|
||||
if (PlayerDistance() > minDistanceForStalk * 2)
|
||||
timeSinceTooDistant += Time.deltaTime;
|
||||
|
||||
if (PlayerDistance() > keptDistanceForStalk * 1.1f && custardCount <= 4)
|
||||
timeSinceTooDistant += Time.deltaTime;
|
||||
|
||||
if (timeSinceTooDistant > 15)
|
||||
{
|
||||
Agent.ResetPath();
|
||||
timeSinceTooDistant = 0;
|
||||
|
||||
Vector3 behind = GetNavPosition(Player.Instance.Camera.transform.position - Player.Instance.Camera.transform.forward * minDistanceForStalk / 1.25f);
|
||||
Vector3 front = GetNavPosition(Player.Instance.Camera.transform.position + Player.Instance.Camera.transform.forward * minDistanceForStalk / 1.25f);
|
||||
|
||||
if (Random.Range(0, 100) < 50 && custardCount <= 2)
|
||||
{
|
||||
// tinky casually rushing towards you from the fog in front of you
|
||||
if (Random.Range(0, 100) < 60)
|
||||
chargeTowardPlayerInWander = true;
|
||||
|
||||
this.transform.position = front;
|
||||
}
|
||||
else {
|
||||
this.transform.position = behind;
|
||||
}
|
||||
|
||||
yield break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (custards != null)
|
||||
speed = (custards.Count <= SprintOnlyCustardThreshold) ? RunSpeed : WalkSpeed;
|
||||
else
|
||||
speed = WalkSpeed;
|
||||
|
||||
if (Random.Range(0, 1000) < 5 && Time.time > nextTargetInvalidation) {
|
||||
nextTargetInvalidation = Time.time + Random.Range(10, 40);
|
||||
targetPosition = null;
|
||||
}
|
||||
|
||||
if (recentlyCollectedCustard == null) {
|
||||
if (!targetPosition.HasValue || ReachedDestination())
|
||||
{
|
||||
if (Random.Range(0, 100) < 10 && custards != null)
|
||||
{
|
||||
var custard = custards[Random.Range(0, custards.Count)];
|
||||
targetPosition = GetNavPosition(custard.transform.position);
|
||||
}
|
||||
else {
|
||||
targetPosition = GetNavPosition(this.transform.position + (Random.insideUnitSphere * 40));
|
||||
}
|
||||
|
||||
if (Random.Range(0, 100) < 20 || Random.Range(0, 100) < 70 && custardCount < SprintOnlyCustardThreshold)
|
||||
targetPosition = GetNavPosition(Player.Instance.transform.position + (Random.insideUnitSphere * 15));
|
||||
|
||||
Agent.SetDestination(targetPosition.Value);
|
||||
}
|
||||
} else
|
||||
{
|
||||
targetPosition = recentlyCollectedCustard;
|
||||
Agent.SetDestination(targetPosition.Value);
|
||||
recentlyCollectedCustard = null;
|
||||
}
|
||||
|
||||
if (NextState < States.Stalk)
|
||||
{
|
||||
if (isOffscreen && PlayerDistance() <= minDistanceForStalk)
|
||||
RequestState(States.Stalk);
|
||||
if (!isOffscreen && PlayerDistance() <= minDistanceForChase)
|
||||
RequestState(States.Chase);
|
||||
if (PlayerDistance() <= minDistanceForChase / 1.25f)
|
||||
RequestState(States.Chase);
|
||||
}
|
||||
|
||||
yield break;
|
||||
}
|
||||
|
||||
public void RequestState(States state)
|
||||
{
|
||||
NextState = state;
|
||||
}
|
||||
|
||||
public float PlayerDistance()
|
||||
{
|
||||
if (!Player.Instance) return 0;
|
||||
|
||||
return Vector3.Distance(this.transform.position, Player.Instance.transform.position);
|
||||
}
|
||||
|
||||
public bool CheckIfOffScreen(bool blockedCheck = false) // use isOffscreen instead of this
|
||||
{
|
||||
if (!Player.Instance) return true;
|
||||
|
||||
Vector3 normalized = Player.Instance.Camera.transform.forward.normalized;
|
||||
Vector3 normalized2 = (Player.Instance.Camera.transform.position - (this.transform.position + RaycastOffset)).normalized;
|
||||
float num = Vector3.Dot(normalized, normalized2);
|
||||
|
||||
bool blocked = true;
|
||||
RaycastHit hit;
|
||||
if (Physics.Raycast(this.transform.position + RaycastOffset, normalized2, out hit, 1000f, LayerMask))
|
||||
if (hit.transform.CompareTag("Player"))
|
||||
blocked = false;
|
||||
|
||||
if (num < offscreenDotRange && (!blocked || !blockedCheck))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
private void OnDrawGizmos()
|
||||
{
|
||||
Gizmos.color = Color.green;
|
||||
if (targetPosition != null)
|
||||
Gizmos.DrawLine(this.transform.position, targetPosition.Value);
|
||||
|
||||
Gizmos.color = Color.pink;
|
||||
if (recentlyCollectedCustard != null)
|
||||
Gizmos.DrawLine(this.transform.position, recentlyCollectedCustard.Value);
|
||||
|
||||
Gizmos.color = new Color(1f, 0.5f, 0f, 0.5f);
|
||||
Gizmos.DrawWireSphere(this.transform.position, minDistanceForStalk);
|
||||
|
||||
Gizmos.color = new Color(1f, 0.25f, 0f, 0.25f);
|
||||
Gizmos.DrawWireSphere(this.transform.position, keptDistanceForStalk);
|
||||
|
||||
Gizmos.color = new Color(1f, 0f, 0f, 0.1f);
|
||||
Gizmos.DrawWireSphere(this.transform.position, minDistanceForChase);
|
||||
Gizmos.color = new Color(1f, 0f, 0f, 0.25f);
|
||||
Gizmos.DrawWireSphere(this.transform.position, minDistanceForChase / 1.25f);
|
||||
Gizmos.color = new Color(1f, 0f, 0f, 1f);
|
||||
Gizmos.DrawWireSphere(this.transform.position, minDistanceForChase / 1.75f);
|
||||
|
||||
Gizmos.color = Color.red;
|
||||
Gizmos.DrawLine(this.transform.position + RaycastOffset, this.transform.position + RaycastOffset + this.transform.forward * 10f);
|
||||
|
||||
Gizmos.color = Color.lightPink;
|
||||
Gizmos.DrawWireSphere(this.transform.position + KillOffset, KillRange);
|
||||
|
||||
Gizmos.color = Color.white;
|
||||
}
|
||||
|
||||
private bool ReachedDestination()
|
||||
{
|
||||
if (Agent.pathPending)
|
||||
return false;
|
||||
if (Agent.remainingDistance > Agent.stoppingDistance + 0.25f)
|
||||
return false;
|
||||
|
||||
return !Agent.hasPath || Agent.velocity.sqrMagnitude < 0.01f;
|
||||
}
|
||||
|
||||
private Vector3 GetNavPosition(Vector3 pos)
|
||||
{
|
||||
NavMeshHit hit;
|
||||
if (NavMesh.SamplePosition(pos, out hit, 5f, NavMesh.AllAreas))
|
||||
return hit.position;
|
||||
|
||||
return Agent.transform.position;
|
||||
}
|
||||
|
||||
private Vector3 GetStalkPosition()
|
||||
{
|
||||
float back = Random.Range(keptDistanceForStalk / 2f, keptDistanceForStalk);
|
||||
|
||||
float side = Random.Range(-keptDistanceForStalk / 4f, keptDistanceForStalk / 4f);
|
||||
|
||||
Vector3 desired = Player.Instance.transform.position - (Player.Instance.transform.forward * back) + (Player.Instance.transform.right * side);
|
||||
|
||||
NavMeshHit hit;
|
||||
if (NavMesh.SamplePosition(desired, out hit, 5f, NavMesh.AllAreas))
|
||||
return hit.position;
|
||||
|
||||
return Agent.transform.position;
|
||||
}
|
||||
|
||||
private Vector3 GetChaseTeleportPosition()
|
||||
{
|
||||
float side = Random.Range(-keptDistanceForStalk / 5f, keptDistanceForStalk / 5f);
|
||||
float dist = Vector3.Distance(this.transform.position, Player.Instance.transform.position);
|
||||
|
||||
Vector3 desired = Player.Instance.transform.position + (Player.Instance.transform.forward * dist) + (Player.Instance.transform.right * side);
|
||||
|
||||
NavMeshHit hit;
|
||||
if (NavMesh.SamplePosition(desired, out hit, 5f, NavMesh.AllAreas))
|
||||
return hit.position;
|
||||
|
||||
return Agent.transform.position;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,2 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 1c494df9d7e33f645997302b855b3ec6
|
||||
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: a17ea036e7a202544ba1e2818d6231b7
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,36 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using UnityEngine;
|
||||
|
||||
public class TreeFallTrigger : MonoBehaviour
|
||||
{
|
||||
AudioSource source;
|
||||
Animation anim;
|
||||
|
||||
bool fell = false;
|
||||
|
||||
private void Awake()
|
||||
{
|
||||
source = GetComponent<AudioSource>();
|
||||
anim = GetComponent<Animation>();
|
||||
if (!anim)
|
||||
anim = GetComponentInParent<Animation>();
|
||||
}
|
||||
|
||||
private void OnTriggerEnter(Collider other)
|
||||
{
|
||||
if (Random.Range(0, 100) < 50) return;
|
||||
|
||||
if (other.CompareTag("Player") && !fell)
|
||||
{
|
||||
fell = true;
|
||||
|
||||
if (!anim || !source) return;
|
||||
|
||||
anim.Play("fall");
|
||||
source.Play();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,2 @@
|
||||
fileFormatVersion: 2
|
||||
guid: ef339f08da140604cb439333b2b4beba
|
||||
@@ -0,0 +1,86 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using UnityEngine;
|
||||
using UnityEngine.Events;
|
||||
|
||||
public class Grabbable : MonoBehaviour
|
||||
{
|
||||
protected Rigidbody rb;
|
||||
protected Collider collider;
|
||||
|
||||
bool wasCollecting = false;
|
||||
bool smoothing = false;
|
||||
bool lockSmoothing = false;
|
||||
bool interactedWith = false;
|
||||
|
||||
public virtual void OnPlayerCollect() { }
|
||||
|
||||
private void Awake()
|
||||
{
|
||||
collider = GetComponent<Collider>();
|
||||
rb = GetComponent<Rigidbody>();
|
||||
}
|
||||
|
||||
void Update()
|
||||
{
|
||||
if (!Player.Instance) return;
|
||||
|
||||
if (Vector3.Distance(transform.position, Player.Instance.CustardAnchor.position) < 0.5f || lockSmoothing)
|
||||
smoothing = false;
|
||||
else
|
||||
smoothing = true;
|
||||
|
||||
bool playerCollecting = Player.Instance.collecting && Player.Instance.InRangeForCollectGrab(gameObject);
|
||||
|
||||
if (playerCollecting) {
|
||||
if (Player.Instance.Collecting == null)
|
||||
Player.Instance.Collecting = transform;
|
||||
} else
|
||||
{
|
||||
if (Player.Instance.Collecting == transform)
|
||||
Player.Instance.Collecting = null;
|
||||
}
|
||||
|
||||
if (Player.Instance.Collecting == transform)
|
||||
{
|
||||
if (!smoothing)
|
||||
lockSmoothing = true;
|
||||
|
||||
wasCollecting = true;
|
||||
interactedWith = true;
|
||||
|
||||
transform.position = Vector3.Lerp(transform.position, Player.Instance.CustardAnchor.position, (smoothing) ? Time.deltaTime * 10f : 1);
|
||||
transform.rotation = Quaternion.Lerp(transform.rotation, Player.Instance.CustardAnchor.rotation, (smoothing) ? Time.deltaTime * 10f : 1);
|
||||
|
||||
collider.enabled = false;
|
||||
rb.isKinematic = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
lockSmoothing = false;
|
||||
|
||||
if (wasCollecting)
|
||||
{
|
||||
if (Player.Instance.InRangeForCollect(gameObject))
|
||||
OnPlayerCollect();
|
||||
}
|
||||
wasCollecting = false;
|
||||
|
||||
collider.enabled = true;
|
||||
if (interactedWith)
|
||||
rb.isKinematic = false;
|
||||
}
|
||||
}
|
||||
|
||||
private void OnDrawGizmos()
|
||||
{
|
||||
if (!Player.Instance) return;
|
||||
|
||||
Gizmos.color = Color.pink;
|
||||
Gizmos.DrawWireSphere(transform.position, Player.Instance.CollectGrabRange);
|
||||
Gizmos.color = Color.white;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,2 @@
|
||||
fileFormatVersion: 2
|
||||
guid: c25b59cd85ea2b6419d41113e1fee776
|
||||
@@ -0,0 +1,21 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using UnityEngine;
|
||||
using UnityEngine.SceneManagement;
|
||||
|
||||
public class LandLoader : MonoBehaviour
|
||||
{
|
||||
public string SceneName;
|
||||
public DynamicTime.TimeOfDay TOD;
|
||||
|
||||
public void Load()
|
||||
{
|
||||
PlayerPrefs.SetInt(DynamicTime.PlayerPrefsKey, (int)TOD);
|
||||
PlayerPrefs.Save();
|
||||
|
||||
SceneManager.LoadScene(SceneName);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,2 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 45b3dd2433015464baf0a8fd4704cadf
|
||||
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: b2ac1b6127ea9fe4d9df4f6ee13eed3a
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,22 @@
|
||||
using UnityEngine;
|
||||
|
||||
public class TinkyUnleashingSequence : MonoBehaviour
|
||||
{
|
||||
public DummyWinky dummyWinky;
|
||||
public Animator animator;
|
||||
|
||||
bool played = false;
|
||||
|
||||
public void Play()
|
||||
{
|
||||
if (played) return;
|
||||
played = true;
|
||||
|
||||
animator.Play("Unleash", 0, 0);
|
||||
}
|
||||
|
||||
public void WinkyEvent()
|
||||
{
|
||||
dummyWinky.Unleash();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,2 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 83fdad43615f9104a981586edd5010f8
|
||||
@@ -0,0 +1,17 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using UnityEngine;
|
||||
|
||||
public class UnleasherButton : MonoBehaviour
|
||||
{
|
||||
public TinkyUnleashingSequence sequence;
|
||||
|
||||
private void OnTriggerEnter(Collider other)
|
||||
{
|
||||
if (other.CompareTag("Player Hand") || other.gameObject.layer == 3)
|
||||
sequence.Play();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,2 @@
|
||||
fileFormatVersion: 2
|
||||
guid: c3609886a5a72634cb583a3e3e05e9db
|
||||
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: e5cc8fd743518a2439a63194ca05474d
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -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
|
||||
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: fc91ea0b122f06649be79a1a79fe1e10
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,117 @@
|
||||
using System;
|
||||
using UnityEngine;
|
||||
using UnityEngine.Rendering;
|
||||
|
||||
public class DynamicTime : MonoBehaviour
|
||||
{
|
||||
public static DynamicTime Instance;
|
||||
|
||||
public const string PlayerPrefsKey = "SelectedTOD";
|
||||
|
||||
[Serializable]
|
||||
public class TimePreset
|
||||
{
|
||||
[Header("Sky")]
|
||||
public Material Skybox;
|
||||
[Header("Ambient Lighting")]
|
||||
public float AmbientIntensity;
|
||||
public Color AmbientSkyColor;
|
||||
public Color AmbientEquatorColor;
|
||||
public Color AmbientGroundColor;
|
||||
public AmbientMode AmbientMode;
|
||||
[Header("Fog")]
|
||||
public bool Fog;
|
||||
public float FogDensity;
|
||||
public float FogStartDistance;
|
||||
public float FogEndDistance;
|
||||
public Color FogColor;
|
||||
public FogMode FogMode;
|
||||
[Header("Objects")]
|
||||
public GameObject[] ObjectsToEnable;
|
||||
public GameObject[] ObjectsToDisable;
|
||||
|
||||
internal TimeOfDay tod;
|
||||
}
|
||||
|
||||
public enum TimeOfDay
|
||||
{
|
||||
Day,
|
||||
Dusk,
|
||||
Dawn,
|
||||
Night,
|
||||
Nightmare
|
||||
}
|
||||
|
||||
public TimePreset DayPreset = new();
|
||||
public TimePreset DuskPreset = new();
|
||||
public TimePreset DawnPreset = new();
|
||||
public TimePreset NightPreset = new();
|
||||
public TimePreset NightmarePreset = new();
|
||||
|
||||
public TimeOfDay ActiveTOD;
|
||||
|
||||
private void Awake()
|
||||
{
|
||||
Instance = this;
|
||||
DayPreset.tod = TimeOfDay.Day;
|
||||
DuskPreset.tod = TimeOfDay.Dusk;
|
||||
DawnPreset.tod = TimeOfDay.Dawn;
|
||||
NightPreset.tod = TimeOfDay.Night;
|
||||
NightmarePreset.tod = TimeOfDay.Nightmare;
|
||||
}
|
||||
|
||||
private void Start()
|
||||
{
|
||||
if (PlayerPrefs.HasKey(PlayerPrefsKey))
|
||||
ActiveTOD = (TimeOfDay)PlayerPrefs.GetInt(PlayerPrefsKey, 0);
|
||||
SetTime(ActiveTOD);
|
||||
}
|
||||
|
||||
private TimePreset GetTimePreset(TimeOfDay tod)
|
||||
{
|
||||
switch (tod)
|
||||
{
|
||||
case TimeOfDay.Day:
|
||||
return DayPreset;
|
||||
case TimeOfDay.Dusk:
|
||||
return DuskPreset;
|
||||
case TimeOfDay.Dawn:
|
||||
return DawnPreset;
|
||||
case TimeOfDay.Night:
|
||||
return NightPreset;
|
||||
case TimeOfDay.Nightmare:
|
||||
return NightmarePreset;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public void SetTime(TimeOfDay tod)
|
||||
{
|
||||
var preset = GetTimePreset(tod);
|
||||
if (preset != null)
|
||||
ApplyTimePreset(preset);
|
||||
}
|
||||
|
||||
private void ApplyTimePreset(TimePreset preset)
|
||||
{
|
||||
RenderSettings.skybox = preset.Skybox;
|
||||
|
||||
RenderSettings.ambientIntensity = preset.AmbientIntensity;
|
||||
RenderSettings.ambientMode = preset.AmbientMode;
|
||||
RenderSettings.ambientSkyColor = preset.AmbientSkyColor;
|
||||
RenderSettings.ambientEquatorColor = preset.AmbientEquatorColor;
|
||||
RenderSettings.ambientGroundColor = preset.AmbientGroundColor;
|
||||
|
||||
RenderSettings.fog = preset.Fog;
|
||||
RenderSettings.fogColor = preset.FogColor;
|
||||
RenderSettings.fogDensity = preset.FogDensity;
|
||||
RenderSettings.fogStartDistance = preset.FogStartDistance;
|
||||
RenderSettings.fogEndDistance = preset.FogEndDistance;
|
||||
RenderSettings.fogMode = preset.FogMode;
|
||||
|
||||
foreach (var obj in preset.ObjectsToEnable)
|
||||
obj.SetActive(true);
|
||||
foreach (var obj in preset.ObjectsToDisable)
|
||||
obj.SetActive(false);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,2 @@
|
||||
fileFormatVersion: 2
|
||||
guid: a6461d4e68515944cab4c02ec103c266
|
||||
@@ -0,0 +1,37 @@
|
||||
using TMPro;
|
||||
using UnityEngine;
|
||||
|
||||
public class PopUp : MonoBehaviour
|
||||
{
|
||||
public TMP_Text Text;
|
||||
public float DestroyTime = 5;
|
||||
|
||||
float timeSinceCreation;
|
||||
|
||||
Vector3 offset;
|
||||
bool dropDown;
|
||||
|
||||
private void Start()
|
||||
{
|
||||
timeSinceCreation = Time.time;
|
||||
offset.y = -100;
|
||||
}
|
||||
|
||||
private void Update()
|
||||
{
|
||||
if (!Player.Instance) return;
|
||||
|
||||
if (dropDown)
|
||||
offset.y = Mathf.Lerp(offset.y, -100, Time.deltaTime / 2f);
|
||||
else
|
||||
offset.y = Mathf.Lerp(offset.y, 0, Time.deltaTime * 5f);
|
||||
|
||||
this.transform.position = Vector3.Lerp(this.transform.position, Player.Instance.Camera.transform.position + (Player.Instance.Camera.transform.forward * 5) + offset, Time.deltaTime * 10f);
|
||||
this.transform.rotation = Quaternion.Lerp(this.transform.rotation, Player.Instance.Camera.transform.rotation, Time.deltaTime * 10f);
|
||||
|
||||
if (Time.time > timeSinceCreation + (DestroyTime - 1))
|
||||
dropDown = true;
|
||||
if (Time.time > timeSinceCreation + DestroyTime)
|
||||
Destroy(this.gameObject);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,2 @@
|
||||
fileFormatVersion: 2
|
||||
guid: d1c53045ddfc26a41bcc0f670daee19a
|
||||
@@ -0,0 +1,29 @@
|
||||
using TMPro;
|
||||
using UnityEngine;
|
||||
|
||||
public class PopUps : MonoBehaviour
|
||||
{
|
||||
public static PopUps Instance;
|
||||
|
||||
public GameObject PopUpPrefab;
|
||||
GameObject currentObject;
|
||||
|
||||
private void Awake()
|
||||
{
|
||||
Instance = this;
|
||||
}
|
||||
|
||||
public static void Create(string text = "hello world", float duration = 8)
|
||||
{
|
||||
if (!Instance)
|
||||
return;
|
||||
if (Instance.currentObject)
|
||||
Destroy(Instance.currentObject);
|
||||
|
||||
Instance.currentObject = Instantiate(Instance.PopUpPrefab);
|
||||
|
||||
var popUp = Instance.currentObject.GetComponent<PopUp>();
|
||||
popUp.Text.text = text;
|
||||
popUp.DestroyTime = duration;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,2 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 623944eda42f405499d92a0b05832064
|
||||
@@ -0,0 +1,70 @@
|
||||
using System.Collections;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
|
||||
public class Spookys : MonoBehaviour
|
||||
{
|
||||
public AudioSource AudioSource;
|
||||
public RawImage RawImage;
|
||||
public Texture2D[] Textures;
|
||||
public Texture2D TinkyNear;
|
||||
|
||||
public bool doNow;
|
||||
|
||||
float extraTime = 0;
|
||||
|
||||
private void Update()
|
||||
{
|
||||
extraTime += Time.deltaTime / 10;
|
||||
if (extraTime > 60)
|
||||
extraTime = 60;
|
||||
}
|
||||
|
||||
IEnumerator Loop()
|
||||
{
|
||||
AudioSource.Stop();
|
||||
RawImage.enabled = false;
|
||||
|
||||
while (true)
|
||||
{
|
||||
float nextTime = Time.time + Random.Range(30f + extraTime, 60f + extraTime);
|
||||
yield return new WaitUntil(() => Time.time > nextTime || doNow);
|
||||
|
||||
if (doNow)
|
||||
doNow = false;
|
||||
|
||||
bool useNearby = false;
|
||||
|
||||
if (TinkyWinky.Instance) {
|
||||
float dist = Vector3.Distance(Player.Instance.transform.position, TinkyWinky.Instance.transform.position);
|
||||
if (dist < 50 && TinkyWinky.Instance.ActiveState >= TinkyWinky.States.Stalk)
|
||||
{
|
||||
useNearby = true;
|
||||
}
|
||||
}
|
||||
|
||||
if (useNearby)
|
||||
{
|
||||
AudioSource.pitch = 0.5f;
|
||||
RawImage.texture = TinkyNear;
|
||||
} else
|
||||
{
|
||||
RawImage.texture = Textures[Random.Range(0, Textures.Length)];
|
||||
AudioSource.pitch = 1f;
|
||||
}
|
||||
|
||||
RawImage.enabled = true;
|
||||
AudioSource.Play();
|
||||
|
||||
yield return new WaitForSeconds(0.1f);
|
||||
|
||||
AudioSource.Stop();
|
||||
RawImage.enabled = false;
|
||||
}
|
||||
}
|
||||
|
||||
private void Start()
|
||||
{
|
||||
StartCoroutine(Loop());
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,2 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 8b6a35140760b3b4f918e7d1e7311eb0
|
||||
Reference in New Issue
Block a user