Dialogues - after fix

This commit is contained in:
kabix09 2022-12-24 20:16:41 +01:00
parent 713b7ffa59
commit 92a1c69685
3 changed files with 13 additions and 7 deletions

View File

@ -29,7 +29,7 @@ public class NPCFollowing : MonoBehaviour
// Start is called before the first frame update
void Start()
{
//isAfterAction = System.Convert.ToBoolean(PlayerPrefs.GetInt(gameObject.GetComponent<NPC>().name + ".FirstDialogue"));
isAfterAction = System.Convert.ToBoolean(PlayerPrefs.GetInt(gameObject.GetComponent<NPC>().name + ".FirstDialogue"));
myRigidbody = GetComponent<Rigidbody2D>();
anim = GetComponent<Animator>();
@ -84,8 +84,6 @@ public class NPCFollowing : MonoBehaviour
//start dialogue here we want uga bunga
gameObject.GetComponent<NPC>().State = NPCStateEnum.Talking;
gameObject.GetComponent<NpcDialogueManager>().OpenDialoguePanel();
}
}

View File

@ -38,8 +38,6 @@ public class DialogueManager : MonoBehaviour
public virtual void Start()
{
Dialogue = Instantiate(languageDetector.DetectInstanceBasedOnLanguage());
Dialogue.SetSpeakerName(SpeakerName);
Dialogue.Dialogues.ForEach(dial => dial.Value.SetActionAfterDialogueStep(dial.Key, dial.Value.ResetDialogue)); // reset dial
}
@ -47,8 +45,10 @@ public class DialogueManager : MonoBehaviour
public void Update()
{
if (OpenInDefaultWay && Input.GetKeyDown(keyToOpen) && OpenPanelCondition())
{
OpenDialoguePanel();
}
}
public virtual void OnTriggerEnter2D(Collider2D collision)
@ -76,7 +76,6 @@ public class DialogueManager : MonoBehaviour
if (GetCurrentDialoguePanelStatus())
{
Debug.Log("Close dialog - defaulty way");
Dialogue.BreakDialogueStep();
}
}
@ -85,8 +84,13 @@ public class DialogueManager : MonoBehaviour
public void OpenDialoguePanel()
{
if(OpenPanelCondition())
{
// Update speaker name before every opening
Dialogue.SetSpeakerName(SpeakerName);
gameObject.GetComponent<DialogueManager>().Dialogue.StartDialogue();
}
}
public virtual bool OpenPanelCondition()
{
/*
@ -101,6 +105,7 @@ public class DialogueManager : MonoBehaviour
{
return CanBeOpened;
}
protected virtual bool ComponentEnabledCondition()
{
return !gameObject.GetComponent<DialogueManager>().enabled;
@ -120,7 +125,9 @@ public class DialogueManager : MonoBehaviour
.Where(dialogue => dialogue.Key == multiDialStatius.Item1)
.First()
.Value
.DialogueSteps[multiDialStatius.Item2].DialogueController.CurrentPanel != null;
.DialogueSteps
.ElementAtOrDefault(multiDialStatius.Item2)
?.DialogueController.CurrentPanel != null;
}
}

View File

@ -13,6 +13,7 @@ public class NpcDialogueManager : DialogueManager
base.Start();
CanBeOpened = false;
OpenInDefaultWay = false;
}
public override bool OpenPanelCondition()
{