1
0
forked from cgvr/DeltaVR

2 Commits

5 changed files with 38 additions and 17 deletions

View File

@@ -9,6 +9,7 @@
* npc character:
* klaas on näha temast eespool
* voicelines: list listidest, mille hulgast saab valida
* Unity crash after stopping the game - most likely due to FMOD trying to do something with invalid audio instances
Can't/Won't Do:
* glTF loading: vahetada ära shader Universal render pipeline Lit, mitte panna buildi kaasa glTf oma - **ei saa, objekt on siis ilma tekstuurita, lihtsalt hall**

View File

@@ -146,8 +146,7 @@ public abstract class NPCController : MonoBehaviour
protected virtual void OnPlayerLeave() {}
public void SpeakVoiceLine(int voiceLineId)
public void SpeakVoiceLine(int voiceLineId, GameObject emitter = null, float radioAmount = 0f)
{
if (voiceLineId < 0 || voiceLineId >= voiceLineKeys.Length)
{
@@ -163,7 +162,8 @@ public abstract class NPCController : MonoBehaviour
LoadCurve(key); // load RMS data
currentVoicelineEvent = AudioManager.Instance.PlayDialogue(characterSpecificFolder + "/" + key, gameObject);
emitter = emitter ?? gameObject;
currentVoicelineEvent = AudioManager.Instance.PlayDialogue(characterSpecificFolder + "/" + key, emitter, radioAmount);
if (!currentVoicelineEvent.isValid())
{
Debug.LogError("Failed to start dialogue event.");

View File

@@ -14,6 +14,7 @@ public class ShapeDetectionNPC : NPCController
public Texture2D GeneratedTexture { get; private set; }
public Image imageDisplay;
public ShapeScanner shapeScanner;
public float radioAmount = 1f;
public GameObject GeneratedModel { get; private set; }
public Transform modelSpawnPoint;
@@ -57,8 +58,8 @@ public class ShapeDetectionNPC : NPCController
{
state = 1;
await CallPlayer();
await Task.Delay(2500);
questMarker.MoveTo(radio.transform);
await Task.Delay(2000);
questMarker.MoveTo(radio.transform, true);
}
}
@@ -79,10 +80,14 @@ public class ShapeDetectionNPC : NPCController
{
if (state == 1)
{
SpeakVoiceLine(0);
SpeakVoiceLine(0, radio.gameObject, radioAmount);
await Task.Delay(2000);
SpeakVoiceLine(1);
Invoke(nameof(CallPlayer), 4f);
// Has the player maybe picked up the radio during the last 2 seconds?
if (state == 1)
{
SpeakVoiceLine(1, radio.gameObject, radioAmount);
Invoke(nameof(CallPlayer), 4f);
}
}
}
@@ -90,7 +95,7 @@ public class ShapeDetectionNPC : NPCController
{
if (state == 1)
{
SpeakVoiceLine(2);
SpeakVoiceLine(2, radio.gameObject, radioAmount);
state = 2;
await Task.Delay(5000);
questMarker.MoveTo(microphoneStand.transform);
@@ -102,7 +107,7 @@ public class ShapeDetectionNPC : NPCController
{
if (state == 2)
{
SpeakVoiceLine(3);
SpeakVoiceLine(3, radio.gameObject, radioAmount);
state = 3;
questMarker.MoveTo(imageGenerationButton.transform);
}
@@ -119,7 +124,7 @@ public class ShapeDetectionNPC : NPCController
imageGenerationButton.Deactivate();
if (state == 3)
{
SpeakVoiceLine(4);
SpeakVoiceLine(4, radio.gameObject, radioAmount);
state = 4;
questMarker.MoveTo(modelGenerationButton.transform);
modelGenerationButton.Deactivate();
@@ -130,9 +135,9 @@ public class ShapeDetectionNPC : NPCController
{
if (state == 4)
{
SpeakVoiceLine(5);
SpeakVoiceLine(5, radio.gameObject, radioAmount);
state = 5;
questMarker.MoveTo(shapeScanner.transform);
questMarker.MoveTo(shapeScanner.transform, true);
}
string encodedTexture = Convert.ToBase64String(GeneratedTexture.EncodeToJPG());

View File

@@ -7,10 +7,11 @@ public class QuestMarker : MonoBehaviour
public Transform movingPart;
public float amplitude = 0.1f; // How far up/down it moves
public float frequency = 1.5f; // Speed of oscillation
public float heightAboveTarget = 1f;
public float heightAboveTarget = 0.75f;
private Vector3 startPos;
private Transform playerTransform;
private Transform hoverAboveTransform;
// Start is called before the first frame update
void Start()
@@ -31,6 +32,13 @@ public class QuestMarker : MonoBehaviour
Vector3 lookTargetPos = new Vector3(playerTransform.position.x, transform.position.y, playerTransform.position.z);
transform.LookAt(lookTargetPos);
}
if (hoverAboveTransform != null)
{
Debug.Log("pos before floating: " + transform.position);
transform.position = hoverAboveTransform.position + new Vector3(0f, heightAboveTarget, 0f);
Debug.Log("pos after floating: " + transform.position);
}
}
private void OnTriggerEnter(Collider other)
@@ -49,8 +57,15 @@ public class QuestMarker : MonoBehaviour
}
}
public void MoveTo(Transform target)
public void MoveTo(Transform target, bool attach = false)
{
transform.position = target.position + new Vector3(0, heightAboveTarget, 0);
if (attach)
{
hoverAboveTransform = target;
} else
{
hoverAboveTransform = null;
}
}
}