用户:
白毛Whitehair查看:7 回复:4 评论:7 创建时间:2022-05-02T11:35:57
求代码!求代码!求代码!求代码!求代码!求代码!求代码!求代码!求代码!求代码!
飞跃的流星丨冲四千粉我的跑酷部分代码:
//console.clear();//清空控制台
require('./胜利判断.js');
//require('./实体创建.js');
//require('./精灵跟随.js');
require('./SQL存档.js');
//require('./等级侦测.js');
world.onPlayerJoin(({ entity }) => {
entity.onVoxelContact(async({ entity , voxel}) => {
if(voxel == voxels.id('lava02')) {
entity.enableDamage = true;
entity.hurt(10);
sleep(2)
}
})
})
world.onDie(async ({ entity }) => {
if (!entity.isPlayer) return;
for (let t = 1; t <= 6; t++) {
entity.player.directMessage(`你还有 ${String(6 - t)} 秒后复活`);
await sleep(1000);
}
entity.player.forceRespawn();
});
world.onVoxelContact(({ entity, voxel, x, y, z }) => {
if (voxel === voxels.id('carpet_08')) {
entity.hp = entity.maxHp
}
})
//for (const e of world.querySelectorAll('*')) {//遍历所有实体
// if (e.id.startsWith('存档点')) {//如果当前实体名左边部分刚好是"存档点", 比如 存档点-1 存档点-2...
// e.collides = true //开启碰撞
// e.fixed = true //固定实体不被推移
// e.meshScale = e.meshScale.scale(1) //放大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.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.canFly = true
// world.say(`恭喜${other.player.name}到达了跑酷终点并获得了飞行奖励`)
// other.player.spawnPoint = e.position // 喵家重生点坐标设置成存档点的坐标
// }
// }
// })
// }
//}
//world.onPress(async({entity,button})=>{
//if(button == Box3ButtonType.ACTION0){
//const say = await entity.player.dialog({
// type:'input',
// title:'请输入要说的话:',
// content:'',
// confirmText:'发送',
//})
//if(say == null||say.length >= 20 ){return}
// world.say(entity.player.name+':'+say)
//}
//})
world.onPlayerJoin(({ entity }) => {
entity.onFluidEnter(() => {
entity.position.copy(entity.player.spawnPoint)
entity.position.y += 0
})
})
world.onPlayerLeave(({ entity }) => {
update.call(entity);
world.onPlayerJoin(({ entity }) => {
entity.onVoxelContact(async ({ entity, voxel }) => {
if (voxel == voxels.id('lava02')) {
entity.enableDamage = true;
entity.hurt(1);
sleep(2)
}
})
})
world.onDie(async ({ entity }) => {
if (!entity.isPlayer) return;
for (let t = 1; t <= 6; t++) {
entity.player.directMessage(`你还有 ${String(6 - t)} 秒后复活`);
await sleep(1000);
}
entity.player.forceRespawn();
});
world.onVoxelContact(({ entity, voxel, x, y, z }) => {
if (voxel === voxels.id('carpet_08')) {
entity.hp = entity.maxHp
}
})
//world.onPress(async({entity,button})=>{
//if(button == Box3ButtonType.ACTION0){
//const say = await entity.player.dialog({
// type:'input',
// title:'请输入要说的话:',
// content:'',
// confirmText:'发送',
//})
//if(say == null||say.length >= 20 ){return}
// world.say(entity.player.name+':'+say)
//}
//})
world.onPlayerJoin(({ entity }) => {
entity.onFluidEnter(() => {
entity.position.copy(entity.player.spawnPoint)
entity.position.y += 0
})
})
world.querySelectorAll('.invisible').forEach((e) => { e.meshInvisible = true })
const TEST_PLAYER = ['飞跃的流星']
world.onPlayerJoin(({ entity }) => {
if (!TEST_PLAYER.includes(entity.player.name)) return;
world.say(`创作者——${entity.player.name} 出现了!`);
})
})
world.onPlayerJoin(({ entity }) => {
entity.cundang = 1000000000
});
world.onPress(async ({ button, entity, raycast: { hitEntity, distance } }) => {
if (button == "action1") {
const s = await entity.player.dialog({
type: Box3DialogType.SELECT,
title: "操作台",
content: `请选择操作`,
options: [`存档(还剩${entity.cundang}次)`, '退出', '回到存档点']
});
if (!s) { return }
if (s.value == `存档(还剩${entity.cundang}次)`) {
if (entity.cundang >= 1) {
entity.cundang -= 1
entity.player.spawnPoint.copy(entity.position)
entity.player.directMessage(`存档成功,次数剩余${entity.cundang}`)
}
else { entity.player.directMessage(`次数不足`) }
}
if (s.value == '回到存档点') {
entity.position.set(entity.player.spawnPoint)
}
return
}
})
world.onPlayerJoin(({entity})=>{if(entity.player.name==点赞1
评论