1 line
30 KiB
JavaScript
1 line
30 KiB
JavaScript
function events(){this.init()}events.prototype.init=function(){this.eventdata=functions_d6ad677b_427a_4623_b50f_a445a3b0ef8a.events;this.events={battle:function(c,b,a){b.battle(c.event.id,c.x,c.y);if(b.isset(a)){a()}},getItem:function(c,b,a){b.getItem(c.event.id,1,c.x,c.y);if(b.isset(a)){a()}},openDoor:function(c,b,a){b.openDoor(c.event.id,c.x,c.y,true,function(){if(b.isset(a)){a()}b.replay()})},changeFloor:function(c,b,a){var d={};if(b.isset(c.event.data.loc)){d={x:c.event.data.loc[0],y:c.event.data.loc[1]}}if(b.isset(c.event.data.direction)){d.direction=c.event.data.direction}b.changeFloor(c.event.data.floorId,c.event.data.stair,d,c.event.data.time,function(){if(b.isset(a)){a()}b.replay()})},passNet:function(c,b,a){b.events.passNet(c);if(b.isset(a)){a()}},changeLight:function(c,b,a){b.events.changeLight(c.x,c.y);if(b.isset(a)){a()}},ski:function(c,b,a){b.events.ski();if(b.isset(a)){a()}},pushBox:function(c,b,a){b.events.pushBox(c);if(b.isset(a)){a()}},action:function(c,b,a){b.events.insertAction(c.event.data,c.x,c.y,a)}}};events.prototype.getEvents=function(a){if(!core.isset(a)){return this.events}return this.events[a]};events.prototype.initGame=function(){return this.eventdata.initGame()};events.prototype.startGame=function(a){if(core.status.isStarting){return}core.status.isStarting=true;core.hideStartAnimate(function(){core.drawText(core.clone(core.firstData.startText),function(){if(core.flags.showBattleAnimateConfirm){core.status.event.selection=core.flags.battleAnimate?0:1;core.ui.drawConfirmBox("你想开启战斗动画吗?\n之后可以在菜单栏中开启或关闭。\n(强烈建议新手开启此项)",function(){core.flags.battleAnimate=true;core.setLocalStorage("battleAnimate",true);core.startGame(a);core.utils.__init_seed();core.events.setInitData(a)},function(){core.flags.battleAnimate=false;core.setLocalStorage("battleAnimate",false);core.startGame(a);core.utils.__init_seed();core.events.setInitData(a)})}else{core.startGame(a);core.utils.__init_seed();core.events.setInitData(a)}})})};events.prototype.setInitData=function(a){return this.eventdata.setInitData(a)};events.prototype.win=function(a){return this.eventdata.win(a)};events.prototype.lose=function(a){return this.eventdata.lose(a)};events.prototype.gameOver=function(c,d){core.clearMap("animate",0,0,416,416);core.dom.gif2.innerHTML="";core.clearMap("weather",0,0,416,416);core.animateFrame.weather.type=null;core.animateFrame.weather.level=0;core.animateFrame.weather.nodes=[];core.setFg(null,0);core.ui.closePanel();var a=function(){core.ui.closePanel();core.ui.drawConfirmBox("你想下载录像吗?",function(){var e={name:core.firstData.name,version:core.firstData.version,hard:core.status.hard,seed:core.getFlag("seed"),route:core.encodeRoute(core.status.route)};core.download(core.firstData.name+"_"+core.formatDate2(new Date())+".h5route",JSON.stringify(e));core.restart()},function(){core.restart()})};var b=function(){core.ui.closePanel();if(!core.isset(c)){a();return}var e=function(h){var g=core.status.hero.hp;if(h==undefined){g=1}var f=new FormData();f.append("type","score");f.append("name",core.firstData.name);f.append("version",core.firstData.version);f.append("platform",core.platform.isPC?"PC":core.platform.isAndroid?"Android":core.platform.isIOS?"iOS":"");f.append("hard",core.status.hard);f.append("username",h||"");f.append("ending",c);f.append("lv",core.status.hero.lv);f.append("hp",Math.min(g,Math.pow(2,63)));f.append("atk",core.status.hero.atk);f.append("def",core.status.hero.def);f.append("mdef",core.status.hero.mdef);f.append("money",core.status.hero.money);f.append("experience",core.status.hero.experience);f.append("steps",core.status.hero.steps);f.append("seed",core.getFlag("seed"));f.append("totalTime",Math.floor(core.status.hero.statistics.totalTime/1000));f.append("route",core.encodeRoute(core.status.route));if(main.isCompetition){core.http("POST","/games/competition/upload.php",f)}else{core.http("POST","/games/upload.php",f)}setTimeout(function(){a()},150)};core.ui.drawConfirmBox("你想记录你的ID和成绩吗?",function(){if(main.isCompetition){e("")}else{e(prompt("请输入你的ID:"))}},function(){if(main.isCompetition){a()}else{e(undefined)}});return};if(d){core.drawText("录像回放完毕!",function(){core.restart()})}else{if(core.isset(core.values.maxValidHp)&&core.status.hero.hp>core.values.maxValidHp){core.drawText("作弊可耻!",function(){core.restart()})}else{if(core.hasFlag("debug")){core.drawText("\t[系统提示]调试模式下无法上传成绩",function(){core.restart()})}else{b()}}}};events.prototype.afterChangeFloor=function(a){if(main.mode!="play"){return}return this.eventdata.afterChangeFloor(a)};events.prototype.doEvents=function(b,c,d,a){if(!core.isset(b)){return}if(!(b instanceof Array)){b=[b]}core.waitHeroToStop(function(){core.lockControl();core.status.event={id:"action",data:{list:[{todo:core.clone(b),total:core.clone(b),condition:"false"}],x:c,y:d,callback:a}};core.events.doAction()})};events.prototype.doAction=function(){core.status.boxAnimateObjs=[];clearInterval(core.status.event.interval);core.clearMap("ui",0,0,416,416);core.setAlpha("ui",1);if(core.status.event.data.list.length==0){var callback=core.status.event.data.callback;core.ui.closePanel();if(core.isset(callback)){callback()}core.replay();return}var current=core.status.event.data.list[0];if(current.todo.length==0){if(core.calValue(current.condition)){current.todo=core.clone(current.total)}else{core.status.event.data.list.shift()}this.doAction();return}var data=current.todo.shift();core.status.event.data.current=data;var x=core.status.event.data.x,y=core.status.event.data.y;if(typeof data=="string"){core.status.event.data.type="text";if(core.status.replay.replaying){core.events.doAction()}else{core.ui.drawTextBox(data)}return}core.status.event.data.type=data.type;switch(data.type){case"text":if(core.status.replay.replaying){core.events.doAction()}else{core.ui.drawTextBox(data.text)}break;case"autoText":if(core.status.replay.replaying){core.events.doAction()}else{core.ui.drawTextBox(data.text);setTimeout(function(){core.events.doAction()},data.time||3000)}break;case"setText":if(data.position=="up"||data.position=="down"||data.position=="center"){core.status.textAttribute.position=data.position}["background","title","text"].forEach(function(t){if(core.isset(data[t])&&(data[t] instanceof Array)&&data[t].length>=3){if(data[t].length==3){data[t].push(1)}core.status.textAttribute[t]=data[t]}});if(core.isset(data.bold)){core.status.textAttribute.bold=data.bold}if(core.isset(data.time)){core.status.textAttribute.time=data.time}core.events.doAction();break;case"tip":core.drawTip(core.replaceText(data.text));core.events.doAction();break;case"show":if(!core.isset(data.loc)){data.loc=[x,y]}if((typeof data.loc[0]=="number"||typeof data.loc[0]=="string")&&(typeof data.loc[1]=="number"||typeof data.loc[1]=="string")){data.loc=[[core.calValue(data.loc[0]),core.calValue(data.loc[1])]]}if(core.isset(data.time)&&data.time>0&&(!core.isset(data.floorId)||data.floorId==core.status.floorId)){core.animateBlock(data.loc,"show",data.time,function(){data.loc.forEach(function(t){core.showBlock(t[0],t[1],data.floorId)});core.events.doAction()})}else{data.loc.forEach(function(t){core.showBlock(t[0],t[1],data.floorId)});this.doAction()}break;case"hide":if(!core.isset(data.loc)){data.loc=[x,y]}if((typeof data.loc[0]=="number"||typeof data.loc[0]=="string")&&(typeof data.loc[1]=="number"||typeof data.loc[1]=="string")){data.loc=[[core.calValue(data.loc[0]),core.calValue(data.loc[1])]]}data.loc.forEach(function(t){core.removeBlock(t[0],t[1],data.floorId)});if(core.isset(data.time)&&data.time>0&&(!core.isset(data.floorId)||data.floorId==core.status.floorId)){core.animateBlock(data.loc,"hide",data.time,function(){core.events.doAction()})}else{this.doAction()}break;case"setBlock":if(core.isset(data.loc)){x=core.calValue(data.loc[0]);y=core.calValue(data.loc[1])}core.setBlock(data.number,x,y,data.floorId);this.doAction();break;case"animate":if(core.isset(data.loc)){if(data.loc=="hero"){x=core.getHeroLoc("x");y=core.getHeroLoc("y")}else{if(data.loc instanceof Array){x=core.calValue(data.loc[0]);y=core.calValue(data.loc[1])}}}core.drawAnimate(data.name,x,y,function(){core.events.doAction()});break;case"move":if(core.isset(data.loc)){x=core.calValue(data.loc[0]);y=core.calValue(data.loc[1])}core.moveBlock(x,y,data.steps,data.time,data.immediateHide,function(){core.events.doAction()});break;case"moveHero":core.eventMoveHero(data.steps,data.time,function(){core.events.doAction()});break;case"changeFloor":var heroLoc={x:core.calValue(data.loc[0]),y:core.calValue(data.loc[1])};if(core.isset(data.direction)){heroLoc.direction=data.direction}core.changeFloor(data.floorId||core.status.floorId,null,heroLoc,data.time,function(){core.lockControl();core.events.doAction()});break;case"changePos":core.clearMap("hero",0,0,416,416);if(core.isset(data.loc)){core.setHeroLoc("x",core.calValue(data.loc[0]));core.setHeroLoc("y",core.calValue(data.loc[1]))}if(core.isset(data.direction)){core.setHeroLoc("direction",data.direction)}core.drawHero();this.doAction();break;case"showImage":if(core.isset(data.loc)&&core.isset(core.material.images.images[data.name])){core.canvas.animate.drawImage(core.material.images.images[data.name],core.calValue(data.loc[0]),core.calValue(data.loc[1]))}else{core.clearMap("animate",0,0,416,416)}this.doAction();break;case"animateImage":if(core.status.replay.replaying){this.doAction()}else{if(core.isset(data.loc)&&core.isset(core.material.images.images[data.name])&&(data.action=="show"||data.action=="hide")){core.events.animateImage(data.action,core.material.images.images[data.name],data.loc,data.time,function(){core.events.doAction()})}else{this.doAction()}}break;case"showGif":if(core.isset(data.loc)&&core.isset(core.material.images.images[data.name])){var gif=new Image();gif.src=core.material.images.images[data.name].src;gif.style.position="absolute";gif.style.left=(core.calValue(data.loc[0])*core.domStyle.scale)+"px";gif.style.top=(core.calValue(data.loc[1])*core.domStyle.scale)+"px";core.dom.gif2.appendChild(gif)}else{core.dom.gif2.innerHTML=""}this.doAction();break;case"moveImage":if(core.status.replay.replaying){this.doAction()}else{if(core.isset(data.from)&&core.isset(data.to)&&core.isset(core.material.images.images[data.name])){core.events.moveImage(core.material.images.images[data.name],data.from,data.to,data.time,function(){core.events.doAction()})}else{this.doAction()}}break;case"setFg":core.setFg(data.color,data.time,function(){core.events.doAction()});break;case"setWeather":core.setWeather(data.name,data.level);this.doAction();break;case"openDoor":var floorId=data.floorId||core.status.floorId;var block=core.getBlock(core.calValue(data.loc[0]),core.calValue(data.loc[1]),floorId);if(block!=null){if(floorId==core.status.floorId){core.openDoor(block.block.event.id,block.block.x,block.block.y,false,function(){core.events.doAction()})}else{core.removeBlock(block.block.x,block.block.y,floorId);this.doAction()}break}this.doAction();break;case"openShop":if(core.status.replay.replaying){core.status.shops[data.id].visited=true;core.status.event.data.list=[];this.doAction()}else{core.events.openShop(data.id)}break;case"disableShop":core.events.disableQuickShop(data.id);this.doAction();break;case"battle":core.battle(data.id,null,null,true,function(){core.events.doAction()});break;case"trigger":var toX=core.calValue(data.loc[0]),toY=core.calValue(data.loc[1]);var block=core.getBlock(toX,toY);if(block!=null){block=block.block;if(core.isset(block.event)&&block.event.trigger=="action"){core.status.event.data.list=[{todo:core.clone(block.event.data),total:core.clone(block.event.data),condition:"false"}];core.status.event.data.x=block.x;core.status.event.data.y=block.y}}this.doAction();break;case"playSound":if(!core.status.replay.replaying){core.playSound(data.name)}this.doAction();break;case"playBgm":core.playBgm(data.name);this.doAction();break;case"pauseBgm":core.pauseBgm();this.doAction();break;case"resumeBgm":core.resumeBgm();this.doAction();break;case"setVolume":data.value=parseInt(data.value||0);if(data.value>100){data.value=100}data.value=data.value/100;core.musicStatus.volume=data.value;if(core.isset(core.musicStatus.playingBgm)){core.material.bgms[core.musicStatus.playingBgm].volume=data.value}core.musicStatus.gainNode.gain.value=data.value;this.doAction();break;case"setValue":try{var value=core.calValue(data.value);if(data.name.indexOf("status:")==0){value=parseFloat(value);core.setStatus(data.name.substring(7),value)}if(data.name.indexOf("item:")==0){value=parseInt(value);var itemId=data.name.substring(5);if(value>core.itemCount(itemId)){core.getItem(itemId,value-core.itemCount(itemId))}else{core.setItem(itemId,value)}}if(data.name.indexOf("flag:")==0){core.setFlag(data.name.substring(5),value)}}catch(e){console.log(e)}if(core.status.hero.hp<=0){core.status.hero.hp=0;core.updateStatusBar();core.events.lose()}else{core.updateStatusBar();this.doAction()}break;case"setHeroIcon":this.setHeroIcon(data.name);this.doAction();break;case"input":var value;if(core.status.replay.replaying){var action=core.status.replay.toReplay.shift();if(action.indexOf("input:")==0){value=parseInt(action.substring(6))}else{core.stopReplay();core.drawTip("录像文件出错");return}}else{core.interval.onDownInterval="tmp";value=prompt(core.replaceText(data.text))}value=Math.abs(parseInt(value)||0);core.status.route.push("input:"+value);core.setFlag("input",value);this.doAction();break;case"if":if(core.calValue(data.condition)){core.events.insertAction(data["true"])}else{core.events.insertAction(data["false"])}this.doAction();break;case"choices":if(core.status.replay.replaying){if(core.status.replay.toReplay.length==0){core.status.replay.replaying=false;core.drawTip("录像回放完毕")}else{var action=core.status.replay.toReplay.shift(),index;if(action.indexOf("choices:")==0&&((index=parseInt(action.substring(8)))>=0)&&index<data.choices.length){core.status.event.selection=index;setTimeout(function(){core.status.route.push("choices:"+index);core.events.insertAction(data.choices[index].action);core.events.doAction()},750/core.status.replay.speed)}else{core.stopReplay();core.drawTip("录像文件出错")}}}core.ui.drawChoices(data.text,data.choices);break;case"while":if(core.calValue(data.condition)){core.unshift(core.status.event.data.list,{todo:core.clone(data.data),total:core.clone(data.data),condition:data.condition})}this.doAction();break;case"break":core.status.event.data.list.shift();this.doAction();break;case"continue":if(core.calValue(core.status.event.data.list[0].condition)){core.status.event.data.list[0].todo=core.clone(core.status.event.data.list[0].total)}else{core.status.event.data.list.shift()}this.doAction();break;case"win":core.events.win(data.reason,function(){core.events.doAction()});break;case"lose":core.events.lose(data.reason,function(){core.events.doAction()});break;case"function":var func=data["function"];if(core.isset(func)){if((typeof func=="string")&&func.indexOf("function")==0){eval("("+func+")()")}else{if(func instanceof Function){func()}}}this.doAction();break;case"update":core.updateStatusBar();this.doAction();break;case"sleep":if(core.status.replay.replaying){core.events.doAction()}else{setTimeout(function(){core.events.doAction()},data.time)}break;case"wait":if(core.status.replay.replaying){var code=core.status.replay.toReplay.shift();if(code.indexOf("input:")==0){var value=parseInt(code.substring(6));core.status.route.push("input:"+value);if(value>=10000){core.setFlag("type",1);core.setFlag("x",parseInt((value-10000)/100));core.setFlag("y",value%100)}else{core.setFlag("type",0);core.setFlag("keycode",value)}core.events.doAction()}else{core.stopReplay();core.drawTip("录像文件出错")}}break;case"revisit":var block=core.getBlock(x,y);if(block!=null){block=block.block;if(core.isset(block.event)&&block.event.trigger=="action"){core.status.event.data.list=[{todo:core.clone(block.event.data),total:core.clone(block.event.data),condition:"false"}]}}this.doAction();break;case"exit":core.status.event.data.list=[];core.events.doAction();break;default:core.status.event.data.type="text";core.ui.drawTextBox("\t[警告]出错啦!\n"+data.type+" 事件不被支持...")}return};events.prototype.insertAction=function(a,c,d,b){if(core.status.event.id==null){this.doEvents(a,c,d,b)}else{core.unshift(core.status.event.data.list[0].todo,a);if(core.isset(c)){core.status.event.data.x=c}if(core.isset(d)){core.status.event.data.y=d}if(core.isset(b)){core.status.event.data.callback=b}}};events.prototype.getNextItem=function(){if(!core.status.heroStop||!core.flags.enableGentleClick){return}var b=core.nextX(),c=core.nextY();var a=core.getBlock(b,c);if(a==null){return}if(a.block.event.trigger=="getItem"){core.getItem(a.block.event.id,1,b,c);core.status.route.push("getNext")}};events.prototype.getItem=function(d,e,f,g,a){core.playSound("item.mp3");var c=core.material.items[d].cls;core.items.getItemEffect(d,e);core.removeBlock(f,g);var h="获得 "+core.material.items[d].name;if(e>1){h+="x"+e}if(c==="items"){h+=core.items.getItemEffectTip(d)}core.drawTip(h,core.material.icons.items[d]);core.canvas.event.clearRect(f*32,g*32,32,32);core.updateStatusBar();var b=core.floors[core.status.floorId].afterGetItem[f+","+g];if(core.isset(b)){core.events.doEvents(b,f,g,a)}else{if(core.isset(a)){a()}}};events.prototype.openDoor=function(d,i,j,f,a){if(core.interval.openDoorAnimate!=null){return}if(!core.terrainExists(i,j,d)&&d!="lava"&&d!="star"){if(core.isset(a)){a()}return}if(core.status.automaticRoute.moveStepBeforeStop.length==0){core.status.automaticRoute.moveStepBeforeStop=core.status.automaticRoute.autoStepRoutes.slice(core.status.automaticRoute.autoStep-1,core.status.automaticRoute.autoStepRoutes.length);if(core.status.automaticRoute.moveStepBeforeStop.length>=1){core.status.automaticRoute.moveStepBeforeStop[0].step-=core.status.automaticRoute.movedStep}}core.stopAutomaticRoute();var g=30;var c=d;if(c.length<4||c.substring(c.length-4)!="Door"){c=c+"Door";g=70}if(!core.isset(core.material.icons.animates[c])){if(core.isset(a)){a()}return}var e=d.replace("Door","Key");if(f&&(e=="specialKey"||core.isset(core.material.items[e]))){var e=d.replace("Door","Key");if(!core.hasItem(e)){if(e!="specialKey"){core.drawTip("你没有"+core.material.items[e].name)}else{core.drawTip("无法开启此门")}core.clearContinueAutomaticRoute();return}core.autosave(true);core.removeItem(e)}core.playSound("door.mp3");var h=0;var b=core.material.icons.animates[c];core.status.replay.animate=true;core.removeGlobalAnimate(i,j);core.interval.openDoorAnimate=window.setInterval(function(){h++;if(h==4){clearInterval(core.interval.openDoorAnimate);core.interval.openDoorAnimate=null;core.removeBlock(i,j);core.status.replay.animate=false;core.events.afterOpenDoor(d,i,j,a);return}core.canvas.event.clearRect(32*i,32*j,32,32);core.canvas.event.drawImage(core.material.images.animates,32*h,32*b,32,32,32*i,32*j,32,32)},g/core.status.replay.speed)};events.prototype.battle=function(c,d,e,b,a){if(core.status.automaticRoute.moveStepBeforeStop.length==0){core.status.automaticRoute.moveStepBeforeStop=core.status.automaticRoute.autoStepRoutes.slice(core.status.automaticRoute.autoStep-1,core.status.automaticRoute.autoStepRoutes.length);if(core.status.automaticRoute.moveStepBeforeStop.length>=1){core.status.automaticRoute.moveStepBeforeStop[0].step-=core.status.automaticRoute.movedStep}}core.stopHero();core.stopAutomaticRoute();if(!core.enemys.canBattle(c)&&!b){core.drawTip("你打不过此怪物!");core.clearContinueAutomaticRoute();return}if(!core.isset(core.status.event.id)){core.autosave(true)}if(core.flags.battleAnimate&&!core.status.replay.replaying){core.waitHeroToStop(function(){core.ui.drawBattleAnimate(c,function(){core.events.afterBattle(c,d,e,a)})})}else{if(core.flags.equipment&&core.getFlag("sword","sword0")!="sword0"){core.playSound("zone.mp3");core.drawAnimate("sword",d,e)}else{core.playSound("attack.mp3");core.drawAnimate("hand",d,e)}core.events.afterBattle(c,d,e,a)}};events.prototype.trigger=function(g,h){var d=core.status.thisMap.blocks;var e;for(var a=0;a<d.length;a++){if(d[a].x==g&&d[a].y==h&&!(core.isset(d[a].enable)&&!d[a].enable)){e=d[a].event&&d[a].event.noPass;if(e){core.clearAutomaticRouteNode(g,h)}if(core.isset(d[a].event)&&core.isset(d[a].event.trigger)){var f=d[a].event.trigger;if(f=="changeFloor"&&!e){var c=core.flags.portalWithoutTrigger;if(core.isset(d[a].event.data)&&core.isset(d[a].event.data.portalWithoutTrigger)){c=d[a].event.data.portalWithoutTrigger}if(c){if(core.status.replay.replaying){if(core.status.replay.toReplay[0]=="no"){core.status.replay.toReplay.shift();core.status.route.push("no");continue}}else{if(core.status.automaticRoute.autoHeroMove||core.status.automaticRoute.autoStep<core.status.automaticRoute.autoStepRoutes.length){core.status.route.push("no");continue}}}}core.status.automaticRoute.moveDirectly=false;core.material.events[f](d[a],core,function(b){})}}}};events.prototype.changeFloor=function(d,h,f,j,b,e){var c=!(j==0)&&!core.status.replay.replaying;j=j||800;j/=20;core.lockControl();core.stopHero();core.stopAutomaticRoute();core.clearContinueAutomaticRoute();core.status.replay.animate=true;core.dom.floorNameLabel.innerHTML=core.status.maps[d].title;if(!core.isset(h)&&!core.isset(f)){f=core.status.hero.loc}if(core.isset(h)){if(!core.isset(f)){f={}}if(core.isset(core.floors[d][h])){f.x=core.floors[d][h][0];f.y=core.floors[d][h][1]}else{var a=core.status.maps[d].blocks;for(var g in a){if(core.isset(a[g].event)&&!(core.isset(a[g].enable)&&!a[g].enable)&&a[g].event.id===h){f.x=a[g].x;f.y=a[g].y;break}}}if(!core.isset(f.x)){f.x=core.status.hero.loc.x;f.y=core.status.hero.loc.y}}if(core.status.maps[d].canFlyTo&&core.status.hero.flyRange.indexOf(d)<0){core.status.hero.flyRange.push(d);core.status.hero.flyRange.sort(function(i,k){return core.floorIds.indexOf(i)-core.floorIds.indexOf(k)})}window.setTimeout(function(){var i=function(){var l=core.status.maps[d].name;if(!core.isset(l)||l==""){l=" "}core.statusBar.floor.innerHTML=l;if(/^[+-]?\d+$/.test(l)){core.statusBar.floor.style.fontStyle="italic"}else{core.statusBar.floor.style.fontStyle="normal"}if(core.isset(core.floors[d].bgm)){core.playBgm(core.floors[d].bgm)}if(core.status.event.id==null){if(core.isset(core.floors[d].color)){var k=core.floors[d].color;core.dom.curtain.style.background=core.arrayToRGB(k);if(core.isset(k[3])){core.dom.curtain.style.opacity=k[3]}else{core.dom.curtain.style.opacity=1}core.status.curtainColor=k}else{core.dom.curtain.style.background="#000000";core.dom.curtain.style.opacity=0}}if(core.isset(core.floors[d].weather)){core.setWeather(core.floors[d].weather[0],core.floors[d].weather[1])}else{core.setWeather()}core.dom.gif.innerHTML="";if(!core.isset(e)){core.status.maps[d].blocks.forEach(function(m){if(core.isset(m.enable)&&!m.enable&&core.isset(m.event)&&m.event.cls.indexOf("enemy")==0&&core.enemys.hasSpecial(core.material.enemys[m.event.id].special,23)){m.enable=true}})}core.drawMap(d,function(){if(core.isset(f.direction)){core.setHeroLoc("direction",f.direction)}core.setHeroLoc("x",f.x);core.setHeroLoc("y",f.y);core.clearMap("hero",0,0,416,416);core.drawHero();var m=function(){core.unLockControl();core.status.replay.animate=false;core.events.afterChangeFloor(d);if(core.isset(b)){b()}};if(c){core.hide(core.dom.floorMsgGroup,j/4,function(){m()})}else{m()}})};core.playSound("floor.mp3");if(c){core.show(core.dom.floorMsgGroup,j/2,function(){i()})}else{i()}},25)};events.prototype.animateImage=function(g,c,d,f,b){f=f||0;if((g!="show"&&g!="hide")||f<=0){if(core.isset(b)){b()}return}clearInterval(core.interval.tipAnimate);core.setAlpha("data",1);var e=0;if(g=="hide"){e=1}core.setOpacity("data",e);core.canvas.data.drawImage(c,core.calValue(d[0]),core.calValue(d[1]));core.status.replay.animate=true;var a=setInterval(function(){if(g=="show"){e+=0.1}else{e-=0.1}core.setOpacity("data",e);if(e>=1||e<=0){clearInterval(a);core.clearMap("data",0,0,416,416);core.setOpacity("data",1);core.status.replay.animate=false;if(core.isset(b)){b()}}},f/10)};events.prototype.moveImage=function(g,d,j,i,b){i=i||1000;clearInterval(core.interval.tipAnimate);core.setAlpha("data",1);core.setOpacity("data",1);core.status.replay.animate=true;var e=core.calValue(d[0]),f=core.calValue(d[1]),k=core.calValue(j[0]),l=core.calValue(j[1]);var h=0;var c=function(){core.clearMap("data",0,0,416,416);var m=parseInt(e+(k-e)*h/64);var n=parseInt(f+(l-f)*h/64);core.canvas.data.drawImage(g,m,n)};c();var a=setInterval(function(){h++;c();if(h>=64){clearInterval(a);core.clearMap("data",0,0,416,416);core.status.replay.animate=false;if(core.isset(b)){b()}}},i/64)};events.prototype.openShop=function(shopId,needVisited){var shop=core.status.shops[shopId];shop.times=shop.times||0;shop.visited=shop.visited||false;if(needVisited&&!shop.visited){if(shop.times==0){core.drawTip("该商店尚未开启")}else{core.drawTip("该商店已失效")}return}shop.visited=true;var selection=core.status.event.selection;var actions=[];if(core.isset(core.status.event.data)&&core.isset(core.status.event.data.actions)){actions=core.status.event.data.actions}var fromList;if(core.isset(core.status.event.data)&&core.isset(core.status.event.data.fromList)){fromList=core.status.event.data.fromList}core.ui.closePanel();core.lockControl();core.status.event.id="shop";core.status.event.data={id:shopId,shop:shop,actions:actions,fromList:fromList};core.status.event.selection=selection;var content="\t["+shop.name+","+shop.icon+"]";var times=shop.times,need=eval(shop.need);content=content+shop.text.replace(/\${([^}]+)}/g,function(word,value){return eval(value)});var use=shop.use=="experience"?"经验":"金币";var choices=[];for(var i=0;i<shop.choices.length;i++){var choice=shop.choices[i];var text=choice.text;if(core.isset(choice.need)){text+="("+eval(choice.need)+use+")"}choices.push(text)}choices.push("离开");core.ui.drawChoices(content,choices)};events.prototype.disableQuickShop=function(a){core.status.shops[a].visited=false};events.prototype.canUseQuickShop=function(a){if(core.isset(core.floors[core.status.floorId].canUseQuickShop)&&!core.floors[core.status.floorId].canUseQuickShop){return"当前不能使用快捷商店。"}return null};events.prototype.setHeroIcon=function(a){if(core.isset(core.material.images.images[a])&&core.material.images.images[a].width==128){core.setFlag("heroIcon",a);core.material.images.hero.src=core.material.images.images[a].src;core.material.icons.hero.height=core.material.images.images[a].height/4;core.drawHero()}};events.prototype.checkLvUp=function(){if(!core.flags.enableLevelUp||core.status.hero.lv>=core.firstData.levelUp.length){return}var need=core.firstData.levelUp[core.status.hero.lv].need;if(!core.isset(need)){return}if(core.status.hero.experience>=need){core.status.hero.lv++;var effect=core.firstData.levelUp[core.status.hero.lv-1].effect;if(typeof effect=="string"){if(effect.indexOf("function")==0){eval("("+effect+")()")}else{effect.split(";").forEach(function(t){core.doEffect(t)})}}else{if(effect instanceof Function){effect()}}this.checkLvUp()}};events.prototype.useItem=function(b){core.ui.closePanel();if(b=="book"){core.openBook(false);return}if(b=="fly"){core.useFly(false);return}if(b=="centerFly"){core.status.usingCenterFly=true;var a="rgba(255,0,0,0.5)";if(core.canUseItem("centerFly")){a="rgba(0,255,0,0.5)"}core.fillRect("ui",(12-core.getHeroLoc("x"))*32,(12-core.getHeroLoc("y"))*32,32,32,a);core.drawTip("请确认当前中心对称飞行器的位置");return}if(core.canUseItem(b)){core.useItem(b)}else{core.drawTip("当前无法使用"+core.material.items[b].name)}};events.prototype.addPoint=function(a){return this.eventdata.addPoint(a)};events.prototype.afterBattle=function(b,c,d,a){return this.eventdata.afterBattle(b,c,d,a)};events.prototype.afterOpenDoor=function(b,c,d,a){return this.eventdata.afterOpenDoor(b,c,d,a)};events.prototype.passNet=function(a){if(core.hasItem("shoes")){return}if(a.event.id=="lavaNet"){}if(a.event.id=="poisonNet"){if(core.hasFlag("poison")){return}core.setFlag("poison",true)}if(a.event.id=="weakNet"){if(core.hasFlag("weak")){return}core.setFlag("weak",true);var d=core.values.weakValue;var b=d>=1?d:Math.floor(d*core.status.hero.atk);var c=d>=1?d:Math.floor(d*core.status.hero.def);core.setFlag("weakAtk",b);core.setFlag("weakDef",c);core.status.hero.atk-=b;core.status.hero.def-=c}if(a.event.id=="curseNet"){if(core.hasFlag("curse")){return}core.setFlag("curse",true)}core.updateStatusBar()};events.prototype.changeLight=function(c,d){var a=core.getBlock(c,d);if(a==null){return}var b=a.index;a=a.block;if(a.event.id!="light"){return}a.id=166;a.event={cls:"terrains",id:"darkLight",noPass:true};core.drawBlock(a);this.afterChangeLight(c,d)};events.prototype.afterChangeLight=function(a,b){return this.eventdata.afterChangeLight(a,b)};events.prototype.ski=function(a){if(!core.isset(a)){a=core.status.automaticRoute.lastDirection||core.getHeroLoc("direction")}if(core.status.event.id!="ski"){core.waitHeroToStop(function(){core.status.event.id="ski";core.events.ski(a)})}else{core.moveHero(a,function(){if(core.status.event.id=="ski"){core.status.event.id=null;core.unLockControl();core.replay()}})}};events.prototype.pushBox=function(b){if(b.event.id!="box"&&b.event.id!="boxed"){return}var f={up:{x:0,y:-1},left:{x:-1,y:0},down:{x:0,y:1},right:{x:1,y:0}};var c=core.getHeroLoc("direction"),d=b.x+f[c].x,e=b.y+f[c].y;if(d<0||d>12||e<0||e>12){return}var a=core.getBlock(d,e,null,false);if(a!=null&&!(core.isset(a.block.event)&&a.block.event.id=="flower")){return}if(a==null){core.status.thisMap.blocks.push(core.maps.initBlock(d,e,169));a=core.getBlock(d,e)}else{a.block.id=170;a.block.event=core.maps.initBlock(null,null,170).event}core.drawBlock(a.block);if(b.event.id=="box"){core.removeBlock(b.x,b.y)}else{b.id=168;b.event=core.maps.initBlock(null,null,168).event;core.drawBlock(b)}core.updateStatusBar();core.status.replay.animate=true;core.moveHero(c,function(){core.status.replay.animate=false;core.status.route.pop();core.events.afterPushBox();core.replay()})};events.prototype.afterPushBox=function(){return this.eventdata.afterPushBox()};events.prototype.afterUseBomb=function(){return this.eventdata.afterUseBomb()};events.prototype.beforeSaveData=function(a){return this.eventdata.beforeSaveData(a)};events.prototype.afterLoadData=function(a){return this.eventdata.afterLoadData(a)}; |