猫史档案馆


[存档点] 存档点怎么搞

用户:亿只懒Ink亿只懒Ink查看:0 回复:4 评论:0 创建时间:2021-03-06T21:44:55


                                 如题

                            求代码啊啊啊


回复

上一页1 页 / 共 1下一页
薹灣解放再改名薹灣解放再改名

for (const e of world.querySelectorAll('*')) {//遍历所有实体
    if (e.id.startsWith('存档点')) {//如果当前实体名左边部分刚好是"存档点", 比如 存档点-1 存档点-2...
        e.collides = 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.spawnPoint = e.position // 喵家重生点坐标设置成存档点的坐标
                }
            }
        })
    }
}

world.onPlayerJoin(({ entity }) => {
    entity.onFluidEnter(() => {//当玩家掉到水里
        entity.position.copy(entity.player.spawnPoint)
        entity.position.y += 4
    })
})

点赞1


评论


薹灣解放再改名薹灣解放再改名

for (const e of world.querySelectorAll('*')) {//遍历所有实体
    if (e.id.startsWith('存档点')) {//如果当前实体名左边部分刚好是"存档点"
        e.collides = true //开启碰撞
        e.fixed = true //固定实体不被推移
        e.onEntityContact(({ other }) => { //每当存档点碰到另一个实体
            if (other.isPlayer) { //另一个实体是玩家
                 other.player.directMessage('到达新的存档点') // 给玩家发消息
                other.player.spawnPoint = e.position // 玩家重生点坐标设置成存档点的坐标
            }
        })
    }
}
/*-------------------------------------------------------------------------------------------------------------------*/
world.onPlayerJoin(({ entity }) => {
    entity.onFluidEnter(() => {
        entity.position.copy(entity.player.spawnPoint)//侦测
        entity.position.y += 2
        entity.player.directMessage(`${entity.player.name}溺水身亡`) // 给玩家发消息
    })
})
/*--------------------------------------------------------------------------------------------------------------------------*/

for (const e of world.querySelectorAll('*')) {//遍历所有实体
    if (e.id.startsWith('终点-1')) {//如果当前实体名左边部分刚好是"终点"
        e.collides = true //开启碰撞
        e.fixed = true //固定实体不被推移
        e.onEntityContact(({ other }) => { //每当终点碰到另一个实体
            if (other.isPlayer) { //另一个实体是玩家
                world.say(`${other.player.name} 到了跑酷的终点,让我们恭喜TA`)//向世界广播
                if (e.position !== other.player.spawnPoint) {
                    other.player.directMessage('恭喜你,到了终点,获得了飞行能力,逛一逛地图吧') // 给玩家发消息
                    other.player.spawnPoint = e.position // 玩家重生点坐标设置成存档点的坐标
                }
                other.player.canFly = true;
            }
        })
    }
}

/*-----------------------------------------------------------------------------------------------------------*/

点赞2


评论


薹灣解放再改名薹灣解放再改名

任选2个

点赞0


评论


LCG_剑少LCG_剑少

if (e.id == "起点") {         e.collides = true //开启碰撞         e.fixed = true //固定实体不被推移         e.onEntityContact(async({ other }) => { //每当存档点碰到另一个实体             if (other.isPlayer) { //另一个实体是玩家                 if (e.position !== other.player.spawnPoint) { // 检测当前存档点是否玩家重生点, 避免反复在同一个存档点做多余的保存                     world.say(other.player.name + " 出发啦!") 起点也给你一下

点赞0


评论