用户:
老葵查看:13 回复:9 评论:13 创建时间:2020-06-13T15:22:13
话不多说,直接上代码
world.onPlayerJoin(({ entity }) => {
entity.enableDamage = true;
entity.player.Qiang = 0;
entity.player.Lengque = 0;
entity.player.directMessage('请务必快去找喵!落地是没有喵的!')
entity.player.onPress(async({ button, raycast:{ hitEntity, direction } }) => {
if (button !== 'action0' || !hitEntity) {
return;
}
hitEntity.velocity.x += direction.x;
hitEntity.velocity.y += direction.y;
hitEntity.velocity.z += direction.z;
if(entity.player.Lengque == 0){
if(entity.player.Qiang == 1){
hitEntity.hurt(10);
entity.player.Lengque = 1;
await sleep(100);//静待一段时间,time是输入的参数,默认值为1000毫秒
entity.player.Lengque = 0;
}
else if(entity.player.Qiang == 2){
hitEntity.hurt(80);
entity.player.Lengque = 1;
await sleep(100);//静待一段时间,time是输入的参数,默认值为1000毫秒
entity.player.Lengque = 0;
}
else if(entity.player.Qiang == 3){
hitEntity.hurt(40);
entity.player.Lengque = 1;
await sleep(600);
entity.player.Lengque = 0;
}
}
});
});
加标签,开实体
1是冲锋喵
2是喵喵
3是喵
还有加这段代码
world.querySelectorAll('.1').forEach((e)=>{
e.onEntityContact(({entity,other})=>{
other.player.Qiang=1;
world.say(other.player.name + ' 捡到了冲锋喵');
})
})
world.querySelectorAll('.2').forEach((e)=>{
e.onEntityContact(({entity,other})=>{
other.player.Qiang=3;
world.say(other.player.name + ' 捡到了喵喵');
})
})
world.querySelectorAll('.3').forEach((e)=>{
e.onEntityContact(({entity,other})=>{
other.player.Qiang=2;
world.say(other.player.name + ' 捡到了喵');
})
})
就没了
再见
(赶时间做作业)