added queue to barks, modified barks manager, barks trigger
This commit is contained in:
@@ -4,6 +4,7 @@ using System.Collections.Generic;
|
||||
using PixelCrushers;
|
||||
using PixelCrushers.DialogueSystem;
|
||||
using Sirenix.OdinInspector;
|
||||
using Sirenix.Utilities;
|
||||
using UnityEngine;
|
||||
using Random = UnityEngine.Random;
|
||||
|
||||
@@ -14,6 +15,9 @@ namespace Beyond
|
||||
[Serializable]
|
||||
public class Bark
|
||||
{
|
||||
[Tooltip("Conversation to get bark content from.")]
|
||||
[ConversationPopup(false)]
|
||||
public string barkConversation = string.Empty;
|
||||
public string barkText;
|
||||
public AudioClip clip;
|
||||
}
|
||||
@@ -39,6 +43,26 @@ namespace Beyond
|
||||
public Queue<int> m_barkQueue = new Queue<int>();
|
||||
public AudioSource m_audioSource;
|
||||
|
||||
private Dictionary<string, int> m_conversationToEntry = new Dictionary<string, int>();
|
||||
|
||||
private static BarkManager s_instance;
|
||||
|
||||
public static BarkManager Instance => s_instance;
|
||||
|
||||
public override void Awake()
|
||||
{
|
||||
base.Awake();
|
||||
if (s_instance != null)
|
||||
{
|
||||
Debug.LogError("BarkManager instance already exists! destroying...");
|
||||
Destroy(this);
|
||||
}
|
||||
else
|
||||
{
|
||||
s_instance = this;
|
||||
}
|
||||
}
|
||||
|
||||
public void PlayBark(int num)
|
||||
{
|
||||
m_barkQueue.Enqueue(num);
|
||||
@@ -72,6 +96,19 @@ namespace Beyond
|
||||
*/
|
||||
}
|
||||
|
||||
public void PlayBark(string conversation)
|
||||
{
|
||||
if (m_conversationToEntry.ContainsKey(conversation))
|
||||
{
|
||||
m_barkQueue.Enqueue(m_conversationToEntry[conversation]);
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
Debug.LogError("BarkManager: Conversation not found: "+conversation, this);
|
||||
}
|
||||
}
|
||||
|
||||
//private AudioSource audioSourceLast;
|
||||
//private GameObject audioSource => Player.Instance.audioSource;
|
||||
|
||||
@@ -118,6 +155,10 @@ namespace Beyond
|
||||
//audioSourceLast = audioObject.GetComponent<AudioSource>();
|
||||
m_audioSource.PlayOneShot(b.clip);
|
||||
}
|
||||
if (!string.IsNullOrWhiteSpace(b.barkConversation))
|
||||
{
|
||||
DialogueManager.Bark(b.barkConversation, Player.Instance.transform);
|
||||
}
|
||||
if (!string.IsNullOrEmpty(b.barkText))
|
||||
{
|
||||
DialogueManager.BarkString(b.barkText, Player.Instance.transform);
|
||||
@@ -145,6 +186,14 @@ namespace Beyond
|
||||
m_saveData.wasPlayed = new bool[m_barks.Length];
|
||||
for (int i = 0; i < m_saveData.wasPlayed.Length; i++)
|
||||
m_saveData.wasPlayed[i] = false;
|
||||
for (int i=0; i<m_barks.Length; i++)
|
||||
{
|
||||
var b = m_barks[i];
|
||||
if (b.barks.Length == 1 && !b.barks[0].barkConversation.IsNullOrWhitespace())
|
||||
{
|
||||
m_conversationToEntry[b.barks[0].barkConversation] = i;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public override string RecordData()
|
||||
|
||||
Reference in New Issue
Block a user