用户:
幽梦子曦查看:0 回复:0 评论:0 创建时间:2020-12-21T14:56:21
// 玩家进入游戏时,弹出一个对话框 world.onPlayerJoin(({ entity }) => { const dialog = entity.player.dialog({ type: Box3DialogType.TEXT, title: "吉吉喵", content: `你好,${entity.player.name},很高兴认识你。`, }); }); console.clear()
require('./ray_crazy.js') function randint(min,max){ return Math.round(Math.random()*(max-1)+min); } //min是最小max是最大
// 关闭玩家和玩家之间的碰撞 world.addCollisionFilter('player','player');
var red = 0;//红队的初始芝士 var blue = 0;//蓝队的初始芝士 var people = 0;//人数初始芝士 var start = '否'; var father_Christmas = []; var fcm; var gift = '否'
//具体分组代码,以上是芝士 world.onPlayerJoin(async({ entity })=>{ entity.player.swimSpeed = 2.5; entity.player.swimAcceleration = 0.1; entity.position.set(57, 68, 59) entity.player.scale = 0.8; if(red > blue){ entity.player.dui = 'blue'; blue = (typeof blue == 'number' ? blue : 0) + 1;
}else if(blue > red){ entity.player.dui = 'red'; red = (typeof red == 'number' ? red : 0) + 1; }else{ entity.player.dui = 'red'; red = (typeof red == 'number' ? red : 0) + 1; } world.say(entity.player.name + '被选为' + entity.player.dui + '队。') people = (typeof people == 'number' ? people : 0) + 1; await sleep(500); if(people >= 3){ if(start == '否'){ start = '是'; world.say('开始游戏!') world.querySelectorAll('player').forEach((x)=>{ father_Christmas.push(x.player.name); }) var fcm = father_Christmas[randint(0, father_Christmas.length)]; world.say(fcm + '被选为放置礼物的人~') world.querySelectorAll('player').forEach((x)=>{ if(x.player.name == fcm){ x.player.invisible = true; x.player.showName = false; } }) while(gift == '否'){ world.querySelectorAll('player').forEach((x)=>{ if(x.player.name == fcm){ switch (entity.player.walkState) { // 正在奔跑 case Box喵layerWalkState.CROUCH: world.querySelectorAll('present').forEach((p) =>{ p.onPress(({button,raycast}) =>{ let pos = raycast.voxelIndex if(button == 'action0'){ p.position = new Box3Vector3(pos) } }); p.position = fcm }); //voxels.setVoxel(x,position,x, x.position.y - 1, x.position.z, 'red_gift'); world.say('礼物已放置!赶快来寻找吧!'); gift = '是'; break; // 在其他行走状态不显示粒子 default: }; } }) await sleep(10); } } } }) world.ambientSound.sample = 'audio/666.mp3'; world.onChat(async({message,entity})=>{ if(message==='粒子特效'&&entity.isPlayer){ Object.assign(entity, { particleRate: 500,//粒子数量,可更改,越大粒子越多 particleSize: [5, 4, 3, 2, 1],//粒子在每个阶段的大小,可更改 particleColor: [//例子在每个阶段的颜色,可更改 new Box3RGBColor(0,5,6),//第一阶段 new Box3RGBColor(6, 4, 5),//第二阶段 new Box3RGBColor(0, 6, 5),//第三阶段 new Box3RGBColor(0, 6, 8),//第四阶段 new Box3RGBColor(0, 0, 8),//第五阶段 ], particleLifetime: 1, particleVelocitySpread: new Box3Vector3(2, 2 ,2), }); } }) world.onPlayerJoin(({ entity }) => { Object.assign(entity, { particleRate: 500,//粒子数量,可更改,越大粒子越多 particleSize: [5, 4, 3, 2, 1],//粒子在每个阶段的大小,可更改 particleColor: [//例子在每个阶段的颜色,可更改 new Box3RGBColor(4,5,20),//第一阶段 new Box3RGBColor(0, 4, 8),//第二阶段 new Box3RGBColor(0, 5, 8),//第三阶段 new Box3RGBColor(0, 6, 9),//第四阶段 new Box3RGBColor(0, 0, 10),//第五阶段 ], particleLifetime: 1, particleVelocitySpread: new Box3Vector3(2, 2 ,2), }); }) world.onChat(({ entity, message }) => { if (entity&&entity.isPlayer) { if(entity&&'管喵名字 用空格隔开'.split(' ').indexOf(entity.player.name)!=-1&&message.charAt(0)=='$'){ try{ world.say('<~ '+eval(message.split('$')[1]))}catch(err){ world.say('Error:'+err) } }; } })