Add new dialogue system, add sound effects to walk cycle
This commit is contained in:
21
Assets/Scripts/AudioPlayer.cs
Normal file
21
Assets/Scripts/AudioPlayer.cs
Normal 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()
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -8,7 +8,7 @@ namespace Scampz.GameJam
|
||||
{
|
||||
void Start()
|
||||
{
|
||||
GameManager.Instance.LoadScene(SceneNames.FirstPreRenderedScene, LoadSceneMode.Additive);
|
||||
GameManager.Instance.LoadScene(SceneNames.ThirdPreRenderedScene, LoadSceneMode.Additive);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
13
Assets/Scripts/Dialogue.cs
Normal file
13
Assets/Scripts/Dialogue.cs
Normal file
@@ -0,0 +1,13 @@
|
||||
using UnityEngine;
|
||||
|
||||
namespace Scampz.GameJam
|
||||
{
|
||||
[System.Serializable]
|
||||
public class Dialogue
|
||||
{
|
||||
public string name;
|
||||
|
||||
[TextArea(3, 10)]
|
||||
public string[] sentences;
|
||||
}
|
||||
}
|
||||
69
Assets/Scripts/DialogueManager.cs
Normal file
69
Assets/Scripts/DialogueManager.cs
Normal 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
|
||||
}
|
||||
}
|
||||
}
|
||||
14
Assets/Scripts/DialogueTrigger.cs
Normal file
14
Assets/Scripts/DialogueTrigger.cs
Normal file
@@ -0,0 +1,14 @@
|
||||
using UnityEngine;
|
||||
|
||||
namespace Scampz.GameJam
|
||||
{
|
||||
public class DialogueTrigger : MonoBehaviour
|
||||
{
|
||||
public Dialogue dialogue;
|
||||
|
||||
public void TriggerDialogue()
|
||||
{
|
||||
DialogueManager.Instance.StartDialogue(dialogue);
|
||||
}
|
||||
}
|
||||
}
|
||||
19
Assets/Scripts/Footsteps.cs
Normal file
19
Assets/Scripts/Footsteps.cs
Normal 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);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -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));
|
||||
|
||||
@@ -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()
|
||||
|
||||
Reference in New Issue
Block a user