quests, next line fixed
This commit is contained in:
16
Assets/Script/NpcUI.cs
Normal file
16
Assets/Script/NpcUI.cs
Normal file
@@ -0,0 +1,16 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
|
||||
public class NpcUI : MonoBehaviour
|
||||
{
|
||||
public Button btnNext;
|
||||
public void Start(){
|
||||
btnNext.onClick.AddListener(onNext);
|
||||
}
|
||||
|
||||
void onNext(){
|
||||
npcScript.activeNpc.NextLine();
|
||||
}
|
||||
}
|
||||
11
Assets/Script/NpcUI.cs.meta
Normal file
11
Assets/Script/NpcUI.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 5a35344bf9ff1da4f94548babcd8c109
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -7,6 +7,9 @@ using UnityEngine.UI;
|
||||
|
||||
public class npcScript : MonoBehaviour
|
||||
{
|
||||
|
||||
public static npcScript activeNpc;
|
||||
|
||||
public GameObject npcPanel;
|
||||
public GameObject textBtn;
|
||||
public TMP_Text npcText;
|
||||
@@ -36,6 +39,7 @@ public class npcScript : MonoBehaviour
|
||||
IEnumerator textLoad()
|
||||
{
|
||||
isLoadingText = true;
|
||||
Debug.Log($"Reading line {questLineIndex} from quest {activeQuest}", gameObject);
|
||||
foreach (char letter in questData[activeQuest].questLines[questLineIndex].ToCharArray())
|
||||
{
|
||||
npcText.text += letter;
|
||||
@@ -73,7 +77,7 @@ public class npcScript : MonoBehaviour
|
||||
{
|
||||
if (other.CompareTag("Player"))
|
||||
{
|
||||
|
||||
Debug.Log($"Player entered into {gameObject.name}",gameObject);
|
||||
if (other.transform == playerNetwork.localPlayerTransform)
|
||||
{
|
||||
playerNetwork pnet = playerNetwork.localPlayerTransform.GetComponent<playerNetwork>();
|
||||
@@ -112,6 +116,7 @@ public class npcScript : MonoBehaviour
|
||||
}
|
||||
|
||||
isPlayerClose = true;
|
||||
activeNpc= this;
|
||||
if (npcPanel.activeInHierarchy)
|
||||
{
|
||||
ResetTexts();
|
||||
@@ -131,11 +136,16 @@ public class npcScript : MonoBehaviour
|
||||
|
||||
void LoadText()
|
||||
{
|
||||
if(!isPlayerClose){
|
||||
Debug.Log("This player aint in my area", gameObject);
|
||||
return;
|
||||
}
|
||||
npcText.text = "";
|
||||
if (textLoopAsync != null)
|
||||
{
|
||||
StopCoroutine(textLoopAsync);
|
||||
}
|
||||
Debug.Log("request quest line text load",gameObject);
|
||||
textLoopAsync = StartCoroutine(textLoad());
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user