最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

c# - Dialogue Manager 3 (Godot 4) DialogueEnded event - Stack Overflow

programmeradmin1浏览0评论

I'm currently working on the dialogue system in Godot 4 using Dialogue Manager 3. I created a function "checkDialogueFinished" to check whether the dialogue event has ended already. Its supposed to get subscribed to in the "checkInteract" function but it never does. Any help will be appreciated, tyia!

using Godot;
using System;
using DialogueManagerRuntime;


public partial class ObjectInteract : Node {
    private Resource dialogue = GD.Load<Resource>("res://Dialogue/Test.dialogue");
    private bool isInDialogue = false;
    
    /*
        Function Desc: Gets the distance between an object and the player via slope
        @param ObjectX -> x-coordinate of the Object
        @param ObjectY -> y-coordinate of the Object
        @param PlayerX -> x-coordinate of the Player
        @param PlayerY -> y-coordinate of the Player
    */
    public float getDistanceSlope(float ObjectX, float ObjectY, float PlayerX, float PlayerY){
        float dx = ObjectX - PlayerX;
        float dy = ObjectY - PlayerY;
        float distance = dx * dx + dy * dy;
        float trueDistance = (float)Math.Sqrt(distance);

        return distance;
    }
    /*
        Function Desc: Checks whether the player is close enough to interact with the object
        @param slope -> Distance between object and player 
        @param objectName -> Name of the object
    */
    public void checkInteract(float slope){
        if (slope < 850 && Input.IsActionJustPressed("interact") && !isInDialogue){
            DialogueManager.ShowExampleDialogueBalloon(dialogue);
            isInDialogue = true;

            DialogueManager.DialogueEnded += checkDialogueFinished;
            GD.Print("Event fired!");
        }
    }

    private void checkDialogueFinished(Resource dialogue) {
        GD.Print("Event ended, setting isInDialogue back to false!");
        isInDialogue = false;

        DialogueManager.DialogueEnded -= checkDialogueFinished;
    }
}

I tried checking the DialogueManagerRuntime but still haven't found a solution.

发布评论

评论列表(0)

  1. 暂无评论