猫史档案馆


--源码--

用户:小苏打_小苏打_查看:0 回复:0 评论:0 创建时间:2021-08-03T16:25:16


console.clear();
const mscale = 1 / 16;
const Quatx = new Box3Quaternion(0, 0, 0, 1);
const ADMIN_LIST = ['逍遥客/飞鱼室长', '星辰大海Starsea', '小苏打__', '星德薇', '蜜雪冰城爱好者', '逍遥客'/*, '小苏打_'*/];


let timexxx = 300000;
let blue = [];
let red = [];
let huosheng = "?"
let redKILLblue = 0
let bluesafe = 0
let zixiangcansha = 0

function joinRed(entity){
    entity.addTag('red')
    entity.player.color.set(1,0,0)
    world.say(` ${entity.player.name} 被分配到红队追捕者队`)
    entity.player.spawnPoint = world.querySelector('#CSD-1').position.add({x:0,y:3,z:0})
    entity.player.forceRespawn()
    red.push(entity)
}
function joinBlue(entity){
    entity.addTag('blue')
    entity.player.color.set(0,0,1)
    world.say(` ${entity.player.name} 被分配到蓝队逃生队`)
    entity.player.spawnPoint = world.querySelector('#CSD-0').position.add({x:0,y:3,z:0})
    entity.player.forceRespawn()
    blue.push(entity)
}
world.onTick(()=>{
    timexxx += 喵;
    if((timexxx >= 30000 && timexxx <= 300喵) || (timexxx >= 60000 && timexxx <= 600喵) || (timexxx >= 90000 && timexxx <= 900喵) || (timexxx >= 120000 && timexxx <= 1200喵) || (timexxx >= 150000 && timexxx <= 1500喵)){
        /**
         * enableDoubleJump
         * runSpeed
         * jumpPower
         * swimSpeed
        */

        world.querySelectorAll('player').forEach((e) => {
            if(!(e.hasTag('blue') || e.hasTag('red'))){
                return ;
            }
            e.player.enableDoubleJump = false;
            e.player.runSpeed = 0.44;
            e.player.jumpPower = 0.96;
            e.player.swimSpeed = 0.4;

            if(Math.floor(Math.random()*2)){
                if(Math.floor(Math.random()*2)){
                    e.player.enableDoubleJump = true;
                    e.player.dialog({
                        type: Box3DialogType.TEXT,
                        title: "随机技能!",
                        content: "你获得了 二段跳 技能!"
                    })
                }else{
                    e.player.runSpeed = 0.44+Math.random();
                    e.player.dialog({
                        type: Box3DialogType.TEXT,
                        title: "随机技能!",
                        content: "你获得了 随机奔跑速度 技能!"
                    })
                }
            }else{
                if(Math.floor(Math.random()*2)){
                    e.player.jumpPower = 0.96+Math.random();
                    e.player.dialog({
                        type: Box3DialogType.TEXT,
                        title: "随机技能!",
                        content: "你获得了 随机跳跃高度 技能!"
                    })
                }else{
                    e.player.swimSpeed = 0.4+Math.random();
                    e.player.dialog({
                        type: Box3DialogType.TEXT,
                        title: "随机技能!",
                        content: "你获得了 随机游泳速度 技能!"
                    })
                }
            }
        })
    }
    if(timexxx >= 180000){
        timexxx = 0;
        world.querySelectorAll('player').forEach((entity) => {
            if(entity.hasTag('blue')){
                entity.removeTag('blue')
            }else if(entity.hasTag('red')){
                entity.removeTag('red')
            }
            entity.player.spectator = true;
            entity.player.invisible = true;
            entity.player.showName = false;
            entity.showHealthBar = false;
            entity.player.forceRespawn();
        });
        (async function(){
            red = []
            blue = []

            timexxx = 0;
            bluesafe = blue.length - redKILLblue
            if(bluesafe >= 1){
                huosheng = "逃生"
            }else{
                huosheng = "追捕"
            }
            world.say('本轮游戏已结束,下面进入中场休息,并广播各队战绩。下一轮游戏即将开始。')
            await sleep(5000)
            world.say('本轮游戏获胜队为:' + huosheng)
            await sleep(3000)
            world.say('本轮游戏中,追捕队捕获了 ' + redKILLblue + ' 人')
            await sleep(3000)
            world.say('一共有 ' + bluesafe + ' 人逃过了追捕队的追捕')
            await sleep(3000)
            world.say('另外,有 '+zixiangcansha+' 人被自己的同伴残忍杀害。这里温馨提醒:注意你身边的叛徒!')
            await sleep(5000)
            world.say('新一轮游戏即将开始!')
            await sleep(1000)
            world.say('4')
            await sleep(1000)
            world.say('3')
            await sleep(1000)
            world.say('2')
            await sleep(1000)
            world.say('1')
            await sleep(1000)
            world.say('0')


            world.querySelectorAll('player').forEach((entity) => {
                entity.player.spectator = false;
                entity.player.invisible = false;
                entity.player.showName = true;
                entity.player.forceRespawn();

                if(blue.length == red.length){
                    if(Math.random() < 0.5){
                        joinBlue(entity)
                    }else{
                        joinRed(entity)
                    }         
                }else if(blue.length > red.length){
                    joinRed(entity)
                }else{
                    joinBlue(entity)
                }



                
                entity.enableDamage = true;
                entity.showHealthBar = true;
                if (ADMIN_LIST.includes(entity.player.name)) {
                    entity.damage = 10;
                    entity.maxHp = 1024;
                    entity.hp = 1024;
                }else{
                    entity.hp = 喵;
                    entity.damage = 3;
                }
                entity.player.onPress(({ button, raycast: { hitEntity, direction } }) => {
                    if (button == 'action0' && hitEntity && entity.hp > 0) {
                        if (entity.position.distance(hitEntity.position) > 30) {
                            entity.player.directMessage('距离过远')
                        }else{
                            if(hitEntity.isPlayer){
                                hitEntity.velocity.x += direction.x;
                                hitEntity.velocity.y += 0.2;
                                hitEntity.velocity.z += direction.z;
                                hitEntity.hurt(entity.damage * Math.random() + entity.damage, {
                                    attacker: entity,
                                });
                            }
                        }
                        if(hitEntity.hp <= 0){
                            if(hitEntity.hasTag('blue')){
                                if(entity.hasTag('blue')){
                                    zixiangcansha += 1;
                                }
                                if(entity.hasTag('red')){
                                    redKILLblue += 1;
                                }
                            }else if(hitEntity.hasTag('red')){
                                if(entity.hasTag('red')){
                                    zixiangcansha += 1;
                                }
                            }
                        }
                    }
                });
            })        
        }())



    }
})



/*
function buddyFollow(entity, mesh, y) {
    const buddy = world.createEntity({
        mesh,
        position: entity.position,
        meshScale: [mscale, mscale, mscale],
        gravity: false, //不受重力影响
        fixed: false, //可推移
        collides: true, //可碰撞
        friction: 0, //无摩擦力
        mass: 0.01, //非常轻
    });

    const tgPos = entity.position;//僚机的目标位置
    const budPos = buddy.position;//僚机的当前位置
    const facing = entity.player.facingDirection;//玩家的朝向
    const ratio = 0.3;//追随的灵敏度, 最好设在0.5左右, 1.0表示立即移到玩家位置

    const dist = 2; //与玩家保持的距离
    const yOffset = y; //y轴位移, 保持僚机在头顶或脚下

    const ticker = world.onTick(() => {

        //要让小精灵跟在玩家背后, 需要计算xz轴的位移: 玩家朝向的反方向
        const xOffset = -facing.x * dist;
        const zOffset = -facing.z * dist;

        //当前位置与目标位置在xyz轴的差距
        const xDiff = tgPos.x - budPos.x;
        const yDiff = tgPos.y - budPos.y;
        const zDiff = tgPos.z - budPos.z;

        //计算xyz方向上 当前位置向目标位置靠拢的速度
        const 喵 = (xDiff + xOffset) * ratio;
        const vy = (yDiff + yOffset) * ratio;
        const vz = (zDiff + zOffset) * ratio;

        buddy.velocity.set(喵, vy, vz);//设置僚机速度

        if (buddy.velocity.sqrMag() > 0.005) {//速度要足够大, 才触发转向, 防止抖动
            buddy.meshOrientation = Quatx.rotateY(Math.atan2(zDiff, xDiff)); //让小精灵一直面向玩家
        }
    })

    return () => {
        ticker.cancel(); //关掉tick循环
        buddy.destroy(); //移除僚机实体
    }
}
world.onPlayerJoin(({ entity }) => {
    entity.setPet = buddyFollow(entity, 'mesh/皮卡丘.vb', -1) //给玩家增加宠物
})

world.onPlayerLeave(({ entity }) => {
    //玩家离开地图时, 切记一定要关掉tick循环以及销毁小精灵实体, 否则随着人数增加, 服务器积累到一定程度就会崩溃
    entity.setPet() //干掉宠物
})
*/



function textDialog(entity, content, title) {

    return entity.player.dialog({ //弹出对话框

        type: Box3DialogType.TEXT, //对话框类型为纯文本

        content, //文本内容

        title, //对话框左上角标题内容

    })

} 






//NPC是non-player character的简称, 表示游戏里无人控制的虚构人物

for (const npc of world.querySelectorAll('.NPC')) {

    npc.enableInteract = true //允许当前npc实体触发交互

    npc.interactRadius = 4.5 //交互范围

    npc.interactHint = npc.id //交互提示文本显示实体名字

    npc.interactColor.set(0, 1, 0) //交互提示文本颜色为绿色



    if (npc.id == '空气墙') { 

        npc.onInteract(async ({ entity }) => { //当玩家对这个npc按E触发交互, npc对玩家打招呼

            textDialog(entity, `${entity.player.name},想逃跑?想多了 `, npc.id)

        })

    }
    if (npc.id == '小寒') { 

        npc.onInteract(async ({ entity }) => { //当玩家对这个npc按E触发交互, npc对玩家打招呼

            textDialog(entity, `${entity.player.name},你想吃点什么呢 `, npc.id)

        })

    }
    
    if (npc.id == '导游') { 

        npc.onInteract(async ({ entity }) => { //当玩家对这个npc按E触发交互, npc对玩家打招呼

            textDialog(entity, `${entity.player.name},你好呀,欢迎来到梦想镇消防局`, npc.id)

        })

    }
    if (npc.id == '鸭子') { 

        npc.onInteract(async ({ entity }) => { //当玩家对这个npc按E触发交互, npc对玩家打招呼

            textDialog(entity, `${entity.player.name},你好呀,这里的生活可舒服了~`, npc.id)

        })

    }
    if (npc.id == '老人') { 

        npc.onInteract(async ({ entity }) => { //当玩家对这个npc按E触发交互, npc对玩家打招呼

            textDialog(entity, `${entity.player.name},你好呀,欢迎来到上田村`, npc.id)

        })

    }
    if (npc.id == '村民') { 

        npc.onInteract(async ({ entity }) => { //当玩家对这个npc按E触发交互, npc对玩家打招呼

            textDialog(entity, `${entity.player.name},今年肯定好收成啊`, npc.id)

        })

    }
    if (npc.id == '村民2') { 

        npc.onInteract(async ({ entity }) => { //当玩家对这个npc按E触发交互, npc对玩家打招呼

            textDialog(entity, `${entity.player.name},有空常来玩啊~`, npc.id)

        })

    }
    if (npc.id == '村民3') { 

        npc.onInteract(async ({ entity }) => { //当玩家对这个npc按E触发交互, npc对玩家打招呼

            textDialog(entity, `${entity.player.name},听说去城里的车开通了~以后进城快多了~~`, npc.id)

        })

    }
    if (npc.id == '路标式公交车站') { 

    npc.onInteract(async ({ entity }) => { //当玩家对这个npc按E触发交互, npc对玩家打招呼

        textDialog(entity, `${entity.player.name}上面写着711公交车站`, npc.id)

    })

    }
    if (npc.id == '喵') { 

    npc.onInteract(async ({ entity }) => { //当玩家对这个npc按E触发交互, npc对玩家打招呼

        textDialog(entity, `${entity.player.name}这里好好玩啊~`, npc.id)

    })

    }
    if (npc.id == '开关') { 

    npc.onInteract(async ({ entity }) => { //当玩家对这个npc按E触发交互, npc对玩家打招呼

        textDialog(entity, `${entity.player.name}欢迎来到梦想镇博物馆`, npc.id)

    })

    }
    if (npc.id == '警察') { 

    npc.onInteract(async ({ entity }) => { //当玩家对这个npc按E触发交互, npc对玩家打招呼

        textDialog(entity, `${entity.player.name}我劝你别进去啊`, npc.id)

    })

    }
    if (npc.id == '缆车管喵') { 

    npc.onInteract(async ({ entity }) => { //当玩家对这个npc按E触发交互, npc对玩家打招呼

        textDialog(entity, `${entity.player.name}游览途中别动哦~~~`, npc.id)

    })

    } 
    if (npc.id == '缆车站工作人员') { 

    npc.onInteract(async ({ entity }) => { //当玩家对这个npc按E触发交互, npc对玩家打招呼

        textDialog(entity, `${entity.player.name}上面是缆车站你可以去看看哦~~~踩着板就可以上去了哦~`, npc.id)

    })

    } 
    if (npc.id == '游客') { 

    npc.onInteract(async ({ entity }) => { //当玩家对这个npc按E触发交互, npc对玩家打招呼

        textDialog(entity, `${entity.player.name}, 你好呀,欢迎来到梦想镇步行街`, npc.id)

    })

    }
    if (npc.id == '锤头鲨勋章-1') { 

    npc.onInteract(async ({ entity }) => { //当玩家对这个npc按E触发交互, npc对玩家打招呼

        textDialog(entity, `${entity.player.name}, 锤头鲨勋章象征着追捕者大队`, npc.id)

    })

    }
    if (npc.id == '大熊猫勋章-1') { 

    npc.onInteract(async ({ entity }) => { //当玩家对这个npc按E触发交互, npc对玩家打招呼

        textDialog(entity, `${entity.player.name},大熊猫勋章象征着逃生者大队`, npc.id)

    })

    }
    if (npc.id == '长隆帅帅') { 

        npc.onInteract(async ({ entity }) => { //当玩家对这个npc按E触发交互, npc对玩家打招呼

            textDialog(entity, `${entity.player.name},你好呀`, npc.id)

        })

    }
    if (npc.id == '公示牌') { 

        npc.onInteract(async ({ entity }) => { //当玩家对这个npc按E触发交互, npc对玩家打招呼

            textDialog(entity, `${entity.player.name},管喵你好呀,公示牌:L霸屏输出防止骂人`, npc.id)

        })

    }
    if (npc.id == '李白') { 

    npc.onInteract(async ({ entity }) => { //当玩家对这个npc按E触发交互, npc对玩家打招呼

        textDialog(entity, `${entity.player.name},年轻人要和我一起写诗吗`, npc.id)

    })

    }
}











world.onPlayerJoin(({entity}) => {
    entity.player.spectator = true;
    entity.player.invisible = true;
    entity.enableDamage = false;
    entity.player.showName = false;


    entity.onDie(({entity}) => {
        entity.player.spectator = true;
        entity.player.invisible = true;
        entity.enableDamage = false;
        entity.player.showName = false;
        var dialog = entity.player.dialog({
            type:Box3DialogType.TEXT,
            title: "你被击杀",
            content: "你已经被击杀,请等待下一轮游戏开始。"
        })
    })
})






world.onVoxelContact(({entity,voxel})=>{
    if(!entity.isPlayer){
        return ;
    }
    if(voxel==voxels.id('S')){
        entity.player.spawnPoint.copy(entity.position)
        entity.player.directMessage('1号公共存档点,存档成功')
    }
    if(voxel==voxels.id('glass')){
        entity.player.forceRespawn()
    }
})

world.onVoxelContact(({entity,voxel})=>{
    if(!entity.isPlayer){
        return ;
    }
    if(voxel==voxels.id('A')){
        entity.player.spawnPoint.copy(entity.position)
        entity.player.directMessage('2号公共存档点,存档成功')
    }
    if(voxel==voxels.id('glass')){
        entity.player.forceRespawn()
    }
})



world.onVoxelContact(({entity,voxel})=>{
    if(!entity.isPlayer){
        return ;
    }
    if(voxel==voxels.id('B')){
    entity.player.spawnPoint.copy(entity.position)
    entity.player.directMessage('3号公共存档点,存档成功')
    }
    if(voxel==voxels.id('glass')){
    entity.player.forceRespawn()
    }
})

world.onVoxelContact(({entity,voxel})=>{
    if(!entity.isPlayer){
        return ;
    }
    if(voxel==voxels.id('C')){
    entity.player.spawnPoint.copy(entity.position)
    entity.player.directMessage('4号公共存档点,存档成功')
    }
    if(voxel==voxels.id('glass')){
    entity.player.forceRespawn()
    }
})
world.onVoxelContact(({entity,voxel})=>{
    if(!entity.isPlayer){
        return ;
    }
    if(voxel==voxels.id('L')){
    entity.player.spawnPoint.copy(entity.position)
    entity.player.directMessage('有人骂人!!!霸屏中----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------')
    }
    if(voxel==voxels.id('glass')){
    entity.player.forceRespawn()
    }
})






world.onVoxelContact(({ entity, voxel }) => {
    if (voxel == voxels.id('lab_material_13')) {
        if(!entity.isPlayer){
            return ;
        }
        entity.player.directMessage('公交系统提醒您请勿进去轨道哦~~~')
    }
})
world.onVoxelContact(({ entity, voxel }) => {
    if (voxel == voxels.id('conveyor')) {
        entity.player.spawnPoint.copy(entity.position)
        entity.player.directMessage('缆车行驶中勿动→→→→→')
    }
})



const elevator = world.querySelector('#电梯电梯') // 
elevator.collides = true // 电梯开启碰撞检测
elevator.fixed = true // 
world.onEntityContact(async ({entity, other})=>{  // 实时监测整个世界的实体碰撞事件。entity指被碰撞的实体, other则是主动撞过来的实体
    if(entity.id=='电梯电梯' && other.isPlayer){ // 如果 玩家踏上了电梯
        await sleep(1000)

        if(entity.position.y<14){ // 如果玩家y低于2楼地板, 则判定玩家在1楼

            entity.velocity.y = 0.4 // 电梯持续上移 

            world.say(other.player.name+' 坐电梯上楼')
            await sleep(5500)
            elevator.position.y = 46
            elevator.velocity.y = 0
            await sleep(5000)
            elevator.velocity.y = -0.4
            await sleep(5500)
            elevator.velocity.y = 0
            elevator.position.y = 11.1

        }
    }

})



console.clear()

function particleSpread(entity, colorList, scale = 1) {
    entity.particleRate = 550//粒子生成速率
    entity.particleLifetime = 2//粒子存活时间为2秒
    entity.particleColor = colorList//粒子的颜色列表
    entity.particleSize = [15 * scale, 10 * scale, 5 * scale, 2 * scale, scale]//粒子在5个阶段的大小
    entity.particleSizeSpread = 2 * scale//粒子的大小的随机变化幅度
    entity.particleVelocitySpread = [20 * scale, 20 * scale, 20 * scale]//粒子XYZ方向速度的随机变化幅度
    entity.particleAcceleration = [0, -10 * scale, 0]//粒子往下飘落模拟重力效果
}

const YELLOW = new Box3RGBColor(10, 10, 2)//黄
const CYAN = new Box3RGBColor(2, 10, 10)//青
const MAGENTA = new Box3RGBColor(10, 2, 10)//品红
const RED = new Box3RGBColor(10, 2, 2)//红
const GREEN = new Box3RGBColor(2, 10, 2)//绿
const BLUE = new Box3RGBColor(2, 2, 10)//蓝

//各个颜色5个粒子阶段的颜色列表
const ColorList = [
    [YELLOW, YELLOW, YELLOW, YELLOW, YELLOW],
    [CYAN, CYAN, CYAN, CYAN, CYAN],
    [MAGENTA, MAGENTA, MAGENTA, MAGENTA, MAGENTA],
    [RED, RED, RED, RED, RED],
    [GREEN, GREEN, GREEN, GREEN, GREEN],
    [BLUE, BLUE, BLUE, BLUE, BLUE],
]


function randomColor() {
    return ColorList[Math.floor(ColorList.length * Math.random())] //随机选取一个颜色列表
}

const MeshScale = [1 / 16, 1 / 16, 1 / 16] //默认的模型缩放系数
async function particleShoot(entity) {
    const fireball = world.createEntity({
        bounds: [0, 0, 0], // 隐形实体默认大小是1x1x1的方块, 现在把它从方块缩成大小为0x0x0的1个点
        collides: false, // 开启碰撞
        gravity: false, // 不受重力影响
        position: entity.position,
    })

    const color = randomColor()//随机颜色
    particleSpread(fireball, color, 0.3) //粒子大小系数缩到0.3, 形成小火球

    await sleep(100) // 等待0.1秒后升空
    fireball.velocity.set(0, 1, 0) // 火球速度为每秒向上1格

    await sleep(2000) //升空2秒后爆炸

    fireball.velocity.set(0, 0, 0) // 火球停止运动
    particleSpread(fireball, color, 1) // 系数增大到1, 让火球变大

    await sleep(1500) //大火球等待1.5秒后消失
    fireball.destroy()
}

const firework = world.querySelector('#新年烟花-1')
firework.enableInteract = true
firework.interactRadius = 3
firework.onInteract(async () => {
    var n = 3 //每次
    while (n-- > 0) {
        particleShoot(firework)//在"新年烟花-1"实体的位置发射烟花
        await sleep(2000)//每隔2秒射1发
    }
})
//苏打上面的是烟花









var tickM10 = 0;
world.onTick(()=>{
    tickM10 += 1;
    tickM10 = tickM10 % 10;
    if(!tickM10){
        world.querySelectorAll(".duck").forEach(async (e) => {
            e.collides = true;
            e.mass = 0.05;
            e.fixed = false;
            e.gravity = true;
            if(Math.floor(Math.random()*2)){
                if(Math.floor(Math.random()*2)){
                    e.velocity.x += 0.1;
                }else{
                    e.velocity.x -= 0.1;
                }
            }else{
                if(Math.floor(Math.random()*2)){
                    e.velocity.z += 0.1;
                }else{
                    e.velocity.z -= 0.1;
                }
            }
        })
    }
})
var tickM102 = 0;
world.onTick(()=>{
    tickM102 += 1;
    tickM102 = tickM102 % 3;
    if(!tickM102){
        world.querySelectorAll(".羊").forEach((e) => {
            e.collides = true;
            e.mass = 0.001;
            e.fixed = false;
            e.gravity = true;
            if(Math.floor(Math.random()*2)){
                if(Math.floor(Math.random()*2)){
                    e.velocity.x += 0.5;
                }else{
                    e.velocity.x -= 0.5;
                }
            }else{
                if(Math.floor(Math.random()*2)){
                    e.velocity.z += 0.5;
                }else{
                    e.velocity.z -= 0.5;
                }
            }
        })
    }
})




let csd0 = world.querySelector('#CSD-0');
csd0.enableInteract = true;
csd0.interactRadius = 2;
csd0.interactHint = '按下e传送'
csd0.onInteract(async ({entity}) => {
    entity.position = new Box3Vector3(153,20,32);
    entity.player.directMessage('已传送: script:telposition')
})
let csd1 = world.querySelector('#CSD-1');
csd1.enableInteract = true;
csd1.interactRadius = 2;
csd1.interactHint = '按下e传送'
csd1.onInteract(async ({entity}) => {
    entity.position = new Box3Vector3(118,20,161);
    entity.player.directMessage('已传送: script:telposition')
})





/*传送骂人者但是要一个管喵在监狱里面。。。。。苏打你自己改和看。。。。*/
world.onChat(({entity,message})=>{
    if(message[0] == '/'){
        if(!ADMIN_LIST.includes(entity.player.name)){return ;}
        let command = message.split(' ')
        console.log(command)
        console.log(command[0] == '/tp')
        console.log(command[2] == 'jy')
        if(command[0] == '/tp'){
            if(command[2] == 'jy'){
                world.querySelectorAll('player').forEach(async (e) => {
                    if(e.player.name == command[1]){
                        console.log('1')
                        e.player.spawnPoint.copy(new Box3Vector3(75,12,102))
                        e.player.forceRespawn()
                    }
                })
            }
            
        }
        
    }
})








//注意, 飞机的模型需要在模型编辑器里将它旋转到机头指向X轴的正方向
async function loop(entity, fn) {
    while (!entity.destroyed) { //不断循环直到实体不在场景里
        fn()
        await sleep(60) //每60毫秒执行一次fn, 相当于一秒内能执行16.666次
    }
}
const Quat = new Box3Quaternion(0, 0, 0, 1) //默认的旋转状态
function flyAround(plane) {
    plane.gravity = false //取消重力对飞机的影响
    let speed = 0.1 //飞机的前进速度
    let rotation = 0 //飞机的旋转弧度
    let rotSpeed = 0.1 //飞机当前的旋转速度
    loop(plane, () => {
        const sdx = Math.cos(rotation) * speed //用余弦计算x轴上的速度
        const vz = Math.sin(rotation) * speed //用正弦计算z轴上的速度
        plane.velocity.set(sdx, 0, vz) //更新飞机当前的速度
        plane.meshOrientation = Quat.rotateY(rotation) //按当前旋转弧度更新飞机的朝向
        if (rotation > Math.PI || rotation < -Math.PI) {//当飞机旋转到达完全相反的方向(180度)
            rotSpeed *= -1 //飞机改变旋转方向
        }
        rotation += rotSpeed //更新飞机的旋转弧度
    })
}
const plane = world.querySelector('#玩吧') //获取场景中的飞机实体
flyAround(plane) //让飞机动起来


world.onPlayerJoin(({ entity }) => {
    let dialog = entity.player.dialog({
        type: Box3DialogType.TEXT,
        title: "简介",    // 对话框标题。通常对应是讲话人的名字。//上面
        titleTextColor: new Box3RGBAColor(0, 0, 0, 1), // 标题字体颜色。
        titleBackgroundColor: new Box3RGBAColor(0.968, 0.702, 0.392, 1), // 标题背景颜色。
        content: `你好,${entity.player.name},欢迎来到本游戏!\n每30秒你将随机获得择技能,如跳高,隐身,疾跑等等等等,\n玩法简介:如果你属于逃生组,你的目标是:5分钟内内逃生闭免被追捕杀喵;\n如果你属于追捕组,你的目标是:追捕尽可能抓获更多逃生者,最终为自己的队伍取得胜利。\nEnjoy yourself!`, // 对话框内容。也就是对话正在讲什么。
        contentTextColor: new Box3RGBAColor(0, 0, 0, 1),  // 对话框字体颜色。
        contentBackgroundColor: new Box3RGBAColor(1, 1, 1, 1), // 对话框背景颜色。
    });
});




const elevatorx = world.querySelector('#上层镂空式公交车') 
elevatorx.fixed = true //不可推移
elevatorx.collides = true //可碰撞
const pos = elevatorx.position//

const ani = elevatorx.animate([// 1+5+1+2=9, 总时间被切成9份
    { position: pos, duration: 5 },// 1/9 的时间停留在地面
    { position: pos.add({ x: 100, y: 0, z: 0 }), duration: 5 },// 1/9 的时间停留在楼顶
    { position: pos.add({x:100,y:0,z:0}), duration: 5 },
    { position: pos, duration: 5 },// 2/9 的时间从楼顶回到地面
], {
    duration: 16 * 20, //播放一个循环共用时9秒(系统默认每秒16帧)
    iterations:  Infinity,//动画只播放1次
    direction: Box3AnimationDirection.WRAP,//让动画实体从终点回到起点
})

ani.play({
    duration: 16 * 20, //播放一个循环共用时9秒
    iterations: Infinity,//动画无限次循环播放
    direction: Box3AnimationDirection.WRAP,//让动画实体从终点回到起点
});







 


回复

上一页1 页 / 共 0下一页