Dialogues - fix dynamic language detection

This commit is contained in:
kabix09 2023-01-05 15:47:02 +01:00
parent 35ed59b247
commit 13051eb240
5 changed files with 69 additions and 5 deletions

View File

@ -13,7 +13,6 @@ public class PatrollingEnemy : Enemy
//public Transform target; //public Transform target;
public Animator anim; public Animator anim;
public int isKilled;
//isKilled = 0 - mob ALIVE //isKilled = 0 - mob ALIVE
//isKilled = 1 - mob DEAD //isKilled = 1 - mob DEAD

View File

@ -36,9 +36,9 @@ public class DialogueManager : MonoBehaviour
/// </summary> /// </summary>
public bool OpenInDefaultWay = true; public bool OpenInDefaultWay = true;
public virtual void Start() public virtual void Start()
{ {
if(languageDetector.InstanceTemplates.Count() > 0) if (languageDetector.InstanceTemplates.Count() > 0)
{ {
// create and config dailogue // create and config dailogue
CreateInstanceBasedOnLanguage(); CreateInstanceBasedOnLanguage();
@ -52,6 +52,14 @@ public class DialogueManager : MonoBehaviour
{ {
if (OpenInDefaultWay && Input.GetKeyDown(keyToOpen) && OpenPanelCondition()) if (OpenInDefaultWay && Input.GetKeyDown(keyToOpen) && OpenPanelCondition())
{ {
if (languageDetector.InstanceTemplates.Count() > 0)
{
// create and config dailogue
CreateInstanceBasedOnLanguage();
Dialogue.BuildCurrentDialogue();
}
OpenDialoguePanel(); OpenDialoguePanel();
} }
} }

View File

@ -30,8 +30,8 @@ public class NpcMissionManager : DialogueManager // ScriptableObject
CanBeOpened = false; CanBeOpened = false;
OpenInDefaultWay = false; OpenInDefaultWay = false;
CreateInstanceBasedOnLanguage();
CreateInstanceBasedOnLanguage();
// UPDATE DIALOGUE // UPDATE DIALOGUE
// search in scene manager list // search in scene manager list
@ -53,7 +53,6 @@ public class NpcMissionManager : DialogueManager // ScriptableObject
Mission.BuildMission(); Mission.BuildMission();
if (FreeDialogue != null) if (FreeDialogue != null)
FreeDialogue.Build(); FreeDialogue.Build();
} }
@ -70,6 +69,29 @@ public class NpcMissionManager : DialogueManager // ScriptableObject
{ {
CanBeOpened = true; CanBeOpened = true;
CreateInstanceBasedOnLanguage();
// UPDATE DIALOGUE
// search in scene manager list
if (Mission != null)
{
var machedDialogueData = ((MissionDataManager)MissionDataManager.Instance).GetMission(Mission);
if (machedDialogueData != null)
{
UpdateMissionState(machedDialogueData);
}
else
{
Debug.Log("Start - UpdateProggres");
UpdateProggres();
}
}
Mission.BuildMission();
Mission.StartDialogue(); Mission.StartDialogue();
} }
} }

View File

@ -15,6 +15,14 @@ public class NpcDialogueManager : DialogueManager
CanBeOpened = false; CanBeOpened = false;
OpenInDefaultWay = false; OpenInDefaultWay = false;
if (languageDetector.InstanceTemplates.Count() > 0)
{
// create and config dailogue
CreateInstanceBasedOnLanguage();
Dialogue.BuildCurrentDialogue();
}
// UPDATE DIALOGUE // UPDATE DIALOGUE
// search in scene manager list // search in scene manager list
if (Dialogue != null) if (Dialogue != null)
@ -36,6 +44,31 @@ public class NpcDialogueManager : DialogueManager
{ {
if (Input.GetKeyDown(keyToOpen) && OpenPanelCondition()) if (Input.GetKeyDown(keyToOpen) && OpenPanelCondition())
{ {
// Refrsh dialogue language and proggres after each opening trial
if (languageDetector.InstanceTemplates.Count() > 0)
{
// create and config dailogue
CreateInstanceBasedOnLanguage();
Dialogue.BuildCurrentDialogue();
}
// UPDATE DIALOGUE
// search in scene manager list
if (Dialogue != null)
{
var machedDialogueData = ((MultiDialogueDataManager)MultiDialogueDataManager.Instance).GetDialogue(Dialogue);
if (machedDialogueData != null)
{
UpdateDialogueState(machedDialogueData);
}
else
{
UpdateProggres();
}
}
OpenDialoguePanel(); OpenDialoguePanel();
} }
} }

View File

@ -68,6 +68,8 @@ public class NpcShopManager : MonoBehaviour
*/ */
if (gameObject.GetComponent<NpcDialogueManager>().CanBeOpened && Input.GetKeyDown(ShopUIManager.Instance.keyToOpen) && !ShopUIManager.Instance.GetPanelStatus()) if (gameObject.GetComponent<NpcDialogueManager>().CanBeOpened && Input.GetKeyDown(ShopUIManager.Instance.keyToOpen) && !ShopUIManager.Instance.GetPanelStatus())
{ {
CreateInstanceBasedOnLanguage();
// Open dialogue panel (Shop will be opened later) // Open dialogue panel (Shop will be opened later)
Dialogue.StartDialogue(); Dialogue.StartDialogue();