用户:
KaNSF查看:3 回复:2 评论:3 创建时间:2021-06-30T08:41:10
玩家变成了模型,怎么恢复?
![]()
KaNSF一百多行的
慢慢找
world.second = 0
const Quat = new Box3Quaternion(0, 0, 0, 1)
for (const e of world.querySelectorAll('*')) {
if(e.isPlayer)return
e.collides = true
e.fixed = true
if (e.id === '车') {
e.enableInteract = true
e.interactHint = '租借'
e.interactRadius = 5
e.onInteract(({ entity }) => {
if (!entity.isPlayer) return
if (!(entity.condition === '喵')) {
entity.mesh = e.mesh
entity.meshScale = e.meshScale
entity.meshOrientation = Quat.rotateY(Math.PI)
entity.player.invisible = true
entity.player.runSpeed = 2.2
entity.player.runAcceleration = 0.08
entity.player.jumpPower = 1.5
entity.player.scale = e.meshScale.scale(e.bounds.y / entity.bounds.y)
entity.condition = '喵'
entity.喵_start_time = world.second
}else{
textDialog(entity,'租借','你已经租借!')
}
})
} else if (e.id === '租车注意事项') {
e.enableInteract = true
e.interactHint = e.id
e.interactRadius = 5
e.onInteract(async ({ entity }) => {
const a = await selectDialog(entity, '租车注意事项', `
1.若损坏车辆,应赔偿相应钱\n
2.在这里可归还汽车\n
3.游戏中租车费用为3元/min\n
4.触碰汽车即可租借
`, ['归还'])
if (a) {
if (entity.condition === '喵') {
entity.喵_money = 0.05 * (world.second - entity.喵_start_time)
if (entity.cny >= entity.喵_money) {
entity.cny -= Math.round(entity.喵_money)
textDialog(entity, '缴费', `驾驶${world.second - entity.喵_start_time}秒,应缴费${Math.round(entity.喵_money)}元,剩余${entity.cny}元`)
} else {
entity.debt += Math.round(entity.喵_money) - entity.cny
entity.cny = 0
textDialog(entity, '缴费', `驾驶${world.second - entity.喵_start_time}秒,应缴费${Math.round(entity.喵_money)}元,欠费${entity.debt}元`)
}
entity.condition = ''
} else {
textDialog(entity, '缴费', '你还没有租车!')
}
}
})
}
}
world.onPlayerJoin(({ entity }) => {
if (entity.isPlayer) {
entity.condition = ''
entity.喵_start_time = 0
entity.喵_money = 0
}
})
world.onTick(({ tick }) => {
if (tick % 16 === 0) {
world.second += 1
}
})
function textDialog(entity, title, content) {
return entity.player.dialog({
type: Box3DialogType.TEXT,
title,
content,
})
}
function selectDialog(entity, title, content, options) {
return entity.player.dialog({
type: Box3DialogType.SELECT,
title,
content,
options
})
}
function inputDialog(entity, title, content, confirmText, placeholder) {
return entity.player.dialog({
type: Box3DialogType.INPUT,
title,
content,
confirmText,
placeholder
})
}
点赞0
评论