using System; using System.Collections; using System.Collections.Generic; using System.Linq; using UnityEngine; //[Serializable] //[CreateAssetMenu(fileName = "New Mission", menuName = "Mission/New Mission")] public class NpcMissionManager : DialogueManager // ScriptableObject { [SerializeField] public Mission MissionTemplate; /* We user object CLONED TO PREVENT overwritting changes in main object inassets */ [SerializeField] public Mission Mission; [SerializeField] public DialogueStepModel FreeDialogue; // List, Value : UnityEvent> public List, MissionProcess>> EndactionEventList; public void Start() { Mission = Instantiate(MissionTemplate); Mission.SetSpeakerName(gameObject.GetComponent().Name); //Mission.BuildMission(); if (FreeDialogue != null) FreeDialogue.Build(); } public void Update() { } public override void OnTriggerEnter2D(Collider2D collision) { // don't listen when component is disabled if (ComponentEnabledCondition()) return; if (collision.gameObject.tag == "Player" && !GetCurrentDialoguePanelStatus()) { CanBeOpened = true; SpeakerName = collision.gameObject.name; Mission.StartDialogue(); } } public override void OnTriggerExit2D(Collider2D collision) { // don't listen when component is disabled if (ComponentEnabledCondition()) return; if (collision.gameObject.tag == "Player") { CanBeOpened = false; if (GetCurrentDialoguePanelStatus()) { Debug.Log("BreakDialogueStep"); Mission.BreakDialogueStep(); } } } /* public void Talk() { if (Mission == null || Mission.Status == MissionStatusEnum.Finished) { // show free dialogue //if(FreeDialogue != null) //FreeDialogue.DialogueController. } else { // continue mission Mission.StartDialogue(); } } */ protected override bool ComponentEnabledCondition() { return !gameObject.GetComponent().enabled; } public override bool GetCurrentDialoguePanelStatus() { Debug.Log(Mission .GetCurrentStep() .DialogueStep.CurrentStep ); Debug.Log(Mission .GetCurrentStep() .DialogueStep .GetCurrentStep() .DialogueController .CurrentPanel ); return Mission .GetCurrentStep() .DialogueStep .GetCurrentStep() // ? .DialogueController .CurrentPanel != null; } }