game: die my workl has ended
This commit is contained in:
parent
743dc76913
commit
5953046a78
5 changed files with 65 additions and 41 deletions
|
@ -5535,7 +5535,6 @@ GameObject:
|
||||||
- component: {fileID: 520849220}
|
- component: {fileID: 520849220}
|
||||||
- component: {fileID: 520849219}
|
- component: {fileID: 520849219}
|
||||||
- component: {fileID: 520849216}
|
- component: {fileID: 520849216}
|
||||||
- component: {fileID: 520849217}
|
|
||||||
- component: {fileID: 520849218}
|
- component: {fileID: 520849218}
|
||||||
m_Layer: 0
|
m_Layer: 0
|
||||||
m_Name: Game Manager
|
m_Name: Game Manager
|
||||||
|
@ -5575,18 +5574,6 @@ MonoBehaviour:
|
||||||
shiftStarted: 0
|
shiftStarted: 0
|
||||||
currentNPC: {fileID: 0}
|
currentNPC: {fileID: 0}
|
||||||
currentNPCCorrectDepartment:
|
currentNPCCorrectDepartment:
|
||||||
--- !u!114 &520849217
|
|
||||||
MonoBehaviour:
|
|
||||||
m_ObjectHideFlags: 0
|
|
||||||
m_CorrespondingSourceObject: {fileID: 0}
|
|
||||||
m_PrefabInstance: {fileID: 0}
|
|
||||||
m_PrefabAsset: {fileID: 0}
|
|
||||||
m_GameObject: {fileID: 520849214}
|
|
||||||
m_Enabled: 1
|
|
||||||
m_EditorHideFlags: 0
|
|
||||||
m_Script: {fileID: 11500000, guid: 8c6fa011a2b389049b558ccdf6b38c38, type: 3}
|
|
||||||
m_Name:
|
|
||||||
m_EditorClassIdentifier:
|
|
||||||
--- !u!114 &520849218
|
--- !u!114 &520849218
|
||||||
MonoBehaviour:
|
MonoBehaviour:
|
||||||
m_ObjectHideFlags: 0
|
m_ObjectHideFlags: 0
|
||||||
|
@ -6764,7 +6751,7 @@ MonoBehaviour:
|
||||||
m_Script: {fileID: 11500000, guid: 0bab791ccf13189449b82b8f0b70b269, type: 3}
|
m_Script: {fileID: 11500000, guid: 0bab791ccf13189449b82b8f0b70b269, type: 3}
|
||||||
m_Name:
|
m_Name:
|
||||||
m_EditorClassIdentifier:
|
m_EditorClassIdentifier:
|
||||||
shiftDuration: 60
|
shiftDuration: 20
|
||||||
npcSpawnArea: {fileID: 1126609776}
|
npcSpawnArea: {fileID: 1126609776}
|
||||||
--- !u!1 &741702766
|
--- !u!1 &741702766
|
||||||
GameObject:
|
GameObject:
|
||||||
|
|
|
@ -52,7 +52,7 @@ public class GameManager : MonoBehaviour
|
||||||
public void SetCurrentNPC(GameObject npc)
|
public void SetCurrentNPC(GameObject npc)
|
||||||
{
|
{
|
||||||
currentNPC = npc;
|
currentNPC = npc;
|
||||||
|
NpcManager.instance.currentNpcs.Remove(npc);
|
||||||
NpcMovementRework npcScript = npc.GetComponent<NpcMovementRework>();
|
NpcMovementRework npcScript = npc.GetComponent<NpcMovementRework>();
|
||||||
if (npcScript != null)
|
if (npcScript != null)
|
||||||
{
|
{
|
||||||
|
|
|
@ -31,10 +31,10 @@ public class NpcMovementRework : MonoBehaviour
|
||||||
|
|
||||||
[SerializeField] private GameObject npcSpeechBubble;
|
[SerializeField] private GameObject npcSpeechBubble;
|
||||||
[SerializeField] private GameObject npcAnswerPanel;
|
[SerializeField] private GameObject npcAnswerPanel;
|
||||||
|
|
||||||
public NpcData npcData;
|
public NpcData npcData;
|
||||||
public string correctService;
|
public string correctService;
|
||||||
|
|
||||||
public void Update()
|
public void Update()
|
||||||
{
|
{
|
||||||
if (agent.velocity.magnitude > 0.1)
|
if (agent.velocity.magnitude > 0.1)
|
||||||
|
@ -53,7 +53,7 @@ public class NpcMovementRework : MonoBehaviour
|
||||||
agent = gameObject.GetComponent<NavMeshAgent>();
|
agent = gameObject.GetComponent<NavMeshAgent>();
|
||||||
animator = gameObject.GetComponent<Animator>();
|
animator = gameObject.GetComponent<Animator>();
|
||||||
Backend.instance.FirebaseGet(this);
|
Backend.instance.FirebaseGet(this);
|
||||||
|
|
||||||
npcSpeechBubble.SetActive(false);
|
npcSpeechBubble.SetActive(false);
|
||||||
npcAnswerPanel.SetActive(false);
|
npcAnswerPanel.SetActive(false);
|
||||||
StartCoroutine(SitDown());
|
StartCoroutine(SitDown());
|
||||||
|
@ -63,33 +63,33 @@ public class NpcMovementRework : MonoBehaviour
|
||||||
{
|
{
|
||||||
StartCoroutine(CustomerCalled());
|
StartCoroutine(CustomerCalled());
|
||||||
}
|
}
|
||||||
|
|
||||||
public IEnumerator CustomerCalled()
|
public IEnumerator CustomerCalled()
|
||||||
{
|
{
|
||||||
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);
|
GameManager.instance.SetCurrentNPC(this.gameObject);
|
||||||
|
|
||||||
npcSpeechBubble.SetActive(true);
|
npcSpeechBubble.SetActive(true);
|
||||||
npcAnswerPanel.SetActive(true);
|
npcAnswerPanel.SetActive(true);
|
||||||
PlayerDialogueInteraction.instance.playerDialogue.SetActive(true);
|
PlayerDialogueInteraction.instance.playerDialogue.SetActive(true);
|
||||||
|
|
||||||
yield return new WaitUntil(() => npcData != null);
|
yield return new WaitUntil(() => npcData != null);
|
||||||
|
|
||||||
correctService = npcData.correctDepartment;
|
correctService = npcData.correctDepartment;
|
||||||
|
|
||||||
LoadNPCDialogue();
|
LoadNPCDialogue();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -105,36 +105,64 @@ public class NpcMovementRework : MonoBehaviour
|
||||||
var seat = NpcManager.instance.Seats[i];
|
var seat = NpcManager.instance.Seats[i];
|
||||||
while (!seat.Available)
|
while (!seat.Available)
|
||||||
{
|
{
|
||||||
i = Random.Range(0, NpcManager.instance.Seats.Length);
|
i = Random.Range(0, NpcManager.instance.Seats.Length);
|
||||||
seat = NpcManager.instance.Seats[i];
|
seat = NpcManager.instance.Seats[i];
|
||||||
yield return new WaitForSeconds(2f);
|
yield return new WaitForSeconds(2f);
|
||||||
}
|
}
|
||||||
|
|
||||||
seat.Available = false;
|
seat.Available = false;
|
||||||
var sittingPosition = seat.SeatObject.transform.position;
|
var sittingPosition = seat.SeatObject.transform.position;
|
||||||
sittingPosition.y = 0;
|
sittingPosition.y = 0;
|
||||||
agent.SetDestination(sittingPosition);
|
agent.SetDestination(sittingPosition);
|
||||||
|
|
||||||
while (true)
|
while (true)
|
||||||
{
|
{
|
||||||
var dist= Vector3.Distance(sittingPosition,gameObject.transform.position);
|
var dist = Vector3.Distance(sittingPosition, gameObject.transform.position);
|
||||||
if (dist < 0.05f)
|
if (dist < 0.05f)
|
||||||
{
|
{
|
||||||
agent.SetDestination(gameObject.transform.position);
|
agent.SetDestination(gameObject.transform.position);
|
||||||
animator.SetBool(IsSitting, true);
|
animator.SetBool(IsSitting, true);
|
||||||
gameObject.transform.rotation = seat.SeatObject.transform.rotation;
|
gameObject.transform.rotation = seat.SeatObject.transform.rotation;
|
||||||
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
yield return 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public void Despawn(bool endDay = false)
|
||||||
|
{
|
||||||
|
if (endDay)
|
||||||
|
{
|
||||||
|
var random = Random.Range(0, NpcManager.instance.spawnPoints.Length);
|
||||||
|
StartCoroutine(DespawnWhenReached(NpcManager.instance.spawnPoints[random]));
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
var random = Random.Range(0, NpcManager.instance.despawnPoints.Length);
|
||||||
|
StartCoroutine(DespawnWhenReached(NpcManager.instance.despawnPoints[random]));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private IEnumerator DespawnWhenReached(Transform destination)
|
||||||
|
{
|
||||||
|
agent.SetDestination(destination.position);
|
||||||
|
while (true)
|
||||||
|
{
|
||||||
|
var dist = Vector3.Distance(destination.position, gameObject.transform.position);
|
||||||
|
if (dist < 1)
|
||||||
|
{
|
||||||
|
agent.SetDestination(gameObject.transform.position);
|
||||||
|
Destroy(gameObject);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
yield return 0;
|
yield return 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Despawn()
|
|
||||||
{
|
|
||||||
var random = Random.Range(0, NpcManager.instance.despawnPoints.Length);
|
|
||||||
agent.SetDestination(NpcManager.instance.despawnPoints[random].position);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void LoadNPCDialogue()
|
public void LoadNPCDialogue()
|
||||||
{
|
{
|
||||||
|
@ -151,13 +179,13 @@ public class NpcMovementRework : MonoBehaviour
|
||||||
|
|
||||||
npcWelcomeText.text = "Hello";
|
npcWelcomeText.text = "Hello";
|
||||||
initialStatementText.text = npcData.initialStatement;
|
initialStatementText.text = npcData.initialStatement;
|
||||||
|
|
||||||
npcAnswerOneText.text = npcData.answer1;
|
npcAnswerOneText.text = npcData.answer1;
|
||||||
npcAnswerTwoText.text = npcData.answer2;
|
npcAnswerTwoText.text = npcData.answer2;
|
||||||
npcAnswerThreeText.text = npcData.answer3;
|
npcAnswerThreeText.text = npcData.answer3;
|
||||||
|
|
||||||
npcClarifiedResponse.text = "I see...";
|
npcClarifiedResponse.text = "I see...";
|
||||||
|
|
||||||
PlayerDialogueInteraction.instance.SetPlayerQuestions(npcData.question1, npcData.question2, npcData.question3);
|
PlayerDialogueInteraction.instance.SetPlayerQuestions(npcData.question1, npcData.question2, npcData.question3);
|
||||||
PlayerDialogueInteraction.instance.SetPlayerResposne(npcData.response3);
|
PlayerDialogueInteraction.instance.SetPlayerResposne(npcData.response3);
|
||||||
}
|
}
|
||||||
|
|
|
@ -136,6 +136,14 @@ public class NpcManager : MonoBehaviour
|
||||||
isSpawning = false;
|
isSpawning = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void EndDay()
|
||||||
|
{
|
||||||
|
foreach (var npc in currentNpcs)
|
||||||
|
{
|
||||||
|
npc.GetComponent<NpcMovementRework>().Despawn(true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
[Serializable]
|
[Serializable]
|
||||||
public struct Seat
|
public struct Seat
|
||||||
{
|
{
|
||||||
|
|
|
@ -70,6 +70,7 @@ public class ShiftManager : MonoBehaviour
|
||||||
remainingTime = shiftDuration;
|
remainingTime = shiftDuration;
|
||||||
gm.shiftStarted = false;
|
gm.shiftStarted = false;
|
||||||
dayManager.doneAShift = true;
|
dayManager.doneAShift = true;
|
||||||
|
NpcManager.instance.EndDay();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void AllowShiftStart()
|
public void AllowShiftStart()
|
||||||
|
|
Loading…
Add table
Reference in a new issue