用户:
Robot一只屑代码师查看:7 回复:4 评论:7 创建时间:2022-05-28T11:51:57
呜呜呜呜,最近我图人太少了,觉得可以公开代码了
上吧
console.clear(); // 清空控制台
world.onPlayerJoin(({ entity }) => { // 当实体进入地图
if (entity.isPlayer) { // 如果实体是一个玩家
entity.addTag('NotInGame'); // 添加标签 “不在游戏中”
if (world.querySelectorAll('player').length >= 2) { // 如果玩家的数量 >= 9 则开始游戏
for (const c of world.querySelectorAll('.NotInGame')) { // 让所有不在游戏中的玩家传送到 “游戏区”
c.player.spawnPoint.set(54, 11, 102); // 重新重生点
c.player.forceRespawn(); // 强制传送
c.removeTag('NotInGame'); // 删掉标签 “不在游戏中”
c.player.dialog({ // 对话框
type: Box3DialogType.TEXT,
title: `欢迎`,
content: `开始!`
})
}
}
else { // 如果玩家人数不够,就执行这些代码
entity.player.spawnPoint.set(58, 11, 115); // 在上层 “休息区” 出生
entity.player.forceRespawn(); // 强制传送(重生)
entity.player.dialog({ // 发送对话框
type: Box3DialogType.TEXT,
title: `欢迎`,
content: `目前人数未达到 2 人,请等待其他玩家进入~~`
})
}
}
});
const Quat = new Box3Quaternion(0, 0, 0, 1)
for (const e of world.querySelectorAll('#远洋渔船-1')) {
e.collides = true
e.fixed = true
e.onEntityContact(({ other }) => {
if (other.isPlayer) { // 如果跟当前实体碰撞的是玩家实体
other.player.invisible = true // 玩家皮肤隐藏
other.mesh = e.mesh // 玩家的外形换成当前实体的外形
other.meshScale.copy(e.meshScale) // 玩家外形的缩放比例设成跟当前实体一样
//如果模型方向不正确, 则建议在模型编辑器里把模型转向修正
//也可以尝试下面其中一行代码, 但不同的模型需要转的角度不同, 无法通用
other.meshOrientation = Quat.rotateY(Math.PI) // 如果模型方向不对, 尝试旋转180度来修正, Math.PI是180度的弧度值
other.meshOrientation = Quat.rotateY(Math.PI/2)
other.meshOrientation = Quat.rotateY(-Math.PI/2) // 如果模型方向不对, 尝试旋转-90度来修正
other.player.scale = e.meshScale.scale(e.bounds.y / other.bounds.y) //喵家的隐形碰撞盒缩放到模型刚好贴地
}
})
}
world.querySelectorAll('.实体标签').forEach((e)=>{
e.onEntityContact(({entity,other})=>{
world.say(`有人获奖了!3秒后重启`)
})
})
world.querySelectorAll('.实体标签').forEach(async(e)=>{
e.onEntityContact(async({entity,other})=>{
if(other.isPlayer){
world.say('游戏开始咯!!')
other.position.set(54, 11, 102);
}
})
})
world.onPlayerJoin(({ entity }) => {
entity.player.enableJump = false;
});
for (let i = 0; i < 128; i++) {
for (let j = 9; j < 137; j++) {
for (let k = 0; k < 1; k++) {
voxels.setVoxel(i, j, k, 'ice')
}
}
}
for (let i = 0; i < 1; i++) {
for (let j = 9; j < 137; j++) {
for (let k = 0; k < 128; k++) {
voxels.setVoxel(i, j, k, 'ice')
}
}
}
for (let i = 0; i < 128; i++) {
for (let j = 9; j < 137; j++) {
for (let k = 126; k < 127; k++) {
voxels.setVoxel(i, j, k, 'ice')
}
}
}
for (let i = 126; i < 127; i++) {
for (let j = 9; j < 137; j++) {
for (let k = 0; k < 128; k++) {
voxels.setVoxel(i, j, k, 'ice')
}
}
}
for (let i = 0; i < 128; ++i) {
for (let j = 0; j < 128; ++j) {
voxels.setVoxel(i, 15, j, 'ice')
}
}
world.addCollisionFilter('player', 'player')
Robot一只屑代码师console.clear(); // 清空控制台
world.onPlayerJoin(({ entity }) => { // 当实体进入地图
if (entity.isPlayer...
自己看上面吧...........
点赞0
评论
Robot一只屑代码师https://box3.codemao.cn/e/4cf6d35aa9134fac8277?p=MF6YzU8NUdWzGtVbKp1JhaSZZdq80TYGboXqypP1n5A%2FzG2m%2BQMAVndWVzdA%3D%3D
点赞0
评论