猫史档案馆


求修改一下这个代码!

用户:山海kvz山海kvz查看:0 回复:1 评论:0 创建时间:2022-07-23T10:24:31


for (const e of world.querySelectorAll('*')) {//遍历所有实体
    if (e.id.startsWith('奖杯')) {//如果当前实体名左边部分刚好是"存档点", 比如 存档点-1 存档点-2...
        e.collides = true //开启碰撞
        e.fixed = true //固定实体不被推移
        e.meshScale = e.meshScale.scale(2) //放大2倍
        e.onEntityContact(({ other }) => { //每当存档点碰到另一个实体
            if (other.isPlayer) { //另一个实体是玩家
                if (e.position !== other.player.spawnPoint) { // 检测当前存档点是否玩家重生点, 避免反复在同一个存档点做多余的保存
                    other.player.directMessage('恭喜你!已通关!') // 给玩家发消息
                    other.player.spawnPoint = e.position // 喵家重生点坐标设置成存档点的坐标
                }
            }
        })
    }
}
for (const e of world.querySelectorAll('*')) {//遍历所有实体
    if (e.id.startsWith('我')) {//如果当前实体名左边部分刚好是"存档点", 比如 存档点-1 存档点-2...
        e.collides = true //开启碰撞
        e.fixed = true //固定实体不被推移
        e.meshScale = e.meshScale.scale(2) //放大2倍
        e.onEntityContact(({ other }) => { //每当存档点碰到另一个实体
            if (other.isPlayer) { //另一个实体是玩家
                if (e.position !== other.player.spawnPoint) { // 检测当前存档点是否玩家重生点, 避免反复在同一个存档点做多余的保存
                    other.player.directMessage('嗨!我是作者,很感谢你来玩这个作品,收藏吧!') // 给玩家发消息
                    other.player.spawnPoint = e.position // 喵家重生点坐标设置成存档点的坐标
                }
            }
        })
    }
}
for (const e of world.querySelectorAll('*')) {//遍历所有实体
    if (e.id.startsWith('吉吉喵-科技形态')) {//如果当前实体名左边部分刚好是"存档点", 比如 存档点-1 存档点-2...
        e.collides = true //开启碰撞
        e.fixed = true //固定实体不被推移
        e.meshScale = e.meshScale.scale(2) //放大2倍
        e.onEntityContact(({ other }) => { //每当存档点碰到另一个实体
            if (other.isPlayer) { //另一个实体是玩家
                if (e.position !== other.player.spawnPoint) { // 检测当前存档点是否玩家重生点, 避免反复在同一个存档点做多余的保存
                    other.player.directMessage('我也进化了!哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!') // 给玩家发消息
                    other.player.spawnPoint = e.position // 喵家重生点坐标设置成存档点的坐标
                }
            }
        })
    }
}





world.onPress(async({entity,button})=>{
    if(button == 'action1'){
        const r = await entity.player.dialog({
            type:Box3DialogType.SELECT,
            hasArrow : true,
            dialogclass:'no-close',
//            title:'菜单',
//            titleBackgroundColor:new Box3RGBAColor(1,1,1,1),
//            titleTextColor:new Box3RGBAColor(1,1,1,1),
//            content:`${entity.player.name}的菜单`,
            contentBackgroundColor:new Box3RGBAColor(0,0,0,0),
            contentTextColor:new Box3RGBAColor(1,1,1,1),
            options:['背包','退出'],
            
            
            
        })
    }
})
/**
 * godzilla
 */

world.querySelectorAll('#哥斯拉头套-1').forEach((e) => e.destroy());
world.querySelectorAll('#哥斯拉装甲-1').forEach((e) => e.destroy());
world.querySelectorAll('#哥斯拉尾巴-1').forEach((e) => e.destroy());
world.querySelectorAll('#哥斯拉左小腿-1').forEach((e) => e.destroy());
world.querySelectorAll('#哥斯拉左小腿-2').forEach((e) => e.destroy());
world.querySelectorAll('#哥斯拉左小腿-3').forEach((e) => e.destroy());
world.querySelectorAll('#哥斯拉左小腿-4').forEach((e) => e.destroy());
world.querySelectorAll('#哥斯拉左小腿-5').forEach((e) => e.destroy());
world.querySelectorAll('#哥斯拉左小腿-6').forEach((e) => e.destroy());
world.querySelectorAll('#哥斯拉左小腿-7').forEach((e) => e.destroy());
world.querySelectorAll('#哥斯拉左小腿-8').forEach((e) => e.destroy());
const WEAPON = {
    1: { // 头部
        mesh: world.querySelector('狗头').mesh,
        parts: [Box3BodyPart.HEAD],
        scale: new Box3Vector3(0.52, 0.41, 0.52), // 调整大小
        orientation: new Box3Quaternion(0, 1, 0, -1).rotateX(0).rotateY(0),
        offset: new Box3Vector3(0, 0.58, 0), //调整位置
    },
    2: { // 身体
        mesh: world.querySelector('#哥斯拉装甲-1').mesh,
        parts: [Box3BodyPart.TORSO],
        scale: new Box3Vector3(0.36, 0.37, 0.34), // 调整大小
        orientation: new Box3Quaternion(0, 1, 0, 0).rotateX(0).rotateY(0),
        offset: new Box3Vector3(0, 0.22, -0.15), //调整位置
    },
    3: { // 尾巴
        mesh: world.querySelector('#哥斯拉尾巴-1').mesh,
        parts: [Box3BodyPart.HIPS],
        scale: new Box3Vector3(0.25, 0.25, 0.25), // 调整大小
        orientation: new Box3Quaternion(0, 1, 0, 0).rotateX(0).rotateY(0),
        offset: new Box3Vector3(0, 0.1, -0.73), //调整位置
    },
    4: { // 左上臂
        mesh: world.querySelector('#哥斯拉左小腿-1').mesh,
        parts: [Box3BodyPart.LEFT_UPPER_ARM],
        scale: new Box3Vector3(0.52, 0.31, 0.52), // 调整大小
        orientation: new Box3Quaternion(0, 1, 0, 0).rotateX(0).rotateY(0).rotateZ(0),
        offset: new Box3Vector3(0, 0, 0), //调整位置
    },
    5: { // 左下臂
        mesh: world.querySelector('#哥斯拉左小腿-2').mesh,
        parts: [Box3BodyPart.LEFT_LOWER_ARM],
        scale: new Box3Vector3(0.52, 0.31, 0.52), // 调整大小
        orientation: new Box3Quaternion(0, 1, 0, 0),
        offset: new Box3Vector3(0, 0, 0), //调整位置
    },
    6: { // 右上臂
        mesh: world.querySelector('#哥斯拉左小腿-3').mesh,
        parts: [Box3BodyPart.RIGHT_UPPER_ARM],
        scale: new Box3Vector3(0.52, 0.31, 0.52), // 调整大小
        orientation: new Box3Quaternion(0, 1, 0, 0),
        offset: new Box3Vector3(0, 0, 0), //调整位置
    },
    7: { // 右下臂
        mesh: world.querySelector('#哥斯拉左小腿-4').mesh,
        parts: [Box3BodyPart.RIGHT_LOWER_ARM],
        scale: new Box3Vector3(0.52, 0.31, 0.52), // 调整大小
        orientation: new Box3Quaternion(0, 1, 0, 0),
        offset: new Box3Vector3(0, 0, 0), //调整位置
    },
    8: { // 左大腿
        mesh: world.querySelector('#哥斯拉左小腿-5').mesh,
        parts: [Box3BodyPart.LEFT_UPPER_LEG],
        scale: new Box3Vector3(0.52, 0.53, 0.52), // 调整大小
        orientation: new Box3Quaternion(0, 1, 0, 0),
        offset: new Box3Vector3(0, 0, 0), //调整位置
    },
    9: { // 左小腿
        mesh: world.querySelector('#哥斯拉左小腿-6').mesh,
        parts: [Box3BodyPart.LEFT_LOWER_LEG],
        scale: new Box3Vector3(0.52, 0.53, 0.52), // 调整大小
        orientation: new Box3Quaternion(0, 1, 0, 0),
        offset: new Box3Vector3(0, 0, 0), //调整位置
    },
    10: { // 右大腿
        mesh: world.querySelector('#哥斯拉左小腿-7').mesh,
        parts: [Box3BodyPart.RIGHT_UPPER_LEG],
        scale: new Box3Vector3(0.52, 0.53, 0.52), // 调整大小
        orientation: new Box3Quaternion(0, 1, 0, 0),
        offset: new Box3Vector3(0, 0, 0), //调整位置
    },
    11: { // 右小腿
        mesh: world.querySelector('#哥斯拉左小腿-8').mesh,
        parts: [Box3BodyPart.RIGHT_LOWER_LEG],
        scale: new Box3Vector3(0.52, 0.53, 0.52), // 调整大小
        orientation: new Box3Quaternion(0, 1, 0, 0),
        offset: new Box3Vector3(0, 0, 0), //调整位置
    },
};

function godzillaWeapon(entity, camp) {
    WEAPON[camp].parts.forEach((part) => entity.player.addWearable({
        bodyPart: part, // 装备
        mesh: WEAPON[camp].mesh, // 设置武器mesh
        orientation: WEAPON[camp].orientation, // 设置方向
        scale: WEAPON[camp].scale, // 设置大小
        offset: WEAPON[camp].offset, // 设置位置
    }));
}

function trueGodzillaWeapon(entity){
    godzillaWeapon(entity, '1')
    godzillaWeapon(entity, '2')
    godzillaWeapon(entity, '3')
    godzillaWeapon(entity, '4')
    godzillaWeapon(entity, '5')
    godzillaWeapon(entity, '6')
    godzillaWeapon(entity, '7')
    godzillaWeapon(entity, '8')
    godzillaWeapon(entity, '9')
    godzillaWeapon(entity, '10')
    godzillaWeapon(entity, '11')
}

world.onPlayerJoin(({ entity }) => {
    entity.player.skinInvisible.head=true;
    entity.player.skinInvisible.hips=true;
    entity.player.skinInvisible.leftFoot=false;
    entity.player.skinInvisible.leftHand=false;
    entity.player.skinInvisible.leftLowerArm=true;
    entity.player.skinInvisible.leftLowerLeg=true;
    entity.player.skinInvisible.leftShoulder=true;
    entity.player.skinInvisible.leftUpperArm=true;
    entity.player.skinInvisible.leftUpperLeg=true;
    entity.player.skinInvisible.neck=true;
    entity.player.skinInvisible.rightFoot=false;
    entity.player.skinInvisible.rightHand=false;
    entity.player.skinInvisible.rightLowerArm=true;
    entity.player.skinInvisible.rightLowerLeg=true;
    entity.player.skinInvisible.rightShoulder=true;
    entity.player.skinInvisible.rightUpperArm=true;
    entity.player.skinInvisible.rightUpperLeg=true;
    entity.player.skinInvisible.torso=true;
    trueGodzillaWeapon(entity)
})


回复

上一页1 页 / 共 1下一页
山海kvz山海kvz

求求大佬了!我也放模型了!

点赞0


评论