Add new dialogue system, add sound effects to walk cycle

This commit is contained in:
2022-08-14 13:56:16 -07:00
parent 432f578360
commit dd76b8b9fe
31 changed files with 6963 additions and 533 deletions

View File

@@ -0,0 +1,21 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
namespace Scampz.GameJam
{
public class AudioPlayer : MonoBehaviour
{
// Start is called before the first frame update
void Start()
{
}
// Update is called once per frame
void Update()
{
}
}
}

View File

@@ -8,7 +8,7 @@ namespace Scampz.GameJam
{
void Start()
{
GameManager.Instance.LoadScene(SceneNames.FirstPreRenderedScene, LoadSceneMode.Additive);
GameManager.Instance.LoadScene(SceneNames.ThirdPreRenderedScene, LoadSceneMode.Additive);
}
}
}

View File

@@ -0,0 +1,13 @@
using UnityEngine;
namespace Scampz.GameJam
{
[System.Serializable]
public class Dialogue
{
public string name;
[TextArea(3, 10)]
public string[] sentences;
}
}

View File

@@ -0,0 +1,69 @@
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using TMPro;
using UnityEngine;
namespace Scampz.GameJam
{
public class DialogueManager : MonoBehaviour
{
[SerializeField]
private TextMeshProUGUI nameText;
[SerializeField]
private TextMeshProUGUI dialogueText;
public float TextSpeed = 0.1f;
public static DialogueManager Instance { get; private set; }
public Queue<string> sentences;
private void Awake()
{
if (Instance == null)
Instance = this;
}
public void Start()
{
sentences = new Queue<string>();
}
public void StartDialogue(Dialogue dialogue)
{
nameText.text = dialogue.name;
sentences.Clear();
foreach (var sentence in dialogue.sentences)
sentences.Enqueue(sentence);
DisplayNextSentence();
}
public void DisplayNextSentence()
{
if (!sentences.Any())
EndDialogue();
var sentence = sentences.Dequeue();
StopAllCoroutines();
StartCoroutine(TypeSentence(sentence));
}
private IEnumerator TypeSentence(string sentence)
{
dialogueText.text = string.Empty;
foreach (var letter in sentence.ToCharArray())
{
dialogueText.text += letter;
yield return null;
yield return new WaitForSecondsRealtime(TextSpeed);
}
}
private void EndDialogue()
{
// do nothing currently
}
}
}

View File

@@ -0,0 +1,14 @@
using UnityEngine;
namespace Scampz.GameJam
{
public class DialogueTrigger : MonoBehaviour
{
public Dialogue dialogue;
public void TriggerDialogue()
{
DialogueManager.Instance.StartDialogue(dialogue);
}
}
}

View File

@@ -0,0 +1,19 @@
using System.Linq;
using UnityEngine;
namespace Scampz.GameJam
{
public class Footsteps : MonoBehaviour
{
[SerializeField]
private AudioClip[] clips;
[SerializeField]
private AudioSource audioSource;
private void Step()
{
var clip = clips.First();
audioSource.PlayOneShot(clip);
}
}
}

View File

@@ -7,6 +7,7 @@ namespace Scampz.GameJam
public class GameManager : MonoBehaviour
{
public static GameManager Instance;
public Animator animator;
void Awake()
{
@@ -21,16 +22,16 @@ namespace Scampz.GameJam
StartCoroutine(LoadSceneAsync(levelIndex, loadSceneMode));
}
public void UnloadScene(int levelIndex)
{
StartCoroutine(UnloadSceneAsync(levelIndex));
}
public void LoadScene(string sceneName, LoadSceneMode loadSceneMode)
{
StartCoroutine(LoadSceneAsync(sceneName, loadSceneMode));
}
public void UnloadScene(int levelIndex)
{
StartCoroutine(UnloadSceneAsync(levelIndex));
}
public void UnloadScene(string sceneName)
{
StartCoroutine(UnloadSceneAsync(sceneName));

View File

@@ -1,4 +1,3 @@
using Scampz.GameJam.Assets.Scripts;
using UnityEngine;
namespace Scampz.GameJam
@@ -12,7 +11,7 @@ namespace Scampz.GameJam
public void OnTriggerEnter(Collider collider)
{
animator.SetTrigger("FadeOut");
//animator.SetTrigger("FadeOut");
}
public void EnableControls()