浏览代码

Merging Dialogue branching to the Quest System.

/main
uChema 4 年前
当前提交
79e39b28
共有 17 个文件被更改,包括 50 次插入35 次删除
  1. 2
      UOP1_Project/Assets/Art/Nature/Flowers.meta
  2. 2
      UOP1_Project/Assets/ScriptableObjects/SceneData.meta
  3. 2
      UOP1_Project/Assets/ScriptableObjects/SceneData/Locations.meta
  4. 2
      UOP1_Project/Assets/ScriptableObjects/SceneData/Menus.meta
  5. 2
      UOP1_Project/Assets/ScriptableObjects/StateMachine/Protagonist.meta
  6. 2
      UOP1_Project/Assets/ScriptableObjects/StateMachine/Protagonist/Actions.meta
  7. 2
      UOP1_Project/Assets/ScriptableObjects/StateMachine/Protagonist/Conditions.meta
  8. 2
      UOP1_Project/Assets/ScriptableObjects/StateMachine/Protagonist/States.meta
  9. 4
      UOP1_Project/Assets/Scripts/Cutscenes/CutsceneManager.cs
  10. 6
      UOP1_Project/Assets/Scripts/Cutscenes/DialogueControlTrack/DialogueBehaviour.cs
  11. 18
      UOP1_Project/Assets/Scripts/Dialogues/DialogueDataSO.cs
  12. 2
      UOP1_Project/Assets/Scripts/Dialogues/DialogueLineSO.cs
  13. 17
      UOP1_Project/Assets/Scripts/Dialogues/DialogueManager.cs
  14. 6
      UOP1_Project/Assets/Scripts/Events/ScriptableObjects/UI/DialogueLineChannelSO.cs
  15. 4
      UOP1_Project/Assets/Scripts/UI/UIDialogueManager.cs
  16. 4
      UOP1_Project/Assets/Scripts/UI/UIManager.cs
  17. 8
      UOP1_Project/Assets/Art/Nature/Flower.meta

2
UOP1_Project/Assets/Art/Nature/Flowers.meta


fileFormatVersion: 2
guid: 71cb940d0f0bc124f96087ccd5004b93
guid: 543e5532648d6d14f9e0c3d828f8cbed
folderAsset: yes
DefaultImporter:
externalObjects: {}

2
UOP1_Project/Assets/ScriptableObjects/SceneData.meta


fileFormatVersion: 2
guid: e271b750d2bb8f64d8f7c8637675da4c
guid: 58cd3c0eba455b8418fec6114f6b5377
folderAsset: yes
DefaultImporter:
externalObjects: {}

2
UOP1_Project/Assets/ScriptableObjects/SceneData/Locations.meta


fileFormatVersion: 2
guid: b502ac1c517c278438d9f1e588024581
guid: d40864ab1de059641aff6a72fa0fb2bc
folderAsset: yes
DefaultImporter:
externalObjects: {}

2
UOP1_Project/Assets/ScriptableObjects/SceneData/Menus.meta


fileFormatVersion: 2
guid: 5000cd25fc9cc2048b4432eaf33f0b88
guid: b52f14308d4d6774baa23f479c3d04bd
folderAsset: yes
DefaultImporter:
externalObjects: {}

2
UOP1_Project/Assets/ScriptableObjects/StateMachine/Protagonist.meta


fileFormatVersion: 2
guid: d230f7c554e81b244bfed84bda39fb82
guid: 643c6fa3d71bc8c43acaa960af682407
folderAsset: yes
DefaultImporter:
externalObjects: {}

2
UOP1_Project/Assets/ScriptableObjects/StateMachine/Protagonist/Actions.meta


fileFormatVersion: 2
guid: 8e60fd50527f7904794623b771901faf
guid: bbe2e029f8e37b54b814f7394d53a2d4
folderAsset: yes
DefaultImporter:
externalObjects: {}

2
UOP1_Project/Assets/ScriptableObjects/StateMachine/Protagonist/Conditions.meta


fileFormatVersion: 2
guid: c2c72c7f1f1e1464fa361f64a7b618bc
guid: ad7bb52f784e55b4a86f8b74316124fd
folderAsset: yes
DefaultImporter:
externalObjects: {}

2
UOP1_Project/Assets/ScriptableObjects/StateMachine/Protagonist/States.meta


fileFormatVersion: 2
guid: 804b3b4960b69144db0d6ee7bb8249bb
guid: 39b3d2075bd49c6449a699e84c6f5558
folderAsset: yes
DefaultImporter:
externalObjects: {}

4
UOP1_Project/Assets/Scripts/Cutscenes/CutsceneManager.cs


private void HandleDirectorStopped(PlayableDirector director) => CutsceneEnded();
public void PlayDialogueFromClip(DialogueLineSO dialogueLine)
public void PlayDialogueFromClip(DialogueLineSO dialogueLine, ActorSO actor)
_dialogueManager.DisplayDialogueLine(dialogueLine);
_dialogueManager.DisplayDialogueLine(dialogueLine, actor);
}
/// <summary>

6
UOP1_Project/Assets/Scripts/Cutscenes/DialogueControlTrack/DialogueBehaviour.cs


public class DialogueBehaviour : PlayableBehaviour
{
[SerializeField] private DialogueLineSO _dialogueLine = default;
[SerializeField] private ActorSO _actor = default;
[SerializeField] private bool _pauseWhenClipEnds = default; //This won't work if the clip ends on the very last frame of the Timeline
[HideInInspector] public CutsceneManager cutsceneManager;

if (playable.GetGraph().IsPlaying()
&& cutsceneManager.IsCutscenePlaying)
{
if (_dialogueLine != null)
if (_dialogueLine != null&& _actor != null)
cutsceneManager.PlayDialogueFromClip(_dialogueLine);
cutsceneManager.PlayDialogueFromClip(_dialogueLine, _actor );
_dialoguePlayed = true;
}
else

18
UOP1_Project/Assets/Scripts/Dialogues/DialogueDataSO.cs


[CreateAssetMenu(fileName = "newDialogue", menuName = "CutsceneSystem/Dialogue Data")]
public class DialogueDataSO : ScriptableObject
{
public List<DialogueLineSO> dialogueLines;
public List<Choice> Choices;
[SerializeField] private ActorSO _actor = default;
[SerializeField] private List<DialogueLineSO> _dialogueLines;
[SerializeField] private List<Choice> _choices;
public ActorSO Actor => _actor;
public List<DialogueLineSO> DialogueLines => _dialogueLines;
public List<Choice> Choices => _choices;
//TODO: Add support for branching conversations
// Maybe add 2 (or more) special line slots which represent a choice in a conversation

[Serializable]
public class Choice
{
[SerializeField] private string _optionName;
[SerializeField] private DialogueDataSO _response;
[SerializeField] private DialogueLineSO _response;
[SerializeField] private DialogueDataSO _nextDialogue;
public string OptionName { get => _optionName; }
public DialogueDataSO Response { get => _response; }
public DialogueLineSO Response { get => _response; }
public DialogueDataSO NextDialogue { get => _nextDialogue; }
}

2
UOP1_Project/Assets/Scripts/Dialogues/DialogueLineSO.cs


[CreateAssetMenu(fileName = "newLineOfDialogue", menuName = "Dialogues/Line of Dialogue")]
public class DialogueLineSO : ScriptableObject
{
public ActorSO Actor { get => _actor; }
[SerializeField] private ActorSO _actor = default;
[SerializeField] private LocalizedString _sentence = default; //TODO: Connect this with localisation
}

17
UOP1_Project/Assets/Scripts/Dialogues/DialogueManager.cs


/// </summary>
public class DialogueManager : MonoBehaviour
{
[SerializeField] private ChoiceBox _choiceBox; // TODO: Demonstration purpose only. Remove or adjust later.
// [SerializeField] private ChoiceBox _choiceBox; // TODO: Demonstration purpose only. Remove or adjust later.
private bool _reachedEndOfDialogue { get => _counter >= _currentDialogueDataSO.dialogueLines.Count; }
private bool _reachedEndOfDialogue { get => _counter >= _currentDialogueDataSO.DialogueLines.Count; }
/// <summary>
/// Displays DialogueData in the UI, one by one.

{
BeginDialogueData(dialogueDataSO);
DisplayDialogueLine(_currentDialogueDataSO.dialogueLines[_counter]);
DisplayDialogueLine(_currentDialogueDataSO.DialogueLines[_counter], dialogueDataSO.Actor);
}
/// <summary>

/// This function is also called by <c>DialogueBehaviour</c> from clips on Timeline during cutscenes.
/// </summary>
/// <param name="dialogueLine"></param>
public void DisplayDialogueLine(DialogueLineSO dialogueLine)
public void DisplayDialogueLine(DialogueLineSO dialogueLine, ActorSO actor)
Debug.Log("A line of dialogue has been spoken: \"" + dialogueLine.Sentence + "\" by " + dialogueLine.Actor.ActorName);
Debug.Log("A line of dialogue has been spoken: \"" + dialogueLine.Sentence + "\" by " +actor.ActorName );
}
private void OnAdvance()

if (!_reachedEndOfDialogue)
{
DisplayDialogueLine(_currentDialogueDataSO.dialogueLines[_counter]);
DisplayDialogueLine(_currentDialogueDataSO.DialogueLines[_counter], _currentDialogueDataSO.Actor);
}
else
{

_inputReader.advanceDialogueEvent -= OnAdvance;
// TODO: Demonstration purpose only. Remove or adjust later.
_choiceBox.Show(_currentDialogueDataSO.Choices, this);
//_choiceBox.Show(_currentDialogueDataSO.Choices, this);
}
public void DialogueEnded()

}
// TODO: Demonstration purpose only. Remove or adjust later.
/*
[Serializable]
public class ChoiceBox
{

_gameObject.SetActive(false);
}
}
*/

6
UOP1_Project/Assets/Scripts/Events/ScriptableObjects/UI/DialogueLineChannelSO.cs


[CreateAssetMenu(menuName = "Events/UI/Dialogue line Channel")]
public class DialogueLineChannelSO : ScriptableObject
{
public UnityAction<DialogueLineSO> OnEventRaised;
public void RaiseEvent(DialogueLineSO line)
public UnityAction<DialogueLineSO, ActorSO> OnEventRaised;
public void RaiseEvent(DialogueLineSO line, ActorSO actor)
OnEventRaised.Invoke(line);
OnEventRaised.Invoke(line, actor);
}
}

4
UOP1_Project/Assets/Scripts/UI/UIDialogueManager.cs


[SerializeField] LocalizeStringEvent lineText = default;
[SerializeField] LocalizeStringEvent actorNameText = default;
public void SetDialogue(DialogueLineSO dialogueLine)
public void SetDialogue(DialogueLineSO dialogueLine, ActorSO actor)
actorNameText.StringReference = dialogueLine.Actor.ActorName;
actorNameText.StringReference = actor.ActorName;
}

4
UOP1_Project/Assets/Scripts/UI/UIManager.cs


[SerializeField]
UIInteractionManager interactionPanel;
public void OpenUIDialogue(DialogueLineSO dialogueLine)
public void OpenUIDialogue(DialogueLineSO dialogueLine, ActorSO actor)
dialogueController.SetDialogue(dialogueLine);
dialogueController.SetDialogue(dialogueLine, actor);
dialogueController.gameObject.SetActive(true);
}
public void CloseUIDialogue()

8
UOP1_Project/Assets/Art/Nature/Flower.meta


fileFormatVersion: 2
guid: 71cb940d0f0bc124f96087ccd5004b93
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:
正在加载...
取消
保存