added queue to barks, modified barks manager, barks trigger
This commit is contained in:
@@ -1,12 +1,15 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using PixelCrushers.DialogueSystem;
|
||||
using UnityEngine;
|
||||
using UnityEngine.Events;
|
||||
|
||||
[System.Serializable]
|
||||
public class ActionResponse
|
||||
{
|
||||
public string barkText;
|
||||
[Tooltip("Conversation to get bark content from.")]
|
||||
[ConversationPopup(false)]
|
||||
public string barkConversation;
|
||||
public AudioClip audioClip;
|
||||
public UnityEvent responseEvent;
|
||||
public float delay = 0f;
|
||||
|
||||
@@ -20,8 +20,9 @@ public class QuestTriggerBase : Saver
|
||||
public bool wasFired;
|
||||
}
|
||||
// Start is called before the first frame update
|
||||
virtual public void Awake()
|
||||
public override void Awake()
|
||||
{
|
||||
base.Awake();
|
||||
m_audioSource = GetComponent<AudioSource>();
|
||||
m_audioSource.playOnAwake = false;
|
||||
gameObject.layer = LayerMask.NameToLayer("Triggers");
|
||||
@@ -40,13 +41,15 @@ public class QuestTriggerBase : Saver
|
||||
|
||||
}
|
||||
|
||||
public virtual void Start()
|
||||
public override void Start()
|
||||
{
|
||||
base.Start();
|
||||
Player.Instance.ThirdPersonController.onDead.AddListener(OnDead);
|
||||
}
|
||||
|
||||
public virtual void OnDestroy()
|
||||
public override void OnDestroy()
|
||||
{
|
||||
base.OnDestroy();
|
||||
if (Player.Instance != null && Player.Instance.ThirdPersonController != null)
|
||||
Player.Instance.ThirdPersonController.onDead.RemoveListener(OnDead);
|
||||
}
|
||||
@@ -83,9 +86,10 @@ public class QuestTriggerBase : Saver
|
||||
m_audioSource.clip = action.audioClip;
|
||||
m_audioSource.Play();
|
||||
}
|
||||
if (action.barkText != null && action.barkText != "")
|
||||
if (action.barkConversation != null && action.barkConversation != "")
|
||||
{
|
||||
DialogueManager.BarkString(action.barkText, m_player);
|
||||
//DialogueManager.BarkString(action.barkText, m_player);
|
||||
BarkManager.Instance.PlayBark(action.barkConversation);
|
||||
}
|
||||
if (action.responseEvent != null)
|
||||
{
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using PixelCrushers.DialogueSystem;
|
||||
using Sirenix.Utilities;
|
||||
using UnityEngine;
|
||||
|
||||
namespace Beyond
|
||||
@@ -15,6 +17,9 @@ namespace Beyond
|
||||
public ActionResponse m_actionResponse;
|
||||
|
||||
public MaterialChanger[] m_materialsToChange;
|
||||
//[Tooltip("Conversation to get bark content from.")]
|
||||
//[ConversationPopup(false)]
|
||||
//public string m_conversationBark = string.Empty;
|
||||
|
||||
|
||||
[Serializable]
|
||||
@@ -86,6 +91,11 @@ namespace Beyond
|
||||
}
|
||||
}
|
||||
|
||||
//if (!m_conversationBark.IsNullOrWhitespace())
|
||||
//{
|
||||
// BarkManager.Instance.PlayBark(m_conversationBark);
|
||||
//}
|
||||
|
||||
|
||||
yield return null;
|
||||
}
|
||||
|
||||
@@ -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