猫史档案馆


我我我。。。在作喵。。。(很作喵地复制了将近700行的代码)

用户:查看:11 回复:5 评论:11 创建时间:2020-10-28T21:25:10


————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————三层密封—————————————————————————

const seasons = ['春', '夏', '秋', '冬'];
const Springleaf = 'green_leaf'; 
const Summerleaf = 'leaf_05'; 
const Fallleaf = 'leaf_03'; 
const Winterleaf = 'winter_leaf'
async function replaceblock(a, b) { 
    for (y = 0; y < 128; y++) { 
        for (x = 0; x < 128; x++) { 
            for (z = 0; z < 128; z++) { 
                if (voxels.getVoxel(x, y, z) == voxels.id(a)) { 
                    voxels.setVoxel(x, y, z, voxels.id(b)) 
                } 
            } 
        } 
    } 
}
const grass = ['grass', 'dark_grass', 'yellow_grass', 'white_grass']
const time = 100000;//这个2是每个季节隔几秒
(async function changeseason() {
    while (true) {
        replaceblock(Winterleaf, Springleaf); replaceblock(grass[3], grass[0]); world.say(seasons[0] + '天到了');
        world.snowDensity = 0.4;                                   // 雪的密度
        world.snowFallSpeed = 0.3;                                 // 下落速度
        world.snowSizeLo = 0.3;                                    // 最小直径
        world.snowSizeHi = 0.6;                                   // 最大直径
        world.snowColor = new Box3RGBColor(255, 128,192,220);   // 颜色
        world.snowTexture = 'snow/sakura.part';                    // 纹理
        for (y = 0; y < 128; y++) {
            for (x = 0; x < 128; x++) {
                for (z = 0; z < 128; z++) {
                    if (voxels.getVoxel(x, y, z) == voxels.id('ice')) {
                        voxels.setVoxel(x, y, z, voxels.id('water'))
                    }
                }
            }
        }
        await sleep(time);
        replaceblock(Springleaf, Summerleaf); replaceblock(grass[0], grass[1]); world.say(seasons[1] + '天到了');
        await sleep(time);
        if (seasons[3] === '秋') {
            for (y = 0; y < 128; y++) {
                for (x = 0; x < 128; x++) {
                    for (z = 0; z < 128; z++) {
                        if (voxels.getVoxel(x, y, z) == voxels.id('yellow_grass')) {
                            voxels.setVoxel(x, y, z, voxels.id('grass'))
                        }
                    }
                }
            }
        }
        replaceblock(Summerleaf, Fallleaf); replaceblock(grass[1], grass[2]); world.say(seasons[2] + '天到了');
        await sleep(time);
        replaceblock(Fallleaf, Winterleaf); replaceblock(grass[2], grass[3]); world.say(seasons[3] + '天到了');
        for (y = 0; y < 128; y++) {
            for (x = 0; x < 128; x++) {
                for (z = 0; z < 128; z++) {
                    if (voxels.getVoxel(x, y, z) == voxels.id('water')) {
                        voxels.setVoxel(x, y, z, voxels.id('ice'))
                    }
                }
            }
        }
        world.snowDensity = 0.4;                                   // 雪的密度
        world.snowFallSpeed = 0.3;                                 // 下落速度
        world.snowSizeLo = 0.3;                                    // 最小直径
        world.snowSizeHi = 0.6;                                   // 最大直径
        world.snowColor = new Box3RGBAColor(1, 1, 1, 1);   // 颜色
        world.snowTexture = 'snow/snow.part';                    // 纹理
        await sleep(time)
    }
})();
world.lightMod = 'natural'    // 调整光照模式为自然
world.sunPhase = 0
world.sunFrequency = 0.0001        // 将太阳运动频率设置为0,使日光不再随时间而变化。
world.onVoxelContact(async({entity,voxel})=>{
    const c=voxels.id('lava02')
    if(voxel===c){
        entity.position.set(99,20,113)
        entity.player.color = new Box3RGBColor(1, 0, 0)
        world.say(entity.player.name+'被岩浆烤伤,被送进了医院。。。')
        await sleep(5000)
        entity.player.color = new Box3RGBColor(1, 1, 1)
        entity.player.directMessage('治疗完成')
    }
})
world.onPlayerJoin(({ entity }) => {
    entity.player.addWearable({
        bodyPart: Box3BodyPart.HEAD,//装备穿戴的位置在身上
        mesh: 'mesh/跳伞包.vb',//装备是一个叫做“天使之翼”的模型
        orientation: new Box3Quaternion(0, 1, 0, 0).rotateY(Math.PI/2),
        scale: new Box3Vector3(1, 1, 1),//模型大小长宽高都缩小***倍
        offset: new Box3Vector3(0, -0.5, -0.45),//装备的位置,向人背后偏移一些
    });
})
world.onPlayerJoin(({ entity }) => {
    entity.player.addWearable({
        bodyPart: Box3BodyPart.HEAD,//装备穿戴的位置在身上
        mesh: 'mesh/大南瓜2.vb',//装备是一个叫做“天使之翼”的模型
        orientation: new Box3Quaternion(0, 1, 0, 15).rotateY(Math.PI/2),
        scale: new Box3Vector3(0.5, 0.5, 0.5),//模型大小长宽高都缩小***倍
        offset: new Box3Vector3(0, 0.5, 0),//装备的位置,向人背后偏移一些
    });
})
world.onPlayerJoin(({ entity }) => {
   world.onTick((tick) => { PlayerUpdate(entity)});
});
const particle_blueCrystal = {
    particleRate: 1000,
    particleLifetime: 2,
    particleSize: [8, 6, 4, 2, 0.5],
    particleColor: [
        new Box3RGBColor(1,1,0),
        new Box3RGBColor(1,1,0),
        new Box3RGBColor(1,0,0),
        new Box3RGBColor(1,0,0),
        new Box3RGBColor(1,1,1)],
}
const particle_flame = {
    particleRate: 450,
    particleLifetime: 1.75,
    particleSize: [2, 0.65, 0.23],
    particleColor: [
        new Box3RGBColor(0,0,1),
        new Box3RGBColor(0,1,1),
        new Box3RGBColor(1,1,1)],
}
function PlayerUpdate(entity) {
    switch (entity.player.moveState) {
        case Box喵layerMoveState.SWIM:
            Object.assign(entity, particle_flame);
            break;
        default:
            Object.assign(entity, { particleRate: 0 });
    };
};
world.onPlayerJoin(({entity})=>{
    entity.position.set(98,73, 77);
    entity.player.enableDoubleJump = false;
    entity.maxHp=100
});
world.onPlayerJoin(({entity}) => {
    entity.player.dialog({
        type: Box3DialogType.TEXT,
        title: "寒江的雪",
        content: `你好,${entity.player.name},很高兴认识你。现在,由我教你在这个地图里的基本规则:1.牛奶是不会结冰的好了   2.地图里有彩蛋,自己找找吧~~~,现在说“跳伞”进入这个迷一样的世界吧!`,
    });
})
world.querySelectorAll('.飞机模型').forEach(async(e)=>{//感谢toby
    var v1=0.1;//速度 挑一个地方就够了
    while(true){
        e.position.x+=v1;
        if(e.position.x>128){
            e.position.x=0
        }
        await sleep(10)
    }
})
world.querySelectorAll('.火车').forEach(async(e)=>{//感谢toby
    var v2=0.05;//速度 挑一个地方就够了
    while(true){
        e.position.z+=v2;
        if(e.position.z>128){
            e.position.z=0
        }
        await sleep(10)
    }
})
const npc1 = world.querySelector('.椰子树的标签');
npc1.enableInteract=true; // 允许进行互动
npc1.interactRadius = 8;   // 实体的互动范围
npc1.interactHint=npc1.id; // 互动提示框显示实体的名称
npc1.interactColor = new Box3RGBColor(1,1,1);  // 互动提示的文字颜色
npc1.onInteract(async({entity}) => {
    const result = await entity.player.dialog({
        type: Box3DialogType.TEXT,   // 对话框的类型,TEXT是文本框。
        title: npc1.id,               // 对话框标题为NPC名字,表示正在说话的是NPC
        lookEye: entity,             // 将相机放在玩家位置
        lookTarget: npc1,             // 相机镜头对准NPC
        content: `${entity.player.name},这是一个植物研究所,据说,这里有一个地下室,或许,旁边那个传送门可以下去。`,
    });
});
const npc2 = world.querySelector('.停车场牌');
npc2.enableInteract=true; // 允许进行互动
npc2.interactRadius = 3;   // 实体的互动范围
npc2.interactHint=npc2.id; // 互动提示框显示实体的名称
npc2.interactColor = new Box3RGBColor(1,1,1);  // 互动提示的文字颜色
npc2.onInteract(async({entity}) => {
    const result = await entity.player.dialog({
        type: Box3DialogType.TEXT,   // 对话框的类型,TEXT是文本框。
        title: npc2.id,               // 对话框标题为NPC名字,表示正在说话的是NPC
        lookEye: entity,             // 将相机放在玩家位置
        lookTarget: npc2,             // 相机镜头对准NPC
        content: `${entity.player.name},这里是一个停车场,在这里,你可以坐车(碰到你想坐的车子)想下车就说“下车”就可以了。(在操作里你应该知道了吧)`,
    });
});
const npc3 = world.querySelector('.告示牌1');
npc3.enableInteract=true; // 允许进行互动
npc3.interactRadius = 3;   // 实体的互动范围
npc3.interactHint=npc3.id; // 互动提示框显示实体的名称
npc3.interactColor = new Box3RGBColor(1,1,1);  // 互动提示的文字颜色
npc3.onInteract(async({entity}) => {
    const result = await entity.player.dialog({
        type: Box3DialogType.TEXT,   // 对话框的类型,TEXT是文本框。
        title: npc3.id,               // 对话框标题为NPC名字,表示正在说话的是NPC
        lookEye: entity,             // 将相机放在玩家位置
        lookTarget: npc3,             // 相机镜头对准NPC
        content: `${entity.player.name},这里是一片森林,据说,里面有一个村庄,但人们总是找不到村庄的位置。但是,你看,他们也过万圣节!`,
    });
});
const npc4 = world.querySelector('.商店门');
npc4.enableInteract = true; // 允许进行互动
npc4.interactRadius = 3;   // 实体的互动范围
npc4.interactHint = npc4.id; // 互动提示框显示实体的名称
npc4.interactColor = new Box3RGBColor(1,1,1);  // 互动提示的文字颜色
npc4.onInteract(async({entity}) => {
    const result = await entity.player.dialog({
        type: Box3DialogType.SELECT,
        title: npc4.id,
        titleTextColor: new Box3RGBAColor(0, 0, 0, 1),
        titleBackgroundColor: new Box3RGBAColor(0.968, 0.702, 0.392, 1),
        content: `${entity.player.name},你要进去吗?`,
        options: ['要', '下次吧','不,我要出去'],   // 将提供玩家选择的选项放入数组里。
        contentTextColor:  new Box3RGBAColor(0, 0, 0, 1),
        contentBackgroundColor: new Box3RGBAColor(1, 1, 1, 1),
        lookEye: entity.position.add(entity.player.facingDirection.scale(5)),
        lookTarget: entity,
    });
    switch (result.index) {
        case 0:
            entity.player.directMessage('进去啦~');
            entity.position.set(113,10, 50);
            break;
        case 1:
            entity.player.directMessage('好吧。。。');
            break;
        case 2:
            entity.player.directMessage('下次再来~');
            entity.position.set(103,10, 50);
            break;
        default:
    }
});
const npc5 = world.querySelector('.带标签的花')
npc5.enableInteract=true; // 允许进行互动
npc5.interactRadius = 8;   // 实体的互动范围
npc5.interactHint=npc5.id; // 互动提示框显示实体的名称
npc5.interactColor = new Box3RGBColor(1,1,1);  // 互动提示的文字颜色
npc5.onInteract(async({entity}) => {
    const result = await entity.player.dialog({
        type: Box3DialogType.TEXT,   // 对话框的类型,TEXT是文本框。
        title: npc5.id,               // 对话框标题为NPC名字,表示正在说话的是NPC
        lookEye: entity,             // 将相机放在玩家位置
        lookTarget: npc5,             // 相机镜头对准NPC
        content: `${entity.player.name},据说,正上方有空岛,并且空岛上有模型的的地方,有惊喜!空岛上的模型,代表的就是下方的惊喜是什么!`,
    });
});
const npc6 = world.querySelector('.全息屏')
npc6.enableInteract=true; // 允许进行互动
npc6.interactRadius = 5;   // 实体的互动范围
npc6.interactHint=npc6.id; // 互动提示框显示实体的名称
npc6.interactColor = new Box3RGBColor(1,1,1);  // 互动提示的文字颜色
npc6.onInteract(async({entity}) => {
    const result = await entity.player.dialog({
        type: Box3DialogType.TEXT,   // 对话框的类型,TEXT是文本框。
        title: npc6.id,               // 对话框标题为NPC名字,表示正在说话的是NPC
        lookEye: entity,             // 将相机放在玩家位置
        lookTarget: npc6,             // 相机镜头对准NPC
        content: `${entity.player.name},这里是世界中心,这里可以去天空商业区噢~~~`,
    });
});
const npc7 = world.querySelector('.地下村庄');
npc7.enableInteract = true; // 允许进行互动
npc7.interactRadius = 3;   // 实体的互动范围
npc7.interactHint = npc7.id; // 互动提示框显示实体的名称
npc7.interactColor = new Box3RGBColor(1,1,1);  // 互动提示的文字颜色
npc7.onInteract(async({entity}) => {
    const result = await entity.player.dialog({
        type: Box3DialogType.SELECT,
        title: npc7.id,
        titleTextColor: new Box3RGBAColor(0, 0, 0, 1),
        titleBackgroundColor: new Box3RGBAColor(0.968, 0.702, 0.392, 1),
        content: `${entity.player.name},你要进去吗?`,
        options: ['要', '下次吧'],   // 将提供玩家选择的选项放入数组里。
        contentTextColor:  new Box3RGBAColor(0, 0, 0, 1),
        contentBackgroundColor: new Box3RGBAColor(1, 1, 1, 1),
        lookEye: entity.position.add(entity.player.facingDirection.scale(5)),
        lookTarget: entity,
    });
    switch (result.index) {
        case 0:
            world.say(entity.player.name+' 到了地下村庄~~~')
            entity.player.directMessage('进去啦~');
            entity.position.set(103, 2, 3);
            break;
        case 1:
            entity.player.directMessage('好吧。。。');
            break;
        default:
    }
});
const npc8 = world.querySelector('.村民1')
npc8.enableInteract=true; // 允许进行互动
npc8.interactRadius = 4;   // 实体的互动范围
npc8.interactHint=npc8.id; // 互动提示框显示实体的名称
npc8.interactColor = new Box3RGBColor(1,1,1);  // 互动提示的文字颜色
npc8.onInteract(async({entity}) => {
    const result = await entity.player.dialog({
        type: Box3DialogType.TEXT,   // 对话框的类型,TEXT是文本框。
        title: npc8.id,               // 对话框标题为NPC名字,表示正在说话的是NPC
        lookEye: entity,             // 将相机放在玩家位置
        lookTarget: npc8,             // 相机镜头对准NPC
        content: `${entity.player.name},这里是地下村庄!不过呢,作者 寒江的雪 说:“地下村庄还没建好。”不好意思,几天后再来~~~`,
    });
});
const npc9 = world.querySelector('.返回');
npc9.enableInteract = true; // 允许进行互动
npc9.interactRadius = 3;   // 实体的互动范围
npc9.interactHint = npc9.id; // 互动提示框显示实体的名称
npc9.interactColor = new Box3RGBColor(1,1,1);  // 互动提示的文字颜色
npc9.onInteract(async({entity}) => {
    const result = await entity.player.dialog({
        type: Box3DialogType.SELECT,
        title: npc9.id,
        titleTextColor: new Box3RGBAColor(0, 0, 0, 1),
        titleBackgroundColor: new Box3RGBAColor(0.968, 0.702, 0.392, 1),
        content: `${entity.player.name},你要返回地面吗?`,
        options: ['要', '再看看'],   // 将提供玩家选择的选项放入数组里。
        contentTextColor:  new Box3RGBAColor(0, 0, 0, 1),
        contentBackgroundColor: new Box3RGBAColor(1, 1, 1, 1),
        lookEye: entity.position.add(entity.player.facingDirection.scale(5)),
        lookTarget: entity,
    });
    switch (result.index) {
        case 0:
            entity.player.directMessage('成功返回');
            entity.position.set(3, 15, 3);
            break;
        case 1:
            break;
        default:
    }
});
const npc10 = world.querySelector('.服务员');
npc10.enableInteract = true; // 允许进行互动
npc10.interactRadius = 3;   // 实体的互动范围
npc10.interactHint = npc10.id; // 互动提示框显示实体的名称
npc10.interactColor = new Box3RGBColor(1,1,1);  // 互动提示的文字颜色
npc10.onInteract(async({entity}) => {
    const result = await entity.player.dialog({
        type: Box3DialogType.SELECT,
        title: npc10.id,
        titleTextColor: new Box3RGBAColor(0, 0, 0, 1),
        titleBackgroundColor: new Box3RGBAColor(0.968, 0.702, 0.392, 1),
        content: `${entity.player.name},这里是世界中心,我是这里的服务员。最近这里有万圣节活动,不过一些人不喜欢万圣节头套,所以,我这里负责回收头套,请问您要回收头套吗?`,
        options: ['要', '算了'],   // 将提供玩家选择的选项放入数组里。
        contentTextColor:  new Box3RGBAColor(0, 0, 0, 1),
        contentBackgroundColor: new Box3RGBAColor(1, 1, 1, 1),
        lookEye: entity.position.add(entity.player.facingDirection.scale(5)),
        lookTarget: entity,
    });
    switch (result.index) {
        case 0:
            entity.player.directMessage('回收成功');
            const headWears = entity.player.wearables(Box3BodyPart.HEAD); 
            entity.player.removeWearable(headWears[0])
            break;
        case 1:
            break;
        default:
    }
});
const npc11 = world.querySelector('.万圣小屋');
npc11.enableInteract = true; // 允许进行互动
npc11.interactRadius = 7;   // 实体的互动范围
npc11.interactHint = npc11.id; // 互动提示框显示实体的名称
npc11.interactColor = new Box3RGBColor(1,1,1);  // 互动提示的文字颜色
npc11.onInteract(async ({entity, targetEntity}) => {
const npcScript = [
    {
        type: Box3DialogType.TEXT,
        title: targetEntity.id,
        content: "现在这里正举行万圣节活动",
        hasArrow: true,
    },
    {
        type: Box3DialogType.TEXT,
        title: targetEntity.id,
        content: "你也看到了,到处都是南瓜灯,包括你的头套。",
        hasArrow: true,

    },
    {
        type: Box3DialogType.TEXT,
        title: targetEntity.id,
        content: "当然,头套可以找世界中心的服务员回收,不过,在你退出游戏之前,头套不会回来。。。", 

    },
    {
        type: Box3DialogType.TEXT,
        title: targetEntity.id,
        content: "希望你明白了",
    }];

    // 通过循环,读取数组的长度,将剧本按顺序放入对话框。
    for (i=0; i < npcScript.length; i++){
        // 弹出对话框
        const dialog = await entity.player.dialog(npcScript[i]);
        // 如果对话框不是选择类型对话框,就跳过后面的事件。
        if (!dialog || npcScript[i].type != Box3DialogType.SELECT) continue;
    }
});
const npc12 = world.querySelector('.活动告示');
npc12.enableInteract = true; // 允许进行互动
npc12.interactRadius = 3;   // 实体的互动范围
npc12.interactHint = npc10.id; // 互动提示框显示实体的名称
npc12.interactColor = new Box3RGBColor(1,1,1);  // 互动提示的文字颜色
npc12.onInteract(async({entity}) => {
    const result = await entity.player.dialog({
        type: Box3DialogType.SELECT,
        title: npc10.id,
        titleTextColor: new Box3RGBAColor(0, 0, 0, 1),
        titleBackgroundColor: new Box3RGBAColor(0.968, 0.702, 0.392, 1),
        content: `${entity.player.name},这是活动告示牌,要看看吗?`,
        options: ['要', '算了'],   // 将提供玩家选择的选项放入数组里。
        contentTextColor:  new Box3RGBAColor(0, 0, 0, 1),
        contentBackgroundColor: new Box3RGBAColor(1, 1, 1, 1),
        lookEye: entity.position.add(entity.player.facingDirection.scale(5)),
        lookTarget: entity,
    });
    switch (result.index) {
        case 0:
            entity.player.directMessage('现在,这个迷一样的世界正在举行万圣节活动,有什么想详细了解的,可以去天空商业区的万圣小屋看看。')
            break;
        case 1:
            break;
        default:
    }
});
const TEST_PLAYER = ['寒江的雪','难起的名字','宝宝Abner']
world.onPlayerJoin(({ entity }) => {
    if (!TEST_PLAYER.includes(entity.player.name)) return; // 如果玩家名称不在列表里,则跳过后续脚本。
    world.say(`恭迎创作人 ${entity.player.name} !`);
    entity.player.addWearable({
        bodyPart: Box3BodyPart.TORSO,//装备穿戴的位置在身上
        mesh: 'mesh/飞翔的小蓝鸟.vb',//装备是一个叫做“天使之翼”的模型
        orientation: new Box3Quaternion(0, 1, 0, 1).rotateY(Math.PI/2),
        scale: new Box3Vector3(1, 1, 1),//模型大小长宽高都缩小***倍
        offset: new Box3Vector3(0, 2, 0),//装备的位置,向人背后偏移一些
        emissive: emissive=0.05
    });
})
world.onPlayerLeave(({ entity }) => {
    if (!TEST_PLAYER.includes(entity.player.name)) return; // 如果玩家名称不在列表里,则跳过后续脚本。
    world.say(`恭送创作人 ${entity.player.name} !`);
})
world.onPlayerLeave(({ entity }) => {
    world.say(`${entity.player.name} 离开了迷之世界。`);
});
world.onChat(async({ entity, message }) => {
    if (entity && entity.isPlayer) {
        str = message;
        if(str=='简介'){
            entity.player.directMessage('系统客服:本地图属于竞赛类地图')
            await sleep(1000)
            entity.player.directMessage('【特别鸣谢】')
            await sleep(1000)
            entity.player.directMessage('地图拥有者:寒江的雪')
            await sleep(1000)
            entity.player.directMessage('创作团队:帮助我完成这个地图的所有人(毕竟,有些人只是帮我在论坛上解决代码问题。。。)')
            await sleep(3000)
            entity.player.directMessage('感谢以上大佬参与!祝你玩得开心(*^▽^*)')
        }else if(str=='跳伞'){
            if(entity.position.y > 71){
                entity.player.addWearable({
                    bodyPart: Box3BodyPart.HEAD,//装备穿戴的位置在身上
                    mesh: 'mesh/跳伞伞.vb',//装备是一个叫做“天使之翼”的模型
                    orientation: new Box3Quaternion(0, 1, 0, 0).rotateY(Math.PI/2),
                    scale: new Box3Vector3(4, 4, 4),//模型大小长宽高都缩小***倍
                    offset: new Box3Vector3(0, 2, 0),//装备的位置,向人背后偏移一些
                });
                entity.position = new Box3Vector3(98,69,77);
                entity.player.directMessage(entity.player.name+' 欢迎来到谜之世界!!!')
                await sleep(1000)
                if (!entity.isPlayer) return;
                const headWears = entity.player.wearables(Box3BodyPart.HEAD); 
                // 假设只有1个装备 `headWears[0]` 
                entity.player.removeWearable(headWears[0]);
                entity.player.removeWearable(headWears[2]);
            }else{
                entity.player.directMessage('弄啥嘞???')
            }
        }else if(str=='我错了'){
            if(entity.position.y < 8){
                if(entity.position.x < 20){
                    entity.position = new Box3Vector3(40,10,40);
                    entity.player.directMessage(' 希望你不要一错再错 '+entity.player.name+'')
                }else{
                    entity.player.directMessage('弄啥嘞???')
                }
            }else{
                entity.player.directMessage('弄啥嘞???')
            }
        }else if(str=='取消载具'){
            entity.mesh='';
            entity.player.invisible=false;
            entity.player.canFly = false;
            entity.player.enableJump = true;
            entity.player.walkSpeed=0.22;
            entity.player.runSpeed=0.4;
        }else if(str=='取消飞行'){
            entity.player.canFly = false
            entity.player.directMessage('成功取消飞行!')
        }       
    }
})
world.querySelectorAll('.尼桑跑车').forEach((e)=>{
    e.onEntityContact(({entity,other})=>{  
        if(!other.isPlayer){return} 
        other.mesh=entity.mesh;
        other.meshScale=entity.meshScale;
        other.player.invisible=true;
        other.player.walkAcceleration=1;
        other.player.walkSpeed+=1;
        other.player.runSpeed+=1;
        entity.meshOrientation = entity.meshOrientation.rotateY(Math/-90);
        world.say(other.player.name+" 开走了尼桑跑车");
        other.player.directMessage('说“取消载具”即可下车')
    })
})
world.onEntityContact(({entity,other})=>{
    if(entity.isPlayer===false){
        if(other.isPlayer===true){
            if(entity.hasTag('货车')){
                if(other.mesh===''){
                    other.meshOrientation = new Box3Quaternion(0, 1, 0, 0);//调整方向
                    other.mesh=entity.mesh;
                    other.meshScale=entity.meshScale;
                    other.player.canFly=false;
                    other.player.invisible=true;
                    other.player.walkSpeed+=1;
                    other.player.runSpeed+=1;
                    other.position.set(67.2,14,25.5)
                    world.say(other.player.name+" 开走了货车");
                    other.player.directMessage('说“下车”即可下车')
                }
            }
        }
    }
});
world.querySelectorAll('.碰瓷的').forEach((e)=>{//“门”是模型标签
    e.onEntityContact(({other})=>{//这边是框架
        sleep(500).then(()=>{
            other.mesh='';
            other.player.invisible=false;
            other.player.canFly = false;
            other.position.set(2,2,2);//本质上只有这一行是传送
            other.player.walkSpeed=0.22;
            other.player.runSpeed=0.4;
            world.say('SANS被撞了!!!可怜的肇事者 '+other.player.name+' 被抓进了地牢。。。')  
        })
    })    
});//就这个
world.querySelectorAll('.办公桌').forEach((e)=>{//“门”是模型标签
    e.onEntityContact(({other})=>{
        sleep(500).then(()=>{
            other.player.directMessage(''+other.player.name+' 想出去吗,认错就可以了。。。(说“我错了”)')    
        })
    })    
});
world.querySelectorAll(".天空传送门").forEach((entity) => {
    entity.meshInvisible= true;
})
world.querySelectorAll('.门1钮').forEach((e)=>{//“门”是模型标签
    e.onClick(({clicker,entity})=>{
        sleep(500).then(()=>{
            world.querySelectorAll(".门1").forEach((entity) => {
                entity.meshInvisible= true;
            })
            world.addCollisionFilter('.门1','player');
            entity.position.set(98.3,0,2.6)
            world.say('1号门 '+clicker.player.name+' 被激活了!')
            clicker.player.directMessage('你成功激活了某个门')
        })
    })    
});
world.querySelectorAll('.门1').forEach((e)=>{//“门”是模型标签
    e.onEntityContact(({other})=>{
        sleep(500).then(()=>{
            other.player.directMessage('你发现:门开不了。。。')
        })     
    });
})
world.querySelectorAll('.传送门1/1').forEach((e)=>{//“门”是模型标签
    e.onEntityContact(({other})=>{
        sleep(500).then(()=>{
            other.position.set(110,2,39)
        })
    })    
})
world.querySelectorAll('.传送门1/2').forEach((e)=>{//“门”是模型标签
    e.onEntityContact(({other})=>{
        sleep(500).then(()=>{
            other.position.set(101,34,37)
        })
    })    
})
world.querySelectorAll('.单向门').forEach((e)=>{//“门”是模型标签
    e.onEntityContact(({other})=>{
        sleep(500).then(()=>{
            other.player.directMessage('这不过就是一个单向传送门啊(进不去的)')
        })
    })    
})
world.querySelectorAll('.飞行触发器').forEach((e)=>{//“门”是模型标签
    e.onEntityContact(({other})=>{
        sleep(500).then(()=>{
            world.say(other.player.name+' 学会了飞行!!!')
            other.player.directMessage('哇哦!飞起来了!(说“取消飞行”即可取消)')
            other.player.canFly = true;
        })
    })    
})
// 添加检测玩家进入或离开 x:48-喵, y:8-20, z: 50-72 的区域
const area = world.addTrigger({
    selector: 'player',
    bounds: {
        lo: [32, 18, 98],
        hi: [39, 27, 104],
    },
})

// 有玩家进入区域
area.onEnter(async({ entity }) => {
    const result = await entity.player.dialog({
        type: Box3DialogType.SELECT,
        title: "传送门",
        titleTextColor: new Box3RGBAColor(0, 0, 0, 1),
        titleBackgroundColor: new Box3RGBAColor(0.968, 0.702, 0.392, 1),
        content: `${entity.player.name},这里通往天空商业区,你要去吗?`,
        options: ['要', '下次吧'],   // 将提供玩家选择的选项放入数组里。
        contentTextColor:  new Box3RGBAColor(0, 0, 0, 1),
        contentBackgroundColor: new Box3RGBAColor(1, 1, 1, 1),
        lookEye: entity.position.add(entity.player.facingDirection.scale(5)),
        lookTarget: entity,
    });
    switch (result.index) {
        case 0:
            world.say(entity.player.name+' 传送到了空中商业区~~~')
            entity.player.directMessage('传送成功~');
            entity.position.set(121,60, 5);
            break;
        case 1:
            entity.player.directMessage('好吧。。。');
            entity.position.set(46,18, 101);
            break;
        default:
    }
});
world.onEntityContact(({entity,other})=>{
    if(entity.isPlayer===false){
        if(other.isPlayer===true){
            if(entity.hasTag('飞机')){
                if(other.mesh===''){
                    other.meshOrientation = new Box3Quaternion(0, 1, 0, 0);//调整方向
                    other.mesh=entity.mesh;
                    other.meshScale=entity.meshScale;
                    other.player.canFly=true;
                    other.player.invisible=true;
                    world.say(other.player.name+" 开走了飞机");
                    other.player.directMessage('说“取消载具”即可下飞机')
                }
            }
        }
    }
});
world.querySelectorAll('.医院门').forEach((e)=>{//“门”是模型标签
    e.onEntityContact(({other})=>{
        sleep(500).then(()=>{
            other.player.directMessage('点击即可开门')
        })
    })    
});
world.querySelectorAll('.医院门').forEach((e)=>{//“门”是模型标签
    e.onClick(({entity})=>{
        sleep(500).then(async()=>{
            entity.meshInvisible= true;
            world.addCollisionFilter('.医院门','player');
            await sleep(5000)
            entity.meshInvisible= false;
            world.removeCollisionFilter('.医院门','player');
        })
    })    
});


回复

上一页1 页 / 共 1下一页

无聊至极(自古沙发归帖主)

emotion_编程猫_冷漠

点赞0


评论


白篮白篮

700行怎么了呢,做项目时候经常是万行扑脸的center_imageemotion_doge

点赞0


评论


上吊上吊

emotion_编程猫_厉害了

点赞0


评论


minecraft_funnyminecraft_funny

https://box3create.codemao.cn/games/c38d0c2096e174732a85?p=%2FWuNeGZ106hWaXYGiRS6dji96bz3lzE1so8IxxS4QmA8m1wCTXLgt喵250cmlidXRvcg%3D%3D

点赞0


评论


独行的疾风雀IVup独行的疾风雀IVup

看来你没有看过百度的H T M L代码

点赞0


评论