game: fixed the endless walking
This commit is contained in:
parent
833fb0b50b
commit
2adf242307
4 changed files with 45 additions and 39 deletions
|
@ -21,6 +21,7 @@ public class NpcMovementRework : MonoBehaviour
|
|||
/// Animation assigning
|
||||
/// </summary>
|
||||
public Animator animator;
|
||||
|
||||
private static readonly int IsSitting = Animator.StringToHash("isSitting");
|
||||
private static readonly int Speed = Animator.StringToHash("Speed");
|
||||
|
||||
|
@ -28,6 +29,7 @@ public class NpcMovementRework : MonoBehaviour
|
|||
/// NPC's dialogue variables
|
||||
/// </summary>
|
||||
public TextMeshProUGUI npcWelcomeText;
|
||||
|
||||
public TextMeshProUGUI initialStatementText;
|
||||
public TextMeshProUGUI npcAnswerOneText;
|
||||
public TextMeshProUGUI npcAnswerTwoText;
|
||||
|
@ -41,7 +43,7 @@ public class NpcMovementRework : MonoBehaviour
|
|||
/// NPC Data referemce
|
||||
/// </summary>
|
||||
public NpcData npcData;
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Variable to store service
|
||||
/// </summary>
|
||||
|
@ -74,54 +76,33 @@ public class NpcMovementRework : MonoBehaviour
|
|||
npcSpeechBubble.SetActive(false);
|
||||
npcAnswerPanel.SetActive(false);
|
||||
StartCoroutine(SitDown());
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Call coroutine to call client
|
||||
/// </summary>
|
||||
public void Called()
|
||||
{
|
||||
StartCoroutine(CustomerCalled());
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Coroutine to get NPC to coe to table
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public IEnumerator CustomerCalled()
|
||||
public void CustomerCalled()
|
||||
{
|
||||
animator.SetBool(IsSitting, false);
|
||||
var pos = NpcManager.instance.desk;
|
||||
agent.SetDestination(pos.position);
|
||||
|
||||
while (true)
|
||||
{
|
||||
var npcpos = gameObject.transform.position;
|
||||
npcpos.y = 0;
|
||||
var dist = Vector3.Distance(pos.position, npcpos);
|
||||
var npcpos = gameObject.transform.position;
|
||||
npcpos.y = 0;
|
||||
}
|
||||
|
||||
if (dist < 1.0f)
|
||||
{
|
||||
agent.SetDestination(gameObject.transform.position);
|
||||
gameObject.transform.rotation = pos.transform.rotation;
|
||||
public void Stop()
|
||||
{
|
||||
agent.SetDestination(gameObject.transform.position);
|
||||
GameManager.instance.SetCurrentNPC(this.gameObject);
|
||||
|
||||
GameManager.instance.SetCurrentNPC(this.gameObject);
|
||||
npcSpeechBubble.SetActive(true);
|
||||
npcAnswerPanel.SetActive(true);
|
||||
PlayerDialogueInteraction.instance.playerDialogue.SetActive(true);
|
||||
correctService = npcData.correctDepartment;
|
||||
|
||||
npcSpeechBubble.SetActive(true);
|
||||
npcAnswerPanel.SetActive(true);
|
||||
PlayerDialogueInteraction.instance.playerDialogue.SetActive(true);
|
||||
|
||||
yield return new WaitUntil(() => npcData != null);
|
||||
|
||||
correctService = npcData.correctDepartment;
|
||||
|
||||
LoadNPCDialogue();
|
||||
break;
|
||||
}
|
||||
|
||||
yield return 0;
|
||||
}
|
||||
LoadNPCDialogue();
|
||||
}
|
||||
|
||||
|
||||
|
@ -139,10 +120,10 @@ public class NpcMovementRework : MonoBehaviour
|
|||
seat = NpcManager.instance.Seats[i];
|
||||
yield return new WaitForSeconds(2f);
|
||||
}
|
||||
|
||||
|
||||
seat.Available = false;
|
||||
var sittingPosition = seat.SeatObject.transform.position;
|
||||
|
||||
|
||||
agent.SetDestination(sittingPosition);
|
||||
Debug.Log("Sitting down");
|
||||
while (true)
|
||||
|
@ -160,7 +141,7 @@ public class NpcMovementRework : MonoBehaviour
|
|||
yield return 0;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Despawning NPCs
|
||||
|
|
|
@ -20,7 +20,7 @@ public class NextButton : MonoBehaviour
|
|||
var randomnpc = npcs[Random.Range(0, npcs.Count)];
|
||||
|
||||
GameManager.instance.SetCurrentNPC(randomnpc);
|
||||
randomnpc.GetComponent<NpcMovementRework>().Called();
|
||||
randomnpc.GetComponent<NpcMovementRework>().CustomerCalled();
|
||||
|
||||
PlayerDialogueInteraction.instance.ResetChecklist();
|
||||
PlayerDialogueInteraction.instance.ResetDialogue();
|
||||
|
|
14
SSLR/Assets/Scripts/TableCollider.cs
Normal file
14
SSLR/Assets/Scripts/TableCollider.cs
Normal file
|
@ -0,0 +1,14 @@
|
|||
|
||||
using System;
|
||||
using UnityEngine;
|
||||
|
||||
public class TableCollider : MonoBehaviour
|
||||
{
|
||||
private void OnTriggerEnter(Collider other)
|
||||
{
|
||||
if (other.CompareTag("NPC"))
|
||||
{
|
||||
other.GetComponent<NpcMovementRework>().Stop();
|
||||
}
|
||||
}
|
||||
}
|
11
SSLR/Assets/Scripts/TableCollider.cs.meta
Normal file
11
SSLR/Assets/Scripts/TableCollider.cs.meta
Normal file
|
@ -0,0 +1,11 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 5ed21d83f6d63754aad737a383513a18
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
Loading…
Add table
Reference in a new issue