Reworked the dialogue system
Now the dialogue can use tags to add special effects Reorganized project structure, updating may require adding some using statements
This commit is contained in:
parent
95bad523b9
commit
0e8b8b1835
25 changed files with 1912 additions and 1266 deletions
|
@ -1,38 +1,40 @@
|
|||
using UnityEngine;
|
||||
using Cinemachine;
|
||||
|
||||
public class CMCameraTrigger : MonoBehaviour{
|
||||
namespace SimpleTools.Cinemachine {
|
||||
public class CMCameraTrigger : MonoBehaviour {
|
||||
|
||||
CinemachineVirtualCamera vcam;
|
||||
CinemachineVirtualCamera vcam;
|
||||
|
||||
void Awake(){
|
||||
vcam = GetComponentInChildren<CinemachineVirtualCamera>(true);
|
||||
vcam.gameObject.SetActive(false);
|
||||
}
|
||||
void Awake() {
|
||||
vcam = GetComponentInChildren<CinemachineVirtualCamera>(true);
|
||||
vcam.gameObject.SetActive(false);
|
||||
}
|
||||
|
||||
#region 3D
|
||||
void OnTriggerEnter(Collider col){
|
||||
if (col.CompareTag("Player")){
|
||||
vcam.gameObject.SetActive(true);
|
||||
}
|
||||
}
|
||||
void OnTriggerExit(Collider col){
|
||||
if (col.CompareTag("Player")){
|
||||
vcam.gameObject.SetActive(true);
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
#region 3D
|
||||
void OnTriggerEnter(Collider col) {
|
||||
if (col.CompareTag("Player")) {
|
||||
vcam.gameObject.SetActive(true);
|
||||
}
|
||||
}
|
||||
void OnTriggerExit(Collider col) {
|
||||
if (col.CompareTag("Player")) {
|
||||
vcam.gameObject.SetActive(true);
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region 2D
|
||||
void OnTriggerEnter2D(Collider2D col){
|
||||
if (col.CompareTag("Player")){
|
||||
vcam.gameObject.SetActive(true);
|
||||
}
|
||||
}
|
||||
void OnTriggerExit2D(Collider2D col){
|
||||
if (col.CompareTag("Player")){
|
||||
vcam.gameObject.SetActive(false);
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
#region 2D
|
||||
void OnTriggerEnter2D(Collider2D col) {
|
||||
if (col.CompareTag("Player")) {
|
||||
vcam.gameObject.SetActive(true);
|
||||
}
|
||||
}
|
||||
void OnTriggerExit2D(Collider2D col) {
|
||||
if (col.CompareTag("Player")) {
|
||||
vcam.gameObject.SetActive(false);
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
}
|
|
@ -1,36 +1,38 @@
|
|||
using Cinemachine;
|
||||
using UnityEngine;
|
||||
|
||||
public static class ScreenShake{
|
||||
namespace SimpleTools.Cinemachine {
|
||||
public static class ScreenShake {
|
||||
|
||||
static CinemachineVirtualCamera vCam;
|
||||
static ScreenShakeUpdate shakeUpdate;
|
||||
static CinemachineVirtualCamera vCam;
|
||||
static ScreenShakeUpdate shakeUpdate;
|
||||
|
||||
class ScreenShakeUpdate : MonoBehaviour {
|
||||
[HideInInspector] public float shakeTimer;
|
||||
[HideInInspector] public float shakeTimerTotal;
|
||||
[HideInInspector] public float startingIntensity;
|
||||
class ScreenShakeUpdate : MonoBehaviour {
|
||||
[HideInInspector] public float shakeTimer;
|
||||
[HideInInspector] public float shakeTimerTotal;
|
||||
[HideInInspector] public float startingIntensity;
|
||||
|
||||
void Update(){
|
||||
if (shakeTimer > 0){
|
||||
shakeTimer -= Time.deltaTime;
|
||||
CinemachineBasicMultiChannelPerlin multiChannelPerlin = vCam.GetCinemachineComponent<CinemachineBasicMultiChannelPerlin>();
|
||||
multiChannelPerlin.m_AmplitudeGain = Mathf.Lerp(startingIntensity, 0f, 1 - (shakeTimer / shakeTimerTotal));
|
||||
}
|
||||
}
|
||||
}
|
||||
void Update() {
|
||||
if (shakeTimer > 0) {
|
||||
shakeTimer -= Time.deltaTime;
|
||||
CinemachineBasicMultiChannelPerlin multiChannelPerlin = vCam.GetCinemachineComponent<CinemachineBasicMultiChannelPerlin>();
|
||||
multiChannelPerlin.m_AmplitudeGain = Mathf.Lerp(startingIntensity, 0f, 1 - (shakeTimer / shakeTimerTotal));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>Shake the camera
|
||||
/// <para>It needs a cinemachine camera with a noise profile in it.</para>
|
||||
/// </summary>
|
||||
public static void Shake(float intensity, float time){
|
||||
if(vCam == null){
|
||||
vCam = Camera.main.GetComponent<CinemachineBrain>().ActiveVirtualCamera.VirtualCameraGameObject.GetComponent<CinemachineVirtualCamera>();
|
||||
}
|
||||
if(shakeUpdate == null){
|
||||
shakeUpdate = new GameObject("ShakeUpdate").AddComponent<ScreenShakeUpdate>();
|
||||
}
|
||||
shakeUpdate.startingIntensity = intensity;
|
||||
shakeUpdate.shakeTimer = shakeUpdate.shakeTimerTotal = time;
|
||||
}
|
||||
}
|
||||
/// <summary>Shake the camera
|
||||
/// <para>It needs a cinemachine camera with a noise profile in it.</para>
|
||||
/// </summary>
|
||||
public static void Shake(float intensity, float time) {
|
||||
if (vCam == null) {
|
||||
vCam = Camera.main.GetComponent<CinemachineBrain>().ActiveVirtualCamera.VirtualCameraGameObject.GetComponent<CinemachineVirtualCamera>();
|
||||
}
|
||||
if (shakeUpdate == null) {
|
||||
shakeUpdate = new GameObject("ShakeUpdate").AddComponent<ScreenShakeUpdate>();
|
||||
}
|
||||
shakeUpdate.startingIntensity = intensity;
|
||||
shakeUpdate.shakeTimer = shakeUpdate.shakeTimerTotal = time;
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue