# 对话系统 (dialogueSystem)

  • 支持读取json来定义对话内容以及分支
{
    "id": "dialogue1",
    "enter_type": "direct",
    // "enter": [
    //         {"text": "你好", "to_index": 0}
    //         {"text": "再见", "to_index": -1}
    //     ],
    "dialogue": {
        "c0": {"text": "你好", "name": "Steve", "to_index": 1, "waiting": 0.5, "index": 0, "type": "chat"},
        "c1": {"text": "你好啊", "name": "Alex", "to_index": 2, "waiting": 0.5, "index": 1, "type": "chat"},
        "c2": {"text": "你叫什么名字?", "name": "Steve", "to_index": 3, "waiting": 0.5, "index": 2, "type": "chat"},
        "c3": {"index": 3, "branch": 
            [
                {"text": "我叫 Alex!", "to_index": 4},
                {"text": "我也不知道我叫什么!", "to_index": 5}
            ], 
            "type": "branch"
        },
        "c4": {"text": "你好啊! Alex!", "name": "Steve", "to_index": 6, "waiting": 0.5, "index": 4, "type": "chat"},
        "c5": {"text": "你居然不知道你叫什么???", "name": "Steve", "to_index": 7, "waiting": 0.5, "index": 5, "type": "chat"},
        "c6": {"text": "你好啊! Steve", "name": "Alex", "to_index": 10, "waiting": 0.5, "index": 6, "type": "chat"},
        "c7": {"text": "哈哈哈,我在开玩笑", "name": "Alex", "to_index": 8, "waiting": 0.5, "index": 7, "type": "chat"},
        "c8": {"text": "好吧", "name": "Steve", "to_index": 9, "waiting": 0.5, "index": 7, "type": "chat"},
        "c9": {"text": "...", "name": "Alex", "to_index": 10, "waiting": 0.5, "index": 7, "type": "chat"},
        "c10": {"text": "你知道这是什么游戏吗? Alex", "name": "Steve", "to_index": 11, "waiting": 0.5, "index": 10, "type": "chat"},
        "c11": {"text": "不知道", "name": "Alex", "to_index": 12, "waiting": 0.5, "index": 11, "type": "chat"},
        "c12": {"text": "这是由 Terrxx 开发的游戏 Misty 迷雾之塔!", "name": "Steve", "to_index": 13, "waiting": 0.5, "index": 12, "type": "chat"},
        "c13": {"text": "你将在游戏中扮演 ** 并...", "name": "Steve", "to_index": 14, "waiting": 0.5, "index": 13, "type": "chat"},
        "c14": {"text": "开始你的冒险吧!", "name": "Steve", "to_index": -1, "waiting": 0.5, "index": 14, "type": "chat"}
    }
}

# 流程图:

# 参数说明

参数 参数类型 说明
id string 对话唯一id
enter_type dialogueType 进入对话的方式
enter List<选择条目> 若enter_type为chat对话数据(最多只能有5条)
dialogue Dict<c$, 对话条目> 对话数据

若enter_type为direct,那么直接进入对话,从对话条目c0直接开始
若enter_type为chat,则进入对话之前,靠近NPC会显示悬浮选择框,若点击选择框则跳转到对话条目

# 对话条目

    "c$": {
        "text": "你好",
        "name": "Steve",
        "to_index": 1,
        "waiting": 0.5,
        "index": 0,
        "type": "chat"
    }
  • Key

    参数 参数类型 说明 是否一定需要参数
    c_$ string 对话条目index
  • Value

    参数 参数类型 说明 是否一定需要参数
    text string 对话文本
    name string 对话目标名称
    to_index int 该对话结束后跳转到下一对话(若对话完毕该值填-1)
    waiting float 对话需要阅读等待时间才能跳转到下一对话
    index int 当前对话的条目index,对应key
    type dialogueType 当前对话条目的类型
    branch List<选择条目> 选择条目

# 选择条目

    {
        "text": "我也不知道我叫什么!",
        "to_index": 5
    }
参数 参数类型 说明 是否一定需要参数
text string 对话文本
to_index int 该对话结束后跳转到下一对话(若对话完毕该值填-1)

# dialogueType

参数 说明
chat 表示当前为对话条目
branch 表示当前为选择条目

# 演示

上次更新: 3/11/2025, 7:05:54 PM