猫史档案馆


求助(代码哪里错了)

用户:和平相处666和平相处666查看:0 回复:1 评论:0 创建时间:2022-01-29T12:25:36


//敢毁图我让他见不到明天的太阳!!!!!!!!!! const meshScale=1/5 console.clear()   const MeshScale = [1 / 16, 1 / 16, 1 / 16] //正常的模型缩放比例 const Quat = new Box3Quaternion(0, 0, 0, 1) //默认的旋转状态

 

world.onPress(async ({ entity, button }) => {          if (button === Box3ButtonType.ACTION0 ) {         if(entity.wuqivb!=''){         const d = entity.player.facingDirection //玩家的朝向         const 喵 = world.createEntity({             mesh:entity.wuqivb,             meshScale: MeshScale,             collides: true, // 开启碰撞             gravity: false, // 不受重力影响             position: entity.position, // 在玩家的位置生成飞刀             velocity: d.scale(2), // 飞刀的初速度是玩家朝向向量的2倍             meshOrientation: Quat.rotateY(Math.atan2(d.z, d.x)), // 刀头指向玩家的朝向         })         喵.id = entity.player.userKey //将小刀的id设置成玩家userKey, 便于碰撞过滤器识别         喵.onEntityContact(async({ other }) => {//每当飞刀碰到另一个实体                  other.hurt(entity.shanghai)//被碰实体受10点伤害                 entity.jing+=entity.shanghai                 if(entity.jing>=entity.yu*50){                     entity.jing-=entity.yu*50                     entity.yu+=1                     entity.lv+=1                     entity.maxHp+=10                     entity.hp+=10                 }         })         await sleep(2000)//等2秒后        喵.destroy()}//清除飞刀, 防止飞刀数量太多超过服务器负载     }else if(button === Box3ButtonType.ACTION1 ){     entity.xu=entity.yu*50-entity.jing     const xuanze = await entity.player.dialog({         type: Box3DialogType.SELECT,         title: "选项",         titleTextColor: new Box3RGBAColor(0, 0, 0, 1),         titleBackgroundColor: new Box3RGBAColor(0.968, 0.702, 0.392, 1),         content: `名称:${entity.player.name}         金币:${entity.qian}         血量:${entity.hp}/${entity.maxHp}         等级:${entity.lv},升级还需${entity.xu}经验值`,         options:  ['背包', '脱离卡点','装备栏','保存'],   // 将提供玩家选择的选项放入数组里。         contentTextColor:  new Box3RGBAColor(0, 0, 0, 1),         contentBackgroundColor: new Box3RGBAColor(1, 1, 1, 0.3),         lookTarget: entity,     });

 

    // 如果玩家点击了屏幕其他区域,取消了对话框。     if(!xuanze || xuanze === null){          entity.la=''         entity.player.directMessage('');         return;      }

 

    // 判断玩家选了什么选项。     switch (xuanze.index) {         case 1:             entity.hurt(喵000000000)             break         case 0:             const beibaoxuanze = await entity.player.dialog({         type: Box3DialogType.SELECT,         title: "背包",         titleTextColor: new Box3RGBAColor(0, 0, 0, 1),         titleBackgroundColor: new Box3RGBAColor(0.968, 0.702, 0.392, 1),         content: ``,         options: entity.beibao,   // 将提供玩家选择的选项放入数组里。         contentTextColor:  new Box3RGBAColor(0, 0, 0, 1),         contentBackgroundColor: new Box3RGBAColor(1, 1, 1, 0.5),         lookTarget: entity,     });

 

    // 如果玩家点击了屏幕其他区域,取消了对话框。     if(!beibaoxuanze || beibaoxuanze === null){          entity.player.directMessage('');         return;      }     let abc=['1','2','3','4','5','6','7','8','9','0']     entity.lb=eval(beibaoxuanze.value[beibaoxuanze.value.length-3]+beibaoxuanze.value[beibaoxuanze.value.length-2]+beibaoxuanze.value[beibaoxuanze.value.length-1])     if(beibaoxuanze.value[1]in abc){        entity.la=beibaoxuanze.value[0]     }else if(beibaoxuanze.value[2]in abc){         entity.la=beibaoxuanze.value[0]+beibaoxuanze.value[1]     }else if(beibaoxuanze.value[3]in abc){         entity.la=beibaoxuanze.value[0]+beibaoxuanze.value[1]+beibaoxuanze.value[2]     }else if(beibaoxuanze.value[4]in abc){         entity.la=beibaoxuanze.value[0]+beibaoxuanze.value[1]+beibaoxuanze.value[2]+beibaoxuanze.value[3]     }     entity.beibaoa=[]     for(const e of entity.beibao){         let abc=['1','2','3','4','5','6','7','8','9','0']         if(e[1]in abc){        entity.a=e[0]     }else if(e[2]in abc){         entity.a=e[0]+e[1]     }else if(e[3]in abc){         entity.a=e[0]+e[1]+e[2]     }else if(e[4]in abc){         entity.a=e[0]+e[1]+e[2]+e[3]     }         if (entity.a==='铁'){                          entity.beibaoa.push('铁')         }else if (entity.a==='喵'){                          entity.beibaoa.push('喵')         }     }     if(entity.la==='喵'){     if(entity.wuqi!=''){         entity.beibao.push(entity.wuqi)     }                entity.beibao=entity.beibao.splice(entity.beibaoa.indexOf('喵')+1)                entity.wuqivb='mesh/喵.vb'        entity.wuqi=beibaoxuanze.value        entity.shanghai=entity.lb     }else if(entity.la==='强化喵'){         if(entity.wuqi!=''){         entity.beibao.push(entity.wuqi)     }console.log(entity.beibao)        entity.beibao= entity.beibao.splice(entity.beibaoa.indexOf('强化喵')+1)        entity.wuqivb='mesh/进化喵.vb'        entity.wuqi=beibaoxuanze.value        entity.shanghai=entity.lb     }     // 判断玩家选了什么选项。     }



         } })

 

world.onPlayerJoin(({ entity }) => { //当玩家进入地图时     if(entity.player.name==='搬砖喵'||entity.player.name==='吉吉喵'||entity.player.name==='借鉴喵'){         entity.addTag('ghost') //本喵不受攻击     }     entity.enableDamage = true //允许这个玩家受伤     entity.wuqi=''     entity.wuqivb=''     entity.toukui=''     entity.qian=100     entity.jiao=''     entity.bei=''     entity.lv=0     entity.jing=0     entity.yu=1     entity.collides=false     entity.id = entity.player.userKey//把userKey作为玩家的id     if(Math.random()>=0.5){        entity.beibao=['铁000','铁000','铁000','铁000','铁000','铁000','铁000','铁000','铁000']     }else{         entity.beibao=['铁000','铁000','铁000','铁000','铁000','铁000','铁000','铁000','铁000']     }     world.addCollisionFilter('#' + entity.id, '#' + entity.id)//让id跟玩家id一样的实体不会相互碰撞, 比如玩家的飞刀不会碰到玩家, 自己的飞刀之间也不会碰撞 }) world.addCollisionFilter('.ghost', '*')

 

world.onPlayerLeave(({ entity }) => { //当玩家离开地图时     world.removeCollisionFilter('#' + entity.id, '#' + entity.id)//取消这个玩家的碰撞过滤器 }) world.onDie(async({ entity, attacker }) => {        const meshScale = 1/16 //默认模型方块大小倍数为地图方块的1/16             world.createEntity({         mesh:'mesh/大铁片.vb',/*mesh样子,但是在这边没啥用,填实体在文件中的位置就行*/         id:entity.player.boxId,/*id名称,设置为玩家的boxId*/         position:[entity.position.x,entity.position.y+1,entity.position.z],/*position位置,设置为玩家所在的位置*/         enableInteract:true,/*enableInteract互动,设置为开启(true)*/         interactRadius:5,/*interactRadius互动范围,设置为5格*/         meshScale:[meshScale,meshScale,meshScale],//xyz放大倍数      })     world.querySelectorAll('#'+entity.player.boxId).forEach(async(b)=>{         b.addTag('玩家背包')//添加喵g:玩家背包         b.ps=entity//把他的主人设置为玩家         b.meshInvisible=false;//开启隐形         b.collides=false//关闭物理         b.gravity=false//关闭物理         b.id='dbfdgh'         b.onInteract(async({entity:user,targetEntity})=>{            if(user.id!=b.id){            user.beibao.push('铁000')            b.destroy()            }     })})         for (let t = 1; t <= 5; t++) {         entity.player.directMessage(`倒计时 ${String(5 - t)} 秒后复活`);         await sleep(1000);     }

 

    entity.player.forceRespawn();  // 让玩家重生 }) const ji = world.querySelector('#机器人'); ji.enableInteract = true ; // 开启实体互动功能 ji.interactHint = '合成机器人';    // 进入互动范围时提示的文字 ji.interactRadius = 4;     // 互动范围大小

 

// 场景中所有可以互动的实体,互动时都会触发此事件 ji.onInteract(async ({entity, targetEntity}) => {      entity.beibaoa=[]         entity.tie=0     entity.qiang=0     entity.ke=[]     entity.hao=[]     for(const e of entity.beibao){

 

        let abc=['1','2','3','4','5','6','7','8','9','0']         if(e[1]in abc){        entity.a=e[0]     }else if(e[2]in abc){         entity.a=e[0]+e[1]     }else if(e[3]in abc){         entity.a=e[0]+e[1]+e[2]     }else if(e[4]in abc){         entity.a=e[0]+e[1]+e[2]+e[3]     }         if (entity.a==='铁'){             entity.tie++             entity.beibaoa.push('铁')         }else if (entity.a==='喵'){             entity.qiang+=1             entity.beibaoa.push('喵')         }     }     if(entity.qiang>=1&&entity.tie>=5){         entity.ke.push('强化喵')     }      if(entity.tie>=3){         entity.ke.push('喵')     }     const hecheng = await entity.player.dialog({         type: Box3DialogType.SELECT,         title: "选项",         titleTextColor: new Box3RGBAColor(0, 0, 0, 1),         titleBackgroundColor: new Box3RGBAColor(0.968, 0.702, 0.392, 1),         content: `可合成`,         options:  entity.ke,   // 将提供玩家选择的选项放入数组里。         contentTextColor:  new Box3RGBAColor(0, 0, 0, 1),         contentBackgroundColor: new Box3RGBAColor(0, 0, 0, 0.3),         lookTarget: entity,     });

 

    // 如果玩家点击了屏幕其他区域,取消了对话框。     if(!hecheng || hecheng === null){          entity.player.directMessage('');         return;      }     switch(hecheng.value){         case'强化喵':             entity.hao=['铁','铁','铁','铁','铁','喵']             for(const i of entity.hao){                 console.log(i)                 console.log(entity.beibaoa.indexOf(i))                   entity.beibao= entity.beibao.splice(0,entity.beibaoa.indexOf(i))+[',']+entity.beibao.splice(entity.beibaoa.indexOf(i),entity.beibao.length)                  entity.beibaoa=  entity.beibaoa.remove(i)                  console.log(entity.beibaoa+'sfg')                 console.log(entity.beibao)             }                  let b =Math.random()                  console.log(entity.beibaoa+'sfg')                 console.log(entity.beibao)                  if(b<=0.333){                      entity.beibao.push('强化喵006')                      entity.beibaoa.push('强化喵')                  }else if(b<=0.667){                      entity.beibao.push('强化喵007')                      entity.beibaoa.push('强化喵')                  }else {                      entity.beibao.push('强化喵008')                      entity.beibaoa.push('强化喵')                  }                  console.log(entity.beibaoa+'sdf')                 console.log(entity.beibao)                      break            case'喵':         entity.hao=['铁','铁','铁']                      for(const i of entity.hao){                                                                    entity.beibao= entity.beibao.splice(entity.beibaoa.indexOf(i)+1)                  entity.beibaoa= entity.beibaoa.splice(entity.beibaoa.indexOf(i)+1)

 

                 }                  let h =Math.random()                  if(h<=0.5){                                             entity.beibao.push('喵004')                                         }else {                      entity.beibao.push('喵005')                                       }                      break      }

 

}); center_image


回复

上一页1 页 / 共 1下一页
我是axt我是axt

center_image

点赞0


评论