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 Animator anim;
public int isKilled;
//isKilled = 0 - mob ALIVE
//isKilled = 1 - mob DEAD

View File

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

View File

@ -30,8 +30,8 @@ public class NpcMissionManager : DialogueManager // ScriptableObject
CanBeOpened = false;
OpenInDefaultWay = false;
CreateInstanceBasedOnLanguage();
CreateInstanceBasedOnLanguage();
// UPDATE DIALOGUE
// search in scene manager list
@ -53,7 +53,6 @@ public class NpcMissionManager : DialogueManager // ScriptableObject
Mission.BuildMission();
if (FreeDialogue != null)
FreeDialogue.Build();
}
@ -70,6 +69,29 @@ public class NpcMissionManager : DialogueManager // ScriptableObject
{
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();
}
}

View File

@ -15,6 +15,14 @@ public class NpcDialogueManager : DialogueManager
CanBeOpened = false;
OpenInDefaultWay = false;
if (languageDetector.InstanceTemplates.Count() > 0)
{
// create and config dailogue
CreateInstanceBasedOnLanguage();
Dialogue.BuildCurrentDialogue();
}
// UPDATE DIALOGUE
// search in scene manager list
if (Dialogue != null)
@ -36,6 +44,31 @@ public class NpcDialogueManager : DialogueManager
{
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();
}
}

View File

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