Compare commits
No commits in common. "3e8481d6ea47c050a652926bbd0d5a549941a82c" and "4dd6e7bf2c5115713c05ea1bb95984c588f9219d" have entirely different histories.
3e8481d6ea
...
4dd6e7bf2c
@ -919,7 +919,6 @@ GameObject:
|
|||||||
- component: {fileID: 274103194}
|
- component: {fileID: 274103194}
|
||||||
- component: {fileID: 274103193}
|
- component: {fileID: 274103193}
|
||||||
- component: {fileID: 274103192}
|
- component: {fileID: 274103192}
|
||||||
- component: {fileID: 274103195}
|
|
||||||
m_Layer: 0
|
m_Layer: 0
|
||||||
m_Name: Beaver
|
m_Name: Beaver
|
||||||
m_TagString: Interactable
|
m_TagString: Interactable
|
||||||
@ -987,33 +986,6 @@ Transform:
|
|||||||
- {fileID: 243848965}
|
- {fileID: 243848965}
|
||||||
m_Father: {fileID: 0}
|
m_Father: {fileID: 0}
|
||||||
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
||||||
--- !u!54 &274103195
|
|
||||||
Rigidbody:
|
|
||||||
m_ObjectHideFlags: 0
|
|
||||||
m_CorrespondingSourceObject: {fileID: 0}
|
|
||||||
m_PrefabInstance: {fileID: 0}
|
|
||||||
m_PrefabAsset: {fileID: 0}
|
|
||||||
m_GameObject: {fileID: 274103191}
|
|
||||||
serializedVersion: 4
|
|
||||||
m_Mass: 1
|
|
||||||
m_Drag: 0
|
|
||||||
m_AngularDrag: 0.05
|
|
||||||
m_CenterOfMass: {x: 0, y: 0, z: 0}
|
|
||||||
m_InertiaTensor: {x: 1, y: 1, z: 1}
|
|
||||||
m_InertiaRotation: {x: 0, y: 0, z: 0, w: 1}
|
|
||||||
m_IncludeLayers:
|
|
||||||
serializedVersion: 2
|
|
||||||
m_Bits: 0
|
|
||||||
m_ExcludeLayers:
|
|
||||||
serializedVersion: 2
|
|
||||||
m_Bits: 0
|
|
||||||
m_ImplicitCom: 1
|
|
||||||
m_ImplicitTensor: 1
|
|
||||||
m_UseGravity: 1
|
|
||||||
m_IsKinematic: 1
|
|
||||||
m_Interpolate: 0
|
|
||||||
m_Constraints: 0
|
|
||||||
m_CollisionDetection: 0
|
|
||||||
--- !u!1001 &333271331
|
--- !u!1001 &333271331
|
||||||
PrefabInstance:
|
PrefabInstance:
|
||||||
m_ObjectHideFlags: 0
|
m_ObjectHideFlags: 0
|
||||||
|
@ -1,4 +1,3 @@
|
|||||||
using System.Collections;
|
|
||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
using TMPro;
|
using TMPro;
|
||||||
using UnityEngine.UI;
|
using UnityEngine.UI;
|
||||||
@ -17,25 +16,10 @@ public class DialogManager : MonoBehaviour
|
|||||||
public void ShowDialog(string message)
|
public void ShowDialog(string message)
|
||||||
{
|
{
|
||||||
print("should be showing dialog");
|
print("should be showing dialog");
|
||||||
StartCoroutine(ShowDialogCoroutine(message));
|
dialogText.text = message;
|
||||||
dialogPanel.SetActive(true);
|
dialogPanel.SetActive(true);
|
||||||
playerMovement.moveAllowed = false;
|
playerMovement.moveAllowed = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Coroutine to show dialog. Each letter is displayed one by one
|
|
||||||
IEnumerator ShowDialogCoroutine(string message)
|
|
||||||
{
|
|
||||||
dialogText.text = ""; // Clear previous text
|
|
||||||
dialogPanel.SetActive(true);
|
|
||||||
playerMovement.moveAllowed = false;
|
|
||||||
|
|
||||||
foreach (char letter in message)
|
|
||||||
{
|
|
||||||
dialogText.text += letter; // Append each letter
|
|
||||||
// KRAUSI MACH SOUND HIER DRINNE REIN PRO LETTER
|
|
||||||
yield return new WaitForSeconds(0.05f); // Wait for a short duration before showing the next letter
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public void HideDialog()
|
public void HideDialog()
|
||||||
{
|
{
|
||||||
|
@ -19,7 +19,6 @@ public class PlayerInteraction : MonoBehaviour
|
|||||||
[SerializeField] private GameObject dialogManagerObject;
|
[SerializeField] private GameObject dialogManagerObject;
|
||||||
|
|
||||||
private DialogManager dialogManager;
|
private DialogManager dialogManager;
|
||||||
private List<GameObject> interactableObjects = new List<GameObject>();
|
|
||||||
void Start()
|
void Start()
|
||||||
{
|
{
|
||||||
InteractAction.action.Enable();
|
InteractAction.action.Enable();
|
||||||
@ -35,59 +34,32 @@ public class PlayerInteraction : MonoBehaviour
|
|||||||
{
|
{
|
||||||
if (context.performed)
|
if (context.performed)
|
||||||
{
|
{
|
||||||
|
Ray ray = new Ray(transform.position, transform.forward);
|
||||||
GameObject speaker = interactableObjects.Count > 0 ? ColliderInteractable() : PhysicsRaycastInteractable();
|
RaycastHit hit;
|
||||||
|
|
||||||
dialog = speaker.GetComponent<QuestGiver>().Talk();
|
if (Physics.Raycast(ray, out hit, interactRange))
|
||||||
// immedeately start the dialog
|
|
||||||
dialogManager.ShowDialog("<b>" + dialog[dialogIndex].speaker + ": " + dialog[dialogIndex].text);
|
|
||||||
// skip the 0th dialog entry since it has already been shown
|
|
||||||
dialogIndex++;
|
|
||||||
if (dialogIndex >= dialog.Length)
|
|
||||||
{
|
{
|
||||||
// reset the dialog index if we reach the end of the dialog
|
if (hit.collider.CompareTag("Interactable"))
|
||||||
dialogIndex = 0;
|
{
|
||||||
// reset the dialog to be null so it cannot be scrolled through when not in an interaction
|
//Debug.Log("Interacted with: " + hit.collider.name);
|
||||||
dialog = null;
|
// You can add more actions here
|
||||||
dialogManager.HideDialog();
|
dialog = hit.collider.GetComponent<QuestGiver>().Talk();
|
||||||
|
// immedeately start the dialog
|
||||||
|
dialogManager.ShowDialog(dialog[dialogIndex].speaker + ": " + dialog[dialogIndex].text);
|
||||||
|
// skip the 0th dialog entry since it has already been shown
|
||||||
|
dialogIndex++;
|
||||||
|
if (dialogIndex >= dialog.Length)
|
||||||
|
{
|
||||||
|
// reset the dialog index if we reach the end of the dialog
|
||||||
|
dialogIndex = 0;
|
||||||
|
// reset the dialog to be null so it cannot be scrolled through when not in an interaction
|
||||||
|
dialog = null;
|
||||||
|
dialogManager.HideDialog();
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private GameObject PhysicsRaycastInteractable()
|
|
||||||
{
|
|
||||||
Ray ray = new Ray(transform.position, transform.forward);
|
|
||||||
RaycastHit hit;
|
|
||||||
|
|
||||||
if (Physics.Raycast(ray, out hit, interactRange))
|
|
||||||
{
|
|
||||||
if (hit.collider.CompareTag("Interactable"))
|
|
||||||
{
|
|
||||||
//Debug.Log("Interacted with: " + hit.collider.name);
|
|
||||||
// You can add more actions here
|
|
||||||
return hit.collider.gameObject;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
private GameObject ColliderInteractable()
|
|
||||||
{
|
|
||||||
print("test");
|
|
||||||
float closestDistance = float.MaxValue;
|
|
||||||
int pos = -1;
|
|
||||||
for (int i = 0; i < interactableObjects.Count; i++)
|
|
||||||
{
|
|
||||||
if ((interactableObjects[i].transform.position - transform.position).magnitude < closestDistance)
|
|
||||||
{
|
|
||||||
closestDistance = (interactableObjects[i].transform.position - transform.position).magnitude;
|
|
||||||
pos = i;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return interactableObjects[pos];
|
|
||||||
}
|
|
||||||
|
|
||||||
void onDialogContinue(InputAction.CallbackContext context)
|
void onDialogContinue(InputAction.CallbackContext context)
|
||||||
{
|
{
|
||||||
@ -110,22 +82,9 @@ public class PlayerInteraction : MonoBehaviour
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void OnTriggerEnter(Collision other)
|
void Update()
|
||||||
{
|
{
|
||||||
print("outside");
|
|
||||||
if (other.gameObject.tag == "Interactable")
|
|
||||||
{
|
|
||||||
print("inside");
|
|
||||||
interactableObjects.Add(other.gameObject);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void OnTriggerExit(Collision other)
|
|
||||||
{
|
|
||||||
if (other.gameObject.tag == "Interactable")
|
|
||||||
{
|
|
||||||
interactableObjects.Remove(other.gameObject);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void CollectBlueberry(int newBlueberries)
|
public void CollectBlueberry(int newBlueberries)
|
||||||
|
@ -1,5 +1,8 @@
|
|||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
using UnityEditor.SearchService;
|
||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
|
using UnityEngine.Events;
|
||||||
|
using UnityEngine.InputSystem;
|
||||||
|
|
||||||
public class QuestGiver : MonoBehaviour
|
public class QuestGiver : MonoBehaviour
|
||||||
{
|
{
|
||||||
|
Loading…
Reference in New Issue
Block a user