예제 #1
0
    public override void RunAction()
    {
        // TODO: Use all the other variables from this action
        DialogSystem dialogSystem = GameObject.Find("Dialog System").GetComponent <DialogSystem>();

        AuroraObject nonPC = owner;

        if (GameObject.Find("State System").GetComponent <StateSystem>().PC == nonPC)
        {
            nonPC = converse;
        }

        // Get the default conversation for the character if it's not provided
        if (sDialogResRef == "")
        {
            // NWNLexicon: "PCs can have dialogue with NPCs, placeables, triggers, and doors"
            if (nonPC.template.GetType() == typeof(AuroraUTC))
            {
                sDialogResRef = ((AuroraUTC)nonPC.template).Conversation;
            }
            else if (nonPC.template.GetType() == typeof(AuroraUTP))
            {
                sDialogResRef = ((AuroraUTP)nonPC.template).Conversation;
            }
            else if (nonPC.template.GetType() == typeof(AuroraUTT))
            {
                throw new Exception("Conversations with triggers not yet implemented");
            }
            else if (nonPC.template.GetType() == typeof(AuroraUTD))
            {
                sDialogResRef = ((AuroraUTD)nonPC.template).Conversation;
            }
            else
            {
                throw new Exception("Cannot start a dialog with object of type " + nonPC.template.GetType());
            }
        }

        if (sDialogResRef == null || sDialogResRef == "")
        {
            Debug.Log("Aborting the current dialog");
            dialogSystem.AbortDialog();

            Debug.Log("Starting new dialog if one exists");
            Debug.Log(((AuroraUTC)owner.template).Conversation);
            // Get the default dialog for the current caller
            if (((AuroraUTC)owner.template).Conversation != null && ((AuroraUTC)nonPC.template).Conversation != "")
            {
                dialogSystem.StartDialog(((AuroraUTC)owner.template).Conversation, owner);
            }
        }
        else
        {
            Debug.Log("Starting dialog " + sDialogResRef);
            dialogSystem.StartDialog(sDialogResRef, owner);
        }
    }