Esempio n. 1
0
        private static void SetupCanvas(UnityUIDialogueUI ui, DialogueSystemController dialogueManager)
        {
            if (FindObjectOfType <UnityEngine.EventSystems.EventSystem>() == null)
            {
                new GameObject("EventSystem", typeof(UnityEngine.EventSystems.EventSystem),
                               typeof(UnityEngine.EventSystems.StandaloneInputModule),
                               typeof(UnityEngine.EventSystems.TouchInputModule));
            }
            var canvas = dialogueManager.GetComponentInChildren <Canvas>();

            if (canvas == null)
            {
                var canvasObject = new GameObject("Canvas");
                canvasObject.layer = 5;                 // Built-in UI layer.
                canvasObject.AddComponent <Canvas>();
                canvasObject.AddComponent <UnityEngine.UI.CanvasScaler>();
                canvasObject.AddComponent <UnityEngine.UI.GraphicRaycaster>();
                canvas            = canvasObject.GetComponent <Canvas>();
                canvas.renderMode = RenderMode.ScreenSpaceOverlay;
                canvasObject.transform.SetParent(dialogueManager.transform);
            }
            var uiInstance = Instantiate(ui) as UnityUIDialogueUI;

            uiInstance.transform.SetParent(canvas.transform, false);
            dialogueManager.displaySettings.dialogueUI = uiInstance.gameObject;
        }
Esempio n. 2
0
        private void DrawSelectDBStage()
        {
            EditorGUILayout.LabelField("Select Dialogue Database", EditorStyles.boldLabel);
            EditorWindowTools.StartIndentedSection();
            EditorGUILayout.HelpBox("Assign the dialogue database that the NPC will use for conversations and barks.", MessageType.Info);
            if (dialogueManager == null)
            {
                dialogueManager = FindObjectOfType <DialogueSystemController>();
            }
            if (database == null && dialogueManager != null)
            {
                database = dialogueManager.initialDatabase;
            }
            DialogueDatabase newDatabase = EditorGUILayout.ObjectField("Dialogue Database", database, typeof(DialogueDatabase), true) as DialogueDatabase;

            if (newDatabase != database)
            {
                database = newDatabase;
                CreateConversationList(database);
            }
            if (dialogueManager != null && database != null && dialogueManager.initialDatabase != database)
            {
                EditorGUILayout.HelpBox("This is not the initial database assigned to the Dialogue Manager. Remember to load this database at runtime before using the NPC. You can use the Extra Databases component or DialogueManager.AddDatabase() in script. Also make sure the internal IDs are unique across databases. You can use the Unique ID Tool to do this.", MessageType.Warning);
            }
            EditorWindowTools.EndIndentedSection();
            DrawNavigationButtons(true, (database != null), false);
        }
 private void OnEnable()
 {
     dialogueSystemController       = target as DialogueSystemController;
     displaySettingsProperty        = serializedObject.FindProperty("displaySettings");
     persistentDataSettingsProperty = serializedObject.FindProperty("persistentDataSettings");
     foldouts = EditorPrefs.HasKey(InspectorEditorPrefsKey) ? JsonUtility.FromJson <Foldouts>(EditorPrefs.GetString(InspectorEditorPrefsKey)) : new Foldouts();
 }
Esempio n. 4
0
    // Проинициализировать все составляющие контроллер компоненты.
    private void initialize()
    {
        _pauseMenu = FindObjectOfType <PauseMenu>();
        Assert.IsNotNull(_pauseMenu);

        _eventSystem = FindObjectOfType <EventSystem>();
        Assert.IsNotNull(_eventSystem);

        _dialogueSystemController = FindObjectOfType <DialogueSystemController>();

        _isInitialized = true;
    }
Esempio n. 5
0
    //Used to pause conversations during conversation. Now pauses at the next line.
    public void Pause()
    {
        pausePlayModeActive = false;
        // Set conversations to wait for continue button push
        DialogueSystemController dsc = GameObject.Find("Dialogue Manager").GetComponent <DialogueSystemController> ();

        dsc.displaySettings.subtitleSettings.continueButton = DisplaySettings.SubtitleSettings.ContinueButtonMode.Always;

        Time.timeScale = 0;
        //Debug.Log("before pause");
        GameObject.Find("Pelaaja").GetComponent <AudioSource>().Pause();
        //Debug.Log("after pause");
        audioPaused = true;
    }
Esempio n. 6
0
 public static void HandleUnityUIDialogueUI(UnityUIDialogueUI ui, DialogueSystemController dialogueManager)
 {
     if (ui == null)
     {
         return;
     }
     if (Tools.IsPrefab(ui.gameObject) && (ui.GetComponentInParent <Canvas>() == null))
     {
         if (EditorUtility.DisplayDialog("Unity UI Dialogue UI", "A Unity UI Dialogue UI must be a child of a Canvas. Add a Canvas (if needed) and an instance of the dialogue UI to the Dialogue Manager?", "OK", "Cancel"))
         {
             SetupCanvas(ui, dialogueManager);
         }
         else
         {
             dialogueManager.displaySettings.dialogueUI = null;
         }
     }
 }
Esempio n. 7
0
 private static DialogueSystemController FindOrCreateInstance()
 {
     if (instance == null)
     {
         instance = GameObject.FindObjectOfType(typeof(DialogueSystemController)) as DialogueSystemController;
         if (instance == null)
         {
             if (DialogueSystemController.applicationIsQuitting)
             {
                 instance = null;
             }
             else
             {
                 instance = new GameObject("Dialogue Manager").AddComponent <DialogueSystemController>();
             }
         }
     }
     return(instance);
 }
 public static void HandleCanvasDialogueUI(CanvasDialogueUI ui, DialogueSystemController dialogueManager)
 {
     if (ui == null)
     {
         return;
     }
     if (Tools.IsPrefab(ui.gameObject) && (ui.GetComponentInParent <Canvas>() == null))
     {
         if (EditorUtility.DisplayDialog("Canvas-Based Dialogue UI", "Would you like to add an instance of this dialogue UI prefab as a child of the Dialogue Manager?",
                                         "Add Instance", "Use Prefab"))
         {
             SetupCanvas(ui, dialogueManager);
         }
         else
         {
             //--- Allow prefabs now: dialogueManager.displaySettings.dialogueUI = null;
         }
     }
 }
Esempio n. 9
0
 // Start is called before the first frame update
 void Start()
 {
     dsc = GameObject.FindObjectOfType <DialogueSystemController>();
     if (tutorialController != null)
     {
         // Make sure the tutorial var in dialogue lua is true
         DialogueLua.SetVariable("endTutorial", false);
         Invoke("StartTutorial", 0.2f);
     }
     else
     {
         // Enable the quest controller objects
         questController.NoQuestActiveGameObjects();
         tutorialIsActive = false;
         tutorialEnded    = true;
         dsc.displaySettings.subtitleSettings.continueButton = DisplaySettings.SubtitleSettings.ContinueButtonMode.Optional;
         GameObject.FindObjectOfType <PlayerController>().GetComponentInChildren <TargetIndicator>().tutorial = false;
     }
 }
Esempio n. 10
0
    /*
     * public void OnConversationLine(Subtitle subtitle)
     * {
     *
     *      if (oldLine != null)
     *      {
     *              GameObject oldSpeaker = GameObject.Find(oldLine.speakerInfo.nameInDatabase);
     *              if(oldSpeaker.GetComponent<Animator>() != null)
     *                      oldSpeaker.GetComponent<Animator>().SetBool("IsTalking", false);
     *      }
     *      GameObject speaker = GameObject.Find(subtitle.speakerInfo.nameInDatabase);
     *
     *      if(speaker.GetComponent<Animator>() != null)
     *              speaker.GetComponent<Animator> ().SetBool ("IsTalking", true);
     *
     *      oldLine = subtitle;
     * //		logConversation (subtitle);
     *
     *      latestLine = subtitle;
     * }
     */



    //Used to continue conversations during conversation pause
    public void Play()
    {
        pausePlayModeActive = false;
        // Set conversations to autoplay -> Don't need to click continue to move forward
        DialogueSystemController dsc = GameObject.Find("Dialogue Manager").GetComponent <DialogueSystemController> ();

        dsc.displaySettings.subtitleSettings.continueButton = DisplaySettings.SubtitleSettings.ContinueButtonMode.Never;

        Time.timeScale = 1;
        if (GameObject.Find("Pelaaja").GetComponent <AudioSource> () != null)
        {
            //Debug.Log("Vaihe 1");
            if (GameObject.Find("Pelaaja").GetComponent <AudioSource> ().isPlaying)
            {
                //	Debug.Log("Vaihe 2");
            }
            else
            {
                if (audioPaused)
                {
                    //		Debug.Log("Vaihe 3");
                    //GameObject.Find (currentSpeaker).GetComponent<AudioSource> ().Play ();
                    GameObject.Find("Pelaaja").GetComponent <AudioSource> ().Play();
                    audioPaused = false;
                    simulateContinueButtonClick();
                }

                /*
                 * else {
                 *      Debug.Log("Vaihe 4");
                 *      simulateContinueButtonClick ();
                 * }
                 */
            }
        }
    }
 private void OnEnable()
 {
     dialogueSystemController = target as DialogueSystemController;
 }
 static void InitStaticVariables()
 {
     m_instance = null;
 }
 private void Awake()
 {
     dialogueSystemController = dialogueSystem.GetComponent <DialogueSystemController>();
 }