using System; using System.Collections; using System.Collections.Generic; using System.Linq; using UnityEngine; using UnityEngine.Events; [RequireComponent(typeof(NPC))] public class NpcDialogueManager : DialogueManager { public override void Start() { base.Start(); CanBeOpened = false; } public override bool OpenPanelCondition() { /* * Conditions: * - npc bust me in Talking mode * - player is in collision range * - panel assigned to next sentence in dialogue must be closed */ return gameObject.GetComponent().State == NPCStateEnum.Talking && base.OpenPanelCondition(); } protected virtual bool ColliderTypeCondition() { return !gameObject.GetComponent().enabled; } /// /// Function to invoke actions declared in manager on object from scene not onto asset /// /// Used in Dialogue ScriptableObject Template /// /// public void DialogueEndAction(int dialogueIndex) { GameObject.FindObjectsOfType().Where(obj => obj.name == gameObject.name).First().GetComponent().InvokeDialogueEndAction(dialogueIndex); } /// /// Function to invoke actions declared in manager (on current object) /// /// Use this to invoke actions which we want to occured after specific Dialogue /// /// protected void InvokeDialogueEndAction(int dialogueIndex) { EndactionEventList.Where(el => el.Key.Key == dialogueIndex).ToList().ForEach(el => el.Value.Invoke()); } /// /// Function to invoke actions declared in manager on object from scene not onto asset /// /// Used in Dialogue ScriptableObject Template /// public void StepEndAction() { GameObject.FindObjectsOfType().Where(obj => obj.name == gameObject.name).First().GetComponent().InvokeStepEndAction(); } /// /// Function to invoke actions declared in manager (on current object) /// /// Use this to invoke actions which we want to occured after specific Dialogue Step /// protected void InvokeStepEndAction() { var dialogueProgress = Dialogue.DialogueStepStatus(); EndactionEventList.Where(el => el.Key.Key == dialogueProgress.Item1 & el.Key.Value == dialogueProgress.Item2).ToList().ForEach(el => el.Value.Invoke()); } }