tnt graphics, bug fixes, folder organization

This commit is contained in:
2026-03-28 20:47:10 -05:00
parent 57b14d4ba9
commit 6491a3df11
45 changed files with 10533 additions and 148 deletions
+83
View File
@@ -0,0 +1,83 @@
using System.Collections.Generic;
using System.Linq;
using UnityEngine;
public class DialogueVoice : MonoBehaviour
{
[Tooltip("How fast characters will display when speaking.")]
[Range(0.8f, 1.0f)]
public float talkSpeed;
[Tooltip("Character will say a letter every 'n' characters, where the speech interval is 'n'.")]
[Range(1, 5)]
public int speechInterval;
public Voices voice;
private Dictionary<char, AudioClip> charToSoundMap;
private void Start()
{
charToSoundMap = new Dictionary<char, AudioClip>();
string path = GetVoicePath(voice);
if (path != "")
{
MapVoices(Resources.LoadAll<AudioClip>(path));
}
}
public AudioClip GetClipFromChar(char ch)
{
if (charToSoundMap.Count <= 0)
return null;
if (charToSoundMap.ContainsKey(ch))
{
return charToSoundMap[ch];
}
return charToSoundMap.ElementAt(Random.Range(0, charToSoundMap.Count)).Value;
}
private string GetVoicePath(Voices voice)
{
switch (voice)
{
case Voices.Voice_1:
return "VoiceClips/male_voice1";
case Voices.Voice_2:
return "VoiceClips/female_voice1";
default:
return "";
}
}
private void MapVoices(AudioClip[] voiceClips)
{
foreach (AudioClip clip in voiceClips)
{
if (clip.name.Length > 0)
{
if (clip.name == "period")
{
charToSoundMap.Add('.', clip);
}
else
{
// map first char of name to clip
charToSoundMap.Add(clip.name[0], clip);
}
}
}
}
}
public enum Voices
{
None,
Voice_1,
Voice_2
}
@@ -0,0 +1,2 @@
fileFormatVersion: 2
guid: 9a63e353faf59ff4aac9a348dfdca9dc
@@ -268,6 +268,14 @@ public bool GetCharacterHasControl()
return hasControl;
}
/// <summary>
/// Expose the character controller's velocity
/// </summary>
public Vector3 GetVelocity()
{
return characterController.velocity;
}
/// <summary>
/// Switches the tools in hand by taking an index
///
+30
View File
@@ -0,0 +1,30 @@
using UnityEngine;
// Very simple script, just takes a light on start and slowly fades it to 0
// over the duration specified.
[RequireComponent(typeof(Light))]
public class FadingLight : MonoBehaviour
{
Light lightObj;
public float duration;
public bool isFading;
float timer;
float startIntensity;
void Start()
{
lightObj = GetComponent<Light>();
startIntensity = lightObj.intensity;
}
void Update()
{
timer += Time.deltaTime;
float t = timer / duration;
t = Mathf.Clamp01(t);
lightObj.intensity = Mathf.Lerp(startIntensity, 0, t);
}
}
+2
View File
@@ -0,0 +1,2 @@
fileFormatVersion: 2
guid: 2742aa9b9a50a9d458a4daef485a3956
+2 -4
View File
@@ -6,12 +6,10 @@
// Handle room and scene transitions
public class TeleportHandler : MonoBehaviour
{
Image blackScreenObject;
PlayerController playerController;
private void Start()
{
blackScreenObject = GameManager.Instance.GetBlackScreen();
playerController = GetComponent<PlayerController>();
}
@@ -43,7 +41,7 @@ IEnumerator EnterRoomCoroutine(RoomDoor door)
while (fadeTime < fadeDuration)
{
blackScreenColor.a = Mathf.Lerp(0, 1, fadeTime / fadeDuration);
blackScreenObject.color = blackScreenColor;
GameManager.Instance.GetBlackScreen().color = blackScreenColor;
fadeTime += Time.deltaTime;
yield return null;
}
@@ -55,7 +53,7 @@ IEnumerator EnterRoomCoroutine(RoomDoor door)
while (fadeTime < fadeDuration)
{
blackScreenColor.a = Mathf.Lerp(1, 0, fadeTime / fadeDuration);
blackScreenObject.color = blackScreenColor;
GameManager.Instance.GetBlackScreen().color = blackScreenColor;
playerController.WalkInDirection((door.linkedDoor.WalkDirection.position - playerController.transform.position).normalized);
fadeTime += Time.deltaTime;
+31
View File
@@ -0,0 +1,31 @@
using System;
using System.Linq;
using UnityEngine;
public class Streetlight : MonoBehaviour
{
// Hours that the light starts and ends
public int[] activeHours = { 18, 19, 20, 21, 22, 23, 0, 1, 2, 3, 4, 5, 6 };
Light objectLight;
private float lightIntensity;
void Start()
{
objectLight = GetComponent<Light>();
lightIntensity = objectLight.intensity;
}
// Update is called once per frame
void Update()
{
if (activeHours.Contains(GameManager.Instance.TimeManager.GetCurrentHour()))
{
objectLight.intensity = lightIntensity;
}
else
{
objectLight.intensity = 0;
}
}
}
+2
View File
@@ -0,0 +1,2 @@
fileFormatVersion: 2
guid: 67529f5a831c7b240bc979c3bd269016
+33
View File
@@ -0,0 +1,33 @@
using UnityEngine;
public class Tnt : MonoBehaviour
{
public Light explodeLight;
public ParticleSystem explodeParticle;
public float fuseTime;
public float explosionLengthTime;
float timer = 0;
private bool exploded = false;
void Update()
{
timer += Time.deltaTime;
if (!exploded && timer > fuseTime)
{
exploded = true;
explodeLight.gameObject.SetActive(true);
explodeLight.transform.parent = null;
explodeParticle.gameObject.SetActive(true);
explodeParticle.transform.parent = null;
explodeParticle.transform.localScale = new Vector3(0.05f, 0.05f, 0.05f);
explodeParticle.Play();
Destroy(explodeLight.gameObject, explosionLengthTime);
Destroy(explodeParticle.gameObject, explosionLengthTime);
Destroy(gameObject);
}
}
}
+2
View File
@@ -0,0 +1,2 @@
fileFormatVersion: 2
guid: f876d4c98cbd6c8499fa411ab2468058
+8
View File
@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 20c8faa2469f8aa45be8aae9439949d1
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:
+17
View File
@@ -0,0 +1,17 @@
using UnityEngine;
public class Flashlight : Tool
{
[Header("Flashlight Parameters")]
public Light lightSrc;
public override void Use()
{
lightSrc.enabled = !lightSrc.enabled;
}
public override void UseAlt()
{
}
}
+2
View File
@@ -0,0 +1,2 @@
fileFormatVersion: 2
guid: edd0364a446d1fd489dd8bbb53de613a
+86
View File
@@ -0,0 +1,86 @@
using UnityEngine;
using UnityEngine.Rendering.Universal;
using static UnityEngine.GraphicsBuffer;
public class ThrowableHand : Tool
{
[Header("Throwable Hand Parameters")]
public float range;
public float forceModifier;
public float loft;
public GameObject testBomb;
// Mathematical plane used to catch the raycast from camera to get direction for
// looking at the mouse
private Plane handGroundPlane;
private DecalProjector targetProjection;
private float throwForce;
private void Update()
{
if (GameManager.Instance.GetPlayerController() != null)
{
SetGroundPlane();
DrawTargetProjection();
}
}
private void SetGroundPlane()
{
if (handGroundPlane == null)
{
handGroundPlane = new Plane(Vector3.up, -GameManager.Instance.GetPlayerController().DougBody.transform.position.y);
}
handGroundPlane.distance = -GameManager.Instance.GetPlayerController().DougBody.transform.position.y;
handGroundPlane.normal = Vector3.up;
}
private void DrawTargetProjection()
{
if (targetProjection == null)
{
targetProjection = GetComponentInChildren<DecalProjector>();
}
Ray ray = Camera.main.ScreenPointToRay(Input.mousePosition);
if (handGroundPlane.Raycast(ray, out var distance))
{
Vector3 hitPoint = ray.GetPoint(distance);
float distanceFromPoint = Vector3.Distance(hitPoint, transform.position);
if (distanceFromPoint > range)
{
Vector3 directionTowardMouse = (hitPoint - transform.position).normalized;
targetProjection.transform.position = new Vector3(transform.position.x, hitPoint.y, transform.position.z);
targetProjection.transform.position += directionTowardMouse * range;
throwForce = range;
}
else
{
targetProjection.gameObject.SetActive(true);
targetProjection.transform.position = hitPoint;
throwForce = distanceFromPoint;
}
}
}
public override void Use()
{
GameObject newBomb = Instantiate(testBomb);
newBomb.transform.position = transform.position;
Vector3 direction = transform.forward * throwForce * forceModifier;
direction += GameManager.Instance.GetPlayerController().GetVelocity();
direction.y = loft;
newBomb.GetComponent<Rigidbody>().AddForce(direction, ForceMode.Impulse);
}
public override void UseAlt()
{
throw new System.NotImplementedException();
}
}
@@ -0,0 +1,2 @@
fileFormatVersion: 2
guid: fe5aedf75d904534296ad0d07fe55622
+28
View File
@@ -0,0 +1,28 @@
using UnityEngine;
public class TouchCubeTest : Interactable
{
public override void Interact()
{
// do nothing
}
public override void MoveInsideRange()
{
if (GameManager.Instance.Storybools.hasHelpedSam)
{
Debug.Log("You've already touched the cube!");
}
else
{
Debug.Log("Touched the cube!");
GameManager.Instance.Storybools.hasHelpedSam = true;
SaveSystem.Save();
}
}
public override void MoveOutsideRange()
{
// do nothing
}
}
+2
View File
@@ -0,0 +1,2 @@
fileFormatVersion: 2
guid: a9ab60ad80ee08f4eb031540a5744ab5