diff --git a/H5样板使用指南.docx b/H5样板使用指南.docx new file mode 100644 index 00000000..2740f119 Binary files /dev/null and b/H5样板使用指南.docx differ diff --git a/H5样板使用指南.pdf b/H5样板使用指南.pdf new file mode 100644 index 00000000..28f3f9ce Binary files /dev/null and b/H5样板使用指南.pdf differ diff --git a/libs/core.js b/libs/core.js index 4bebf003..04e6da6d 100644 --- a/libs/core.js +++ b/libs/core.js @@ -630,7 +630,7 @@ core.prototype.onclick = function (x, y, stepPostfix) { // 快捷商店 if (core.status.event.id == 'selectShop') { - core.events.clickSelectShop(x,y); + core.events.clickQuickShop(x,y); return; } @@ -679,124 +679,10 @@ core.prototype.onclick = function (x, y, stepPostfix) { if (core.status.event.id == 'syncSave') { if (x>=4 && x<=8) { if (y==5) { - core.ui.drawConfirmBox("你确定要将本地存档同步到服务器吗?", function(){ - // console.log("同步存档..."); - core.ui.drawWaiting("正在同步,请稍后..."); - - var formData = new FormData(); - formData.append('type', 'save'); - formData.append('name', core.firstData.name); - var saves = []; - for (var i=1;i<=180;i++) { - var data = core.getLocalStorage("save"+i, null); - if (core.isset(data)) { - saves.push(data); - } - } - var save_text = JSON.stringify(saves); - formData.append('data', save_text); - - // send - var xhr = new XMLHttpRequest(); - xhr.open("POST", "../sync.php"); - xhr.timeout = 1000; - xhr.onload = function(e) { - if (xhr.status==200) { - // console.log("同步成功。"); - var response = JSON.parse(xhr.response); - if (response.code<0) { - core.drawText("出错啦!\n无法同步存档到服务器。"); - } - else { - core.drawText("同步成功!\n\n您的存档编号: "+response.code+"\n您的存档密码: "+response.msg+"\n\n请牢记以上两个信息(如截图等),在从服务器\n同步存档时使用。") - } - } - else { - core.drawText("出错啦!\n无法同步存档到服务器。"); - } - }; - xhr.ontimeout = function(e) { - console.log(e); - core.drawText("出错啦!\n无法同步存档到服务器。"); - } - xhr.onerror = function(e) { - console.log(e); - core.drawText("出错啦!\n无法同步存档到服务器。"); - } - xhr.send(formData); - }, function() { - core.ui.drawSyncSave(); - }) + core.syncSave("save"); } if (y==6) { - core.ui.drawConfirmBox("你确定要从服务器加载存档吗?\n该操作将覆盖所有本地存档且不可逆!", function(){ - var id = prompt("请输入存档编号:"); - if (id==null || id=="") { - core.ui.drawSyncSave(); return; - } - var password = prompt("请输入存档密码:"); - if (password==null || password=="") { - core.ui.drawSyncSave(); return; - } - core.ui.drawWaiting("正在同步,请稍后..."); - - var formData = new FormData(); - formData.append('type', 'load'); - formData.append('name', core.firstData.name); - formData.append('id', id); - formData.append('password', password); - - // send - var xhr = new XMLHttpRequest(); - xhr.open("POST", "../sync.php"); - xhr.timeout = 1000; - xhr.onload = function(e) { - if (xhr.status==200) { - // console.log("同步成功。"); - var response = JSON.parse(xhr.response); - switch (response.code) { - case 0: - // 成功 - var data=JSON.parse(response.msg); - // console.log(data); - for (var i=1;i<=180;i++) { - if (i<=data.length) { - core.setLocalStorage("save"+i, data[i-1]); - } - else { - core.removeLocalStorage("save"+i); - } - } - core.drawText("同步成功!\n你的本地所有存档均已被覆盖。"); - break; - case -1: - core.drawText("出错啦!\n存档编号"+id+"不存在!"); - break; - case -2: - core.drawText("出错啦!\n存档密码错误!"); - break; - default: - core.drawText("出错啦!\n无法从服务器同步存档。"); - break; - } - - } - else { - core.drawText("出错啦!\n无法从服务器同步存档。"); - } - }; - xhr.ontimeout = function(e) { - console.log(e); - core.drawText("出错啦!\n无法从服务器同步存档。"); - } - xhr.onerror = function(e) { - console.log(e); - core.drawText("出错啦!\n无法从服务器同步存档。"); - } - xhr.send(formData); - }, function() { - core.ui.drawSyncSave(); - }) + core.syncSave("load"); } } if (x>=5 && x<=7 && y==7) { @@ -1318,7 +1204,7 @@ core.prototype.openDoor = function (id, x, y, needKey, callback) { var speed=30; if (needKey) { var key = id.replace("Door", "Key"); - if (!core.rmItem(key)) { + if (!core.removeItem(key)) { if (key != "specialKey") core.drawTip("你没有" + core.material.items[key].name); else core.drawTip("无法开启此门"); @@ -1395,9 +1281,36 @@ core.prototype.battle = function (id, x, y, force, callback) { core.events.afterBattle(id,x,y,callback); } +core.prototype.trigger = function (x, y) { + var mapBlocks = core.status.thisMap.blocks; + var noPass; + for (var b = 0; b < mapBlocks.length; b++) { + if (mapBlocks[b].x == x && mapBlocks[b].y == y && !(core.isset(mapBlocks[b].enable) && !mapBlocks[b].enable)) { // 启用事件 + noPass = mapBlocks[b].event && mapBlocks[b].event.noPass; + if (noPass) { + core.clearAutomaticRouteNode(x, y); + } + if (core.isset(mapBlocks[b].event) && core.isset(mapBlocks[b].event.trigger)) { + var trigger = mapBlocks[b].event.trigger; + // 转换楼层能否穿透 + if (trigger=='changeFloor' && (core.status.autoHeroMove || core.status.autoStep12 || y<0 || y>12 || core.noPassExists(x,y); +} + core.prototype.npcExists = function (x, y, floorId) { var block = core.getBlock(x,y,floorId); if (block==null) return false; @@ -1650,32 +1558,7 @@ core.prototype.getBlock = function (x, y, floorId, needEnable) { return null; } -core.prototype.removeBlockById = function (index, floorId) { - - var blocks = core.status.maps[floorId].blocks; - var x=blocks[index].x, y=blocks[index].y; - - // 检查该点是否是checkBlock - if (core.floors[floorId].checkBlock.indexOf(x+","+y)>=0) { - blocks[index] = {'x': x, 'y': y, 'event': {'cls': 'terrains', 'id': 'ground', 'noPass': false, 'trigger': 'checkBlock'}}; - return; - } - - // 检查该点是否存在事件 - var event = core.floors[floorId].events[x+","+y]; - if (!core.isset(event)) - event = core.floors[floorId].changeFloor[x+","+y]; - - // 不存在事件,直接删除 - if (!core.isset(event)) { - blocks.splice(index,1); - return; - } - - blocks[index].enable = false; -} - -core.prototype.moveBlock = function(x,y,steps,time,disappear,callback) { +core.prototype.moveBlock = function(x,y,steps,time,immediateHide,callback) { time = time || 500; clearInterval(core.interval.tipAnimate); @@ -1732,7 +1615,7 @@ core.prototype.moveBlock = function(x,y,steps,time,disappear,callback) { var animate=window.setInterval(function() { // 已经移动完毕,消失 if (moveSteps.length==0) { - if (disappear) opacityVal=0; + if (immediateHide) opacityVal=0; else opacityVal -= 0.06; core.setOpacity('data', opacityVal); core.clearMap('data', nowX, nowY, 32, 32); @@ -1834,7 +1717,7 @@ core.prototype.removeBlock = function (x, y, floorId) { // 删除动画,清除地图 if (floorId==core.status.floorId) { - core.rmGlobalAnimate(x, y); + core.removeGlobalAnimate(x, y); core.canvas.event.clearRect(x * 32, y * 32, 32, 32); } @@ -1843,42 +1726,38 @@ core.prototype.removeBlock = function (x, y, floorId) { core.updateFg(); } + +core.prototype.removeBlockById = function (index, floorId) { + + var blocks = core.status.maps[floorId].blocks; + var x=blocks[index].x, y=blocks[index].y; + + // 检查该点是否是checkBlock + if (core.floors[floorId].checkBlock.indexOf(x+","+y)>=0) { + blocks[index] = {'x': x, 'y': y, 'event': {'cls': 'terrains', 'id': 'ground', 'noPass': false, 'trigger': 'checkBlock'}}; + return; + } + + // 检查该点是否存在事件 + var event = core.floors[floorId].events[x+","+y]; + if (!core.isset(event)) + event = core.floors[floorId].changeFloor[x+","+y]; + + // 不存在事件,直接删除 + if (!core.isset(event)) { + blocks.splice(index,1); + return; + } + + blocks[index].enable = false; +} + core.prototype.removeBlockByIds = function (floorId, ids) { ids.sort(function (a,b) {return b-a}).forEach(function (id) { core.removeBlockById(id, floorId); }); } -core.prototype.noPass = function (x, y) { - return x<0 || x>12 || y<0 || y>12 || core.noPassExists(x,y); -} - -core.prototype.trigger = function (x, y) { - var mapBlocks = core.status.thisMap.blocks; - var noPass; - for (var b = 0; b < mapBlocks.length; b++) { - if (mapBlocks[b].x == x && mapBlocks[b].y == y && !(core.isset(mapBlocks[b].enable) && !mapBlocks[b].enable)) { // 启用事件 - noPass = mapBlocks[b].event && mapBlocks[b].event.noPass; - if (noPass) { - core.clearAutomaticRouteNode(x, y); - } - if (core.isset(mapBlocks[b].event) && core.isset(mapBlocks[b].event.trigger)) { - var trigger = mapBlocks[b].event.trigger; - // 转换楼层能否穿透 - if (trigger=='changeFloor' && (core.status.autoHeroMove || core.status.autoStep-1||j.indexOf("iPad")>-1){console.log("你的设备为iphone,不自动播放音乐!");core.musicStatus.isIOS=true;core.musicStatus.soundStatus=false}core.material.ground=new Image();core.material.ground.src="images/ground.png";core.loader(function(){console.log(core.material);core.showStartAnimate()})};core.prototype.showStartAnimate=function(a){core.dom.startPanel.style.opacity=1;core.dom.startPanel.style.display="block";core.dom.startTop.style.opacity=1;core.dom.startTop.style.display="block";core.dom.startButtonGroup.style.display="none";core.dom.startButtons.style.display="block";core.dom.levelChooseButtons.style.display="none";core.status.played=false;core.clearStatus();core.clearMap("all");var b=1;var c=window.setInterval(function(){b-=0.03;if(b<0){clearInterval(c);core.dom.startTop.style.display="none";core.dom.startButtonGroup.style.display="block";if(core.isset(a)){a()}}core.dom.startTop.style.opacity=b},20)};core.prototype.hideStartAnimate=function(a){var b=1;var c=window.setInterval(function(){b-=0.03;if(b<0){clearInterval(c);core.dom.startPanel.style.display="none";if(core.isset(a)){a()}}core.dom.startPanel.style.opacity=b},20)};core.prototype.setStartProgressVal=function(a){core.dom.startTopProgress.style.width=a+"%"};core.prototype.setStartLoadTipText=function(a){core.dom.startTopLoadTips.innerHTML=a};core.prototype.loader=function(c){var f=0,a=0,b=0;a=core.images.length;for(var e in core.sounds){b+=core.sounds[e].length}for(var d=0;d0){return}core.musicStatus.bgmStatus=1;if(core.musicStatus.soundStatus){core.playBgm("bgm","mp3")}return}var a=b.shift();a.oncanplay=function(){core.loadSoundItem(b)};a.load()};core.prototype.isPlaying=function(){if(core.isset(core.status.played)&&core.status.played){return true}return false};core.prototype.clearStatus=function(){for(var a in core.interval){clearInterval(core.interval[a])}core.status={};core.clearStatusBar();core.resize(main.dom.body.clientWidth,main.dom.body.clientHeight)};core.prototype.resetStatus=function(c,b,a,e){for(var d in core.interval){clearInterval(core.interval[d])}core.status=core.clone(core.initStatus);core.status.played=true;core.status.floorId=a;core.status.maps=core.clone(e);core.material.enemys=core.clone(core.enemys.getEnemys());core.status.hero=core.clone(c);core.status.hard=b;core.status.savePage=core.getLocalStorage("savePage",0);core.resize(main.dom.body.clientWidth,main.dom.body.clientHeight)};core.prototype.startGame=function(b,a){console.log("开始游戏");core.resetStatus(core.firstData.hero,b,core.firstData.floorId,core.initStatus.maps);core.changeFloor(core.status.floorId,null,core.firstData.hero.loc,null,function(){core.setHeroMoveTriggerInterval();if(core.isset(a)){a()}})};core.prototype.restart=function(){core.showStartAnimate()};core.prototype.onkeyDown=function(a){if(!core.isset(core.status.holdingKeys)){core.status.holdingKeys=[]}var c={37:true,38:true,39:true,40:true}[a.keyCode];if(c){for(var b=0;bd){c=b;d=a[b]}}e=[{x:0,y:1},{x:-1,y:0},{x:0,y:-1},{x:1,y:0},false][c];if(e){e.x+=f.x;e.y+=f.y;core.status.stepPostfix.push(e);core.fillPosWithPoint(e)}};core.prototype.onup=function(){core.status.holdingPath=0;if(core.status.stepPostfix.length>0){var g=[];var a={"0":{"1":"down","-1":"up"},"-1":{"0":"left"},"1":{"0":"right"}};for(var b=1;b12||c>12){return}if(!core.status.lockControl){core.setAutomaticRoute(b,c,a);return}if(core.status.event.id=="book"){core.events.clickBook(b,c);return}if(core.status.event.id=="fly"){core.events.clickFly(b,c);return}if(core.status.event.id=="settings"){core.events.clickSettings(b,c);return}if(core.status.event.id=="shop"){core.events.clickShop(b,c);return}if(core.status.event.id=="selectShop"){core.events.clickSelectShop(b,c);return}if(core.status.event.id=="toolbox"){core.events.clickToolbox(b,c);return}if(core.status.event.id=="save"||core.status.event.id=="load"){core.events.clickSL(b,c);return}if(core.status.event.id=="confirmBox"){if((b==4||b==5)&&c==7&&core.isset(core.status.event.data.yes)){core.status.event.data.yes()}if((b==7||b==8)&&c==7&&core.isset(core.status.event.data.no)){core.status.event.data.no()}return}if(core.status.event.id=="about"){if(core.isPlaying()){core.ui.closePanel(false)}else{core.showStartAnimate()}return}if(core.status.event.id=="action"){core.events.clickAction(b,c);return}if(core.status.event.id=="text"){core.drawText();return}if(core.status.event.id=="syncSave"){if(b>=4&&b<=8){if(c==5){core.ui.drawConfirmBox("你确定要将本地存档同步到服务器吗?",function(){core.ui.drawWaiting("正在同步,请稍后...");var e=new FormData();e.append("type","save");e.append("name",core.firstData.name);var h=[];for(var f=1;f<=180;f++){var d=core.getLocalStorage("save"+f,null);if(core.isset(d)){h.push(d)}}var g=JSON.stringify(h);e.append("data",g);var j=new XMLHttpRequest();j.open("POST","../sync.php");j.timeout=1000;j.onload=function(i){if(j.status==200){var k=JSON.parse(j.response);if(k.code<0){core.drawText("出错啦!\n无法同步存档到服务器。")}else{core.drawText("同步成功!\n\n您的存档编号: "+k.code+"\n您的存档密码: "+k.msg+"\n\n请牢记以上两个信息(如截图等),在从服务器\n同步存档时使用。")}}else{core.drawText("出错啦!\n无法同步存档到服务器。")}};j.ontimeout=function(i){console.log(i);core.drawText("出错啦!\n无法同步存档到服务器。")};j.onerror=function(i){console.log(i);core.drawText("出错啦!\n无法同步存档到服务器。")};j.send(e)},function(){core.ui.drawSyncSave()})}if(c==6){core.ui.drawConfirmBox("你确定要从服务器加载存档吗?\n该操作将覆盖所有本地存档且不可逆!",function(){var e=prompt("请输入存档编号:");if(e==null||e==""){core.ui.drawSyncSave();return}var f=prompt("请输入存档密码:");if(f==null||f==""){core.ui.drawSyncSave();return}core.ui.drawWaiting("正在同步,请稍后...");var d=new FormData();d.append("type","load");d.append("name",core.firstData.name);d.append("id",e);d.append("password",f);var g=new XMLHttpRequest();g.open("POST","../sync.php");g.timeout=1000;g.onload=function(j){if(g.status==200){var l=JSON.parse(g.response);switch(l.code){case 0:var h=JSON.parse(l.msg);for(var k=1;k<=180;k++){if(k<=h.length){core.setLocalStorage("save"+k,h[k-1])}else{core.removeLocalStorage("save"+k)}}core.drawText("同步成功!\n你的本地所有存档均已被覆盖。");break;case -1:core.drawText("出错啦!\n存档编号"+e+"不存在!");break;case -2:core.drawText("出错啦!\n存档密码错误!");break;default:core.drawText("出错啦!\n无法从服务器同步存档。");break}}else{core.drawText("出错啦!\n无法从服务器同步存档。")}};g.ontimeout=function(h){console.log(h);core.drawText("出错啦!\n无法从服务器同步存档。")};g.onerror=function(h){console.log(h);core.drawText("出错啦!\n无法从服务器同步存档。")};g.send(d)},function(){core.ui.drawSyncSave()})}}if(b>=5&&b<=7&&c==7){core.ui.drawSettings(false)}}};core.prototype.onmousewheel=function(a){if(core.status.lockControl&&core.status.event.id=="fly"){if(a==-1){core.ui.drawFly(core.status.event.data-1)}if(a==1){core.ui.drawFly(core.status.event.data+1)}return}};core.prototype.clearAutomaticRouteNode=function(a,b){core.canvas.ui.clearRect(a*32+5,b*32+5,27,27)};core.prototype.stopAutomaticRoute=function(){if(!core.status.played){return}core.stopAutoHeroMove();core.status.automaticRouting=false;core.status.automaticRouted=false;core.status.autoStepRoutes=[];core.status.automaticRoutingTemp={destX:0,destY:0,moveStep:[]};if(core.status.moveStepBeforeStop.length==0){core.canvas.ui.clearRect(0,0,416,416)}};core.prototype.continueAutomaticRoute=function(){var a=core.status.moveStepBeforeStop;core.status.moveStepBeforeStop=[];if(a.length===0){return}if(a.length===1&&a[0].step===1){return}core.status.automaticRouting=true;core.setAutoHeroMove(a)};core.prototype.clearContinueAutomaticRoute=function(){core.canvas.ui.clearRect(0,0,416,416);core.status.moveStepBeforeStop=[]};core.prototype.setAutomaticRoute=function(a,b,f){if(!core.status.played||core.status.lockControl){return}else{if(core.status.automaticRouting){core.stopAutomaticRoute();return}}if(a==core.status.hero.loc.x&&b==core.status.hero.loc.y&&f.length==0){core.turnHero();return}var e=0;var g=null;var d;core.status.automaticRoutingTemp={destX:0,destY:0,moveStep:[]};if(!(d=core.automaticRoute(a,b))){if(a==core.status.hero.loc.x&&b==core.status.hero.loc.y){d=[]}else{core.canvas.ui.clearRect(0,0,416,416);return}}d=d.concat(f);core.status.automaticRoutingTemp.destX=a;core.status.automaticRoutingTemp.destY=b;core.canvas.ui.save();core.canvas.ui.clearRect(0,0,416,416);core.canvas.ui.fillStyle="#bfbfbf";core.canvas.ui.strokeStyle="#bfbfbf";core.canvas.ui.lineWidth=8;for(var c=0;c12||q<0||q>12){continue}var l=13*p+q;if(core.isset(s[l])){continue}if(p==e&&q==g){s[l]=i;break}if(core.noPassExists(p,q)){continue}var d=1;var b=core.getBlock(p,q);if(b!=null){var k=b.block.event.id;if(k.substring(k.length-3)=="Net"){d=100}if(!core.flags.potionWhileRouting&&k.substring(k.length-6)=="Potion"){d=20}if(b.block.event.trigger=="checkBlock"){d=200}}s[l]=i;r.push(169*(m+d)+l)}if(core.isset(s[13*e+g])){break}}if(!core.isset(s[13*e+g])){return false}var n=e,o=g;while(n!=u||o!=v){var h=s[13*n+o];a.push({direction:h,x:n,y:o});n-=t[h].x;o-=t[h].y}a.reverse();return a};core.prototype.fillPosWithPoint=function(a){core.fillRect("ui",a.x*32+12,a.y*32+12,8,8,"#bfbfbf")};core.prototype.clearStepPostfix=function(){if(core.status.mouseOutCheck>0){core.status.mouseOutCheck--;window.setTimeout(core.clearStepPostfix,1000);return}core.status.holdingPath=0;if(core.status.stepPostfix.length>0){core.status.stepPostfix=[];core.canvas.ui.clearRect(0,0,416,416);core.canvas.ui.restore()}};core.prototype.stopAutoHeroMove=function(){core.status.autoHeroMove=false;core.status.automaticRouting=false;core.status.automaticRouted=false;core.status.autoStep=0;core.status.destStep=0;core.status.movedStep=0;core.status.autoStepRoutes=[];core.stopHero();clearInterval(core.interval.heroAutoMoveScan)};core.prototype.setAutoHeroMove=function(b,a){if(b.length==0){return}core.status.autoStepRoutes=b;core.status.autoStep=0;clearInterval(core.interval.heroAutoMoveScan);core.interval.heroAutoMoveScan=window.setInterval(function(){if(!core.status.autoHeroMove){if(core.status.autoStep==core.status.autoStepRoutes.length){core.stopAutoHeroMove();return}core.autoHeroMove(core.status.autoStepRoutes[core.status.autoStep].direction,core.status.autoStepRoutes[core.status.autoStep].step);core.status.autoStep++}},80)};core.prototype.autoHeroMove=function(a,b){core.status.autoHeroMove=true;core.status.destStep=b;core.moveHero(a)};core.prototype.setHeroMoveInterval=function(b,d,e,a){if(core.status.heroMoving){return}core.status.heroMoving=true;var c=0;core.interval.heroMoveInterval=window.setInterval(function(){switch(b){case"up":c-=4;if(c==-4||c==-8||c==-12||c==-16){core.drawHero(b,d,e,"leftFoot",0,c)}else{if(c==-20||c==-24||c==-28||c==-32){core.drawHero(b,d,e,"rightFoot",0,c)}}if(c==-32){core.setHeroLoc("y","--");core.moveOneStep();if(core.status.heroStop){core.drawHero(b,d,e-1,"stop")}if(core.isset(a)){a()}}break;case"left":c-=4;if(c==-4||c==-8||c==-12||c==-16){core.drawHero(b,d,e,"leftFoot",c)}else{if(c==-20||c==-24||c==-28||c==-32){core.drawHero(b,d,e,"rightFoot",c)}}if(c==-32){core.setHeroLoc("x","--");core.moveOneStep();if(core.status.heroStop){core.drawHero(b,d-1,e,"stop")}if(core.isset(a)){a()}}break;case"down":c+=4;if(c==4||c==8||c==12||c==16){core.drawHero(b,d,e,"leftFoot",0,c)}else{if(c==20||c==24||c==28||c==32){core.drawHero(b,d,e,"rightFoot",0,c)}}if(c==32){core.setHeroLoc("y","++");core.moveOneStep();if(core.status.heroStop){core.drawHero(b,d,e+1,"stop")}if(core.isset(a)){a()}}break;case"right":c+=4;if(c==4||c==8||c==12||c==16){core.drawHero(b,d,e,"leftFoot",c)}else{if(c==20||c==24||c==28||c==32){core.drawHero(b,d,e,"rightFoot",c)}}if(c==32){core.setHeroLoc("x","++");core.moveOneStep();if(core.status.heroStop){core.drawHero(b,d+1,e,"stop")}if(core.isset(a)){a()}}break}},10)};core.prototype.setHeroMoveTriggerInterval=function(){var a,c,d;var b={up:{x:0,y:-1},left:{x:-1,y:0},down:{x:0,y:1},right:{x:1,y:0}};core.interval.heroMoveTriggerInterval=window.setInterval(function(){if(!core.status.heroStop){a=core.getHeroLoc("direction");c=core.getHeroLoc("x");d=core.getHeroLoc("y");var e;e=core.noPass(c+b[a].x,d+b[a].y);if(e){core.trigger(c+b[a].x,d+b[a].y);core.drawHero(a,c,d,"stop");if(core.status.autoHeroMove){core.status.movedStep++;if(core.status.destStep==core.status.movedStep){core.status.autoHeroMove=false;core.status.destStep=0;core.status.movedStep=0;core.status.moveStepBeforeStop=[];core.stopAutomaticRoute()}}else{core.status.heroStop=true}return}core.setHeroMoveInterval(a,c,d,function(){if(core.status.autoHeroMove){core.status.movedStep++;if(core.status.destStep==core.status.movedStep){core.status.autoHeroMove=false;core.status.destStep=0;core.status.movedStep=0;core.stopHero();core.drawHero(core.getHeroLoc("direction"),core.getHeroLoc("x"),core.getHeroLoc("y"),"stop")}}else{if(core.status.heroStop){core.drawHero(core.getHeroLoc("direction"),core.getHeroLoc("x"),core.getHeroLoc("y"),"stop")}}core.trigger(core.getHeroLoc("x"),core.getHeroLoc("y"));clearInterval(core.interval.heroMoveInterval);core.status.heroMoving=false})}},50)};core.prototype.turnHero=function(a){if(core.isset(a)){core.status.hero.loc.direction=a}else{if(core.status.hero.loc.direction=="up"){core.status.hero.loc.direction="right"}else{if(core.status.hero.loc.direction=="right"){core.status.hero.loc.direction="down"}else{if(core.status.hero.loc.direction=="down"){core.status.hero.loc.direction="left"}else{if(core.status.hero.loc.direction=="left"){core.status.hero.loc.direction="up"}}}}}core.drawHero(core.status.hero.loc.direction,core.status.hero.loc.x,core.status.hero.loc.y,"stop",0,0);core.status.automaticRoutingTemp={destX:0,destY:0,moveStep:[]};core.canvas.ui.clearRect(0,0,416,416)};core.prototype.moveHero=function(a){core.setHeroLoc("direction",a);core.status.heroStop=false};core.prototype.moveOneStep=function(){if(core.hasFlag("poison")){core.status.hero.hp-=core.values.poisonDamage;if(core.status.hero.hp<=0){core.status.hero.hp=0;core.updateStatusBar();core.events.lose("poison");return}core.updateStatusBar()}};core.prototype.waitHeroToStop=function(a){core.stopAutomaticRoute();core.clearContinueAutomaticRoute();if(core.isset(a)){core.lockControl();setTimeout(function(){core.drawHero(core.getHeroLoc("direction"),core.getHeroLoc("x"),core.getHeroLoc("y"),"stop");a()},30)}};core.prototype.stopHero=function(){core.status.heroStop=true};core.prototype.drawHero=function(a,f,g,e,c,d){c=c||0;d=d||0;core.clearAutomaticRouteNode(f,g);var b=core.material.icons.heros[core.status.hero.id][a];f=f*32;g=g*32;core.canvas.hero.clearRect(f-32,g-32,96,96);core.canvas.hero.drawImage(core.material.images.heros,b[e]*32,b.loc*32,32,32,f+c,g+d,32,32)};core.prototype.openDoor=function(d,i,j,f,a){if(!core.terrainExists(i,j,d)){if(core.isset(a)){a()}return}if(core.status.moveStepBeforeStop.length==0){core.status.moveStepBeforeStop=core.status.autoStepRoutes.slice(core.status.autoStep-1,core.status.autoStepRoutes.length);if(core.status.moveStepBeforeStop.length>=1){core.status.moveStepBeforeStop[0].step-=core.status.movedStep}}core.stopHero();core.stopAutomaticRoute();var g=30;if(f){var e=d.replace("Door","Key");if(!core.rmItem(e)){if(e!="specialKey"){core.drawTip("你没有"+core.material.items[e].name)}else{core.drawTip("无法开启此门")}core.clearContinueAutomaticRoute();if(core.isset(a)){a()}return}}core.playSound("door","ogg");var h=0;var c=d;if(!(c.substring(c.length-4)=="Door")){c=c+"Door";g=100}var b=core.material.icons.animates[c];core.interval.openDoorAnimate=window.setInterval(function(){h++;if(h==4){clearInterval(core.interval.openDoorAnimate);core.removeBlock(i,j);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.prototype.battle=function(f,h,i,d,a){if(core.status.moveStepBeforeStop.length==0){core.status.moveStepBeforeStop=core.status.autoStepRoutes.slice(core.status.autoStep-1,core.status.autoStepRoutes.length);if(core.status.moveStepBeforeStop.length>=1){core.status.moveStepBeforeStop[0].step-=core.status.movedStep}}core.stopHero();core.stopAutomaticRoute();var b=core.enemys.getDamage(f);if(b>=core.status.hero.hp&&!d){core.drawTip("你打不过此怪物!");core.clearContinueAutomaticRoute();return}core.playSound("attack","ogg");core.status.hero.hp-=b;if(core.status.hero.hp<=0){core.status.hero.hp=0;core.updateStatusBar();core.events.lose("battle");return}var g=core.material.enemys[f].money;if(core.hasItem("coin")){g*=2}if(core.hasFlag("curse")){g=0}core.status.hero.money+=g;var c=core.material.enemys[f].experience;if(core.hasFlag("curse")){c=0}core.status.hero.experience+=c;core.updateStatusBar();if(core.isset(h)&&core.isset(i)){core.removeBlock(h,i);core.canvas.event.clearRect(32*h,32*i,32,32)}core.updateFg();var e="打败 "+core.material.enemys[f].name+",金币+"+g;if(core.flags.enableExperience){e+=",经验+"+core.material.enemys[f].experience}core.drawTip(e);core.events.afterBattle(f,h,i,a)};core.prototype.changeFloor=function(c,f,d,g,b){g=g||50;core.lockControl();core.stopHero();core.stopAutomaticRoute();core.clearContinueAutomaticRoute();core.dom.floorNameLabel.innerHTML=core.status.maps[c].title;if(core.isset(f)){d=core.status.hero.loc;var a=core.status.maps[c].blocks;for(var e in a){if(core.isset(a[e].event)&&!(core.isset(a[e].enable)&&!a[e].enable)&&a[e].event.id===f){d.x=a[e].x;d.y=a[e].y}}}if(core.status.maps[c].canFlyTo&&core.status.hero.flyRange.indexOf(c)<0){if(core.floorIds.indexOf(c)>core.floorIds.indexOf(core.status.floorId)){core.status.hero.flyRange.push(c)}else{core.status.hero.flyRange.unshift(c)}}window.setTimeout(function(){core.playSound("floor","mp3");core.mapChangeAnimate("show",g/2,function(){core.statusBar.floor.innerHTML=core.status.maps[c].name;core.updateStatusBar();core.drawMap(c,function(){setTimeout(function(){core.mapChangeAnimate("hide",g/4,function(){core.unLockControl();core.events.afterChangeFloor(c);if(core.isset(b)){b()}});if(core.isset(d.direction)){core.setHeroLoc("direction",d.direction)}core.setHeroLoc("x",d.x);core.setHeroLoc("y",d.y);core.drawHero(core.getHeroLoc("direction"),core.getHeroLoc("x"),core.getHeroLoc("y"),"stop");core.updateFg()},15)})})},50)};core.prototype.mapChangeAnimate=function(b,c,a){if(b=="show"){core.show(core.dom.floorMsgGroup,c,function(){a()})}else{core.hide(core.dom.floorMsgGroup,c,function(){a()})}};core.prototype.clearMap=function(c,e,f,d,a){if(c=="all"){for(var b in core.canvas){core.canvas[b].clearRect(0,0,416,416)}}else{core.canvas[c].clearRect(e,f,d,a)}};core.prototype.fillText=function(b,d,e,f,c,a){if(core.isset(c)){core.setFillStyle(b,c)}if(core.isset(a)){core.setFont(b,a)}core.canvas[b].fillText(d,e,f)};core.prototype.fillRect=function(b,e,f,d,a,c){if(core.isset(c)){core.setFillStyle(b,c)}core.canvas[b].fillRect(e,f,d,a)};core.prototype.strokeRect=function(c,f,g,e,a,d,b){if(core.isset(d)){core.setStrokeStyle(c,d)}if(core.isset(b)){core.setLineWidth(c,b)}core.canvas[c].strokeRect(f,g,e,a)};core.prototype.setFont=function(b,a){core.canvas[b].font=a};core.prototype.setLineWidth=function(c,a){if(c=="all"){for(var b in core.canvas){core.canvas[b].lineWidth=a}}core.canvas[c].lineWidth=a};core.prototype.saveCanvas=function(a){core.canvas[a].save()};core.prototype.loadCanvas=function(a){core.canvas[a].restore()};core.prototype.setAlpha=function(c,a){if(c=="all"){for(var b in core.canvas){core.canvas[b].globalAlpha=a}}core.canvas[c].globalAlpha=a};core.prototype.setStrokeStyle=function(b,c){if(b=="all"){for(var a in core.canvas){core.canvas[a].strokeStyle=c}}else{core.canvas[b].strokeStyle=c}};core.prototype.setAlpha=function(c,a){if(c=="all"){for(var b in core.canvas){core.canvas[b].globalAlpha=a}}else{core.canvas[c].globalAlpha=a}};core.prototype.setOpacity=function(b,c){if(b=="all"){for(var a in core.canvas){core.canvas[a].canvas.style.opacity=c}}else{core.canvas[b].canvas.style.opacity=c}};core.prototype.setFillStyle=function(b,c){if(b=="all"){for(var a in core.canvas){core.canvas[a].fillStyle=c}}else{core.canvas[b].fillStyle=c}};core.prototype.drawMap=function(h,e){var g=core.status.maps[h];var f=g.blocks;core.status.floorId=h;core.status.thisMap=g;var c,d;core.clearMap("all");core.rmGlobalAnimate(null,null,true);for(var i=0;i<13;i++){for(var j=0;j<13;j++){c=core.material.icons.terrains.ground;d=core.material.images.terrains;core.canvas.bg.drawImage(d,0,c*32,32,32,i*32,j*32,32,32)}}for(var a=0;a=0){a[d]={x:e,y:f,event:{cls:"terrains",id:"ground",noPass:false,trigger:"checkBlock"}};return}var b=core.floors[c].events[e+","+f];if(!core.isset(b)){b=core.floors[c].changeFloor[e+","+f]}if(!core.isset(b)){a.splice(d,1);return}a[d].enable=false};core.prototype.moveBlock=function(m,n,k,l,d,c){l=l||500;clearInterval(core.interval.tipAnimate);core.saveCanvas("data");core.clearMap("data",0,0,416,416);var b=core.getBlock(m,n,core.status.floorId,false);if(b==null){if(core.isset(c)){c()}return}core.removeBlock(m,n);core.clearMap("ui",0,0,416,416);core.setAlpha("ui",1);b=b.block;blockIcon=core.material.icons[b.event.cls][b.event.id];blockImage=core.material.images[b.event.cls];var h=1;core.setOpacity("data",h);core.canvas.data.drawImage(blockImage,0,blockIcon*32,32,32,b.x*32,b.y*32,32,32);var e=[];k.forEach(function(o){if(typeof o=="string"){e.push(o)}else{if(!core.isset(o.value)){e.push(o.direction)}else{for(var p=0;p=1||d<=0){clearInterval(a);core.loadCanvas("data");core.clearMap("data",0,0,416,416);core.setOpacity("data",1);if(core.isset(c)){c()}}},e/10)};core.prototype.addBlock=function(c,d,b){b=b||core.status.floorId;var a=core.getBlock(c,d,b,false);if(a==null){return}a=a.block;if(core.isset(a.enable)&&!a.enable){a.enable=true;if(b==core.status.floorId&&core.isset(a.event)){blockIcon=core.material.icons[a.event.cls][a.event.id];blockImage=core.material.images[a.event.cls];core.canvas.event.drawImage(core.material.images[a.event.cls],0,blockIcon*32,32,32,a.x*32,a.y*32,32,32);core.addGlobalAnimate(a.event.animate,a.x*32,a.y*32,blockIcon,blockImage);core.setGlobalAnimate(core.values.animateSpeed)}}};core.prototype.removeBlock=function(d,e,b){b=b||core.status.floorId;var a=core.getBlock(d,e,b,false);if(a==null){return}var c=a.index;if(b==core.status.floorId){core.rmGlobalAnimate(d,e);core.canvas.event.clearRect(d*32,e*32,32,32)}core.removeBlockById(c,b);core.updateFg()};core.prototype.removeBlockByIds=function(a,b){b.sort(function(c,d){return d-c}).forEach(function(c){core.removeBlockById(c,a)})};core.prototype.noPass=function(a,b){return a<0||a>12||b<0||b>12||core.noPassExists(a,b)};core.prototype.trigger=function(g,h){var d=core.status.thisMap.blocks;var e;for(var a=0;a0){var a=core.canvas.ui.createPattern(core.material.ground,"repeat");core.drawBoxAnimate(a);core.interval.boxAnimate=setInterval(function(){core.drawBoxAnimate(a)},core.values.animateSpeed)}};core.prototype.drawBoxAnimate=function(c){for(var b=0;b=999999999){d="???"}else{if(d>100000){d=(d/10000).toFixed(1)+"w"}}core.setFillStyle("fg","#000000");core.canvas.fg.fillText(d,32*h+2,32*(i+1)-2);core.canvas.fg.fillText(d,32*h,32*(i+1)-2);core.canvas.fg.fillText(d,32*h+2,32*(i+1));core.canvas.fg.fillText(d,32*h,32*(i+1));core.setFillStyle("fg",c);core.canvas.fg.fillText(d,32*h+1,32*(i+1)-1)}}};core.prototype.itemCount=function(b){if(!core.isset(b)||!core.isset(core.material.items[b])){return 0}var a=core.material.items[b].cls;if(a=="items"){return 0}return core.isset(core.status.hero.items[a][b])?core.status.hero.items[a][b]:0};core.prototype.hasItem=function(a){return core.itemCount(a)>0};core.prototype.setItem=function(b,c){var a=core.material.items[b].cls;if(a=="items"){return}if(!core.isset(core.status.hero.items[a])){core.status.hero.items[a]={}}core.status.hero.items[a][b]=c};core.prototype.rmItem=function(b){if(!core.hasItem(b)){return false}var a=core.material.items[b].cls;core.status.hero.items[a][b]--;core.updateStatusBar();if(a=="tools"&&core.status.hero.items[a][b]==0){delete core.status.hero.items[a][b]}return true};core.prototype.useItem=function(a){core.items.useItem(a);return};core.prototype.canUseItem=function(a){return core.items.canUseItem(a)};core.prototype.addItem=function(c,d){var b=core.material.items[c];var a=b.cls;if(a=="items"){return}if(!core.isset(core.status.hero.items[a])){core.status.hero.items[a]={};core.status.hero.items[a][c]=0}else{if(!core.isset(core.status.hero.items[a][c])){core.status.hero.items[a][c]=0}}core.status.hero.items[a][c]+=d};core.prototype.getItem=function(d,e,f,g,a){core.playSound("item","ogg");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()}}};core.prototype.drawTip=function(e,c){var f,g,h,a,b=false,d=0;clearInterval(core.interval.tipAnimate);core.setFont("data","16px Arial");core.saveCanvas("data");core.setOpacity("data",0);if(!core.isset(c)){f=16;g=18;h=f+core.canvas.data.measureText(e).width+16;a=42}else{f=44;g=18;h=f+core.canvas.data.measureText(e).width+8;a=42}core.interval.tipAnimate=window.setInterval(function(){if(b){d-=0.1}else{d+=0.1}core.setOpacity("data",d);core.clearMap("data",5,5,400,a);core.fillRect("data",5,5,h,a,"#000");if(core.isset(c)){core.canvas.data.drawImage(core.material.images.items,0,c*32,32,32,10,8,32,32)}core.fillText("data",e,f+5,g+15,"#fff");if(d>0.6||d<0){if(b){core.loadCanvas("data");core.clearMap("data",5,5,400,a);core.setOpacity("data",1);clearInterval(core.interval.tipAnimate);return}else{if(!core.timeout.getItemTipTimeout){core.timeout.getItemTipTimeout=window.setTimeout(function(){b=true;core.timeout.getItemTipTimeout=null},750)}d=0.6;core.setOpacity("data",d)}}},30)};core.prototype.drawText=function(b,a){if(core.isset(b)){if(typeof b=="string"){b=[{content:b}]}else{if(b instanceof Object&&core.isset(b.content)){b=[b]}else{if(!(b instanceof Array)){core.drawTip("出错了");console.log(b);return}}}core.status.event={id:"text",data:{list:b,callback:a}};core.lockControl();core.stopAutomaticRoute();setTimeout(function(){core.drawText()},30);return}if(core.status.event.data.list.length==0){var a=core.status.event.data.callback;core.ui.closePanel(false);if(core.isset(a)){a()}return}var c=core.status.event.data.list.shift();if(typeof c=="string"){core.ui.drawTextBox(c)}else{core.ui.drawTextBox(c.content,c.id)}};core.prototype.replaceText=function(a){return a.replace(/\${([^}]+)}/g,function(c,b){return core.calValue(b)})};core.prototype.calValue=function(value){value=value.replace(/status:([\w\d_]+)/g,"core.getStatus('$1')");value=value.replace(/item:([\w\d_]+)/g,"core.itemCount('$1')");value=value.replace(/flag:([\w\d_]+)/g,"core.getFlag('$1', false)");return eval(value)};core.prototype.unshift=function(c,d){if(!(c instanceof Array)||!core.isset(d)){return}if(d instanceof Array){core.clone(d).reverse().forEach(function(a){c.unshift(a)})}else{c.unshift(d)}return c};core.prototype.setLocalStorage=function(b,c){try{localStorage.setItem(core.firstData.name+"_"+b,JSON.stringify(c));return true}catch(a){console.log(a);return false}};core.prototype.getLocalStorage=function(b,a){var c=localStorage.getItem(core.firstData.name+"_"+b);if(core.isset(c)){return JSON.parse(c)}return a};core.prototype.removeLocalStorage=function(a){localStorage.removeItem(core.firstData.name+"_"+a)};core.prototype.clone=function(b){if(!core.isset(b)){return b}if(b instanceof Date){var a=new Date();a.setTime(b.getTime());return a}if(b instanceof Array){var a=[];for(var c in b){a[c]=core.clone(b[c])}return a}if(b instanceof Function){return b}if(b instanceof Object){var a={};for(var c in b){if(b.hasOwnProperty(c)){a[c]=core.clone(b[c])}}return a}return b};core.prototype.formatDate=function(a){if(!core.isset(a)){return""}return a.getFullYear()+"-"+core.setTwoDigits(a.getMonth()+1)+"-"+core.setTwoDigits(a.getDate())+" "+core.setTwoDigits(a.getHours())+":"+core.setTwoDigits(a.getMinutes())+":"+core.setTwoDigits(a.getSeconds())};core.prototype.setTwoDigits=function(a){return parseInt(a)<10?"0"+a:a};core.prototype.lose=function(){core.stopAutomaticRoute();if(!core.status.heroStop){setTimeout(function(){core.lose()},30);return}core.events.lose()};core.prototype.debug=function(){core.setStatus("hp",999999);core.setStatus("atk",10000);core.setStatus("def",10000);core.setStatus("mdef",10000);core.setStatus("money",10000);core.setStatus("experience",10000);core.setItem("yellowKey",50);core.setItem("blueKey",50);core.setItem("redKey",50);core.setItem("book",1);core.setItem("fly",1);for(var a in core.status.maps){if(core.status.maps[a].canFlyTo&&core.status.hero.flyRange.indexOf(a)<0){core.status.hero.flyRange.push(a)}}core.updateStatusBar();core.drawTip("作弊成功")};core.prototype.checkStatus=function(c,d,b,a){if(d&&core.status.event.id==c){core.ui.closePanel(a);return false}if(d&&core.status.lockControl){return false}if(core.isset(b)&&b&&!core.hasItem(c)){core.drawTip("你没有"+core.material.items[c].name);return false}if(!core.status.heroStop){core.drawTip("请先停止勇士行动");return false}core.lockControl();core.status.automaticRoutingTemp={destX:0,destY:0,moveStep:[]};core.status.event.id=c;return true};core.prototype.openBook=function(a){if(!core.checkStatus("book",a,true,true)){return}core.useItem("book")};core.prototype.useFly=function(a){if(!core.checkStatus("fly",a,true)){return}if(core.flags.flyNearStair&&!core.nearStair()){core.drawTip("只有在楼梯边才能使用传送器");core.unLockControl();core.status.event.data=null;core.status.event.id=null;return}if(!core.canUseItem("fly")){core.drawTip("楼层传送器好像失效了");core.unLockControl();core.status.event.data=null;core.status.event.id=null;return}core.useItem("fly");return};core.prototype.openToolbox=function(a){if(!core.checkStatus("toolbox",a)){return}core.ui.drawToolbox()};core.prototype.save=function(a){if(!core.checkStatus("save",a)){return}core.ui.drawSLPanel(core.status.savePage)};core.prototype.load=function(a){if(!core.isPlaying()){core.status.event={id:"load",data:null};core.status.lockControl=true;core.dom.startPanel.style.display="none";var b=core.getLocalStorage("savePage",0);core.ui.drawSLPanel(b);return}if(!core.checkStatus("load",a)){return}core.ui.drawSLPanel(core.status.savePage)};core.prototype.doSL=function(b,c){if(c=="save"){if(core.saveData("save"+b)){core.ui.closePanel();core.drawTip("存档成功!");core.setLocalStorage("savePage",core.status.savePage)}else{core.drawTip("存储空间不足,请覆盖已有的存档或在菜单栏中进行清理")}return}else{if(c=="load"){var a=core.getLocalStorage("save"+b,null);if(!core.isset(a)){core.drawTip("无效的存档");return}if(a.version!=core.firstData.version){core.drawTip("存档版本不匹配");return}core.ui.closePanel();core.loadData(a,function(){core.setLocalStorage("savePage",core.status.savePage);core.drawTip("读档成功")});return}}};core.prototype.saveData=function(b){var a={floorId:core.status.floorId,hero:core.clone(core.status.hero),hard:core.status.hard,maps:core.maps.save(core.status.maps),shops:{},version:core.firstData.version,time:new Date().getTime()};for(var c in core.status.shops){a.shops[c]={times:core.status.shops[c].times||0,visited:core.status.shops[c].visited||false}}core.events.beforeSaveData(a);return core.setLocalStorage(b,a)};core.prototype.loadData=function(b,a){core.resetStatus(b.hero,b.hard,b.floorId,core.maps.load(b.maps));for(var c in core.status.shops){core.status.shops[c].times=b.shops[c].times;core.status.shops[c].visited=b.shops[c].visited}core.events.afterLoadData(b);core.changeFloor(b.floorId,null,b.hero.loc,null,function(){core.setHeroMoveTriggerInterval();if(core.isset(a)){a()}})};core.prototype.setStatus=function(a,b){core.status.hero[a]=b};core.prototype.getStatus=function(a){return core.status.hero[a]};core.prototype.setFlag=function(a,b){if(!core.isset(core.status.hero)){return}core.status.hero.flags[a]=b};core.prototype.getFlag=function(b,a){if(!core.isset(core.status.hero)){return a}var c=core.status.hero.flags[b];if(core.isset(c)){return c}return a};core.prototype.hasFlag=function(a){if(core.getFlag(a)){return true}return false};core.prototype.lockControl=function(){core.status.lockControl=true};core.prototype.unLockControl=function(){core.status.lockControl=false};core.prototype.isset=function(a){if(a==undefined||a==null){return false}return true};core.prototype.playSound=function(a,b){if(!core.musicStatus.soundStatus||!core.musicStatus.loaded){return}if(!core.isset(core.material.sounds[b][a])){return}core.musicStatus.playedSound=core.material.sounds[b][a];core.musicStatus.playedSound.play()};core.prototype.playBgm=function(a,b){if(core.musicStatus.isIOS||!core.musicStatus.loaded){return}if(core.isset(core.musicStatus.playedBgm)){core.musicStatus.playedBgm.pause()}core.musicStatus.playedBgm=core.material.sounds[b][a];if(core.musicStatus.soundStatus){core.musicStatus.playedBgm.play()}};core.prototype.changeSoundStatus=function(){if(core.musicStatus.soundStatus){main.core.disabledSound()}else{main.core.enabledSound()}};core.prototype.enabledSound=function(){core.musicStatus.soundStatus=true;core.playBgm("bgm","mp3");core.setLocalStorage("soundStatus",true)};core.prototype.disabledSound=function(){core.musicStatus.playedBgm.pause();core.musicStatus.soundStatus=false;core.setLocalStorage("soundStatus",false)};core.prototype.show=function(b,e,a){if(!core.isset(e)){b.style.display="block";return}b.style.display="block";b.style.opacity=0;var c=0;var d=window.setInterval(function(){c+=0.03;b.style.opacity=c;if(c>1){clearInterval(d);if(core.isset(a)){a()}}},e)};core.prototype.hide=function(c,e,a){if(!core.isset(e)){c.style.display="none";return}var d=1;var b=window.setInterval(function(){d-=0.03;c.style.opacity=d;if(d<0){c.style.display="none";clearInterval(b);if(core.isset(a)){a()}}},e)};core.prototype.clearStatusBar=function(){var a=["floor","hp","atk","def","mdef","money","experience","yellowKey","blueKey","redKey","poison","weak","curse","hard"];a.forEach(function(b){core.statusBar[b].innerHTML=""});core.statusBar.image.book.style.opacity=0.3;core.statusBar.image.fly.style.opacity=0.3};core.prototype.updateStatusBar=function(){if(core.values.HPMAX>0){core.setStatus("hp",Math.min(core.values.HPMAX,core.getStatus("hp")))}var b=["hp","atk","def","mdef","money","experience"];b.forEach(function(c){core.statusBar[c].innerHTML=core.getStatus(c)});var a=["yellowKey","blueKey","redKey"];a.forEach(function(c){core.statusBar[c].innerHTML=core.setTwoDigits(core.status.hero.items.keys[c])});core.statusBar.poison.innerHTML=core.hasFlag("poison")?"毒":"";core.statusBar.weak.innerHTML=core.hasFlag("weak")?"衰":"";core.statusBar.curse.innerHTML=core.hasFlag("curse")?"咒":"";core.statusBar.hard.innerHTML=core.status.hard;if(core.hasItem("book")){core.statusBar.image.book.style.opacity=1}else{core.statusBar.image.book.style.opacity=0.3}if(core.hasItem("fly")){core.statusBar.image.fly.style.opacity=1}else{core.statusBar.image.fly.style.opacity=0.3}core.updateFg()};core.prototype.resize=function(d,c){var b=416;var k=83;var q=49;var l=132;var a=b+6;var s=d;var i=false;if(d>c&&c<422){i=true;s=c}if(s-1||j.indexOf("iPad")>-1){console.log("你的设备为iphone,不自动播放音乐!");core.musicStatus.isIOS=true;core.musicStatus.soundStatus=false}core.material.ground=new Image();core.material.ground.src="images/ground.png";core.loader(function(){console.log(core.material);core.showStartAnimate()})};core.prototype.showStartAnimate=function(a){core.dom.startPanel.style.opacity=1;core.dom.startPanel.style.display="block";core.dom.startTop.style.opacity=1;core.dom.startTop.style.display="block";core.dom.startButtonGroup.style.display="none";core.dom.startButtons.style.display="block";core.dom.levelChooseButtons.style.display="none";core.status.played=false;core.clearStatus();core.clearMap("all");var b=1;var c=window.setInterval(function(){b-=0.03;if(b<0){clearInterval(c);core.dom.startTop.style.display="none";core.dom.startButtonGroup.style.display="block";if(core.isset(a)){a()}}core.dom.startTop.style.opacity=b},20)};core.prototype.hideStartAnimate=function(a){var b=1;var c=window.setInterval(function(){b-=0.03;if(b<0){clearInterval(c);core.dom.startPanel.style.display="none";if(core.isset(a)){a()}}core.dom.startPanel.style.opacity=b},20)};core.prototype.setStartProgressVal=function(a){core.dom.startTopProgress.style.width=a+"%"};core.prototype.setStartLoadTipText=function(a){core.dom.startTopLoadTips.innerHTML=a};core.prototype.loader=function(c){var f=0,a=0,b=0;a=core.images.length;for(var e in core.sounds){b+=core.sounds[e].length}for(var d=0;d0){return}core.musicStatus.bgmStatus=1;if(core.musicStatus.soundStatus){core.playBgm("bgm","mp3")}return}var a=b.shift();a.oncanplay=function(){core.loadSoundItem(b)};a.load()};core.prototype.isPlaying=function(){if(core.isset(core.status.played)&&core.status.played){return true}return false};core.prototype.clearStatus=function(){for(var a in core.interval){clearInterval(core.interval[a])}core.status={};core.clearStatusBar();core.resize(main.dom.body.clientWidth,main.dom.body.clientHeight)};core.prototype.resetStatus=function(c,b,a,e){for(var d in core.interval){clearInterval(core.interval[d])}core.status=core.clone(core.initStatus);core.status.played=true;core.status.floorId=a;core.status.maps=core.clone(e);core.material.enemys=core.clone(core.enemys.getEnemys());core.status.hero=core.clone(c);core.status.hard=b;core.status.savePage=core.getLocalStorage("savePage",0);core.resize(main.dom.body.clientWidth,main.dom.body.clientHeight)};core.prototype.startGame=function(b,a){console.log("开始游戏");core.resetStatus(core.firstData.hero,b,core.firstData.floorId,core.initStatus.maps);core.changeFloor(core.status.floorId,null,core.firstData.hero.loc,null,function(){core.setHeroMoveTriggerInterval();if(core.isset(a)){a()}})};core.prototype.restart=function(){core.showStartAnimate()};core.prototype.onkeyDown=function(a){if(!core.isset(core.status.holdingKeys)){core.status.holdingKeys=[]}var c={37:true,38:true,39:true,40:true}[a.keyCode];if(c){for(var b=0;bd){c=b;d=a[b]}}e=[{x:0,y:1},{x:-1,y:0},{x:0,y:-1},{x:1,y:0},false][c];if(e){e.x+=f.x;e.y+=f.y;core.status.stepPostfix.push(e);core.fillPosWithPoint(e)}};core.prototype.onup=function(){core.status.holdingPath=0;if(core.status.stepPostfix.length>0){var g=[];var a={"0":{"1":"down","-1":"up"},"-1":{"0":"left"},"1":{"0":"right"}};for(var b=1;b12||c>12){return}if(!core.status.lockControl){core.setAutomaticRoute(b,c,a);return}if(core.status.event.id=="book"){core.events.clickBook(b,c);return}if(core.status.event.id=="fly"){core.events.clickFly(b,c);return}if(core.status.event.id=="settings"){core.events.clickSettings(b,c);return}if(core.status.event.id=="shop"){core.events.clickShop(b,c);return}if(core.status.event.id=="selectShop"){core.events.clickQuickShop(b,c);return}if(core.status.event.id=="toolbox"){core.events.clickToolbox(b,c);return}if(core.status.event.id=="save"||core.status.event.id=="load"){core.events.clickSL(b,c);return}if(core.status.event.id=="confirmBox"){if((b==4||b==5)&&c==7&&core.isset(core.status.event.data.yes)){core.status.event.data.yes()}if((b==7||b==8)&&c==7&&core.isset(core.status.event.data.no)){core.status.event.data.no()}return}if(core.status.event.id=="about"){if(core.isPlaying()){core.ui.closePanel(false)}else{core.showStartAnimate()}return}if(core.status.event.id=="action"){core.events.clickAction(b,c);return}if(core.status.event.id=="text"){core.drawText();return}if(core.status.event.id=="syncSave"){if(b>=4&&b<=8){if(c==5){core.ui.drawConfirmBox("你确定要将本地存档同步到服务器吗?",function(){core.ui.drawWaiting("正在同步,请稍后...");var e=new FormData();e.append("type","save");e.append("name",core.firstData.name);var h=[];for(var f=1;f<=180;f++){var d=core.getLocalStorage("save"+f,null);if(core.isset(d)){h.push(d)}}var g=JSON.stringify(h);e.append("data",g);var j=new XMLHttpRequest();j.open("POST","../sync.php");j.timeout=1000;j.onload=function(i){if(j.status==200){var k=JSON.parse(j.response);if(k.code<0){core.drawText("出错啦!\n无法同步存档到服务器。")}else{core.drawText("同步成功!\n\n您的存档编号: "+k.code+"\n您的存档密码: "+k.msg+"\n\n请牢记以上两个信息(如截图等),在从服务器\n同步存档时使用。")}}else{core.drawText("出错啦!\n无法同步存档到服务器。")}};j.ontimeout=function(i){console.log(i);core.drawText("出错啦!\n无法同步存档到服务器。")};j.onerror=function(i){console.log(i);core.drawText("出错啦!\n无法同步存档到服务器。")};j.send(e)},function(){core.ui.drawSyncSave()})}if(c==6){core.ui.drawConfirmBox("你确定要从服务器加载存档吗?\n该操作将覆盖所有本地存档且不可逆!",function(){var e=prompt("请输入存档编号:");if(e==null||e==""){core.ui.drawSyncSave();return}var f=prompt("请输入存档密码:");if(f==null||f==""){core.ui.drawSyncSave();return}core.ui.drawWaiting("正在同步,请稍后...");var d=new FormData();d.append("type","load");d.append("name",core.firstData.name);d.append("id",e);d.append("password",f);var g=new XMLHttpRequest();g.open("POST","../sync.php");g.timeout=1000;g.onload=function(j){if(g.status==200){var l=JSON.parse(g.response);switch(l.code){case 0:var h=JSON.parse(l.msg);for(var k=1;k<=180;k++){if(k<=h.length){core.setLocalStorage("save"+k,h[k-1])}else{core.removeLocalStorage("save"+k)}}core.drawText("同步成功!\n你的本地所有存档均已被覆盖。");break;case -1:core.drawText("出错啦!\n存档编号"+e+"不存在!");break;case -2:core.drawText("出错啦!\n存档密码错误!");break;default:core.drawText("出错啦!\n无法从服务器同步存档。");break}}else{core.drawText("出错啦!\n无法从服务器同步存档。")}};g.ontimeout=function(h){console.log(h);core.drawText("出错啦!\n无法从服务器同步存档。")};g.onerror=function(h){console.log(h);core.drawText("出错啦!\n无法从服务器同步存档。")};g.send(d)},function(){core.ui.drawSyncSave()})}}if(b>=5&&b<=7&&c==7){core.ui.drawSettings(false)}}};core.prototype.onmousewheel=function(a){if(core.status.lockControl&&core.status.event.id=="fly"){if(a==-1){core.ui.drawFly(core.status.event.data-1)}if(a==1){core.ui.drawFly(core.status.event.data+1)}return}};core.prototype.clearAutomaticRouteNode=function(a,b){core.canvas.ui.clearRect(a*32+5,b*32+5,27,27)};core.prototype.stopAutomaticRoute=function(){if(!core.status.played){return}core.stopAutoHeroMove();core.status.automaticRouting=false;core.status.automaticRouted=false;core.status.autoStepRoutes=[];core.status.automaticRoutingTemp={destX:0,destY:0,moveStep:[]};if(core.status.moveStepBeforeStop.length==0){core.canvas.ui.clearRect(0,0,416,416)}};core.prototype.continueAutomaticRoute=function(){var a=core.status.moveStepBeforeStop;core.status.moveStepBeforeStop=[];if(a.length===0){return}if(a.length===1&&a[0].step===1){return}core.status.automaticRouting=true;core.setAutoHeroMove(a)};core.prototype.clearContinueAutomaticRoute=function(){core.canvas.ui.clearRect(0,0,416,416);core.status.moveStepBeforeStop=[]};core.prototype.setAutomaticRoute=function(a,b,f){if(!core.status.played||core.status.lockControl){return}else{if(core.status.automaticRouting){core.stopAutomaticRoute();return}}if(a==core.status.hero.loc.x&&b==core.status.hero.loc.y&&f.length==0){core.turnHero();return}var e=0;var g=null;var d;core.status.automaticRoutingTemp={destX:0,destY:0,moveStep:[]};if(!(d=core.automaticRoute(a,b))){if(a==core.status.hero.loc.x&&b==core.status.hero.loc.y){d=[]}else{core.canvas.ui.clearRect(0,0,416,416);return}}d=d.concat(f);core.status.automaticRoutingTemp.destX=a;core.status.automaticRoutingTemp.destY=b;core.canvas.ui.save();core.canvas.ui.clearRect(0,0,416,416);core.canvas.ui.fillStyle="#bfbfbf";core.canvas.ui.strokeStyle="#bfbfbf";core.canvas.ui.lineWidth=8;for(var c=0;c12||q<0||q>12){continue}var l=13*p+q;if(core.isset(s[l])){continue}if(p==e&&q==g){s[l]=i;break}if(core.noPassExists(p,q)){continue}var d=1;var b=core.getBlock(p,q);if(b!=null){var k=b.block.event.id;if(k.substring(k.length-3)=="Net"){d=100}if(!core.flags.potionWhileRouting&&k.substring(k.length-6)=="Potion"){d=20}if(b.block.event.trigger=="checkBlock"){d=200}}s[l]=i;r.push(169*(m+d)+l)}if(core.isset(s[13*e+g])){break}}if(!core.isset(s[13*e+g])){return false}var n=e,o=g;while(n!=u||o!=v){var h=s[13*n+o];a.push({direction:h,x:n,y:o});n-=t[h].x;o-=t[h].y}a.reverse();return a};core.prototype.fillPosWithPoint=function(a){core.fillRect("ui",a.x*32+12,a.y*32+12,8,8,"#bfbfbf")};core.prototype.clearStepPostfix=function(){if(core.status.mouseOutCheck>0){core.status.mouseOutCheck--;window.setTimeout(core.clearStepPostfix,1000);return}core.status.holdingPath=0;if(core.status.stepPostfix.length>0){core.status.stepPostfix=[];core.canvas.ui.clearRect(0,0,416,416);core.canvas.ui.restore()}};core.prototype.stopAutoHeroMove=function(){core.status.autoHeroMove=false;core.status.automaticRouting=false;core.status.automaticRouted=false;core.status.autoStep=0;core.status.destStep=0;core.status.movedStep=0;core.status.autoStepRoutes=[];core.stopHero();clearInterval(core.interval.heroAutoMoveScan)};core.prototype.setAutoHeroMove=function(b,a){if(b.length==0){return}core.status.autoStepRoutes=b;core.status.autoStep=0;clearInterval(core.interval.heroAutoMoveScan);core.interval.heroAutoMoveScan=window.setInterval(function(){if(!core.status.autoHeroMove){if(core.status.autoStep==core.status.autoStepRoutes.length){core.stopAutoHeroMove();return}core.autoHeroMove(core.status.autoStepRoutes[core.status.autoStep].direction,core.status.autoStepRoutes[core.status.autoStep].step);core.status.autoStep++}},80)};core.prototype.autoHeroMove=function(a,b){core.status.autoHeroMove=true;core.status.destStep=b;core.moveHero(a)};core.prototype.setHeroMoveInterval=function(b,d,e,a){if(core.status.heroMoving){return}core.status.heroMoving=true;var c=0;core.interval.heroMoveInterval=window.setInterval(function(){switch(b){case"up":c-=4;if(c==-4||c==-8||c==-12||c==-16){core.drawHero(b,d,e,"leftFoot",0,c)}else{if(c==-20||c==-24||c==-28||c==-32){core.drawHero(b,d,e,"rightFoot",0,c)}}if(c==-32){core.setHeroLoc("y","--");core.moveOneStep();if(core.status.heroStop){core.drawHero(b,d,e-1,"stop")}if(core.isset(a)){a()}}break;case"left":c-=4;if(c==-4||c==-8||c==-12||c==-16){core.drawHero(b,d,e,"leftFoot",c)}else{if(c==-20||c==-24||c==-28||c==-32){core.drawHero(b,d,e,"rightFoot",c)}}if(c==-32){core.setHeroLoc("x","--");core.moveOneStep();if(core.status.heroStop){core.drawHero(b,d-1,e,"stop")}if(core.isset(a)){a()}}break;case"down":c+=4;if(c==4||c==8||c==12||c==16){core.drawHero(b,d,e,"leftFoot",0,c)}else{if(c==20||c==24||c==28||c==32){core.drawHero(b,d,e,"rightFoot",0,c)}}if(c==32){core.setHeroLoc("y","++");core.moveOneStep();if(core.status.heroStop){core.drawHero(b,d,e+1,"stop")}if(core.isset(a)){a()}}break;case"right":c+=4;if(c==4||c==8||c==12||c==16){core.drawHero(b,d,e,"leftFoot",c)}else{if(c==20||c==24||c==28||c==32){core.drawHero(b,d,e,"rightFoot",c)}}if(c==32){core.setHeroLoc("x","++");core.moveOneStep();if(core.status.heroStop){core.drawHero(b,d+1,e,"stop")}if(core.isset(a)){a()}}break}},10)};core.prototype.setHeroMoveTriggerInterval=function(){var a,c,d;var b={up:{x:0,y:-1},left:{x:-1,y:0},down:{x:0,y:1},right:{x:1,y:0}};core.interval.heroMoveTriggerInterval=window.setInterval(function(){if(!core.status.heroStop){a=core.getHeroLoc("direction");c=core.getHeroLoc("x");d=core.getHeroLoc("y");var e;e=core.noPass(c+b[a].x,d+b[a].y);if(e){core.trigger(c+b[a].x,d+b[a].y);core.drawHero(a,c,d,"stop");if(core.status.autoHeroMove){core.status.movedStep++;if(core.status.destStep==core.status.movedStep){core.status.autoHeroMove=false;core.status.destStep=0;core.status.movedStep=0;core.status.moveStepBeforeStop=[];core.stopAutomaticRoute()}}else{core.status.heroStop=true}return}core.setHeroMoveInterval(a,c,d,function(){if(core.status.autoHeroMove){core.status.movedStep++;if(core.status.destStep==core.status.movedStep){core.status.autoHeroMove=false;core.status.destStep=0;core.status.movedStep=0;core.stopHero();core.drawHero(core.getHeroLoc("direction"),core.getHeroLoc("x"),core.getHeroLoc("y"),"stop")}}else{if(core.status.heroStop){core.drawHero(core.getHeroLoc("direction"),core.getHeroLoc("x"),core.getHeroLoc("y"),"stop")}}core.trigger(core.getHeroLoc("x"),core.getHeroLoc("y"));clearInterval(core.interval.heroMoveInterval);core.status.heroMoving=false})}},50)};core.prototype.turnHero=function(a){if(core.isset(a)){core.status.hero.loc.direction=a}else{if(core.status.hero.loc.direction=="up"){core.status.hero.loc.direction="right"}else{if(core.status.hero.loc.direction=="right"){core.status.hero.loc.direction="down"}else{if(core.status.hero.loc.direction=="down"){core.status.hero.loc.direction="left"}else{if(core.status.hero.loc.direction=="left"){core.status.hero.loc.direction="up"}}}}}core.drawHero(core.status.hero.loc.direction,core.status.hero.loc.x,core.status.hero.loc.y,"stop",0,0);core.status.automaticRoutingTemp={destX:0,destY:0,moveStep:[]};core.canvas.ui.clearRect(0,0,416,416)};core.prototype.moveHero=function(a){core.setHeroLoc("direction",a);core.status.heroStop=false};core.prototype.moveOneStep=function(){if(core.hasFlag("poison")){core.status.hero.hp-=core.values.poisonDamage;if(core.status.hero.hp<=0){core.status.hero.hp=0;core.updateStatusBar();core.events.lose("poison");return}core.updateStatusBar()}};core.prototype.waitHeroToStop=function(a){core.stopAutomaticRoute();core.clearContinueAutomaticRoute();if(core.isset(a)){core.lockControl();setTimeout(function(){core.drawHero(core.getHeroLoc("direction"),core.getHeroLoc("x"),core.getHeroLoc("y"),"stop");a()},30)}};core.prototype.stopHero=function(){core.status.heroStop=true};core.prototype.drawHero=function(a,f,g,e,c,d){c=c||0;d=d||0;core.clearAutomaticRouteNode(f,g);var b=core.material.icons.heros[core.status.hero.id][a];f=f*32;g=g*32;core.canvas.hero.clearRect(f-32,g-32,96,96);core.canvas.hero.drawImage(core.material.images.heros,b[e]*32,b.loc*32,32,32,f+c,g+d,32,32)};core.prototype.openDoor=function(d,i,j,f,a){if(!core.terrainExists(i,j,d)){if(core.isset(a)){a()}return}if(core.status.moveStepBeforeStop.length==0){core.status.moveStepBeforeStop=core.status.autoStepRoutes.slice(core.status.autoStep-1,core.status.autoStepRoutes.length);if(core.status.moveStepBeforeStop.length>=1){core.status.moveStepBeforeStop[0].step-=core.status.movedStep}}core.stopHero();core.stopAutomaticRoute();var g=30;if(f){var e=d.replace("Door","Key");if(!core.removeItem(e)){if(e!="specialKey"){core.drawTip("你没有"+core.material.items[e].name)}else{core.drawTip("无法开启此门")}core.clearContinueAutomaticRoute();if(core.isset(a)){a()}return}}core.playSound("door","ogg");var h=0;var c=d;if(!(c.substring(c.length-4)=="Door")){c=c+"Door";g=100}var b=core.material.icons.animates[c];core.interval.openDoorAnimate=window.setInterval(function(){h++;if(h==4){clearInterval(core.interval.openDoorAnimate);core.removeBlock(i,j);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.prototype.battle=function(f,h,i,d,a){if(core.status.moveStepBeforeStop.length==0){core.status.moveStepBeforeStop=core.status.autoStepRoutes.slice(core.status.autoStep-1,core.status.autoStepRoutes.length);if(core.status.moveStepBeforeStop.length>=1){core.status.moveStepBeforeStop[0].step-=core.status.movedStep}}core.stopHero();core.stopAutomaticRoute();var b=core.enemys.getDamage(f);if(b>=core.status.hero.hp&&!d){core.drawTip("你打不过此怪物!");core.clearContinueAutomaticRoute();return}core.playSound("attack","ogg");core.status.hero.hp-=b;if(core.status.hero.hp<=0){core.status.hero.hp=0;core.updateStatusBar();core.events.lose("battle");return}var g=core.material.enemys[f].money;if(core.hasItem("coin")){g*=2}if(core.hasFlag("curse")){g=0}core.status.hero.money+=g;var c=core.material.enemys[f].experience;if(core.hasFlag("curse")){c=0}core.status.hero.experience+=c;core.updateStatusBar();if(core.isset(h)&&core.isset(i)){core.removeBlock(h,i);core.canvas.event.clearRect(32*h,32*i,32,32)}core.updateFg();var e="打败 "+core.material.enemys[f].name+",金币+"+g;if(core.flags.enableExperience){e+=",经验+"+core.material.enemys[f].experience}core.drawTip(e);core.events.afterBattle(f,h,i,a)};core.prototype.changeFloor=function(c,f,d,g,b){g=g||50;core.lockControl();core.stopHero();core.stopAutomaticRoute();core.clearContinueAutomaticRoute();core.dom.floorNameLabel.innerHTML=core.status.maps[c].title;if(core.isset(f)){d=core.status.hero.loc;var a=core.status.maps[c].blocks;for(var e in a){if(core.isset(a[e].event)&&!(core.isset(a[e].enable)&&!a[e].enable)&&a[e].event.id===f){d.x=a[e].x;d.y=a[e].y}}}if(core.status.maps[c].canFlyTo&&core.status.hero.flyRange.indexOf(c)<0){if(core.floorIds.indexOf(c)>core.floorIds.indexOf(core.status.floorId)){core.status.hero.flyRange.push(c)}else{core.status.hero.flyRange.unshift(c)}}window.setTimeout(function(){core.playSound("floor","mp3");core.mapChangeAnimate("show",g/2,function(){core.statusBar.floor.innerHTML=core.status.maps[c].name;core.updateStatusBar();core.drawMap(c,function(){setTimeout(function(){core.mapChangeAnimate("hide",g/4,function(){core.unLockControl();core.events.afterChangeFloor(c);if(core.isset(b)){b()}});if(core.isset(d.direction)){core.setHeroLoc("direction",d.direction)}core.setHeroLoc("x",d.x);core.setHeroLoc("y",d.y);core.drawHero(core.getHeroLoc("direction"),core.getHeroLoc("x"),core.getHeroLoc("y"),"stop");core.updateFg()},15)})})},50)};core.prototype.mapChangeAnimate=function(b,c,a){if(b=="show"){core.show(core.dom.floorMsgGroup,c,function(){a()})}else{core.hide(core.dom.floorMsgGroup,c,function(){a()})}};core.prototype.clearMap=function(c,e,f,d,a){if(c=="all"){for(var b in core.canvas){core.canvas[b].clearRect(0,0,416,416)}}else{core.canvas[c].clearRect(e,f,d,a)}};core.prototype.fillText=function(b,d,e,f,c,a){if(core.isset(c)){core.setFillStyle(b,c)}if(core.isset(a)){core.setFont(b,a)}core.canvas[b].fillText(d,e,f)};core.prototype.fillRect=function(b,e,f,d,a,c){if(core.isset(c)){core.setFillStyle(b,c)}core.canvas[b].fillRect(e,f,d,a)};core.prototype.strokeRect=function(c,f,g,e,a,d,b){if(core.isset(d)){core.setStrokeStyle(c,d)}if(core.isset(b)){core.setLineWidth(c,b)}core.canvas[c].strokeRect(f,g,e,a)};core.prototype.setFont=function(b,a){core.canvas[b].font=a};core.prototype.setLineWidth=function(c,a){if(c=="all"){for(var b in core.canvas){core.canvas[b].lineWidth=a}}core.canvas[c].lineWidth=a};core.prototype.saveCanvas=function(a){core.canvas[a].save()};core.prototype.loadCanvas=function(a){core.canvas[a].restore()};core.prototype.setAlpha=function(c,a){if(c=="all"){for(var b in core.canvas){core.canvas[b].globalAlpha=a}}core.canvas[c].globalAlpha=a};core.prototype.setStrokeStyle=function(b,c){if(b=="all"){for(var a in core.canvas){core.canvas[a].strokeStyle=c}}else{core.canvas[b].strokeStyle=c}};core.prototype.setAlpha=function(c,a){if(c=="all"){for(var b in core.canvas){core.canvas[b].globalAlpha=a}}else{core.canvas[c].globalAlpha=a}};core.prototype.setOpacity=function(b,c){if(b=="all"){for(var a in core.canvas){core.canvas[a].canvas.style.opacity=c}}else{core.canvas[b].canvas.style.opacity=c}};core.prototype.setFillStyle=function(b,c){if(b=="all"){for(var a in core.canvas){core.canvas[a].fillStyle=c}}else{core.canvas[b].fillStyle=c}};core.prototype.drawMap=function(h,e){var g=core.status.maps[h];var f=g.blocks;core.status.floorId=h;core.status.thisMap=g;var c,d;core.clearMap("all");core.removeGlobalAnimate(null,null,true);for(var i=0; i<13; i++){for(var j=0; j<13; j++){c=core.material.icons.terrains.ground;d=core.material.images.terrains;core.canvas.bg.drawImage(d,0,c*32,32,32,i*32,j*32,32,32)}}for(var a=0; a=0){a[d]={x:e,y:f,event:{cls:"terrains",id:"ground",noPass:false,trigger:"checkBlock"}};return}var b=core.floors[c].events[e+","+f];if(!core.isset(b)){b=core.floors[c].changeFloor[e+","+f]}if(!core.isset(b)){a.splice(d,1);return}a[d].enable=false};core.prototype.moveBlock=function(m,n,k,l,d,c){l=l||500;clearInterval(core.interval.tipAnimate);core.saveCanvas("data");core.clearMap("data",0,0,416,416);var b=core.getBlock(m,n,core.status.floorId,false);if(b==null){if(core.isset(c)){c()}return}core.removeBlock(m,n);core.clearMap("ui",0,0,416,416);core.setAlpha("ui",1);b=b.block;blockIcon=core.material.icons[b.event.cls][b.event.id];blockImage=core.material.images[b.event.cls];var h=1;core.setOpacity("data",h);core.canvas.data.drawImage(blockImage,0,blockIcon*32,32,32,b.x*32,b.y*32,32,32);var e=[];k.forEach(function(o){if(typeof o=="string"){e.push(o)}else{if(!core.isset(o.value)){e.push(o.direction)}else{for(var p=0;p=1||d<=0){clearInterval(a);core.loadCanvas("data");core.clearMap("data",0,0,416,416);core.setOpacity("data",1);if(core.isset(c)){c()}}},e/10)};core.prototype.addBlock=function(c,d,b){b=b||core.status.floorId;var a=core.getBlock(c,d,b,false);if(a==null){return}a=a.block;if(core.isset(a.enable)&&!a.enable){a.enable=true;if(b==core.status.floorId&&core.isset(a.event)){blockIcon=core.material.icons[a.event.cls][a.event.id];blockImage=core.material.images[a.event.cls];core.canvas.event.drawImage(core.material.images[a.event.cls],0,blockIcon*32,32,32,a.x*32,a.y*32,32,32);core.addGlobalAnimate(a.event.animate,a.x*32,a.y*32,blockIcon,blockImage);core.setGlobalAnimate(core.values.animateSpeed)}}};core.prototype.removeBlock=function(d, e, b){b=b||core.status.floorId;var a=core.getBlock(d,e,b,false);if(a==null){return}var c=a.index;if(b==core.status.floorId){core.removeGlobalAnimate(d,e);core.canvas.event.clearRect(d*32,e*32,32,32)}core.removeBlockById(c,b);core.updateFg()};core.prototype.removeBlockByIds=function(a, b){b.sort(function(c, d){return d-c}).forEach(function(c){core.removeBlockById(c,a)})};core.prototype.noPass=function(a, b){return a<0||a>12||b<0||b>12||core.noPassExists(a,b)};core.prototype.trigger=function(g, h){var d=core.status.thisMap.blocks;var e;for(var a=0; a0){var a=core.canvas.ui.createPattern(core.material.ground,"repeat");core.drawBoxAnimate(a);core.interval.boxAnimate=setInterval(function(){core.drawBoxAnimate(a)},core.values.animateSpeed)}};core.prototype.drawBoxAnimate=function(c){for(var b=0;b=999999999){d="???"}else{if(d>100000){d=(d/10000).toFixed(1)+"w"}}core.setFillStyle("fg","#000000");core.canvas.fg.fillText(d,32*h+2,32*(i+1)-2);core.canvas.fg.fillText(d,32*h,32*(i+1)-2);core.canvas.fg.fillText(d,32*h+2,32*(i+1));core.canvas.fg.fillText(d,32*h,32*(i+1));core.setFillStyle("fg",c);core.canvas.fg.fillText(d,32*h+1,32*(i+1)-1)}}};core.prototype.itemCount=function(b){if(!core.isset(b)||!core.isset(core.material.items[b])){return 0}var a=core.material.items[b].cls;if(a=="items"){return 0}return core.isset(core.status.hero.items[a][b])?core.status.hero.items[a][b]:0};core.prototype.hasItem=function(a){return core.itemCount(a)>0};core.prototype.setItem=function(b, c){var a=core.material.items[b].cls;if(a=="items"){return}if(!core.isset(core.status.hero.items[a])){core.status.hero.items[a]={}}core.status.hero.items[a][b]=c};core.prototype.removeItem=function(b){if(!core.hasItem(b)){return false}var a=core.material.items[b].cls;core.status.hero.items[a][b]--;core.updateStatusBar();if(a=="tools"&&core.status.hero.items[a][b]==0){delete core.status.hero.items[a][b]}return true};core.prototype.useItem=function(a){core.items.useItem(a);return};core.prototype.canUseItem=function(a){return core.items.canUseItem(a)};core.prototype.addItem=function(c, d){var b=core.material.items[c];var a=b.cls;if(a=="items"){return}if(!core.isset(core.status.hero.items[a])){core.status.hero.items[a]={};core.status.hero.items[a][c]=0}else{if(!core.isset(core.status.hero.items[a][c])){core.status.hero.items[a][c]=0}}core.status.hero.items[a][c]+=d};core.prototype.getItem=function(d,e,f,g,a){core.playSound("item","ogg");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()}}};core.prototype.drawTip=function(e,c){var f,g,h,a,b=false,d=0;clearInterval(core.interval.tipAnimate);core.setFont("data","16px Arial");core.saveCanvas("data");core.setOpacity("data",0);if(!core.isset(c)){f=16;g=18;h=f+core.canvas.data.measureText(e).width+16;a=42}else{f=44;g=18;h=f+core.canvas.data.measureText(e).width+8;a=42}core.interval.tipAnimate=window.setInterval(function(){if(b){d-=0.1}else{d+=0.1}core.setOpacity("data",d);core.clearMap("data",5,5,400,a);core.fillRect("data",5,5,h,a,"#000");if(core.isset(c)){core.canvas.data.drawImage(core.material.images.items,0,c*32,32,32,10,8,32,32)}core.fillText("data",e,f+5,g+15,"#fff");if(d>0.6||d<0){if(b){core.loadCanvas("data");core.clearMap("data",5,5,400,a);core.setOpacity("data",1);clearInterval(core.interval.tipAnimate);return}else{if(!core.timeout.getItemTipTimeout){core.timeout.getItemTipTimeout=window.setTimeout(function(){b=true;core.timeout.getItemTipTimeout=null},750)}d=0.6;core.setOpacity("data",d)}}},30)};core.prototype.drawText=function(b,a){if(core.isset(b)){if(typeof b=="string"){b=[{content:b}]}else{if(b instanceof Object&&core.isset(b.content)){b=[b]}else{if(!(b instanceof Array)){core.drawTip("出错了");console.log(b);return}}}core.status.event={id:"text",data:{list:b,callback:a}};core.lockControl();core.stopAutomaticRoute();setTimeout(function(){core.drawText()},30);return}if(core.status.event.data.list.length==0){var a=core.status.event.data.callback;core.ui.closePanel(false);if(core.isset(a)){a()}return}var c=core.status.event.data.list.shift();if(typeof c=="string"){core.ui.drawTextBox(c)}else{core.ui.drawTextBox(c.content,c.id)}};core.prototype.replaceText=function(a){return a.replace(/\${([^}]+)}/g,function(c,b){return core.calValue(b)})};core.prototype.calValue=function(value){value=value.replace(/status:([\w\d_]+)/g,"core.getStatus('$1')");value=value.replace(/item:([\w\d_]+)/g,"core.itemCount('$1')");value=value.replace(/flag:([\w\d_]+)/g,"core.getFlag('$1', false)");return eval(value)};core.prototype.unshift=function(c,d){if(!(c instanceof Array)||!core.isset(d)){return}if(d instanceof Array){core.clone(d).reverse().forEach(function(a){c.unshift(a)})}else{c.unshift(d)}return c};core.prototype.setLocalStorage=function(b,c){try{localStorage.setItem(core.firstData.name+"_"+b,JSON.stringify(c));return true}catch(a){console.log(a);return false}};core.prototype.getLocalStorage=function(b,a){var c=localStorage.getItem(core.firstData.name+"_"+b);if(core.isset(c)){return JSON.parse(c)}return a};core.prototype.removeLocalStorage=function(a){localStorage.removeItem(core.firstData.name+"_"+a)};core.prototype.clone=function(b){if(!core.isset(b)){return b}if(b instanceof Date){var a=new Date();a.setTime(b.getTime());return a}if(b instanceof Array){var a=[];for(var c in b){a[c]=core.clone(b[c])}return a}if(b instanceof Function){return b}if(b instanceof Object){var a={};for(var c in b){if(b.hasOwnProperty(c)){a[c]=core.clone(b[c])}}return a}return b};core.prototype.formatDate=function(a){if(!core.isset(a)){return""}return a.getFullYear()+"-"+core.setTwoDigits(a.getMonth()+1)+"-"+core.setTwoDigits(a.getDate())+" "+core.setTwoDigits(a.getHours())+":"+core.setTwoDigits(a.getMinutes())+":"+core.setTwoDigits(a.getSeconds())};core.prototype.setTwoDigits=function(a){return parseInt(a)<10?"0"+a:a};core.prototype.lose=function(){core.stopAutomaticRoute();if(!core.status.heroStop){setTimeout(function(){core.lose()},30);return}core.events.lose()};core.prototype.debug=function(){core.setStatus("hp",999999);core.setStatus("atk",10000);core.setStatus("def",10000);core.setStatus("mdef",10000);core.setStatus("money",10000);core.setStatus("experience",10000);core.setItem("yellowKey",50);core.setItem("blueKey",50);core.setItem("redKey",50);core.setItem("book",1);core.setItem("fly",1);for(var a in core.status.maps){if(core.status.maps[a].canFlyTo&&core.status.hero.flyRange.indexOf(a)<0){core.status.hero.flyRange.push(a)}}core.updateStatusBar();core.drawTip("作弊成功")};core.prototype.checkStatus=function(c,d,b,a){if(d&&core.status.event.id==c){core.ui.closePanel(a);return false}if(d&&core.status.lockControl){return false}if(core.isset(b)&&b&&!core.hasItem(c)){core.drawTip("你没有"+core.material.items[c].name);return false}if(!core.status.heroStop){core.drawTip("请先停止勇士行动");return false}core.lockControl();core.status.automaticRoutingTemp={destX:0,destY:0,moveStep:[]};core.status.event.id=c;return true};core.prototype.openBook=function(a){if(!core.checkStatus("book",a,true,true)){return}core.useItem("book")};core.prototype.useFly=function(a){if(!core.checkStatus("fly",a,true)){return}if(core.flags.flyNearStair&&!core.nearStair()){core.drawTip("只有在楼梯边才能使用传送器");core.unLockControl();core.status.event.data=null;core.status.event.id=null;return}if(!core.canUseItem("fly")){core.drawTip("楼层传送器好像失效了");core.unLockControl();core.status.event.data=null;core.status.event.id=null;return}core.useItem("fly");return};core.prototype.openToolbox=function(a){if(!core.checkStatus("toolbox",a)){return}core.ui.drawToolbox()};core.prototype.save=function(a){if(!core.checkStatus("save",a)){return}core.ui.drawSLPanel(core.status.savePage)};core.prototype.load=function(a){if(!core.isPlaying()){core.status.event={id:"load",data:null};core.status.lockControl=true;core.dom.startPanel.style.display="none";var b=core.getLocalStorage("savePage",0);core.ui.drawSLPanel(b);return}if(!core.checkStatus("load",a)){return}core.ui.drawSLPanel(core.status.savePage)};core.prototype.doSL=function(b,c){if(c=="save"){if(core.saveData("save"+b)){core.ui.closePanel();core.drawTip("存档成功!");core.setLocalStorage("savePage",core.status.savePage)}else{core.drawTip("存储空间不足,请覆盖已有的存档或在菜单栏中进行清理")}return}else{if(c=="load"){var a=core.getLocalStorage("save"+b,null);if(!core.isset(a)){core.drawTip("无效的存档");return}if(a.version!=core.firstData.version){core.drawTip("存档版本不匹配");return}core.ui.closePanel();core.loadData(a,function(){core.setLocalStorage("savePage",core.status.savePage);core.drawTip("读档成功")});return}}};core.prototype.saveData=function(b){var a={floorId:core.status.floorId,hero:core.clone(core.status.hero),hard:core.status.hard,maps:core.maps.save(core.status.maps),shops:{},version:core.firstData.version,time:new Date().getTime()};for(var c in core.status.shops){a.shops[c]={times:core.status.shops[c].times||0,visited:core.status.shops[c].visited||false}}core.events.beforeSaveData(a);return core.setLocalStorage(b,a)};core.prototype.loadData=function(b,a){core.resetStatus(b.hero,b.hard,b.floorId,core.maps.load(b.maps));for(var c in core.status.shops){core.status.shops[c].times=b.shops[c].times;core.status.shops[c].visited=b.shops[c].visited}core.events.afterLoadData(b);core.changeFloor(b.floorId,null,b.hero.loc,null,function(){core.setHeroMoveTriggerInterval();if(core.isset(a)){a()}})};core.prototype.setStatus=function(a,b){core.status.hero[a]=b};core.prototype.getStatus=function(a){return core.status.hero[a]};core.prototype.setFlag=function(a,b){if(!core.isset(core.status.hero)){return}core.status.hero.flags[a]=b};core.prototype.getFlag=function(b,a){if(!core.isset(core.status.hero)){return a}var c=core.status.hero.flags[b];if(core.isset(c)){return c}return a};core.prototype.hasFlag=function(a){if(core.getFlag(a)){return true}return false};core.prototype.lockControl=function(){core.status.lockControl=true};core.prototype.unLockControl=function(){core.status.lockControl=false};core.prototype.isset=function(a){if(a==undefined||a==null){return false}return true};core.prototype.playSound=function(a,b){if(!core.musicStatus.soundStatus||!core.musicStatus.loaded){return}if(!core.isset(core.material.sounds[b][a])){return}core.musicStatus.playedSound=core.material.sounds[b][a];core.musicStatus.playedSound.play()};core.prototype.playBgm=function(a,b){if(core.musicStatus.isIOS||!core.musicStatus.loaded){return}if(core.isset(core.musicStatus.playedBgm)){core.musicStatus.playedBgm.pause()}core.musicStatus.playedBgm=core.material.sounds[b][a];if(core.musicStatus.soundStatus){core.musicStatus.playedBgm.play()}};core.prototype.changeSoundStatus=function(){if(core.musicStatus.soundStatus){main.core.disabledSound()}else{main.core.enabledSound()}};core.prototype.enabledSound=function(){core.musicStatus.soundStatus=true;core.playBgm("bgm","mp3");core.setLocalStorage("soundStatus",true)};core.prototype.disabledSound=function(){core.musicStatus.playedBgm.pause();core.musicStatus.soundStatus=false;core.setLocalStorage("soundStatus",false)};core.prototype.show=function(b,e,a){if(!core.isset(e)){b.style.display="block";return}b.style.display="block";b.style.opacity=0;var c=0;var d=window.setInterval(function(){c+=0.03;b.style.opacity=c;if(c>1){clearInterval(d);if(core.isset(a)){a()}}},e)};core.prototype.hide=function(c,e,a){if(!core.isset(e)){c.style.display="none";return}var d=1;var b=window.setInterval(function(){d-=0.03;c.style.opacity=d;if(d<0){c.style.display="none";clearInterval(b);if(core.isset(a)){a()}}},e)};core.prototype.clearStatusBar=function(){var a=["floor","hp","atk","def","mdef","money","experience","yellowKey","blueKey","redKey","poison","weak","curse","hard"];a.forEach(function(b){core.statusBar[b].innerHTML=""});core.statusBar.image.book.style.opacity=0.3;core.statusBar.image.fly.style.opacity=0.3};core.prototype.updateStatusBar=function(){if(core.values.HPMAX>0){core.setStatus("hp",Math.min(core.values.HPMAX,core.getStatus("hp")))}var b=["hp","atk","def","mdef","money","experience"];b.forEach(function(c){core.statusBar[c].innerHTML=core.getStatus(c)});var a=["yellowKey","blueKey","redKey"];a.forEach(function(c){core.statusBar[c].innerHTML=core.setTwoDigits(core.status.hero.items.keys[c])});core.statusBar.poison.innerHTML=core.hasFlag("poison")?"毒":"";core.statusBar.weak.innerHTML=core.hasFlag("weak")?"衰":"";core.statusBar.curse.innerHTML=core.hasFlag("curse")?"咒":"";core.statusBar.hard.innerHTML=core.status.hard;if(core.hasItem("book")){core.statusBar.image.book.style.opacity=1}else{core.statusBar.image.book.style.opacity=0.3}if(core.hasItem("fly")){core.statusBar.image.fly.style.opacity=1}else{core.statusBar.image.fly.style.opacity=0.3}core.updateFg()};core.prototype.resize=function(d,c){var b=416;var k=83;var q=49;var l=132;var a=b+6;var s=d;var i=false;if(d>c&&c<422){i=true;s=c}if(s= 5 && x <= 7) { var shopList = core.status.shops, keys = Object.keys(shopList); var topIndex = 6 - parseInt((keys.length + 1) / 2); diff --git a/libs/events.min.js b/libs/events.min.js index d3090c95..4e020f14 100644 --- a/libs/events.min.js +++ b/libs/events.min.js @@ -1 +1 @@ -function events(){}events.prototype.init=function(){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);if(b.isset(a)){a()}},changeFloor:function(c,b,a){var d=null;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,a)},openShop:function(c,b,a){b.ui.drawShop(c.event.shopid);if(b.isset(a)){a()}},passNet:function(c,b,a){b.events.passNet(c);if(b.isset(a)){a()}},checkBlock:function(c,b,a){b.events.checkBlock(c.x,c.y);if(b.isset(a)){a()}},action:function(c,b,a){b.events.doEvents(c.event.data,c.x,c.y);if(b.isset(a)){a()}}}};events.prototype.getEvents=function(a){if(a==undefined){return this.events}return this.events[a]};main.instance.events=new events();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(){core.startGame(a)})})};events.prototype.win=function(a){core.waitHeroToStop(function(){core.rmGlobalAnimate(0,0,true);core.clearMap("all");core.drawText(["\t[结局2]恭喜通关!你的分数是${status:hp}。"],function(){core.restart()})})};events.prototype.lose=function(a){core.waitHeroToStop(function(){core.drawText("\t[结局1]你死了。",function(){core.restart()})})};events.prototype.checkBlock=function(g,h){var b=0;var c=[[0,-1],[-1,0],[0,1],[1,0]];var d=[null,null,null,null];for(var f in c){var a=core.getBlock(g+c[f][0],h+c[f][1]);if(a==null){continue}if(a.block.event.cls=="enemys"){d[f]=core.material.enemys[a.block.event.id]}}for(var f in d){if(d[f]!=null&&d[f].special==15){b+=d[f].value}}if(b>0){core.drawTip("受到领域伤害"+b+"点")}core.status.hero.hp-=b;if(core.status.hero.hp<=0){core.status.hero.hp=0;core.updateStatusBar();core.events.lose("zone");return}var e=false;if(d[0]!=null&&d[2]!=null&&d[0].id==d[2].id&&d[0].special==16){e=true}if(d[1]!=null&&d[3]!=null&&d[1].id==d[3].id&&d[1].special==16){e=true}if(e&&core.status.hero.hp>1){core.status.hero.hp=parseInt(core.status.hero.hp/2);core.drawTip("受到夹击,生命变成一半")}core.updateStatusBar()};events.prototype.afterChangeFloor=function(a){if(!core.hasFlag("visited_"+a)){this.doEvents(core.floors[a].firstArrive);core.setFlag("visited_"+a,true)}};events.prototype.doEvents=function(b,c,d,a){core.waitHeroToStop(function(){if(!core.isset(b)){return}if(!(b instanceof Array)){b=[b]}core.lockControl();core.status.event={id:"action",data:{list:core.clone(b),x:c,y:d,callback:a}};core.events.doAction()})};events.prototype.doAction=function(){clearInterval(core.interval.boxAnimate);core.clearMap("ui",0,0,416,416);core.setAlpha("ui",1);if(core.status.event.data.list.length==0){if(core.isset(core.status.event.data.callback)){core.status.event.data.callback()}core.ui.closePanel(false);return}var b=core.status.event.data.list.shift();core.status.event.data.current=b;var m=core.status.event.data.x,n=core.status.event.data.y;if(typeof b=="string"){core.status.event.data.type="text";core.ui.drawTextBox(b);return}core.status.event.data.type=b.type;switch(b.type){case"text":core.ui.drawTextBox(b.data);break;case"show":if(core.isset(b.time)&&b.time>0&&(!core.isset(b.floorId)||b.floorId==core.status.floorId)){core.animateBlock(b.loc[0],b.loc[1],"show",b.time,function(){core.addBlock(b.loc[0],b.loc[1],b.floorId);core.events.doAction()})}else{core.addBlock(b.loc[0],b.loc[1],b.floorId);this.doAction()}break;case"hide":var j=m,k=n,i=core.status.floorId;if(core.isset(b.loc)){j=b.loc[0];k=b.loc[1]}if(core.isset(b.floorId)){i=b.floorId}core.removeBlock(j,k,i);if(core.isset(b.time)&&b.time>0&&i==core.status.floorId){core.animateBlock(j,k,"hide",b.time,function(){core.events.doAction()})}else{this.doAction()}break;case"move":core.moveBlock(m,n,b.steps,b.time,b.disappear,function(){core.events.doAction()});break;case"changeFloor":var f={x:b.loc[0],y:b.loc[1]};if(core.isset(b.direction)){f.direction=b.direction}core.changeFloor(b.floorId||core.status.floorId,null,f,b.time,function(){core.lockControl();core.events.doAction()});break;case"changePos":core.clearMap("hero",0,0,416,416);core.setHeroLoc("x",b.loc[0]);core.setHeroLoc("y",b.loc[1]);core.drawHero(core.getHeroLoc("direction"),core.getHeroLoc("x"),core.getHeroLoc("y"),"stop");this.doAction();break;case"openDoor":var d=b.floorId||core.status.floorId;var a=core.getBlock(b.loc[0],b.loc[1],d);if(a!=null){if(d==core.status.floorId){core.openDoor(a.block.event.id,a.block.x,a.block.y,false,function(){core.events.doAction()})}else{core.removeBlock(a.block.x,a.block.y,d);this.doAction()}break}this.doAction();break;case"openShop":core.events.openShop(b.id);break;case"battle":core.battle(b.id,null,null,true,function(){core.events.doAction()});break;case"trigger":var j=b.loc[0],k=b.loc[1];var a=core.getBlock(j,k);if(a!=null){a=a.block;if(core.isset(a.event)&&a.event.trigger=="action"){core.status.event={id:"action",data:{list:core.clone(a.event.data),x:a.x,y:a.y,callback:core.status.event.data.callback}}}}this.doAction();break;case"playSound":var h=b.name.split(".");if(h.length==2){core.playSound(h[0],h[1])}this.doAction();break;case"setValue":try{var l=core.calValue(b.value);if(b.name.indexOf("status:")==0){l=parseInt(l);core.setStatus(b.name.substring(7),l)}if(b.name.indexOf("item:")==0){l=parseInt(l);var g=b.name.substring(5);if(l>core.itemCount(g)){core.getItem(g,l-core.itemCount(g))}else{core.setItem(g,l)}}if(b.name.indexOf("flag:")==0){core.setFlag(b.name.substring(5),l)}}catch(c){console.log(c)}core.updateStatusBar();this.doAction();break;case"if":if(core.calValue(b.condition)){core.events.insertAction(b["true"])}else{core.events.insertAction(b["false"])}this.doAction();break;case"choices":core.ui.drawChoices(b.text,b.choices);break;case"win":core.events.win(b.reason);break;case"lose":core.events.lose(b.reason);break;case"function":if(core.isset(b["function"])){b["function"]()}this.doAction();break;case"update":core.updateStatusBar();this.doAction();break;case"sleep":setTimeout(function(){core.events.doAction()},b.time);break;case"revisit":var a=core.getBlock(m,n);if(a!=null){a=a.block;if(core.isset(a.event)&&a.event.trigger=="action"){core.status.event.data.list=core.clone(a.event.data)}}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"+b.type+" 事件不被支持...")}return};events.prototype.insertAction=function(a){core.unshift(core.status.event.data.list,a)};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;core.ui.closePanel();core.lockControl();core.status.event={id:"shop",data:{id:shopId,shop:shop}};var content="\t["+shop.name+","+shop.icon+"]";var times=shop.times,need=eval(shop.need);if(need<0){need="若干"}var use=shop.use=="experience"?"经验":"金币";content=content+"勇敢的武士啊,给我"+need+"\n"+use+",你就可以:";var choices=[];for(var i=0;i=0){return"当前不能使用快捷商店。"}return null};events.prototype.useItem=function(a){core.ui.closePanel(false);if(a=="book"){core.openBook(false);return}if(a=="fly"){core.useFly(false);return}if(core.canUseItem(a)){core.useItem(a)}else{core.drawTip("当前无法使用"+core.material.items[a].name)}};events.prototype.afterBattle=function(b,e,f,a){var d=core.material.enemys[b].special;if(d==12&&!core.hasFlag("poison")){core.setFlag("poison",true);core.updateStatusBar()}if(d==13&&!core.hasFlag("weak")){core.setFlag("weak",true);core.status.hero.atk-=core.values.weakValue;core.status.hero.def-=core.values.weakValue;core.updateStatusBar()}if(d==14&&!core.hasFlag("curse")){core.setFlag("curse",true);core.updateStatusBar()}if(core.status.lockControl){if(core.isset(a)){a()}return}var c=core.floors[core.status.floorId].afterBattle[e+","+f];if(core.isset(c)){core.events.doEvents(c,e,f,a)}else{core.continueAutomaticRoute();if(core.isset(a)){a()}}};events.prototype.afterOpenDoor=function(b,d,e,a){if(core.status.lockControl){if(core.isset(a)){a()}return}var c=core.floors[core.status.floorId].afterOpenDoor[d+","+e];if(core.isset(c)){core.events.doEvents(c,d,e,a)}else{core.continueAutomaticRoute();if(core.isset(a)){a()}}};events.prototype.passNet=function(a){if(core.hasItem("shoes")){return}if(a.event.id=="lavaNet"){core.status.hero.hp-=core.values.lavaDamage;if(core.status.hero.hp<=0){core.status.hero.hp=0;core.updateStatusBar();core.events.lose("lava");return}core.drawTip("经过血网,生命-"+core.values.lavaDamage)}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);core.status.hero.atk-=core.values.weakValue;core.status.hero.def-=core.values.weakValue}if(a.event.id=="curseNet"){if(core.hasFlag("curse")){return}core.setFlag("curse",true)}core.updateStatusBar()};events.prototype.beforeSaveData=function(a){};events.prototype.afterLoadData=function(a){};events.prototype.clickAction=function(d,e){if(core.status.event.data.type=="text"){this.doAction();return}if(core.status.event.data.type=="choices"){var b=core.status.event.data.current;var a=b.choices;if(a.length==0){return}if(d>=5&&d<=7){var c=6-parseInt((a.length-1)/2);if(e>=c&&e=10&&a<=12&&b==12){core.ui.closePanel(true)}return};events.prototype.clickFly=function(d,e){if((d==10||d==11)&&e==9){core.ui.drawFly(core.status.event.data-1)}if((d==10||d==11)&&e==5){core.ui.drawFly(core.status.event.data+1)}if(d>=5&&d<=7&&e==12){core.ui.closePanel()}if(d>=0&&d<=9&&e>=3&&e<=11){var b=core.status.hero.flyRange.indexOf(core.status.floorId);var c=core.status.event.data=5&&x<=7){var topIndex=6-parseInt(choices.length/2);if(y>=topIndex&&yeval(use)){core.drawTip("你的"+use_text+"不足");return}eval(use+"-="+need);core.setStatus("money",money);core.setStatus("experience",experience);choice.effect.split(";").forEach(function(t){if(t.indexOf("status:")==0){eval(t.replace("status:","core.status.hero."))}else{if(t.indexOf("item:")==0){eval(t.replace("item:","core.getItem('").replace("+=","', ")+")")}}});core.updateStatusBar();shop.times++;this.openShop(core.status.event.data.id)}else{if(y==topIndex+choices.length){core.status.boxAnimateObjs=[];core.setBoxAnimate();if(core.status.event.data.fromList){core.ui.drawQuickShop()}else{core.ui.closePanel()}}}}};events.prototype.clickSelectShop=function(f,g){if(f>=5&&f<=7){var d=core.status.shops,b=Object.keys(d);var e=6-parseInt((b.length+1)/2);var a=6+parseInt((b.length+1)/2);if(g>=e&&g-e=10&&c<=12&&d==12){core.ui.closePanel(false);return}var b=null;if(d>=4&&d<=7&&c!=12){b=Object.keys(core.status.hero.items.tools).sort()}if(d>=9&&d<=12&&c!=12){b=Object.keys(core.status.hero.items.constants).sort()}if(b==null){return}var a=0;if(d==4||d==5||d==9||d==10){a=parseInt(c/2)}else{a=6+parseInt(c/2)}if(a>=b.length){return}itemId=b[a];if(itemId==core.status.event.data){core.events.useItem(itemId)}else{core.ui.drawToolbox(itemId)}};events.prototype.clickSL=function(b,c){if((b==3||b==4)&&c==12){core.ui.drawSLPanel(core.status.event.data-1)}if((b==8||b==9)&&c==12){core.ui.drawSLPanel(core.status.event.data+1)}if(b>=10&&b<=12&&c==12){core.ui.closePanel(false);if(!core.isPlaying()){core.showStartAnimate()}return}var a=6*core.status.event.data+1;if(c>=1&&c<=4){if(b>=1&&b<=3){core.doSL(a,core.status.event.id)}if(b>=5&&b<=7){core.doSL(a+1,core.status.event.id)}if(b>=9&&b<=11){core.doSL(a+2,core.status.event.id)}}if(c>=7&&c<=10){if(b>=1&&b<=3){core.doSL(a+3,core.status.event.id)}if(b>=5&&b<=7){core.doSL(a+4,core.status.event.id)}if(b>=9&&b<=11){core.doSL(a+5,core.status.event.id)}}};events.prototype.clickSettings=function(a,b){if(a<5||a>7){return}if(b==3){if(core.musicStatus.isIOS){core.drawTip("iOS设备不支持播放音乐");return}core.changeSoundStatus();core.ui.drawSettings(false)}if(b==4){core.ui.drawQuickShop()}if(b==5){core.ui.drawSyncSave()}if(b==6){core.ui.drawConfirmBox("你确定要清空所有本地存档吗?",function(){localStorage.clear();core.drawText("\t[操作成功]你的本地所有存档已被清空。")},function(){core.ui.drawSettings(false)})}if(b==7){core.ui.drawConfirmBox("你确定要重新开始吗?",function(){core.ui.closePanel();core.restart()},function(){core.ui.drawSettings(false)})}if(b==8){core.ui.drawAbout()}if(b==9){core.ui.closePanel()}return}; \ No newline at end of file +function events(){}events.prototype.init=function(){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);if(b.isset(a)){a()}},changeFloor:function(c,b,a){var d=null;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,a)},openShop:function(c,b,a){b.ui.drawShop(c.event.shopid);if(b.isset(a)){a()}},passNet:function(c,b,a){b.events.passNet(c);if(b.isset(a)){a()}},checkBlock:function(c,b,a){b.events.checkBlock(c.x,c.y);if(b.isset(a)){a()}},action:function(c,b,a){b.events.doEvents(c.event.data,c.x,c.y);if(b.isset(a)){a()}}}};events.prototype.getEvents=function(a){if(a==undefined){return this.events}return this.events[a]};main.instance.events=new events();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(){core.startGame(a)})})};events.prototype.win=function(a){core.waitHeroToStop(function(){core.removeGlobalAnimate(0,0,true);core.clearMap("all");core.drawText(["\t[结局2]恭喜通关!你的分数是${status:hp}。"],function(){core.restart()})})};events.prototype.lose=function(a){core.waitHeroToStop(function(){core.drawText("\t[结局1]你死了。",function(){core.restart()})})};events.prototype.checkBlock=function(g, h){var b=0;var c=[[0,-1],[-1,0],[0,1],[1,0]];var d=[null,null,null,null];for(var f in c){var a=core.getBlock(g+c[f][0],h+c[f][1]);if(a==null){continue}if(a.block.event.cls=="enemys"){d[f]=core.material.enemys[a.block.event.id]}}for(var f in d){if(d[f]!=null&&d[f].special==15){b+=d[f].value}}if(b>0){core.drawTip("受到领域伤害"+b+"点")}core.status.hero.hp-=b;if(core.status.hero.hp<=0){core.status.hero.hp=0;core.updateStatusBar();core.events.lose("zone");return}var e=false;if(d[0]!=null&&d[2]!=null&&d[0].id==d[2].id&&d[0].special==16){e=true}if(d[1]!=null&&d[3]!=null&&d[1].id==d[3].id&&d[1].special==16){e=true}if(e&&core.status.hero.hp>1){core.status.hero.hp=parseInt(core.status.hero.hp/2);core.drawTip("受到夹击,生命变成一半")}core.updateStatusBar()};events.prototype.afterChangeFloor=function(a){if(!core.hasFlag("visited_"+a)){this.doEvents(core.floors[a].firstArrive);core.setFlag("visited_"+a,true)}};events.prototype.doEvents=function(b,c,d,a){core.waitHeroToStop(function(){if(!core.isset(b)){return}if(!(b instanceof Array)){b=[b]}core.lockControl();core.status.event={id:"action",data:{list:core.clone(b),x:c,y:d,callback:a}};core.events.doAction()})};events.prototype.doAction=function(){clearInterval(core.interval.boxAnimate);core.clearMap("ui",0,0,416,416);core.setAlpha("ui",1);if(core.status.event.data.list.length==0){if(core.isset(core.status.event.data.callback)){core.status.event.data.callback()}core.ui.closePanel(false);return}var b=core.status.event.data.list.shift();core.status.event.data.current=b;var m=core.status.event.data.x,n=core.status.event.data.y;if(typeof b=="string"){core.status.event.data.type="text";core.ui.drawTextBox(b);return}core.status.event.data.type=b.type;switch(b.type){case"text":core.ui.drawTextBox(b.data);break;case"show":if(core.isset(b.time)&&b.time>0&&(!core.isset(b.floorId)||b.floorId==core.status.floorId)){core.animateBlock(b.loc[0],b.loc[1],"show",b.time,function(){core.addBlock(b.loc[0],b.loc[1],b.floorId);core.events.doAction()})}else{core.addBlock(b.loc[0],b.loc[1],b.floorId);this.doAction()}break;case"hide":var j=m,k=n,i=core.status.floorId;if(core.isset(b.loc)){j=b.loc[0];k=b.loc[1]}if(core.isset(b.floorId)){i=b.floorId}core.removeBlock(j,k,i);if(core.isset(b.time)&&b.time>0&&i==core.status.floorId){core.animateBlock(j,k,"hide",b.time,function(){core.events.doAction()})}else{this.doAction()}break;case"move":core.moveBlock(m,n,b.steps,b.time,b.disappear,function(){core.events.doAction()});break;case"changeFloor":var f={x:b.loc[0],y:b.loc[1]};if(core.isset(b.direction)){f.direction=b.direction}core.changeFloor(b.floorId||core.status.floorId,null,f,b.time,function(){core.lockControl();core.events.doAction()});break;case"changePos":core.clearMap("hero",0,0,416,416);core.setHeroLoc("x",b.loc[0]);core.setHeroLoc("y",b.loc[1]);core.drawHero(core.getHeroLoc("direction"),core.getHeroLoc("x"),core.getHeroLoc("y"),"stop");this.doAction();break;case"openDoor":var d=b.floorId||core.status.floorId;var a=core.getBlock(b.loc[0],b.loc[1],d);if(a!=null){if(d==core.status.floorId){core.openDoor(a.block.event.id,a.block.x,a.block.y,false,function(){core.events.doAction()})}else{core.removeBlock(a.block.x,a.block.y,d);this.doAction()}break}this.doAction();break;case"openShop":core.events.openShop(b.id);break;case"battle":core.battle(b.id,null,null,true,function(){core.events.doAction()});break;case"trigger":var j=b.loc[0],k=b.loc[1];var a=core.getBlock(j,k);if(a!=null){a=a.block;if(core.isset(a.event)&&a.event.trigger=="action"){core.status.event={id:"action",data:{list:core.clone(a.event.data),x:a.x,y:a.y,callback:core.status.event.data.callback}}}}this.doAction();break;case"playSound":var h=b.name.split(".");if(h.length==2){core.playSound(h[0],h[1])}this.doAction();break;case"setValue":try{var l=core.calValue(b.value);if(b.name.indexOf("status:")==0){l=parseInt(l);core.setStatus(b.name.substring(7),l)}if(b.name.indexOf("item:")==0){l=parseInt(l);var g=b.name.substring(5);if(l>core.itemCount(g)){core.getItem(g,l-core.itemCount(g))}else{core.setItem(g,l)}}if(b.name.indexOf("flag:")==0){core.setFlag(b.name.substring(5),l)}}catch(c){console.log(c)}core.updateStatusBar();this.doAction();break;case"if":if(core.calValue(b.condition)){core.events.insertAction(b["true"])}else{core.events.insertAction(b["false"])}this.doAction();break;case"choices":core.ui.drawChoices(b.text,b.choices);break;case"win":core.events.win(b.reason);break;case"lose":core.events.lose(b.reason);break;case"function":if(core.isset(b["function"])){b["function"]()}this.doAction();break;case"update":core.updateStatusBar();this.doAction();break;case"sleep":setTimeout(function(){core.events.doAction()},b.time);break;case"revisit":var a=core.getBlock(m,n);if(a!=null){a=a.block;if(core.isset(a.event)&&a.event.trigger=="action"){core.status.event.data.list=core.clone(a.event.data)}}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"+b.type+" 事件不被支持...")}return};events.prototype.insertAction=function(a){core.unshift(core.status.event.data.list,a)};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;core.ui.closePanel();core.lockControl();core.status.event={id:"shop",data:{id:shopId,shop:shop}};var content="\t["+shop.name+","+shop.icon+"]";var times=shop.times,need=eval(shop.need);if(need<0){need="若干"}var use=shop.use=="experience"?"经验":"金币";content=content+"勇敢的武士啊,给我"+need+"\n"+use+",你就可以:";var choices=[];for(var i=0;i=0){return"当前不能使用快捷商店。"}return null};events.prototype.useItem=function(a){core.ui.closePanel(false);if(a=="book"){core.openBook(false);return}if(a=="fly"){core.useFly(false);return}if(core.canUseItem(a)){core.useItem(a)}else{core.drawTip("当前无法使用"+core.material.items[a].name)}};events.prototype.afterBattle=function(b,e,f,a){var d=core.material.enemys[b].special;if(d==12&&!core.hasFlag("poison")){core.setFlag("poison",true);core.updateStatusBar()}if(d==13&&!core.hasFlag("weak")){core.setFlag("weak",true);core.status.hero.atk-=core.values.weakValue;core.status.hero.def-=core.values.weakValue;core.updateStatusBar()}if(d==14&&!core.hasFlag("curse")){core.setFlag("curse",true);core.updateStatusBar()}if(core.status.lockControl){if(core.isset(a)){a()}return}var c=core.floors[core.status.floorId].afterBattle[e+","+f];if(core.isset(c)){core.events.doEvents(c,e,f,a)}else{core.continueAutomaticRoute();if(core.isset(a)){a()}}};events.prototype.afterOpenDoor=function(b,d,e,a){if(core.status.lockControl){if(core.isset(a)){a()}return}var c=core.floors[core.status.floorId].afterOpenDoor[d+","+e];if(core.isset(c)){core.events.doEvents(c,d,e,a)}else{core.continueAutomaticRoute();if(core.isset(a)){a()}}};events.prototype.passNet=function(a){if(core.hasItem("shoes")){return}if(a.event.id=="lavaNet"){core.status.hero.hp-=core.values.lavaDamage;if(core.status.hero.hp<=0){core.status.hero.hp=0;core.updateStatusBar();core.events.lose("lava");return}core.drawTip("经过血网,生命-"+core.values.lavaDamage)}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);core.status.hero.atk-=core.values.weakValue;core.status.hero.def-=core.values.weakValue}if(a.event.id=="curseNet"){if(core.hasFlag("curse")){return}core.setFlag("curse",true)}core.updateStatusBar()};events.prototype.beforeSaveData=function(a){};events.prototype.afterLoadData=function(a){};events.prototype.clickAction=function(d,e){if(core.status.event.data.type=="text"){this.doAction();return}if(core.status.event.data.type=="choices"){var b=core.status.event.data.current;var a=b.choices;if(a.length==0){return}if(d>=5&&d<=7){var c=6-parseInt((a.length-1)/2);if(e>=c&&e=10&&a<=12&&b==12){core.ui.closePanel(true)}return};events.prototype.clickFly=function(d,e){if((d==10||d==11)&&e==9){core.ui.drawFly(core.status.event.data-1)}if((d==10||d==11)&&e==5){core.ui.drawFly(core.status.event.data+1)}if(d>=5&&d<=7&&e==12){core.ui.closePanel()}if(d>=0&&d<=9&&e>=3&&e<=11){var b=core.status.hero.flyRange.indexOf(core.status.floorId);var c=core.status.event.data=5&&x<=7){var topIndex=6-parseInt(choices.length/2);if(y>=topIndex&&yeval(use)){core.drawTip("你的"+use_text+"不足");return}eval(use+"-="+need);core.setStatus("money",money);core.setStatus("experience",experience);choice.effect.split(";").forEach(function(t){if(t.indexOf("status:")==0){eval(t.replace("status:","core.status.hero."))}else{if(t.indexOf("item:")==0){eval(t.replace("item:","core.getItem('").replace("+=","', ")+")")}}});core.updateStatusBar();shop.times++;this.openShop(core.status.event.data.id)}else{if(y==topIndex+choices.length){core.status.boxAnimateObjs=[];core.setBoxAnimate();if(core.status.event.data.fromList){core.ui.drawQuickShop()}else{core.ui.closePanel()}}}}};events.prototype.clickQuickShop=function(f, g){if(f>=5&&f<=7){var d=core.status.shops,b=Object.keys(d);var e=6-parseInt((b.length+1)/2);var a=6+parseInt((b.length+1)/2);if(g>=e&&g-e=10&&c<=12&&d==12){core.ui.closePanel(false);return}var b=null;if(d>=4&&d<=7&&c!=12){b=Object.keys(core.status.hero.items.tools).sort()}if(d>=9&&d<=12&&c!=12){b=Object.keys(core.status.hero.items.constants).sort()}if(b==null){return}var a=0;if(d==4||d==5||d==9||d==10){a=parseInt(c/2)}else{a=6+parseInt(c/2)}if(a>=b.length){return}itemId=b[a];if(itemId==core.status.event.data){core.events.useItem(itemId)}else{core.ui.drawToolbox(itemId)}};events.prototype.clickSL=function(b,c){if((b==3||b==4)&&c==12){core.ui.drawSLPanel(core.status.event.data-1)}if((b==8||b==9)&&c==12){core.ui.drawSLPanel(core.status.event.data+1)}if(b>=10&&b<=12&&c==12){core.ui.closePanel(false);if(!core.isPlaying()){core.showStartAnimate()}return}var a=6*core.status.event.data+1;if(c>=1&&c<=4){if(b>=1&&b<=3){core.doSL(a,core.status.event.id)}if(b>=5&&b<=7){core.doSL(a+1,core.status.event.id)}if(b>=9&&b<=11){core.doSL(a+2,core.status.event.id)}}if(c>=7&&c<=10){if(b>=1&&b<=3){core.doSL(a+3,core.status.event.id)}if(b>=5&&b<=7){core.doSL(a+4,core.status.event.id)}if(b>=9&&b<=11){core.doSL(a+5,core.status.event.id)}}};events.prototype.clickSettings=function(a,b){if(a<5||a>7){return}if(b==3){if(core.musicStatus.isIOS){core.drawTip("iOS设备不支持播放音乐");return}core.changeSoundStatus();core.ui.drawSettings(false)}if(b==4){core.ui.drawQuickShop()}if(b==5){core.ui.drawSyncSave()}if(b==6){core.ui.drawConfirmBox("你确定要清空所有本地存档吗?",function(){localStorage.clear();core.drawText("\t[操作成功]你的本地所有存档已被清空。")},function(){core.ui.drawSettings(false)})}if(b==7){core.ui.drawConfirmBox("你确定要重新开始吗?",function(){core.ui.closePanel();core.restart()},function(){core.ui.drawSettings(false)})}if(b==8){core.ui.drawAbout()}if(b==9){core.ui.closePanel()}return}; \ No newline at end of file diff --git a/libs/floors/MT0.js b/libs/floors/MT0.js index 54bea8b1..4bc81686 100644 --- a/libs/floors/MT0.js +++ b/libs/floors/MT0.js @@ -2,9 +2,9 @@ // 楼层唯一标识符仅能由字母、数字、下划线组成,且不能由数字开头 // 推荐用法:第20层就用MT20,第38层就用MT38,地下6层就用MT_6(用下划线代替负号),隐藏3层用MT3h(h表示隐藏),等等 main.floors.MT0 = { - 'floorId': 'MT0', // 楼层唯一标识符,需要和名字完全一致 - 'title': "0", // 楼层中文名 - 'name': 0, // 显示在状态栏中的名称 + "floorId": "MT0", // 楼层唯一标识符,需要和名字完全一致 + "title": "主塔 0 层", // 楼层中文名 + "name": 0, // 显示在状态栏中的层数 "canFlyTo": true, // 该楼能否被楼传器飞到(不能的话在该楼也不允许使用楼传器) "map": [ // 地图数据,需要是13x13,建议使用地图生成器来生成 diff --git a/libs/floors/sample0.js b/libs/floors/sample0.js index 977eddd2..f05812a4 100644 --- a/libs/floors/sample0.js +++ b/libs/floors/sample0.js @@ -2,9 +2,9 @@ // 楼层唯一标识符仅能由字母、数字、下划线组成,且不能由数字开头 // 推荐用法:第20层就用MT20,第38层就用MT38,地下6层就用MT_6(用下划线代替负号),隐藏3层用MT3h(h表示隐藏),等等 main.floors.sample0 = { - 'floorId': 'sample0', // 楼层唯一标识符,需要和名字完全一致 - 'title': "样板 0 层", // 楼层中文名 - 'name': 0, // 显示在状态栏中的名称 + "floorId": "sample0", // 楼层唯一标识符,需要和名字完全一致 + "title": "样板 0 层", // 楼层中文名 + "name": 0, // 显示在状态栏中的层数 "canFlyTo": true, // 该楼能否被楼传器飞到(不能的话在该楼也不允许使用楼传器) "map": [ // 地图数据,需要是13x13,建议使用地图生成器来生成 [0, 0, 220, 0, 0, 6, 87, 3, 65, 64, 44, 43, 42], @@ -79,10 +79,10 @@ main.floors.sample0 = { "0,12": {"floorId": "sample0", "stair": "upFloor"}, // 注意,目标层有多个楼梯的话,写stair可能会导致到达位置不确定。这时候推荐写loc指明目标点位置。 "1,12": {"floorId": "sample0", "loc": [1,12]}, "2,12": {"floorId": "sample0", "loc": [2,12]}, - "3,12": {"floorId": "sample0", "loc": [6,1]}, - "4,12": {"floorId": "sample0", "loc": [0,9]}, + "3,12": {"floorId": "sample0", "loc": [6,1], "direction": "up"}, // 切换楼层后勇士面对上方 + "4,12": {"floorId": "sample0", "loc": [0,9], "direction": "left", "time": 1000}, // 切换楼层后勇士面对左边,切换动画1000ms "5,12": {"floorId": "sample0", "loc": [6,10], "portalWithoutTrigger": false}, // 不能穿透 - "6,12": {"floorId": "sample0", "loc": [10,10]}, + "6,12": {"floorId": "sample0", "loc": [10,10], "direction": "left", "time": 1000, "portalWithoutTrigger": false}, }, "afterBattle": { // 战斗后可能触发的事件列表 "2,6": ["\t[ghostSkeleton]不可能,你怎么可能打败我!\n(一个打败怪物触发的事件)"] diff --git a/libs/floors/sample1.js b/libs/floors/sample1.js index 31225c1e..f763c0ca 100644 --- a/libs/floors/sample1.js +++ b/libs/floors/sample1.js @@ -2,9 +2,9 @@ // 楼层唯一标识符仅能由字母、数字、下划线组成,且不能由数字开头 // 推荐用法:第20层就用MT20,第38层就用MT38,地下6层就用MT_6(用下划线代替负号),隐藏3层用MT3h(h表示隐藏),等等 main.floors.sample1 = { - 'floorId': 'sample1', // 楼层唯一标识符,需要和名字完全一致 - 'title': "样板 1 层", // 楼层中文名 - 'name': 1, // 显示在状态栏中的名称 + "floorId": "sample1", // 楼层唯一标识符,需要和名字完全一致 + "title": "样板 1 层", // 楼层中文名 + "name": 1, // 显示在状态栏中的层数 "canFlyTo": true, // 该楼能否被楼传器飞到(不能的话在该楼也不允许使用楼传器) "map": [ // 地图数据,需要是13x13,建议使用地图生成器来生成 [7, 131, 8, 2, 9, 130, 10, 2, 0, 0, 132, 0, 0], diff --git a/libs/floors/sample2.js b/libs/floors/sample2.js index fafb7b59..fde596fb 100644 --- a/libs/floors/sample2.js +++ b/libs/floors/sample2.js @@ -2,9 +2,9 @@ // 楼层唯一标识符仅能由字母、数字、下划线组成,且不能由数字开头 // 推荐用法:第20层就用MT20,第38层就用MT38,地下6层就用MT_6(用下划线代替负号),隐藏3层用MT3h(h表示隐藏),等等 main.floors.sample2 = { - 'floorId': 'sample2', // 楼层唯一标识符,需要和名字完全一致 - 'title': "主塔 40 层", // 楼层中文名 - 'name': 40, // 显示在状态栏中的名称 + "floorId": "sample2", // 楼层唯一标识符,需要和名字完全一致 + "title": "主塔 40 层", // 楼层中文名 + "name": 40, // 显示在状态栏中的层数 "canFlyTo": false, // 该楼能否被楼传器飞到(不能的话在该楼也不允许使用楼传器) "map": [ // 地图数据,需要是13x13,建议使用地图生成器来生成 [5, 5, 5, 5, 5, 5, 87, 5, 5, 5, 5, 5, 5], @@ -296,7 +296,7 @@ main.floors.sample2 = { {"type": "hide", "loc": [4,6]}, {"type": "hide", "loc": [8,6]}, {"type": "hide", "loc": [8,3]}, - {"type": "changeFloor", "floorId": "sample2", "loc": [6,6], "direction": "up", "time": 100}, // 更换勇士地点,合计120毫秒 + {"type": "changeFloor", "floorId": "sample2", "loc": [6,6], "direction": "up", "time": 1000}, // 更换勇士地点,合计1秒 {"type": "show", "loc": [6,5]}, // 显示黄宝石 {"type": "sleep", "time": 200}, // 等待200毫秒 {"type": "playSound", "name": "item.ogg"}, diff --git a/libs/ui.js b/libs/ui.js index 38e0a6ab..284da6e1 100644 --- a/libs/ui.js +++ b/libs/ui.js @@ -351,76 +351,6 @@ ui.prototype.drawQuickShop = function (need) { } -/** - * 绘制商店 - * @param id - */ -ui.prototype.drawShop = function (id) { - var shop = core.status.shops[id]; - // 正在移动中... - - if (!core.status.heroStop) { - setTimeout(function () { - core.ui.drawShop(id); - }, 30); - return; - } - - core.status.event.data = shop; - core.status.event.id = 'shop'; - core.lockControl(); - shop.visited = true; - - var background = core.canvas.ui.createPattern(core.material.ground, "repeat"); - - var times = shop.times, need = eval(shop.need); - - clearInterval(core.interval.tipAnimate); - core.clearMap('data', 0, 0, 416, 416); - core.setOpacity('data', 1); - - core.clearMap('ui', 0, 0, 416, 416); - core.setAlpha('ui', 1); - core.setFillStyle('ui', background); - - var left = 97, top = 64, right = 416 - 2 * left, bottom = 416 - 2 * top; - core.fillRect('ui', left, top, right, bottom, background); - core.strokeRect('ui', left - 1, top - 1, right + 1, bottom + 1, '#FFFFFF', 2); - - // 名称 - core.canvas.ui.textAlign = "center"; - core.fillText('ui', shop.title, left + 135, top + 34, '#FFFFFF', 'bold 19px Verdana'); - - // 动画 - core.strokeRect('ui', left + 15 - 1, top + 30 - 1, 34, 34, '#DDDDDD', 2); - core.status.boxAnimateObjs = []; - core.status.boxAnimateObjs.push({ - 'bgx': left + 15, 'bgy': top + 30, 'bgsize': 32, - 'image': core.material.images.npcs, - 'x': left + 15, 'y': top + 30, 'icon': core.material.icons.npcs[shop.icon] - }); - core.setBoxAnimate(); - - // 对话 - core.canvas.ui.textAlign = "left"; - if (need<0) need="若干"; - var use = shop.use=='experience'?"经验":"金币"; - core.fillText('ui', "勇敢的武士啊,给我" + need, left + 60, top + 65, '#FFFFFF', 'bold 14px Verdana'); - core.fillText('ui', use + "你就可以:", left + 60, top + 83); - - // 选项 - core.canvas.ui.textAlign = "center"; - 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+")" - core.fillText('ui', text, 208, top + 120 + 32 * i, "#FFFFFF", "bold 17px Verdana"); - } - core.fillText('ui', "退出商店", 208, top + 248); - -} - /** * 绘制“请等候...” @@ -835,9 +765,11 @@ ui.prototype.drawAbout = function() { // 名称 core.canvas.ui.textAlign = "left"; - core.fillText('ui', "异空间", text_start, top+35, "#FFD700", "bold 22px Verdana"); - core.fillText('ui', "HTML5复刻版", text_start+75, top+37, "#DDDDDD", "bold 15px Verdana"); + core.fillText('ui', "HTML5 魔塔样板", text_start, top+35, "#FFD700", "bold 22px Verdana"); core.fillText('ui', "作者: 艾之葵", text_start, top + 80, "#FFFFFF", "bold 17px Verdana"); + core.fillText('ui', 'HTML5魔塔交流群:539113091', text_start, top+112); + // TODO: 写自己的“关于”页面 + /* core.fillText('ui', "原作: ss433_2", text_start, top + 112, "#FFFFFF", "bold 17px Verdana"); core.fillText('ui', "制作工具: WebStorm", text_start, top + 144, "#FFFFFF", "bold 17px Verdana"); core.fillText('ui', "测试平台: Chrome/微信/iOS", text_start, top + 176, "#FFFFFF", "bold 17px Verdana"); @@ -846,4 +778,5 @@ ui.prototype.drawAbout = function() { core.fillText('ui', 'iEcho', text_start+len, top+240); core.fillText('ui', '打Dota的喵', text_start+len, top+272); core.fillText('ui', 'HTML5魔塔交流群:539113091', text_start, top+304); + */ } \ No newline at end of file diff --git a/~$样板使用指南.docx b/~$样板使用指南.docx new file mode 100644 index 00000000..bedfefe4 Binary files /dev/null and b/~$样板使用指南.docx differ diff --git a/伤害和临界值计算器.exe b/伤害和临界值计算器.exe new file mode 100644 index 00000000..8d047c63 Binary files /dev/null and b/伤害和临界值计算器.exe differ