Add light intensity focussing
This commit is contained in:
@@ -161,6 +161,17 @@ public class CameraController : MonoBehaviour
|
||||
originalColour = currentlyHoveredRenderer.material.color;
|
||||
currentlyHoveredRenderer.material.color = highlightColour;
|
||||
}
|
||||
|
||||
|
||||
if (currentlyHoveredRenderer.gameObject.GetComponentInParent<DoorManager>() != null)
|
||||
{
|
||||
currentlyHoveredRenderer.gameObject.GetComponentInParent<DoorManager>().isfocussed = 1;
|
||||
}
|
||||
|
||||
if (currentlyHoveredRenderer.gameObject.GetComponentInParent<GuardManager>() != null)
|
||||
{
|
||||
currentlyHoveredRenderer.gameObject.GetComponentInParent<GuardManager>().isfocussed = 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
@@ -181,6 +192,23 @@ public class CameraController : MonoBehaviour
|
||||
{
|
||||
currentlyHoveredRenderer.material.color = originalColour;
|
||||
}
|
||||
|
||||
if (
|
||||
currentlyHoveredRenderer.gameObject.GetComponentInParent<DoorManager>() != null &&
|
||||
currentlyHoveredRenderer.gameObject.GetComponentInParent<DoorManager>() != currentDoorManager
|
||||
)
|
||||
{
|
||||
currentlyHoveredRenderer.gameObject.GetComponentInParent<DoorManager>().isfocussed = 0;
|
||||
}
|
||||
|
||||
if (
|
||||
currentlyHoveredRenderer.gameObject.GetComponent<GuardManager>() != null &&
|
||||
currentlyHoveredRenderer.gameObject.GetComponent<GuardManager>() != currentGuardManager
|
||||
)
|
||||
{
|
||||
currentlyHoveredRenderer.gameObject.GetComponent<GuardManager>().isfocussed = 0;
|
||||
}
|
||||
|
||||
currentlyHoveredRenderer = null;
|
||||
}
|
||||
}
|
||||
@@ -227,14 +255,20 @@ public class CameraController : MonoBehaviour
|
||||
if (talkButton != null) talkButton.gameObject.SetActive(false);
|
||||
if (doorButton != null) doorButton.gameObject.SetActive(false);
|
||||
|
||||
UnsetAll();
|
||||
currentDoorManager = null;
|
||||
currentGuardManager = null;
|
||||
|
||||
if (guard != null)
|
||||
{
|
||||
currentGuardManager = guard;
|
||||
guard.isfocussed = 2;
|
||||
if (talkButton != null) talkButton.gameObject.SetActive(true);
|
||||
}
|
||||
else if (door != null)
|
||||
{
|
||||
currentDoorManager = door;
|
||||
door.isfocussed = 2;
|
||||
if (doorButton != null) doorButton.gameObject.SetActive(true);
|
||||
}
|
||||
}
|
||||
@@ -278,6 +312,7 @@ public class CameraController : MonoBehaviour
|
||||
currentGuardManager = null;
|
||||
currentDoorManager = null;
|
||||
|
||||
UnsetAll();
|
||||
if (talkButton != null) talkButton.gameObject.SetActive(false);
|
||||
if (doorButton != null) doorButton.gameObject.SetActive(false);
|
||||
}
|
||||
@@ -294,4 +329,17 @@ public class CameraController : MonoBehaviour
|
||||
explorationCamera.transform.rotation = startingRotation;
|
||||
}
|
||||
}
|
||||
|
||||
private void UnsetAll()
|
||||
{
|
||||
foreach (var doorManager in LevelLoader.Instance.Doors)
|
||||
{
|
||||
doorManager.isfocussed = 0;
|
||||
}
|
||||
foreach (var doorManager in LevelLoader.Instance.Guards)
|
||||
{
|
||||
doorManager.isfocussed = 0;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -12,6 +12,10 @@ public class DoorManager : MonoBehaviour, IDescribable
|
||||
|
||||
public Material blueMaterial;
|
||||
public Material redMaterial;
|
||||
|
||||
private Light focusLight;
|
||||
public int isfocussed;
|
||||
|
||||
// Start is called once before the first execution of Update after the MonoBehaviour is created
|
||||
void Start()
|
||||
{
|
||||
@@ -23,13 +27,27 @@ public class DoorManager : MonoBehaviour, IDescribable
|
||||
{
|
||||
this.GetComponentInChildren<Renderer>().material = redMaterial;
|
||||
}
|
||||
|
||||
focusLight = transform.FindChildRecursive("FocusLight").GetComponent<Light>();
|
||||
}
|
||||
|
||||
// Update is called once per frame
|
||||
void Update()
|
||||
{
|
||||
|
||||
if (isfocussed == 2 && focusLight.intensity < 200)
|
||||
{
|
||||
focusLight.intensity += Time.deltaTime * 100;
|
||||
}
|
||||
else if (isfocussed == 1 && focusLight.intensity < 100)
|
||||
{
|
||||
focusLight.intensity += Time.deltaTime * 100;
|
||||
}
|
||||
else if (isfocussed == 0 && focusLight.intensity > 30)
|
||||
{
|
||||
focusLight.intensity -= Time.deltaTime * 100;
|
||||
}
|
||||
}
|
||||
|
||||
private void OnDrawGizmos()
|
||||
{
|
||||
#if UNITY_EDITOR
|
||||
|
||||
@@ -15,6 +15,10 @@ public class GuardManager : MonoBehaviour, IDescribable
|
||||
|
||||
public string puzzle;
|
||||
|
||||
|
||||
private Light focusLight;
|
||||
public int isfocussed;
|
||||
|
||||
// Start is called once before the first execution of Update after the MonoBehaviour is created
|
||||
void Start()
|
||||
{
|
||||
@@ -26,12 +30,25 @@ public class GuardManager : MonoBehaviour, IDescribable
|
||||
{
|
||||
Instantiate(hat, transform);
|
||||
}
|
||||
|
||||
focusLight = transform.FindChildRecursive("FocusLight").GetComponent<Light>();
|
||||
}
|
||||
|
||||
// Update is called once per frame
|
||||
void Update()
|
||||
{
|
||||
|
||||
if (isfocussed == 2 && focusLight.intensity < 200)
|
||||
{
|
||||
focusLight.intensity += Time.deltaTime * 100;
|
||||
}
|
||||
else if (isfocussed == 1 && focusLight.intensity < 100)
|
||||
{
|
||||
focusLight.intensity += Time.deltaTime * 100;
|
||||
}
|
||||
else if (isfocussed == 0 && focusLight.intensity > 30)
|
||||
{
|
||||
focusLight.intensity -= Time.deltaTime * 100;
|
||||
}
|
||||
}
|
||||
|
||||
private void OnDrawGizmos()
|
||||
|
||||
Reference in New Issue
Block a user