Start to integrate the artwork

This commit is contained in:
WillJeynes
2026-08-28 20:24:18 +01:00
parent 88b0426f11
commit 0f407509c4
43 changed files with 13412 additions and 43 deletions
+3 -3
View File
@@ -202,11 +202,11 @@ public class CameraController : MonoBehaviour
}
if (
currentlyHoveredRenderer.gameObject.GetComponent<GuardManager>() != null &&
currentlyHoveredRenderer.gameObject.GetComponent<GuardManager>() != currentGuardManager
currentlyHoveredRenderer.gameObject.GetComponentInParent<GuardManager>() != null &&
currentlyHoveredRenderer.gameObject.GetComponentInParent<GuardManager>() != currentGuardManager
)
{
currentlyHoveredRenderer.gameObject.GetComponent<GuardManager>().isfocussed = 0;
currentlyHoveredRenderer.gameObject.GetComponentInParent<GuardManager>().isfocussed = 0;
}
currentlyHoveredRenderer = null;
+7 -2
View File
@@ -15,17 +15,22 @@ public class DoorManager : MonoBehaviour, IDescribable
private Light focusLight;
public int isfocussed;
private LightFlickerer indicatorLight;
// Start is called once before the first execution of Update after the MonoBehaviour is created
void Start()
{
indicatorLight = transform.FindChildRecursive("IndicatorLight").GetComponent<LightFlickerer>();
if (mod == "BLUE")
{
this.GetComponentInChildren<Renderer>().material = blueMaterial;
// this.GetComponentInChildren<Renderer>().material = blueMaterial;
indicatorLight.initialColor = Color.blue;
}
else if (mod == "RED")
{
this.GetComponentInChildren<Renderer>().material = redMaterial;
// this.GetComponentInChildren<Renderer>().material = redMaterial;
indicatorLight.initialColor = Color.red;
}
focusLight = transform.FindChildRecursive("FocusLight").GetComponent<Light>();
+9 -4
View File
@@ -1,8 +1,10 @@
using System;
using System.Collections.Generic;
using DefaultNamespace;
using UnityEditor;
using UnityEngine;
using Utils;
using Utils.Utils;
using Random = UnityEngine.Random;
public class GuardManager : MonoBehaviour, IDescribable
@@ -10,8 +12,7 @@ public class GuardManager : MonoBehaviour, IDescribable
public string type;
public string mod;
public GameObject hat;
public string puzzle;
@@ -19,16 +20,20 @@ public class GuardManager : MonoBehaviour, IDescribable
private Light focusLight;
public int isfocussed;
[SerializeField]
private List<GameEntry<Material>> GuardMaterials;
// Start is called once before the first execution of Update after the MonoBehaviour is created
void Start()
{
if (mod == "SHORT")
{
transform.localScale = new Vector3(1f, 0.1f, 1f);
GetComponentInChildren<Renderer>().material = GuardMaterials.ByKey("OTHER");
}
else if (mod == "HAT")
{
Instantiate(hat, transform);
GetComponentInChildren<Renderer>().material = GuardMaterials.ByKey("HAT");
}
focusLight = transform.FindChildRecursive("FocusLight").GetComponent<Light>();
+158
View File
@@ -0,0 +1,158 @@
using UnityEngine;
public class LightFlickerer : MonoBehaviour
{
[Header("Base Color")]
[SerializeField] public Color initialColor = new Color(1f, 0.55f, 0.2f);
[Header("Color Variations")]
[SerializeField, Range(0f, 1f)]
private float colorVariation = 0.12f;
[SerializeField, Min(2)]
private int colorPermutations = 8;
[Header("Flicker")]
[SerializeField] private float minIntensity = 1.0f;
[SerializeField] private float maxIntensity = 2.0f;
[SerializeField] private float flickerSpeed = 4f;
[Header("Torch Movement")]
[SerializeField] private float movementAmount = 0.03f;
[SerializeField] private float movementSpeed = 2f;
private Light torchLight;
private Color[] colors;
private int currentColor;
private int nextColor;
private float colorTimer;
private float colorTransitionTime;
private Vector3 initialPosition;
private float noiseOffset;
private void Start()
{
torchLight = GetComponent<Light>();
initialPosition = transform.localPosition;
noiseOffset = Random.Range(0f, 1000f);
GenerateColorPermutations();
currentColor = Random.Range(0, colors.Length);
nextColor = GetDifferentColor(currentColor);
colorTransitionTime = Random.Range(0.3f, 0.8f);
colorTimer = 0f;
}
private void Update()
{
FlickerColor();
FlickerIntensity();
FlickerMovement();
}
private void GenerateColorPermutations()
{
colors = new Color[colorPermutations];
for (int i = 0; i < colorPermutations; i++)
{
float variation = Random.Range(-colorVariation, colorVariation);
// Slightly vary each RGB channel independently.
float r = Mathf.Clamp01(initialColor.r + variation * Random.Range(0.7f, 1.2f));
float g = Mathf.Clamp01(initialColor.g + variation * Random.Range(0.7f, 1.2f));
float b = Mathf.Clamp01(initialColor.b + variation * Random.Range(0.7f, 1.2f));
colors[i] = new Color(r, g, b, initialColor.a);
}
}
private void FlickerColor()
{
colorTimer += Time.deltaTime;
float t = colorTimer / colorTransitionTime;
// Smoothly transition between two colors.
float smoothT = Mathf.SmoothStep(0f, 1f, t);
torchLight.color = Color.Lerp(
colors[currentColor],
colors[nextColor],
smoothT
);
if (colorTimer >= colorTransitionTime)
{
currentColor = nextColor;
nextColor = GetDifferentColor(currentColor);
colorTimer = 0f;
// Randomize how long the next transition takes.
colorTransitionTime = Random.Range(
0.25f / flickerSpeed,
0.8f / flickerSpeed
);
}
}
private void FlickerIntensity()
{
// Perlin noise produces a much more natural flame than Random.Range().
float noise = Mathf.PerlinNoise(
noiseOffset,
Time.time * flickerSpeed
);
torchLight.intensity = Mathf.Lerp(
minIntensity,
maxIntensity,
noise
);
}
private void FlickerMovement()
{
float time = Time.time * movementSpeed;
float x = Mathf.PerlinNoise(noiseOffset, time) - 0.5f;
float y = Mathf.PerlinNoise(noiseOffset + 100f, time) - 0.5f;
float z = Mathf.PerlinNoise(noiseOffset + 200f, time) - 0.5f;
transform.localPosition = initialPosition + new Vector3(
x,
y,
z
) * movementAmount;
}
private int GetDifferentColor(int current)
{
if (colors.Length <= 1)
return current;
int result;
do
{
result = Random.Range(0, colors.Length);
}
while (result == current);
return result;
}
// Regenerate the palette if the initial color is changed at runtime.
public void RegenerateColors()
{
GenerateColorPermutations();
}
}
+2
View File
@@ -0,0 +1,2 @@
fileFormatVersion: 2
guid: 8447674bf5ce6891a87c9a89210032b6
+2
View File
@@ -94,6 +94,8 @@ public class StatusManager : Singleton<StatusManager>
bool leftAligned = panel.anchorMin.x == 0f;
AudioManager.Instance.PlaySound(isOpen ? "WordRemove" : "WordAdd");
StartCoroutine(
SlidePanel(panel, !isOpen, panel.rect.width * (leftAligned ? 1 : -1))
);
+66
View File
@@ -0,0 +1,66 @@
using UnityEngine;
[RequireComponent(typeof(Renderer))]
public class TextureTiler : MonoBehaviour
{
[SerializeField]
private float textureWorldSize = 1f;
public enum Surface
{
Floor, // X × Z
WallX, // Y × Z
WallZ // X × Y
}
[SerializeField]
private Surface surface = Surface.Floor;
private Renderer rend;
private void Start()
{
rend = GetComponent<Renderer>();
UpdateTiling();
}
private void UpdateTiling()
{
Vector3 size = transform.lossyScale;
float width;
float height;
switch (surface)
{
case Surface.Floor:
width = size.x;
height = size.z;
break;
case Surface.WallX:
width = size.z;
height = size.y;
break;
case Surface.WallZ:
width = size.x;
height = size.y;
break;
default:
width = size.x;
height = size.y;
break;
}
float tilesX = width / textureWorldSize;
float tilesY = height / textureWorldSize;
// URP
rend.material.SetTextureScale(
"_BaseMap",
new Vector2(tilesX, tilesY)
);
}
}
+2
View File
@@ -0,0 +1,2 @@
fileFormatVersion: 2
guid: 8e702867e24946d529c85ca74996f6d7