猫史档案馆


(括号里的字是凑字数的,直接看正文)

用户:VisualProgramerVisualProgramer查看:1 回复:2 评论:1 创建时间:2022-12-22T10:58:33


// 玩家进入游戏时,弹出一个选项对话框
world.onPlayerJoin(async({ entity }) => {
    const result = await entity.player.dialog({
        type: Box3DialogType.SELECT,
        title: "地图小助手",
        titleTextColor: new Box3RGBAColor(1, 1, 1, 1),
        titleBackgroundColor: new Box3RGBAColor(0.062745098039215, 0.51372549019607842,0.8549019607843137, 1),
        content: `你好,${entity.player.name},很高兴认识你。这里是光耀之路[极简跑酷],玩家可以在这里与商人交互并通关跑酷。下面就跟我来认识一下地图玩法吧!`,
        options: ['没问题!', '现在没空,下次吧'],   // 将提供玩家选择的选项放入数组里。
        contentTextColor:new Box3RGBAColor(0, 0, 0, 1),
        contentBackgroundColor: new Box3RGBAColor(1, 1, 1, 0.7),
        lookEye: entity.position.add(entity.player.facingDirection.scale(5)),
        lookTarget: entity,
    });

    // 如果玩家点击了屏幕其他区域,取消了对话框。
    if(!result || result === null){ 
        entity.player.directMessage('你似乎无视了地图小助手');
        return; 
    }

    // 判断玩家选了什么选项。
    switch (result.index) {
        case 0:
            // 如果选择了第一项
            entity.player.directMessage('那下面就来跟我一起认识吧!');
             const result2 = await entity.player.dialog({
                type: Box3DialogType.SELECT,
                title: "打开背包",
                titleTextColor: new Box3RGBAColor(1, 1, 1, 1),
                titleBackgroundColor: new Box3RGBAColor(0.062745098039215, 0.51372549019607842,0.8549019607843137, 1),
                content: `在游戏中,你可以随时按下e键来打开背包。背包会提示您当前的具体等级以及您当前所拥有的金币、道具。`,
                options: ['我知道了'],   // 将提供玩家选择的选项放入数组里。
                contentTextColor:  new Box3RGBAColor(0, 0, 0, 1),
                contentBackgroundColor: new Box3RGBAColor(1, 1, 1, 0.7),
                lookEye: entity.position.add(entity.player.facingDirection.scale(5)),
                lookTarget: entity
             });
             const result3 = await entity.player.dialog({
                type: Box3DialogType.SELECT,
                title: "获取财产",
                titleTextColor: new Box3RGBAColor(1, 1, 1, 1),
                titleBackgroundColor: new Box3RGBAColor(0.062745098039215, 0.51372549019607842,0.8549019607843137, 1),
                content: `每当您与商人交互,您都会获得随机数量的掉落银币。每当您通过一个关卡时,系统也会根据关卡难度为您发送对应数量的银、金币以及黑金矿`,
                options: ['我知道了'],   // 将提供玩家选择的选项放入数组里。
                contentTextColor:  new Box3RGBAColor(0, 0, 0, 1),
                contentBackgroundColor: new Box3RGBAColor(1, 1, 1, 0.7),
                lookEye: entity.position.add(entity.player.facingDirection.scale(5)),
                lookTarget: entity
             });
             const result4 = await entity.player.dialog({
                type: Box3DialogType.SELECT,
                title: "使用财产",
                titleTextColor: new Box3RGBAColor(1, 1, 1, 1),
                titleBackgroundColor: new Box3RGBAColor(0.062745098039215, 0.51372549019607842,0.8549019607843137, 1),
                content: '本地图共设有12个关卡,难度递增,完全不会的萌新可以从第一关开始,逐渐锻炼自己的跑酷技术。您还可以储备一些药水以应备不时之需。',
                options: ['我知道了'],   // 将提供玩家选择的选项放入数组里。
                contentTextColor:  new Box3RGBAColor(0, 0, 0, 1),
                contentBackgroundColor: new Box3RGBAColor(1, 1, 1, 0.7),
                lookEye: entity.position.add(entity.player.facingDirection.scale(5)),
                lookTarget: entity
             });
            break;
            break;   
            const result6 = await entity.player.dialog({
                type: Box3DialogType.SELECT,
                title: "购买、使喵水",
                titleTextColor: new Box3RGBAColor(1, 1, 1, 1),
                titleBackgroundColor: new Box3RGBAColor(0.062745098039215, 0.51372549019607842,0.8549019607843137, 1),
                content: '银币和金币都可以用于购买药水(不能使用黑金)。目前我们有3种药水,分别是治疗药水、防坠落药水以及复活药水。它们的价格是\n'+'治疗药水:50银币|5金币\n'+'防坠落药水:35银币|3金币\n'+'复活药水:75银币|7金币\n'+'当您需要使喵水时,您需要在公共聊天区打出对应药水的使用代码。\n'+'治疗药水是tr或者zhiliao,防坠落药水是pf或者fangzhuiluo,复活药水是rl或fuhuo。',
                options: ['我知道了'],   // 将提供玩家选择的选项放入数组里。
                contentTextColor:  new Box3RGBAColor(0, 0, 0, 1),
                contentBackgroundColor: new Box3RGBAColor(1, 1, 1, 0.7),
                lookEye: entity.position.add(entity.player.facingDirection.scale(5)),
                lookTarget: entity
             });
            break;
        case 1:
            // 如果选择了第二项
            entity.player.directMessage('好的,你可以随时按下h键来获取帮助。');
            break;
        default:
    }

});

当执行了这串代码后,前面正常,到result4的时候就没有对话框了,也没有报错,哪位大佬能帮忙看一下


回复

上一页1 页 / 共 1下一页
logic罗辑logic罗辑

把result6上面两break;删了

点赞1


评论


ZBS明月清风ZBS明月清风

我看不懂代码

点赞0


评论