game: npc scenarios + player dialogue ui
This commit is contained in:
parent
58eaaebfe7
commit
cf8bad3908
5 changed files with 76 additions and 16 deletions
|
@ -2031,6 +2031,7 @@ GameObject:
|
||||||
- component: {fileID: 272065566}
|
- component: {fileID: 272065566}
|
||||||
- component: {fileID: 272065565}
|
- component: {fileID: 272065565}
|
||||||
- component: {fileID: 272065564}
|
- component: {fileID: 272065564}
|
||||||
|
- component: {fileID: 272065568}
|
||||||
m_Layer: 5
|
m_Layer: 5
|
||||||
m_Name: PlayerDialogue
|
m_Name: PlayerDialogue
|
||||||
m_TagString: Untagged
|
m_TagString: Untagged
|
||||||
|
@ -2124,6 +2125,25 @@ RectTransform:
|
||||||
m_AnchoredPosition: {x: 1.184, y: 1.477}
|
m_AnchoredPosition: {x: 1.184, y: 1.477}
|
||||||
m_SizeDelta: {x: 659.8499, y: 515.963}
|
m_SizeDelta: {x: 659.8499, y: 515.963}
|
||||||
m_Pivot: {x: 0.5, y: 0.5}
|
m_Pivot: {x: 0.5, y: 0.5}
|
||||||
|
--- !u!114 &272065568
|
||||||
|
MonoBehaviour:
|
||||||
|
m_ObjectHideFlags: 0
|
||||||
|
m_CorrespondingSourceObject: {fileID: 0}
|
||||||
|
m_PrefabInstance: {fileID: 0}
|
||||||
|
m_PrefabAsset: {fileID: 0}
|
||||||
|
m_GameObject: {fileID: 272065563}
|
||||||
|
m_Enabled: 1
|
||||||
|
m_EditorHideFlags: 0
|
||||||
|
m_Script: {fileID: 11500000, guid: 7951c64acb0fa62458bf30a60089fe2d, type: 3}
|
||||||
|
m_Name:
|
||||||
|
m_EditorClassIdentifier:
|
||||||
|
m_IgnoreReversedGraphics: 0
|
||||||
|
m_CheckFor2DOcclusion: 0
|
||||||
|
m_CheckFor3DOcclusion: 0
|
||||||
|
m_BlockingMask:
|
||||||
|
serializedVersion: 2
|
||||||
|
m_Bits: 4294967295
|
||||||
|
m_RaycastTriggerInteraction: 1
|
||||||
--- !u!1 &278641001
|
--- !u!1 &278641001
|
||||||
GameObject:
|
GameObject:
|
||||||
m_ObjectHideFlags: 0
|
m_ObjectHideFlags: 0
|
||||||
|
|
|
@ -119,8 +119,21 @@ public class Backend : MonoBehaviour
|
||||||
{
|
{
|
||||||
DataSnapshot snapshot = task.Result;
|
DataSnapshot snapshot = task.Result;
|
||||||
string json = snapshot.GetRawJsonValue();
|
string json = snapshot.GetRawJsonValue();
|
||||||
data = JsonUtility.FromJson<NpcData>(json);
|
|
||||||
target.npcData = data;
|
if (!string.IsNullOrEmpty(json))
|
||||||
|
{
|
||||||
|
target.npcData = JsonUtility.FromJson<NpcData>(json);
|
||||||
|
Debug.Log($"NPC Loaded: {target.npcData.initialStatement}");
|
||||||
|
|
||||||
|
if (GameManager.instance.currentNPC == target.gameObject)
|
||||||
|
{
|
||||||
|
target.LoadNPCDialogue();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
Debug.LogError("Firebase returned empty");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
;
|
;
|
||||||
|
|
|
@ -23,16 +23,14 @@ public class GameManager : MonoBehaviour
|
||||||
public bool dayEnded = false;
|
public bool dayEnded = false;
|
||||||
public bool shiftStarted;
|
public bool shiftStarted;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// NPC in front of desk
|
||||||
|
/// </summary>
|
||||||
public GameObject currentNPC;
|
public GameObject currentNPC;
|
||||||
|
|
||||||
/*[Header("Walk Points (FOR DEBUGGING")]
|
///<summary>
|
||||||
public Transform[] frontWalkPoints;
|
/// References for player-npc dialogue
|
||||||
public Transform[] leftWalkPoints;
|
/// </summary>
|
||||||
public Transform[] rightWalkPoints;
|
|
||||||
|
|
||||||
public GameObject leftWalkPointSet;
|
|
||||||
public GameObject rightWalkPointSet;*/
|
|
||||||
|
|
||||||
[Header("NPC Dialogue")]
|
[Header("NPC Dialogue")]
|
||||||
public TextMeshProUGUI playerQuestionOneText;
|
public TextMeshProUGUI playerQuestionOneText;
|
||||||
public TextMeshProUGUI playerQuestionTwoText;
|
public TextMeshProUGUI playerQuestionTwoText;
|
||||||
|
@ -59,4 +57,13 @@ public class GameManager : MonoBehaviour
|
||||||
|
|
||||||
playerDialogue.SetActive(false);
|
playerDialogue.SetActive(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Setting NPC in front of desk as current
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="npc"></param>
|
||||||
|
public void SetCurrentNPC(GameObject npc)
|
||||||
|
{
|
||||||
|
currentNPC = npc;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -51,9 +51,7 @@ public class NpcMovementRework : MonoBehaviour
|
||||||
Backend.instance.FirebaseGet(this);
|
Backend.instance.FirebaseGet(this);
|
||||||
|
|
||||||
npcSpeechBubble.SetActive(false);
|
npcSpeechBubble.SetActive(false);
|
||||||
|
|
||||||
StartCoroutine(SitDown());
|
StartCoroutine(SitDown());
|
||||||
LoadNPCDialogue();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Called()
|
public void Called()
|
||||||
|
@ -65,18 +63,26 @@ public class NpcMovementRework : MonoBehaviour
|
||||||
{
|
{
|
||||||
var pos = NpcManager.instance.desk;
|
var pos = NpcManager.instance.desk;
|
||||||
agent.SetDestination(pos.position);
|
agent.SetDestination(pos.position);
|
||||||
|
|
||||||
while (true)
|
while (true)
|
||||||
{
|
{
|
||||||
var npcpos = gameObject.transform.position;
|
var npcpos = gameObject.transform.position;
|
||||||
npcpos.y = 0;
|
npcpos.y = 0;
|
||||||
var dist= Vector3.Distance(pos.position,npcpos);
|
var dist= Vector3.Distance(pos.position,npcpos);
|
||||||
|
|
||||||
if (dist<0.5f)
|
if (dist<0.5f)
|
||||||
{
|
{
|
||||||
agent.SetDestination(gameObject.transform.position);
|
agent.SetDestination(gameObject.transform.position);
|
||||||
gameObject.transform.rotation = pos.transform.rotation;
|
gameObject.transform.rotation = pos.transform.rotation;
|
||||||
|
|
||||||
|
GameManager.instance.SetCurrentNPC(this.gameObject);
|
||||||
|
|
||||||
npcSpeechBubble.SetActive(true);
|
npcSpeechBubble.SetActive(true);
|
||||||
GameManager.instance.playerDialogue.SetActive(true);
|
GameManager.instance.playerDialogue.SetActive(true);
|
||||||
|
Debug.Log($"{gameObject.name} reached desk");
|
||||||
|
|
||||||
|
yield return new WaitUntil(() => npcData != null);
|
||||||
|
|
||||||
LoadNPCDialogue();
|
LoadNPCDialogue();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -125,8 +131,17 @@ public class NpcMovementRework : MonoBehaviour
|
||||||
|
|
||||||
public void LoadNPCDialogue()
|
public void LoadNPCDialogue()
|
||||||
{
|
{
|
||||||
Debug.Log("Loading NPC Dialogue");
|
if (GameManager.instance.currentNPC != this.gameObject)
|
||||||
Debug.Log(npcData.initialStatement);
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (npcData == null)
|
||||||
|
{
|
||||||
|
Debug.LogError($"NPC Data is null for {gameObject.name}");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
initialStatementText.text = npcData.initialStatement;
|
initialStatementText.text = npcData.initialStatement;
|
||||||
|
|
||||||
GameManager.instance.playerQuestionOneText.text = npcData.question1;
|
GameManager.instance.playerQuestionOneText.text = npcData.question1;
|
||||||
|
|
|
@ -2,10 +2,15 @@ using UnityEngine;
|
||||||
|
|
||||||
public class NextButton : MonoBehaviour
|
public class NextButton : MonoBehaviour
|
||||||
{
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Next NPC to desk based on scene list
|
||||||
|
/// </summary>
|
||||||
public void CallNext()
|
public void CallNext()
|
||||||
{
|
{
|
||||||
var npcs = NpcManager.instance.currentNpcs;
|
var npcs = NpcManager.instance.currentNpcs;
|
||||||
var randomnpc = npcs[Random.Range(0, npcs.Count)];
|
var randomnpc = npcs[Random.Range(0, npcs.Count)];
|
||||||
|
|
||||||
|
GameManager.instance.SetCurrentNPC(randomnpc);
|
||||||
randomnpc.GetComponent<NpcMovementRework>().Called();
|
randomnpc.GetComponent<NpcMovementRework>().Called();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue