用户:
亨利佐Yahoo查看:0 回复:1 评论:0 创建时间:2022-01-27T20:43:42
火箭急需燃料,你务必去大楼的顶端找到燃料,前提是得冲过两层的考验,作为拯救火箭的人,你有信心吗? 第一关穿越迷宫 第二关令人跑酷 第三关寻找核能源找到全部核能源,可以让火箭重新起飞加油吧! 拥有者、建筑天我 代码亨利佐Yahoo! 主题:#受苦才能过关 创作页:神奇代码岛:喵任务(codemao.cn) 创作者信息: 亨利佐Yahoo!主页:神奇代码岛(codemao.cn),曾发布过《鱿鱼游戏场景还原》、《跑酷(制作中)》等。BoxID:henglizuodandan --------------------------------------------------------我是分割线---------------------------------------------------------- 天我主页:神奇代码岛(codemao.cn),曾发布过《新春快乐/年兽作战》、《分层跑酷》等。BoxID:0HoGx喵zkJrRpjj 以上是本图介绍imgsrc="http://img.t喵t4/appstyle/expression/ext/normal/0b/tootha_thumb.gif"alt="emotion_嘻嘻" 希望能进入创作节,领取皮肤! THANKS
亨利佐Yahoo这里是代码公布:
var jvbaoxiang=['举报箱内容如下:']
var jvbaoxiangshu=0;
const elevator = world.querySelector('#电梯-1') //获取电梯板实体
elevator.fixed = true//不受外力影响
elevator.collides = true//允许碰撞
const startPos = [81.31, 9.03, 9.36]//电梯的最低位置
const endPos = [81.31, 22.59, 9.36]//电梯的最高位置
const ani = elevator.animate([// 1+5+1+2=9, 总时间15秒被切成9份
{ position: startPos, duration: 1 },// 1/9 的时间停留在地面
{ position: startPos, duration: 5 },// 5/9 的时间用于地面往楼顶移动
{ position: endPos, duration: 1 },// 1/9 的时间停留在楼顶
{ position: endPos, duration: 2 },// 2/9 的时间从楼顶回到地面
], {
duration: 16 * 15, //播放一个循环共用时15秒,
iterations: 1,//动画只播放1次
direction: Box3AnimationDirection.WRAP,//让动画实体从终点回到起点
})
ani.onReady(() => {//当动画开始播放时
world.say('电梯准备启动')
})
ani.onFinish(() => {//当动画结束播放时
world.say('电梯自己停了')
})
world.onPress(({ button,entity }) => {
if(entity.diyiguo==true)
if (button === Box3ButtonType.ACTION0) {
//左键重新播放动画
ani.play({
duration: 16 * 15, //播放一个循环共用时15秒(每秒16帧),
iterations: 1,//动画无限次循环播放
direction: Box3AnimationDirection.WRAP,//让动画实体从终点回到起点
})
}
})
world.onPlayerJoin(({ entity })=> {
entity.diyiguo=false
entity.dierguo=false
})
var jiangbei=world.querySelector('#奖杯-1')
jiangbei.enableInteract = true
jiangbei.interactRadius = 1
jiangbei.onInteract(({ entity }) => {
entity.player.directMessage('恭喜您过关第一关')
world.say('恭喜'+entity.player.name+'过关第一关')
entity.diyiguo=true
})
var jiangbei2=world.querySelector('#罐子-1')
jiangbei2.enableInteract = true
jiangbei2.interactRadius = 1
jiangbei2.onInteract(({ entity }) => {
entity.player.canFly=true
entity.player.directMessage('恭喜您过关第三关,现在,飞出这里!')
world.say('恭喜'+entity.player.name+'过关!')
entity.dierguo=true
})
var jiangbei3=world.querySelector('#火箭一一长征五号-3')
jiangbei3.enableInteract = true
jiangbei3.interactRadius = 50
jiangbei3.onInteract(({ entity }) => {
if(entity.diyiguo==true&&entity.dierguo==true){world.say('恭喜'+entity.player.name+'成功发射火箭!');}
})
const TEXT_PlAYER=['天我','亨利佐Yahoo!','吉吉喵']
world.onPlayerJoin(({ entity })=>{
if( !TEXT_PlAYER.includes( entity.player.name))
{
}
})
world.onPress(async({ button, entity })=>{
if(button=='action0')
{
const result2 = await entity.player.dialog({
type:Box3DialogType.SELECT,
title:"控制面板",
content:`尊敬的玩家`+entity.player.name+`请选择命令:`,
options:['切换第一人称','切换第三人称','我要举报']
});
if(!result2 || result2 === null){return;}
switch(result2.index)
{
case 0:
entity.player.cameraMode = Box3CameraMode.FPS;
break;
case 1:
entity.player.cameraMode = Box3CameraMode.FOLLOW;
break;
case 2:{
const result3 = await entity.player.dialog({
type: Box3DialogType.INPUT,
title: "举报系统",
titleTextColor: new Box3RGBAColor(1, 1, 1, 1),
titleBackgroundColor: new Box3RGBAColor(0, 0, 0, 0.98),
content: `${entity.player.name},`,
confirmText: '确定', // 确定按钮上面的文字。按下确定按钮后,提交回答。
placeholder: '举报内容。', // 输入框背景上的提示文字。
});
// 如果玩家点击了屏幕其他区域,取消了对话框。
if(!result3 || result3 === null){
entity.player.directMessage('你似乎无视了举报系统。');
return;
}
entity.player.directMessage(`你回答了: ${result3}` );
jvbaoxiangshu++
jvbaoxiang[jvbaoxiangshu]=result3
}
}
}
})
world.onPress(async ({ button, entity }) => {
if (button == 'action1') {
if (TEXT_PlAYER.includes(entity.player.name)) {
const result = await entity.player.dialog({
type: Box3DialogType.SELECT,
title: "命令系统",
content: `尊敬的作者,请选择您的命令。`,
options: ['开启飞行模式', '关闭飞行模式', '开启跳跃增强', '关闭跳跃增强', '开启速度加成', '关闭速度加成', '开启幽灵模式', '关闭幽灵模式', "开启隐形", "关闭隐形", '隐藏名字', '显示名字', '查看举报箱'] // 将提供玩家选择的选项放入数组里。
});
// 如果玩家点击了屏幕其他区域,取消了对话框。
if (!result || result === null) {
return;
}
// 判断玩家选了什么选项。
switch (result.index) {
case 0:
entity.player.canFly = true;
break;
case 1:
entity.player.canFly = false;
break;
case 2:
entity.player.jumpPower = 2;
entity.player.doubleJumpPower = 2;
break;
case 3:
entity.player.jumpPower = 0.96;
entity.player.doubleJumpPower = 0.9;
break;
case 4:
entity.player.walkSpeed = 10;
entity.player.runSpeed = 20;
entity.player.flySpeed = 30;
break;
case 5:
entity.player.walkSpeed = 0.22;
entity.player.runSpeed = 0.4;
entity.player.flySpeed = 30;
break;
case 6:
entity.player.spectator = true;
break;
case 7:
entity.player.spectator = false
break;
case 8:
entity.player.invisible = true;
break;
case 9:
entity.player.invisible = false;
break;
case 10:
entity.player.showName = false;
break;
case 11:
entity.player.showName = true;
break;
case 12:
{
for(const i of jvbaoxiang)
{
var jvbaoxiang2=[]
jvbaoxiang2.push(i)
}
const result = 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},请查看举报箱。`,
options: jvbaoxiang2, // 将提供玩家选择的选项放入数组里。
});
// 如果玩家点击了屏幕其他区域,取消了对话框。
if(!result || result === null){
entity.player.directMessage('您退出了举报箱');
return;
}
// 判断玩家选了什么选项。
}
default:
}}}}
);
world.ambientSound.sample = 'audio/Da Fault (Inspired by FORTNITE) - 8 Bit Universe.mp3';
const mscale = 1 / 16
const Quat = new Box3Quaternion(0, 0, 0, 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 = Quat.rotateY(Math.atan2(zDiff, xDiff)) //让小精灵一直面向玩家
}
})
return () => {
ticker.cancel() //关掉tick循环
buddy.destroy() //移除僚机实体
}
}
world.onPlayerJoin(({ entity }) => {
entity.setPet = buddyFollow(entity, 'mesh/皮卡丘.vb', -5) //给玩家增加宠物
})
world.onPlayerLeave(({ entity }) => {
//玩家离开地图时, 切记一定要关掉tick循环以及销毁小精灵实体, 否则随着人数增加, 服务器积累到一定程度就会崩溃
entity.setPet() //干掉宠物
})点赞0
评论