Added player character and step in/out of dialogue in scene 101
This commit is contained in:
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 16d046b9603964894b61827ac87b5020
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,47 @@
|
||||
using UnityEngine;
|
||||
using Yarn.Unity;
|
||||
|
||||
namespace NightclubArcadia.Dialogue
|
||||
{
|
||||
/// <summary>
|
||||
/// Trigger-zone interactable: player walks in range, presses E, and this
|
||||
/// starts the given Yarn node. The reverse of DialogueTransitionController's
|
||||
/// <<enter_environment>> — this is the "step into dialogue" half of the loop.
|
||||
/// </summary>
|
||||
public class DialogueInteractable : MonoBehaviour
|
||||
{
|
||||
[SerializeField] private DialogueRunner dialogueRunner;
|
||||
[SerializeField] private GameObject dialogueUI;
|
||||
[SerializeField] private GameObject playerArmature;
|
||||
[SerializeField] private string yarnNodeName = "Bartender_Chat";
|
||||
|
||||
private bool playerInRange = false;
|
||||
|
||||
void OnTriggerEnter(Collider other)
|
||||
{
|
||||
if (other.CompareTag("Player"))
|
||||
playerInRange = true;
|
||||
}
|
||||
|
||||
void OnTriggerExit(Collider other)
|
||||
{
|
||||
if (other.CompareTag("Player"))
|
||||
playerInRange = false;
|
||||
}
|
||||
|
||||
void Update()
|
||||
{
|
||||
if (playerInRange && Input.GetKeyDown(KeyCode.E))
|
||||
{
|
||||
StartConversation();
|
||||
}
|
||||
}
|
||||
|
||||
void StartConversation()
|
||||
{
|
||||
playerArmature.SetActive(false);
|
||||
dialogueUI.SetActive(true);
|
||||
dialogueRunner.StartDialogue(yarnNodeName);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,2 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 99afbbd28c8054d59a7a0dec94f5ec8f
|
||||
@@ -0,0 +1,27 @@
|
||||
using UnityEngine;
|
||||
using Yarn.Unity;
|
||||
|
||||
namespace NightclubArcadia.Dialogue
|
||||
{
|
||||
/// <summary>
|
||||
/// Registers the <<enter_environment>> Yarn command, which steps the player
|
||||
/// out of dialogue and hands control to the 3D environment.
|
||||
/// </summary>
|
||||
public class DialogueTransitionController : MonoBehaviour
|
||||
{
|
||||
[SerializeField] private DialogueRunner dialogueRunner;
|
||||
[SerializeField] private GameObject dialogueUI;
|
||||
[SerializeField] private GameObject playerArmature;
|
||||
|
||||
void Start()
|
||||
{
|
||||
dialogueRunner.AddCommandHandler("enter_environment", EnterEnvironment);
|
||||
}
|
||||
|
||||
void EnterEnvironment()
|
||||
{
|
||||
dialogueUI.SetActive(false);
|
||||
playerArmature.SetActive(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,2 @@
|
||||
fileFormatVersion: 2
|
||||
guid: dc43c99ef338a41ea8f7a18c283fe6df
|
||||
Reference in New Issue
Block a user