diff --git a/_server/fs.js b/_server/fs.js new file mode 100644 index 00000000..3384aa8e --- /dev/null +++ b/_server/fs.js @@ -0,0 +1,101 @@ +(function(){ + fs = {}; + var postsomething = function (data,_ip,callback) { + //callback:function(err, data) + //data:字符串 + var xhr = new XMLHttpRequest(); + xhr.onreadystatechange = function(){ + switch(xhr.readyState){ + case 4 : + if ((xhr.status >= 200 && xhr.status < 300) || xhr.status == 304) { + if (Boolean(callback)){ + if (xhr.responseText.slice(0,6)=='error:'){ + callback(xhr.responseText,null); + } else { + callback(null,xhr.responseText); + } + } + //printf(xhr.responseText) + }else{ + if (Boolean(callback))callback(xhr.status,null); + //printf('error:' + xhr.status+'
'+(xhr.responseText||'')); + } + break; + } + } + xhr.open('post',_ip); + xhr.setRequestHeader('Content-Type','text/plain'); + if(typeof(data)==typeof([][0]) || data==null)data=JSON.stringify({1:2}); + xhr.send(data); + } + + fs.readFile = function (filename,encoding,callback) { + if (typeof(filename)!=typeof('')) + throw 'Type Error in fs.readFile'; + if (encoding=='utf-8'){ + //读文本文件 + //filename:支持"/"做分隔符 + //callback:function(err, data) + //data:字符串 + var data=''; + data+='type=utf8&'; + data+='name='+filename; + postsomething(data,'/readFile',callback); + return; + } + if (encoding=='base64'){ + //读二进制文件 + //filename:支持"/"做分隔符 + //callback:function(err, data) + //data:base64字符串 + var data=''; + data+='type=base64&'; + data+='name='+filename; + postsomething(data,'/readFile',callback); + return; + } + throw 'Type Error in fs.readFile'; + } + + fs.writeFile = function (filename,datastr,encoding,callback) { + if (typeof(filename)!=typeof('') || typeof(datastr)!=typeof('')) + throw 'Type Error in fs.writeFile'; + if (encoding=='utf-8'){ + //写文本文件 + //filename:支持"/"做分隔符 + //callback:function(err) + //datastr:字符串 + var data=''; + data+='type=utf8&'; + data+='name='+filename; + data+='&value='+datastr; + postsomething(data,'/writeFile',callback); + return; + } + if (encoding=='base64'){ + //写二进制文件 + //filename:支持"/"做分隔符 + //callback:function(err) + //datastr:base64字符串 + var data=''; + data+='type=base64&'; + data+='name='+filename; + data+='&value='+datastr; + postsomething(data,'/writeFile',callback); + return; + } + throw 'Type Error in fs.writeFile'; + } + + fs.readdir = function (path, callback) { + //callback:function(err, data) + //path:支持"/"做分隔符,不以"/"结尾 + //data:[filename1,filename2,..] filename是字符串,只包含文件不包含目录 + if (typeof(path)!=typeof('')) + throw 'Type Error in fs.readdir'; + var data=''; + data+='name='+path; + postsomething(data,'/listFile',function(err, data){callback(err,JSON.parse(data))}); + return; + } +})(); \ No newline at end of file diff --git a/_server/fsTest_cs.html b/_server/fsTest_cs.html index 0ae73da0..fc53ee41 100644 --- a/_server/fsTest_cs.html +++ b/_server/fsTest_cs.html @@ -2,109 +2,7 @@ - + - - - - + + + + +}//core 加载['terrains','animates', 'enemys', 'items', 'npcs'] - - - - - + + + diff --git a/images/autotile1.png b/images/autotile1.png new file mode 100644 index 00000000..2dacd883 Binary files /dev/null and b/images/autotile1.png differ diff --git a/images/autotile2.png b/images/autotile2.png new file mode 100644 index 00000000..496bdc9a Binary files /dev/null and b/images/autotile2.png differ diff --git a/images/autotile3.png b/images/autotile3.png new file mode 100644 index 00000000..c7a9179d Binary files /dev/null and b/images/autotile3.png differ diff --git a/images/lv.png b/images/lv.png new file mode 100644 index 00000000..3b9cf96c Binary files /dev/null and b/images/lv.png differ diff --git a/images/terrains.png b/images/terrains.png index a28642a0..31ff78cf 100644 Binary files a/images/terrains.png and b/images/terrains.png differ diff --git a/images/up.png b/images/up.png new file mode 100644 index 00000000..705189d0 Binary files /dev/null and b/images/up.png differ diff --git a/images/常用素材:如需使用请直接替换目录中的对应文件/terrains0:经典.png b/images/常用素材:如需使用请直接替换目录中的对应文件/terrains0:经典.png deleted file mode 100644 index a28642a0..00000000 Binary files a/images/常用素材:如需使用请直接替换目录中的对应文件/terrains0:经典.png and /dev/null differ diff --git a/images/常用素材:如需使用请直接替换目录中的对应文件/terrains1:草地浅色.png b/images/常用素材:如需使用请直接替换目录中的对应文件/terrains1:草地浅色.png deleted file mode 100644 index 78134c13..00000000 Binary files a/images/常用素材:如需使用请直接替换目录中的对应文件/terrains1:草地浅色.png and /dev/null differ diff --git a/images/常用素材:如需使用请直接替换目录中的对应文件/terrains1:草地深色.png b/images/常用素材:如需使用请直接替换目录中的对应文件/terrains1:草地深色.png deleted file mode 100644 index b5fc6cec..00000000 Binary files a/images/常用素材:如需使用请直接替换目录中的对应文件/terrains1:草地深色.png and /dev/null differ diff --git a/images/常用素材:如需使用请直接替换目录中的对应文件/terrains2:冰雪.png b/images/常用素材:如需使用请直接替换目录中的对应文件/terrains2:冰雪.png deleted file mode 100644 index fc980408..00000000 Binary files a/images/常用素材:如需使用请直接替换目录中的对应文件/terrains2:冰雪.png and /dev/null differ diff --git a/images/常用素材:如需使用请直接替换目录中的对应文件/terrains3.png b/images/常用素材:如需使用请直接替换目录中的对应文件/terrains3.png deleted file mode 100644 index da690f39..00000000 Binary files a/images/常用素材:如需使用请直接替换目录中的对应文件/terrains3.png and /dev/null differ diff --git a/images/常用素材:如需使用请直接替换目录中的对应文件/terrains4:木板.png b/images/常用素材:如需使用请直接替换目录中的对应文件/terrains4:木板.png deleted file mode 100644 index 5f0e6442..00000000 Binary files a/images/常用素材:如需使用请直接替换目录中的对应文件/terrains4:木板.png and /dev/null differ diff --git a/images/常用素材:如需使用请直接替换目录中的对应文件/terrains5.png b/images/常用素材:如需使用请直接替换目录中的对应文件/terrains5.png deleted file mode 100644 index 643c3a99..00000000 Binary files a/images/常用素材:如需使用请直接替换目录中的对应文件/terrains5.png and /dev/null differ diff --git a/images/常用素材:如需使用请直接替换目录中的对应文件/terrains6:沙地.png b/images/常用素材:如需使用请直接替换目录中的对应文件/terrains6:沙地.png deleted file mode 100644 index 79730d6c..00000000 Binary files a/images/常用素材:如需使用请直接替换目录中的对应文件/terrains6:沙地.png and /dev/null differ diff --git a/images/常用素材:如需使用请直接替换目录中的对应文件/terrains7:星空神殿.png b/images/常用素材:如需使用请直接替换目录中的对应文件/terrains7:星空神殿.png deleted file mode 100644 index 6e6ceec3..00000000 Binary files a/images/常用素材:如需使用请直接替换目录中的对应文件/terrains7:星空神殿.png and /dev/null differ diff --git a/images/常用素材:如需使用请直接替换目录中的对应文件/terrains8:一层小塔.png b/images/常用素材:如需使用请直接替换目录中的对应文件/terrains8:一层小塔.png deleted file mode 100644 index 6ac4277d..00000000 Binary files a/images/常用素材:如需使用请直接替换目录中的对应文件/terrains8:一层小塔.png and /dev/null differ diff --git a/index.html b/index.html index fb79075f..44c759a0 100644 --- a/index.html +++ b/index.html @@ -47,10 +47,14 @@

-
+

+
+ +

+

@@ -67,7 +71,7 @@

-
+

@@ -75,12 +79,16 @@

+
+ +

+
-
+
@@ -96,10 +104,11 @@

+
- + 此浏览器不支持HTML5
diff --git a/libs/core.js b/libs/core.js index 6c6cfc0d..fb84f7b0 100644 --- a/libs/core.js +++ b/libs/core.js @@ -77,15 +77,18 @@ function core() { 'moveStepBeforeStop': [], // 勇士状态;中心对称飞行器 - 'usingCenterFly':false, // event事件 - 'savePage': null, + 'saveIndex': null, 'shops': {}, 'event': { 'id': null, - 'data': null + 'data': null, + 'selection': null, + 'ui': null, }, + 'curtainColor': null, + 'usingCenterFly':false, 'openingDoor': null, // 动画 @@ -111,6 +114,13 @@ core.prototype.init = function (dom, statusBar, canvas, images, sounds, floorIds core[key] = coreData[key]; } core.flags = core.clone(core.data.flags); + if (!core.flags.enableExperience) + core.flags.enableLevelUp = false; + if (!core.flags.canOpenBattleAnimate) { + core.flags.showBattleAnimateConfirm = false; + core.flags.battleAnimate = false; + core.setLocalStorage('battleAnimate', false); + } core.values = core.clone(core.data.values); core.firstData = core.data.getFirstData(); core.initStatus.shops = core.firstData.shops; @@ -134,6 +144,11 @@ core.prototype.init = function (dom, statusBar, canvas, images, sounds, floorIds core.musicStatus.soundStatus = false; } + // switchs + core.flags.battleAnimate = core.getLocalStorage('battleAnimate', core.flags.battleAnimate); + core.flags.displayEnemyDamage = core.getLocalStorage('enemyDamage', core.flags.displayEnemyDamage); + core.flags.displayExtraDamage = core.getLocalStorage('extraDamage', core.flags.displayExtraDamage); + core.material.ground = new Image(); core.material.ground.src = "images/ground.png"; @@ -203,31 +218,24 @@ core.prototype.loader = function (callback) { for (var i = 0; i < core.images.length; i++) { core.loadImage(core.images[i], function (imgName, image) { core.setStartLoadTipText('正在加载图片 ' + imgName + "..."); - imgName = imgName.split('-'); - imgName = imgName[0]; core.material.images[imgName] = image; loadedImageNum++; core.setStartLoadTipText(imgName + ' 加载完毕...'); core.setStartProgressVal(loadedImageNum * (100 / allImageNum)); if (loadedImageNum == allImageNum) { - // 加载音频 - for (var key in core.sounds) { - for (var i = 0; i < core.sounds[key].length; i++) { - var soundName=core.sounds[key][i]; - soundName = soundName.split('-'); - var sound = new Audio(); - sound.preload = 'none'; - sound.src = 'sounds/' + soundName[0] + '.' + key; - if (soundName[1] == 'loop') { - sound.loop = 'loop'; + + // 加载Autotile + core.material.images.autotile={}; + var autotileIds = Object.keys(core.material.icons.autotile); + for (var x=0;x=4 && x<=8) { - if (y==5) { - core.syncSave("save"); - } - if (y==6) { - core.syncSave("load"); - } - } - if (x>=5 && x<=7) { - if (y==7) { - core.ui.drawConfirmBox("你确定要清空所有本地存档吗?", function() { - localStorage.clear(); - core.drawText("\t[操作成功]你的本地所有存档已被清空。"); - }, function() { - core.ui.drawSettings(false); - }) - } - if (y==8) - core.ui.drawSettings(false); - } + core.events.clickSyncSave(x,y); + return; } } @@ -819,8 +872,8 @@ core.prototype.onmousewheel = function (direct) { // 存读档 if (core.status.lockControl && (core.status.event.id == 'save' || core.status.event.id == 'load')) { - if (direct==1) core.ui.drawSLPanel(core.status.event.data - 1); - if (direct==-1) core.ui.drawSLPanel(core.status.event.data + 1); + if (direct==1) core.ui.drawSLPanel(core.status.event.data - 6); + if (direct==-1) core.ui.drawSLPanel(core.status.event.data + 6); return; } } @@ -1484,13 +1537,14 @@ core.prototype.afterBattle = function(id, x, y, callback) { var experience = core.material.enemys[id].experience; if (core.hasFlag('curse')) experience=0; core.status.hero.experience += experience; - core.updateStatusBar(); if (core.isset(x) && core.isset(y)) { core.removeBlock(x, y); core.canvas.event.clearRect(32 * x, 32 * y, 32, 32); } - core.updateFg(); - var hint = "打败 " + core.material.enemys[id].name + ",金币+" + money; + // core.updateStatusBar(); + var hint = "打败 " + core.material.enemys[id].name; + if (core.flags.enableMoney) + hint += ",金币+" + money; if (core.flags.enableExperience) hint += ",经验+" + core.material.enemys[id].experience; core.drawTip(hint); @@ -1537,15 +1591,19 @@ core.prototype.changeFloor = function (floorId, stair, heroLoc, time, callback) core.clearContinueAutomaticRoute(); core.dom.floorNameLabel.innerHTML = core.status.maps[floorId].title; if (core.isset(stair)) { - // find heroLoc - heroLoc = core.status.hero.loc; + if (!core.isset(heroLoc)) heroLoc={}; var blocks = core.status.maps[floorId].blocks; for (var i in blocks) { if (core.isset(blocks[i].event) && !(core.isset(blocks[i].enable) && !blocks[i].enable) && blocks[i].event.id === stair) { heroLoc.x = blocks[i].x; heroLoc.y = blocks[i].y; + break; } } + if (!core.isset(heroLoc.x)) { + heroLoc.x=core.status.hero.loc.x; + heroLoc.y=core.status.hero.loc.y; + } } if (core.status.maps[floorId].canFlyTo && core.status.hero.flyRange.indexOf(floorId)<0) { if (core.floorIds.indexOf(floorId)>core.floorIds.indexOf(core.status.floorId)) @@ -1555,11 +1613,17 @@ core.prototype.changeFloor = function (floorId, stair, heroLoc, time, callback) } window.setTimeout(function () { - // console.log('地图切换到' + floorId); core.playSound('floor', 'mp3'); core.mapChangeAnimate('show', time/2, function () { - core.statusBar.floor.innerHTML = core.status.maps[floorId].name; - core.updateStatusBar(); + + // 根据文字判断是否斜体 + var floorName = core.status.maps[floorId].name; + if (!core.isset(floorName) || floorName=="") floorName=" " + core.statusBar.floor.innerHTML = floorName; + if (/^[+-]?\d+$/.test(floorName)) + core.statusBar.floor.style.fontStyle = 'italic'; + else core.statusBar.floor.style.fontStyle = 'normal'; + core.drawMap(floorId, function () { setTimeout(function() { core.mapChangeAnimate('hide', time/4, function () { @@ -1572,9 +1636,10 @@ core.prototype.changeFloor = function (floorId, stair, heroLoc, time, callback) core.setHeroLoc('x', heroLoc.x); core.setHeroLoc('y', heroLoc.y); core.drawHero(core.getHeroLoc('direction'), core.getHeroLoc('x'), core.getHeroLoc('y'), 'stop'); - core.updateCheckBlockMap(); - core.updateCheckBlock(); - core.updateFg(); + core.updateStatusBar(); + // core.updateCheckBlockMap(); + // core.updateCheckBlock(); + // core.updateFg(); }, 15) }); }); @@ -1717,13 +1782,13 @@ core.prototype.drawMap = function (mapName, callback) { var mapBlocks = mapData.blocks; core.status.floorId = mapName; core.status.thisMap = mapData; - var blockIcon, blockImage; core.clearMap('all'); core.removeGlobalAnimate(null, null, true); + var groundId = core.floors[mapName].defaultGround || "ground"; + var blockIcon = core.material.icons.terrains[groundId]; + var blockImage = core.material.images.terrains; for (var x = 0; x < 13; x++) { for (var y = 0; y < 13; y++) { - blockIcon = core.material.icons.terrains.ground; - blockImage = core.material.images.terrains; core.canvas.bg.drawImage(blockImage, 0, blockIcon * 32, 32, 32, x * 32, y * 32, 32, 32); } } @@ -1734,7 +1799,7 @@ core.prototype.drawMap = function (mapName, callback) { if (core.isset(block.event) && !(core.isset(block.enable) && !block.enable)) { if (block.event.cls == 'autotile') { // core.drawAutotile(); - autotileMaps[13*block.x + block.y] = true; + autotileMaps[13*block.x + block.y] = block.event.id; continue; } else { @@ -1745,24 +1810,36 @@ core.prototype.drawMap = function (mapName, callback) { } } } - core.drawAutotile('event', autotileMaps, 0, 0, 32); + core.drawAutotile(mapName, 'event', autotileMaps, 0, 0, 32); core.setGlobalAnimate(core.values.animateSpeed); if (core.isset(callback)) callback(); } -core.prototype.drawAutotile = function (canvas, autotileMaps, left, top, size) { +core.prototype.drawAutotile = function (floorId, canvas, autotileMaps, left, top, size, autotileId) { + + if (!core.isset(autotileId)) { + var autotileIds = {}; + autotileMaps.forEach(function (t) { + if (core.isset(t)) autotileIds[t]=true; + }); + Object.keys(autotileIds).forEach(function (t) { + core.drawAutotile(floorId, canvas, autotileMaps, left, top, size, t); + }) + return; + } + var isAutotile = function(x, y) { if (x<0 || x>12 || y<0 || y>12) return 0; - return autotileMaps[13*x+y]?1:0; + return autotileMaps[13*x+y]==autotileId?1:0; } for (var xx=0;xx<13;xx++) { for (var yy=0;yy<13;yy++) { if (isAutotile(xx, yy)) { // 绘制autotile var id=isAutotile(xx, yy - 1) + 2 * isAutotile(xx - 1, yy) + 4 * isAutotile(xx, yy + 1) + 8 * isAutotile(xx + 1, yy); - core.drawAutotileBlock(canvas, left + xx * size, top + yy * size, size, core.material.images.autotile, id); + core.drawAutotileBlock(floorId, canvas, left + xx * size, top + yy * size, size, core.material.images.autotile[autotileId], id); } } } @@ -1770,24 +1847,25 @@ core.prototype.drawAutotile = function (canvas, autotileMaps, left, top, size) { for (var yy=0;yy<13;yy++) { if (isAutotile(xx, yy) + isAutotile(xx + 1, yy) + isAutotile(xx + 1, yy + 1) + isAutotile(xx, yy + 1) != 3) continue; if (!isAutotile(xx, yy)) { - core.drawAutotileBlock(canvas, left + xx * size + size, top + yy * size + size, size, core.material.images.autotile, 16); + core.drawAutotileBlock(floorId, canvas, left + xx * size + size, top + yy * size + size, size, core.material.images.autotile[autotileId], 16); } if (!isAutotile(xx + 1, yy)) { - core.drawAutotileBlock(canvas, left + xx * size + size / 2, top + yy * size + size, size, core.material.images.autotile, 17); + core.drawAutotileBlock(floorId, canvas, left + xx * size + size / 2, top + yy * size + size, size, core.material.images.autotile[autotileId], 17); } if (!isAutotile(xx + 1, yy + 1)) { - core.drawAutotileBlock(canvas, left + xx * size + size / 2, top + yy * size + size / 2, size, core.material.images.autotile, 18); + core.drawAutotileBlock(floorId, canvas, left + xx * size + size / 2, top + yy * size + size / 2, size, core.material.images.autotile[autotileId], 18); } if (!isAutotile(xx, yy + 1)) { - core.drawAutotileBlock(canvas, left + xx * size + size, top + yy * size + size / 2, size, core.material.images.autotile, 19); + core.drawAutotileBlock(floorId, canvas, left + xx * size + size, top + yy * size + size / 2, size, core.material.images.autotile[autotileId], 19); } } } } -core.prototype.drawAutotileBlock = function (map, x, y, size, autotile, index) { +core.prototype.drawAutotileBlock = function (floorId, map, x, y, size, autotile, index) { var canvas = core.canvas[map]; - var blockIcon = core.material.icons.terrains.ground; + var groundId = core.floors[floorId].defaultGround || "ground"; + var blockIcon = core.material.icons.terrains[groundId]; var blockImage = core.material.images.terrains; switch (index) { case 0: @@ -2348,30 +2426,23 @@ core.prototype.hasBetweenAttack = function(x,y) { core.prototype.setFg = function(color, time, callback) { time = time || 750; - core.setOpacity('fg', 1); - var reset = false; - - if (!core.isset(core.status.event.data.currentColor)) { - core.status.event.data.currentColor = [0,0,0,0]; + if (!core.isset(core.status.curtainColor)) { + core.status.curtainColor = [0,0,0,0]; } - var fromColor = core.status.event.data.currentColor; + var fromColor = core.status.curtainColor; - if (!core.isset(color)) { + if (!core.isset(color)) color = [0,0,0,0]; - reset = true; - } - if (color.length==3) { + if (color.length==3) color.push(1); - } if (color[3]<0) color[3]=0; if (color[3]>1) color[3]=1; var step=0; var changeAnimate = setInterval(function() { step++; - core.clearMap('fg', 0, 0, 416, 416); var nowAlpha = fromColor[3]+(color[3]-fromColor[3])*step/25; var nowR = parseInt(fromColor[0]+(color[0]-fromColor[0])*step/25); @@ -2381,19 +2452,13 @@ core.prototype.setFg = function(color, time, callback) { if (nowG<0) nowG=0; if (nowG>255) nowG=255; if (nowB<0) nowB=0; if (nowB>255) nowB=255; - core.setAlpha('fg', nowAlpha); - var toRGB = "#"+((1<<24)+(nowR<<16)+(nowG<<8)+nowB).toString(16).slice(1) - core.fillRect('fg', 0, 0, 416, 416, toRGB); + var toRGB = "#"+((1<<24)+(nowR<<16)+(nowG<<8)+nowB).toString(16).slice(1); + core.dom.curtain.style.background = toRGB; + core.dom.curtain.style.opacity = nowAlpha; if (step>=25) { clearInterval(changeAnimate); - if (reset) { - core.clearMap('fg', 0, 0, 416, 416); - delete core.status.event.data.currentColor; - core.setAlpha('fg', 1); - core.updateFg(); - } - else core.status.event.data.currentColor = color; + core.status.curtainColor = color; if (core.isset(callback)) callback(); } }, time/25); @@ -2443,6 +2508,7 @@ core.prototype.nextY = function () { */ core.prototype.updateFg = function () { + /* // 如果存在颜色 if (core.isset(core.status.event.data) && core.isset(core.status.event.data.currentColor)) { var color=core.status.event.data.currentColor; @@ -2450,6 +2516,7 @@ core.prototype.updateFg = function () { core.fillRect("fg",0,0,416,416,"#"+((1<<24)+(color[0]<<16)+(color[1]<<8)+color[2]).toString(16).slice(1)); return; } + */ if (!core.isset(core.status.thisMap) || !core.isset(core.status.thisMap.blocks)) return; // 更新显伤 @@ -2715,6 +2782,21 @@ core.prototype.calValue = function (value) { return eval(value); } +core.prototype.doEffect = function (expression) { + // 必须使用"+=" + var arr = expression.split("+="); + if (arr.length!=2) return; + var name=arr[0], value=core.calValue(arr[1]); + if (name.indexOf("status:")==0) { + var status=name.substring(7); + core.setStatus(status, core.getStatus(status)+value); + } + else if (name.indexOf("item:")==0) { + var itemId=name.substring(5); + core.setItem(itemId, core.itemCount(itemId)+value); + } +} + core.prototype.splitLines = function(canvas, text, maxLength, font) { if (core.isset(font)) core.setFont(canvas, font); @@ -2900,7 +2982,7 @@ core.prototype.openToolbox = function (need) { core.prototype.save = function(need) { if (!core.checkStatus('save', need)) return; - core.ui.drawSLPanel(core.status.savePage); + core.ui.drawSLPanel(core.status.saveIndex); } core.prototype.load = function (need) { @@ -2910,22 +2992,22 @@ core.prototype.load = function (need) { core.status.event = {'id': 'load', 'data': null}; core.status.lockControl = true; core.dom.startPanel.style.display = 'none'; - var page = core.getLocalStorage('savePage', 0); - core.ui.drawSLPanel(page); + core.ui.drawSLPanel(core.getLocalStorage('saveIndex', 1)); return; } if (!core.checkStatus('load', need)) return; - core.ui.drawSLPanel(core.status.savePage); + core.ui.drawSLPanel(core.status.saveIndex); } core.prototype.doSL = function (id, type) { + core.status.saveIndex=id; if (type=='save') { if (core.saveData("save"+id)) { core.ui.closePanel(); core.drawTip('存档成功!'); - core.setLocalStorage('savePage', core.status.savePage); + core.setLocalStorage('saveIndex', core.status.saveIndex); } else { core.drawTip('存储空间不足,请覆盖已有的存档或在菜单栏中进行清理'); @@ -2944,7 +3026,8 @@ core.prototype.doSL = function (id, type) { } core.ui.closePanel(); core.loadData(data, function() { - core.setLocalStorage('savePage', core.status.savePage); + core.status.saveIndex=id; + core.setLocalStorage('saveIndex', core.status.saveIndex); core.drawTip("读档成功"); }); return; @@ -2953,6 +3036,7 @@ core.prototype.doSL = function (id, type) { core.prototype.syncSave = function(type) { if (type=='save') { + core.status.event.selection=1; core.ui.drawConfirmBox("你确定要将本地存档同步到服务器吗?", function(){ // console.log("同步存档..."); core.ui.drawWaiting("正在同步,请稍后..."); @@ -2999,11 +3083,12 @@ core.prototype.syncSave = function(type) { } xhr.send(formData); }, function() { + core.status.event.selection=0; core.ui.drawSyncSave(); }) } else if (type=='load') { - + core.status.event.selection=1; core.ui.drawConfirmBox("你确定要从服务器加载存档吗?\n该操作将覆盖所有本地存档且不可逆!", function(){ var id = prompt("请输入存档编号:"); if (id==null || id=="") { @@ -3070,6 +3155,7 @@ core.prototype.syncSave = function(type) { } xhr.send(formData); }, function() { + core.status.event.selection=1; core.ui.drawSyncSave(); }) } @@ -3083,7 +3169,6 @@ core.prototype.saveData = function(dataId) { 'hard': core.status.hard, 'maps': core.maps.save(core.status.maps), 'shops': {}, - 'flags': core.flags, 'version': core.firstData.version, "time": new Date().getTime() }; @@ -3101,7 +3186,7 @@ core.prototype.saveData = function(dataId) { core.prototype.loadData = function (data, callback) { - core.resetStatus(data.hero, data.hard, data.floorId, data.flags, core.maps.load(data.maps)); + core.resetStatus(data.hero, data.hard, data.floorId, core.maps.load(data.maps)); // load shop times for (var shop in core.status.shops) { @@ -3125,6 +3210,11 @@ core.prototype.getStatus = function (statusName) { return core.status.hero[statusName]; } +core.prototype.getLvName = function () { + if (core.status.hero.lv>core.firstData.levelUp.length) return core.status.hero.lv; + return core.firstData.levelUp[core.status.hero.lv-1].name || core.status.hero.lv; +} + core.prototype.setFlag = function(flag, value) { if (!core.isset(core.status.hero)) return; core.status.hero.flags[flag]=value; @@ -3245,9 +3335,9 @@ core.prototype.hide = function (obj, speed, callback) { ////// 状态栏相关 ////// core.prototype.clearStatusBar = function() { - var statusList = ['floor', 'hp', 'atk', 'def', 'mdef', 'money', 'experience', 'yellowKey', 'blueKey', 'redKey', 'poison', 'weak', 'curse', 'hard']; + var statusList = ['floor', 'lv', 'hp', 'atk', 'def', 'mdef', 'money', 'experience', 'up', 'yellowKey', 'blueKey', 'redKey', 'poison', 'weak', 'curse', 'hard']; statusList.forEach(function (e) { - core.statusBar[e].innerHTML = ""; + core.statusBar[e].innerHTML = " "; }); core.statusBar.image.book.style.opacity = 0.3; core.statusBar.image.fly.style.opacity = 0.3; @@ -3258,16 +3348,30 @@ core.prototype.clearStatusBar = function() { */ core.prototype.updateStatusBar = function () { + // 检查登记 + core.checkLvUp(); + // 上限999999 if (core.values.HPMAX>0) { core.setStatus('hp', Math.min(core.values.HPMAX, core.getStatus('hp'))); } - // core.statusBar.floor.innerHTML = core.maps.maps[core.status.floorId].name; + var lvName = core.getLvName(); + core.statusBar.lv.innerHTML = lvName; + if (/^[+-]?\d+$/.test(lvName)) + core.statusBar.lv.style.fontStyle = 'italic'; + else core.statusBar.lv.style.fontStyle = 'normal'; + var statusList = ['hp', 'atk', 'def', 'mdef', 'money', 'experience']; statusList.forEach(function (item) { core.statusBar[item].innerHTML = core.getStatus(item); }); + // 进阶 + if (core.flags.enableLevelUp && core.status.hero.lv=core.firstData.levelUp.length) return; + // 计算下一个所需要的数值 + var need=core.firstData.levelUp[core.status.hero.lv].need; + if (!core.isset(need)) return; + if (core.status.hero.experience>=need) { + // 升级 + core.status.hero.lv++; + var effect = core.firstData.levelUp[core.status.hero.lv-1].effect; + if (typeof effect == "string") { + effect.split(";").forEach(function (t) { + core.doEffect(t); + }); + } + else if (effect instanceof Function) { + effect(); + } + core.checkLvUp(); + } +} + core.prototype.resize = function(clientWidth, clientHeight) { // 默认画布大小 @@ -3320,18 +3445,22 @@ core.prototype.resize = function(clientWidth, clientHeight) { statusWidth, statusHeight, statusMaxWidth,statusLabelsLH, toolBarWidth, toolBarHeight, toolBarTop, toolBarBorder, toolsWidth, toolsHeight,toolsMargin,toolsPMaxwidth, - fontSize, margin; + fontSize, toolbarFontSize, margin; - var count = 9; + var count = 11; + if (!core.flags.enableFloor) count--; + if (!core.flags.enableLv) count--; if (!core.flags.enableMDef) count--; + if (!core.flags.enableMoney) count--; if (!core.flags.enableExperience) count--; + if (!core.flags.enableLevelUp) count--; if (!core.flags.enableDebuff) count--; - var statusLineHeight = BASE_LINEHEIGHT * 9/count; + var statusLineHeight = BASE_LINEHEIGHT * 9 / count; + var statusLineFontSize = DEFAULT_FONT_SIZE; + if (count>9) statusLineFontSize = statusLineFontSize * 9 / count; - var shopDisplay, mdefDisplay, expDisplay; - mdefDisplay = core.flags.enableMDef ? 'block' : 'none'; - expDisplay = core.flags.enableExperience ? 'block' : 'none'; + var shopDisplay; statusBarBorder = '3px #fff solid'; toolBarBorder = '3px #fff solid'; @@ -3351,13 +3480,13 @@ core.prototype.resize = function(clientWidth, clientHeight) { var scale = core.domStyle.scale var tempWidth = DEFAULT_CANVAS_WIDTH * scale; - fontSize = DEFAULT_FONT_SIZE * scale; if(!isHorizontal){ //竖屏 core.domStyle.screenMode = 'vertical'; //显示快捷商店图标 shopDisplay = 'block'; //判断应该显示几行 - var col = core.flags.enableMDef || core.flags.enableExperience || core.flags.enableDebuff ? 3 : 2; + // var col = core.flags.enableMDef || core.flags.enableExperience || core.flags.enableDebuff ? 3 : 2; + var col = parseInt((count-1)/3)+1; var tempTopBarH = scale * (BASE_LINEHEIGHT * col + SPACE * 2) + 6; var tempBotBarH = scale * (BASE_LINEHEIGHT + SPACE * 4) + 6; @@ -3384,6 +3513,8 @@ core.prototype.resize = function(clientWidth, clientHeight) { margin = scale * SPACE * 2; toolsMargin = scale * SPACE * 4; + fontSize = DEFAULT_FONT_SIZE * scale; + toolbarFontSize = DEFAULT_FONT_SIZE * scale; }else { //横屏 core.domStyle.screenMode = 'horizontal'; shopDisplay = 'none'; @@ -3401,6 +3532,8 @@ core.prototype.resize = function(clientWidth, clientHeight) { toolBarTop = scale*statusLineHeight * count + SPACE * 2; toolBarBorder = '3px #fff solid'; toolsHeight = scale * BASE_LINEHEIGHT; + fontSize = statusLineFontSize * scale; + toolbarFontSize = DEFAULT_FONT_SIZE * scale; borderRight = ''; statusMaxWidth = scale * DEFAULT_BAR_WIDTH; toolsPMaxwidth = scale * DEFAULT_BAR_WIDTH; @@ -3430,7 +3563,8 @@ core.prototype.resize = function(clientWidth, clientHeight) { toolsHeight = BASE_LINEHEIGHT; borderRight = ''; - fontSize = DEFAULT_FONT_SIZE; + fontSize = statusLineFontSize; + toolbarFontSize = DEFAULT_FONT_SIZE; statusMaxWidth = DEFAULT_BAR_WIDTH; toolsPMaxwidth = DEFAULT_BAR_WIDTH * .9; margin = SPACE * 2; @@ -3455,11 +3589,18 @@ core.prototype.resize = function(clientWidth, clientHeight) { height: canvasWidth + unit, top: canvasTop + unit, right: 0, - // left: canvasLeft + unit, - border: '3px #fff solid', } }, + { + id: 'curtain', + rules: { + width: (canvasWidth - SPACE*2) + unit, + height:(canvasWidth - SPACE*2) + unit, + top: (canvasTop + SPACE) + unit, + right: SPACE + unit, + } + }, { id: 'floorMsgGroup', rules:{ @@ -3511,7 +3652,7 @@ core.prototype.resize = function(clientWidth, clientHeight) { borderBottom: toolBarBorder, borderLeft: toolBarBorder, borderRight: borderRight, - fontSize: fontSize + unit + fontSize: toolbarFontSize + unit } }, { @@ -3530,17 +3671,53 @@ core.prototype.resize = function(clientWidth, clientHeight) { } }, { - id: 'expCol', + id: 'floorCol', rules: { - display: expDisplay + display: core.flags.enableFloor ? 'block': 'none' + } + }, + { + id: 'lvCol', + rules: { + display: core.flags.enableLv ? 'block': 'none' } }, { id: 'mdefCol', rules: { - display: mdefDisplay + display: core.flags.enableMDef ? 'block': 'none' } }, + { + id: 'moneyCol', + rules: { + display: core.flags.enableMoney ? 'block': 'none' + } + }, + { + id: 'expCol', + rules: { + display: core.flags.enableExperience ? 'block': 'none' + } + }, + { + id: 'upCol', + rules: { + display: core.flags.enableLevelUp ? 'block': 'none' + } + }, + { + 'id': 'debuffCol', + rules: { + display: core.flags.enableDebuff ? 'block': 'none' + } + }, + { + id: 'hard', + rules: { + lineHeight: toolsHeight + unit + } + } ] core.domRenderer(); } diff --git a/libs/data.js b/libs/data.js index d91af1c6..d8ad6961 100644 --- a/libs/data.js +++ b/libs/data.js @@ -10,12 +10,13 @@ data.prototype.init = function() { "floorId": "sample0", // 初始楼层ID "hero": { // 勇士初始数据 "name": "阳光", // 勇士名;可以改成喜欢的 + 'lv': 1, // 初始等级,该项必须为正整数 "hp": 1000, // 初始生命值 "atk": 100, // 初始攻击 "def": 100, // 初始防御 "mdef": 100, // 初始魔防 "money": 100, // 初始金币 - "experience": 1000, // 初始经验 + "experience": 0, // 初始经验 "items": { // 初始道具个数 "keys": { "yellowKey": 0, @@ -57,10 +58,11 @@ data.prototype.init = function() { {"text": "防御+4", "effect": "status:def+=4"}, {"text": "魔防+10", "effect": "status:mdef+=10"} // effect只能对status和item进行操作,不能修改flag值。 - // 中间只能用+=符号(也就是只能增加某个属性或道具) + // 必须是X+=Y的形式,其中Y可以是一个表达式,以status:xxx或item:xxx为参数 // 其他effect样例: // "item:yellowKey+=1" 黄钥匙+1 // "item:pickaxe+=3" 破墙镐+3 + // "status:hp+=2*(status:atk+status:def)" 将生命提升攻防和的数值的两倍 ] }, "expShop1": { // 商店唯一ID @@ -73,13 +75,33 @@ data.prototype.init = function() { "choices": [ // 在choices中写need,可以针对每个选项都有不同的需求。 // 这里的need同样可以以times作为参数,比如 "need": "100+20*times" - {"text": "等级+1", "need": "100", "effect": "status:hp+=1000;status:atk+=7;status:def+=7"}, + {"text": "等级+1", "need": "100", "effect": "status:lv+=1;status:hp+=1000;status:atk+=7;status:def+=7"}, // 多个effect直接以分号分开即可。如上面的意思是生命+1000,攻击+7,防御+7。 {"text": "攻击+5", "need": "30", "effect": "status:atk+=5"}, {"text": "防御+5", "need": "30", "effect": "status:def+=5"}, ] - } + }, }, + "levelUp": [ // 经验升级所需要的数值,是一个数组 + {}, // 第一项为初始等级,可以简单留空,也可以写name + + // 每一个里面可以含有三个参数 name, need, effect + // need为所需要的经验数值,是一个正整数。请确保need所需的依次递增 + // name为该等级的名称,也可以省略代表使用系统默认值;本项将显示在状态栏中 + // effect为本次升级所执行的操作,可由若干项组成,由分号分开 + // 其中每一项写法和上面的商店完全相同,同样必须是X+=Y的形式,Y是一个表达式,同样可以使用status:xxx或item:xxx代表勇士的某项数值/道具个数 + {"need": 20, "name": "第二级", "effect": "status:hp+=2*(status:atk+status:def);status:atk+=10;status:def+=10"}, // 先将生命提升攻防和的2倍;再将攻击+10,防御+10 + + // effect也允许写一个function,代表本次升级将会执行的操作 + {"need": 40, "effect": function () { + core.drawText("恭喜升级!"); + core.status.hero.hp *= 2; + core.status.hero.atk += 100; + core.status.hero.def += 100; + }}, + + // 依次往下写需要的数值即可 + ] } // 各种数值;一些数值可以在这里设置 this.values = { @@ -118,9 +140,15 @@ data.prototype.init = function() { // 系统FLAG,在游戏运行中中请不要修改它。 this.flags = { /****** 角色状态相关 ******/ - "enableMDef": true, // 是否涉及勇士的魔防值;如果此项为false,则状态栏不会显示勇士的魔防值 - "enableExperience": true, // 是否涉及经验值;如果此项为false,则状态栏和怪物手册均将不会显示经验值 + "enableNegativeDamage": true, // 是否支持负伤害(回血) + "enableFloor": false, // 是否在状态栏显示当前楼层 + "enableLv": true, // 是否在状态栏显示当前等级 + "enableMDef": true, // 是否在状态栏及战斗界面显示魔防(护盾) + "enableMoney": true, // 是否在状态栏、怪物手册及战斗界面显示金币 + "enableExperience": true, // 是否在状态栏、怪物手册及战斗界面显示经验 + "enableLevelUp": false, // 是否允许等级提升(进阶);如果上面enableExperience为false,则此项恒视为false "enableDebuff": true, // 是否涉及毒衰咒;如果此项为false则不会在状态栏中显示毒衰咒的debuff + ////// 上述的几个开关将直接影响状态栏的显示效果 ////// /****** 道具相关 ******/ "flyNearStair": true, // 是否需要在楼梯边使用传送器 "pickaxeFourDirections": true, // 使用破墙镐是否四个方向都破坏;如果false则只破坏面前的墙壁 @@ -128,6 +156,8 @@ data.prototype.init = function() { "bigKeyIsBox": false, // 如果此项为true,则视为钥匙盒,红黄蓝钥匙+1;若为false,则视为大黄门钥匙 /****** 系统相关 ******/ "startDirectly": false, // 点击“开始游戏”后是否立刻开始游戏而不显示难度选择界面 + "canOpenBattleAnimate": true, // 是否允许用户开启战斗过程;如果此项为false,则下面两项均强制视为false + "showBattleAnimateConfirm": true, // 是否在游戏开始时提供“是否开启战斗动画”的选项 "battleAnimate": true, // 是否默认显示战斗动画;用户可以手动在菜单栏中开关 "displayEnemyDamage": true, // 是否地图怪物显伤;用户可以手动在菜单栏中开关 "displayExtraDamage": false, // 是否地图高级显伤(领域、夹击等);用户可以手动在菜单栏中开关 diff --git a/libs/enemys.js b/libs/enemys.js index a5e8b71f..f236d68d 100644 --- a/libs/enemys.js +++ b/libs/enemys.js @@ -5,7 +5,7 @@ function enemys() { enemys.prototype.init = function () { // 怪物属性初始化定义: this.enemys = { - 'greenSlime': {'name': '绿头怪', 'hp': 100, 'atk': 120, 'def': 0, 'money': 1, 'experience': 0, 'special': 0}, + 'greenSlime': {'name': '绿头怪', 'hp': 100, 'atk': 120, 'def': 0, 'money': 1, 'experience': 1, 'special': 0}, 'redSlime': {'name': '红头怪', 'hp': 0, 'atk': 0, 'def': 0, 'money': 0, 'experience': 0, 'special': 0}, 'blackSlime': {'name': '青头怪', 'hp': 0, 'atk': 0, 'def': 0, 'money': 0, 'experience': 0, 'special': 0}, 'slimelord': {'name': '怪王', 'hp': 100, 'atk': 120, 'def': 0, 'money': 10, 'experience': 0, 'special': 9}, @@ -76,7 +76,7 @@ enemys.prototype.getEnemys = function (enemyId) { } enemys.prototype.hasSpecial = function (special, test) { - return special!=0 && (special%100 == test || this.hasSpecial(parseInt(special/100), test)); + return (special instanceof Array)?special.indexOf(test)>=0:(special!=0&&(special%100==test||this.hasSpecial(parseInt(special/100), test))); } enemys.prototype.getSpecialText = function (enemyId) { @@ -131,7 +131,7 @@ enemys.prototype.getCritical = function (monsterId) { if (this.hasSpecial(monster.special, 3) || this.hasSpecial(monster.special, 10)) return "???"; var last = this.calDamage(core.status.hero.atk, core.status.hero.def, core.status.hero.mdef, monster.hp, monster.atk, monster.def, monster.special); - if (last == 0) return 0; + if (last <= 0) return 0; for (var i = core.status.hero.atk + 1; i <= monster.hp + monster.def; i++) { var damage = this.calDamage(i, core.status.hero.def, core.status.hero.mdef, @@ -147,9 +147,8 @@ enemys.prototype.getCritical = function (monsterId) { enemys.prototype.getCriticalDamage = function (monsterId) { var c = this.getCritical(monsterId); if (c == '???') return '???'; - if (c == 0) return 0; + if (c <= 0) return 0; var monster = core.material.enemys[monsterId]; - // if (c<=0) return 0; var last = this.calDamage(core.status.hero.atk, core.status.hero.def, core.status.hero.mdef, monster.hp, monster.atk, monster.def, monster.special); if (last == 999999999) return '???'; @@ -202,11 +201,7 @@ enemys.prototype.calDamage = function (hero_atk, hero_def, hero_mdef, mon_hp, mo var ans = damage + turn * per_damage + (turn + 1) * counterDamage; ans -= hero_mdef; - // 魔防回血 - // return ans; - - // 魔防不回血 - return ans <= 0 ? 0 : ans; + return core.flags.enableNegativeDamage?ans:Math.max(0, ans); } // 获得当前楼层的怪物列表 diff --git a/libs/events.js b/libs/events.js index 74f6a00e..26d62ac6 100644 --- a/libs/events.js +++ b/libs/events.js @@ -20,12 +20,11 @@ events.prototype.init = function () { callback(); }, 'changeFloor': function (data, core, callback) { - var heroLoc = null; - if (core.isset(data.event.data.loc)) { + var heroLoc = {}; + if (core.isset(data.event.data.loc)) heroLoc = {'x': data.event.data.loc[0], 'y': data.event.data.loc[1]}; - if (core.isset(data.event.data.direction)) - heroLoc.direction = data.event.data.direction; - } + if (core.isset(data.event.data.direction)) + heroLoc.direction = data.event.data.direction; core.changeFloor(data.event.data.floorId, data.event.data.stair, heroLoc, data.event.data.time, callback); }, @@ -66,22 +65,43 @@ events.prototype.startGame = function (hard) { core.hideStartAnimate(function() { core.drawText(core.clone(core.firstData.startText), function() { - core.startGame(hard); - if (hard=='Easy') { // 简单难度 - core.setFlag('hard', 1); // 可以用flag:hard来获得当前难度 - // 可以在此设置一些初始福利,比如设置初始生命值可以调用: - // core.setStatus("hp", 10000); + if (core.flags.showBattleAnimateConfirm) { // 是否提供“开启战斗动画”的选择项 + core.status.event.selection = core.flags.battleAnimate ? 0 : 1; + core.ui.drawConfirmBox("你想开启战斗动画吗?\n之后可以在菜单栏中开启或关闭。\n(强烈建议新手开启此项)", function () { + core.flags.battleAnimate = true; + core.setLocalStorage('battleAnimate', true); + core.startGame(hard); + core.events.setInitData(hard); + }, function () { + core.flags.battleAnimate = false; + core.setLocalStorage('battleAnimate', false); + core.startGame(hard); + core.events.setInitData(hard); + }); } - if (hard=='Normal') { // 普通难度 - core.setFlag('hard', 2); // 可以用flag:hard来获得当前难度 - } - if (hard=='Hard') { // 困难难度 - core.setFlag('hard', 3); // 可以用flag:hard来获得当前难度 + else { + core.startGame(hard); + core.events.setInitData(hard); } }); }) } +////// 简单难度设置初始福利 ////// +events.prototype.setInitData = function (hard) { + if (hard=='Easy') { // 简单难度 + core.setFlag('hard', 1); // 可以用flag:hard来获得当前难度 + // 可以在此设置一些初始福利,比如设置初始生命值可以调用: + // core.setStatus("hp", 10000); + } + if (hard=='Normal') { // 普通难度 + core.setFlag('hard', 2); // 可以用flag:hard来获得当前难度 + } + if (hard=='Hard') { // 困难难度 + core.setFlag('hard', 3); // 可以用flag:hard来获得当前难度 + } +} + ////// 游戏结束事件 ////// events.prototype.win = function(reason) { // 获胜 @@ -166,6 +186,7 @@ events.prototype.doAction = function() { case "tip": core.drawTip(core.replaceText(data.text)); core.events.doAction(); + break; case "show": // 显示 if (core.isset(data.time) && data.time>0 && (!core.isset(data.floorId) || data.floorId==core.status.floorId)) { core.animateBlock(data.loc[0],data.loc[1],'show', data.time, function () { @@ -308,7 +329,6 @@ events.prototype.doAction = function() { core.status.hero.hp=0; core.updateStatusBar(); core.events.lose('damage'); - } else { core.updateStatusBar(); @@ -361,7 +381,7 @@ events.prototype.doAction = function() { break; default: core.status.event.data.type='text'; - core.ui.drawTextBox("\t[警告,]出错啦!\n"+data.type+" 事件不被支持..."); + core.ui.drawTextBox("\t[警告]出错啦!\n"+data.type+" 事件不被支持..."); } return; } @@ -383,9 +403,14 @@ events.prototype.openShop = function(shopId, needVisited) { } shop.visited = true; + var selection = core.status.event.selection; core.ui.closePanel(); core.lockControl(); - core.status.event = {'id': 'shop', 'data': {'id': shopId, 'shop': shop}}; + // core.status.event = {'id': 'shop', 'data': {'id': shopId, 'shop': shop}}; + core.status.event.id = 'shop'; + core.status.event.data = {'id': shopId, 'shop': shop}; + core.status.event.selection = selection; + // 拼词 var content = "\t["+shop.name+","+shop.icon+"]"; var times = shop.times, need=eval(shop.need); @@ -402,9 +427,9 @@ events.prototype.openShop = function(shopId, needVisited) { var text = choice.text; if (core.isset(choice.need)) text += "("+eval(choice.need)+use+")" - choices.push({"text": text}); + choices.push(text); } - choices.push({"text": "离开"}); + choices.push("离开"); core.ui.drawChoices(content, choices); } @@ -462,6 +487,7 @@ events.prototype.useItem = function(itemId) { var fillstyle = 'rgba(255,0,0,0.5)'; if (core.canUseItem('centerFly')) fillstyle = 'rgba(0,255,0,0.5)'; core.fillRect('ui',(12-core.getHeroLoc('x'))*32,(12-core.getHeroLoc('y'))*32,32,32,fillstyle); + core.drawTip("请确认当前中心对称飞行器的位置"); return; } @@ -602,6 +628,46 @@ events.prototype.afterLoadData = function(data) { /*********** 界面上的点击事件 ***************/ /******************************************/ +events.prototype.keyDownCtrl = function () { + if (core.status.event.id=='text') { + core.drawText(); + return; + } + if (core.status.event.id=='action' && core.status.event.data.type=='text') { + this.doAction(); + return; + } +} + +events.prototype.keyUpConfirmBox = function (keycode) { + if (keycode==37) { + core.status.event.selection=0; + core.ui.drawConfirmBox(core.status.event.ui, core.status.event.data.yes, core.status.event.data.no); + } + + if (keycode==39) { + core.status.event.selection=1; + core.ui.drawConfirmBox(core.status.event.ui, core.status.event.data.yes, core.status.event.data.no); + } + + if (keycode==13 || keycode==32 || keycode==67) { + if (core.status.event.selection==0 && core.isset(core.status.event.data.yes)) { + core.status.event.selection=null; + core.status.event.data.yes(); + } + if (core.status.event.selection==1 && core.isset(core.status.event.data.no)) { + core.status.event.selection=null; + core.status.event.data.no(); + } + } +} +events.prototype.clickConfirmBox = function (x,y) { + if ((x == 4 || x == 5) && y == 7 && core.isset(core.status.event.data.yes)) + core.status.event.data.yes(); + if ((x == 7 || x == 8) && y == 7 && core.isset(core.status.event.data.no)) + core.status.event.data.no(); +} + // 正在处理事件时的点击操作... events.prototype.clickAction = function (x,y) { @@ -625,6 +691,42 @@ events.prototype.clickAction = function (x,y) { } } +events.prototype.keyDownAction = function (keycode) { + if (core.status.event.data.type=='choices') { + var data = core.status.event.data.current; + var choices = data.choices; + if (choices.length>0) { + if (keycode==38) { + core.status.event.selection--; + if (core.status.event.selection<0) core.status.event.selection=0; + core.ui.drawChoices(core.status.event.ui.text, core.status.event.ui.choices); + } + if (keycode==40) { + core.status.event.selection++; + if (core.status.event.selection>=choices.length) core.status.event.selection=choices.length-1; + core.ui.drawChoices(core.status.event.ui.text, core.status.event.ui.choices); + } + } + } +} + +events.prototype.keyUpAction = function (keycode) { + if (core.status.event.data.type=='text' && (keycode==13 || keycode==32 || keycode==67)) { + this.doAction(); + return; + } + if (core.status.event.data.type=='choices') { + var data = core.status.event.data.current; + var choices = data.choices; + if (choices.length>0) { + if (keycode==13 || keycode==32 || keycode==67) { + this.insertAction(choices[core.status.event.selection].action); + this.doAction(); + } + } + } +} + // 怪物手册 events.prototype.clickBook = function(x,y) { // 上一页 @@ -642,6 +744,19 @@ events.prototype.clickBook = function(x,y) { return; } +events.prototype.keyDownBook = function (keycode) { + if (keycode==37 || keycode==38) core.ui.drawEnemyBook(core.status.event.data - 1); + else if (keycode==39 || keycode==40) core.ui.drawEnemyBook(core.status.event.data + 1); + return; +} + +events.prototype.keyUpBook = function (keycode) { + if (keycode==27 || keycode==88) { + core.ui.closePanel(true); + return; + } +} + // 飞行器 events.prototype.clickFly = function(x,y) { if ((x==10 || x==11) && y==9) core.ui.drawFly(core.status.event.data-1); @@ -657,6 +772,20 @@ events.prototype.clickFly = function(x,y) { return; } +events.prototype.keyDownFly = function (keycode) { + if (keycode==37 || keycode==38) core.ui.drawFly(core.status.event.data+1); + else if (keycode==39 || keycode==40) core.ui.drawFly(core.status.event.data-1); + return; +} + +events.prototype.keyUpFly = function (keycode) { + if (keycode==71 || keycode==27 || keycode==88) + core.ui.closePanel(); + if (keycode==13 || keycode==32 || keycode==67) + this.clickFly(5,5); + return; +} + // 商店 events.prototype.clickShop = function(x,y) { var shop = core.status.event.data.shop; @@ -687,12 +816,7 @@ events.prototype.clickShop = function(x,y) { // 更新属性 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.doEffect(t); }); core.updateStatusBar(); shop.times++; @@ -709,14 +833,47 @@ events.prototype.clickShop = function(x,y) { } } +events.prototype.keyDownShop = function (keycode) { + var shop = core.status.event.data.shop; + var choices = shop.choices; + if (keycode==38) { + core.status.event.selection--; + if (core.status.event.selection<0) core.status.event.selection=0; + core.ui.drawChoices(core.status.event.ui.text, core.status.event.ui.choices); + } + if (keycode==40) { + core.status.event.selection++; + if (core.status.event.selection>choices.length) core.status.event.selection=choices.length; + core.ui.drawChoices(core.status.event.ui.text, core.status.event.ui.choices); + } +} + +events.prototype.keyUpShop = function (keycode) { + if (keycode==27 || keycode==88) { + if (core.status.event.data.fromList) { + core.status.boxAnimateObjs = []; + core.setBoxAnimate(); + core.ui.drawQuickShop(); + } + else + core.ui.closePanel(); + return; + } + var shop = core.status.event.data.shop; + var choices = shop.choices; + if (keycode==13 || keycode==32 || keycode==67) { + var topIndex = 6 - parseInt(choices.length / 2); + this.clickShop(6, topIndex+core.status.event.selection); + } + return; +} + // 快捷商店 events.prototype.clickQuickShop = function(x, y) { + var shopList = core.status.shops, keys = Object.keys(shopList); if (x >= 5 && x <= 7) { - var shopList = core.status.shops, keys = Object.keys(shopList); - var topIndex = 6 - parseInt((keys.length + 1) / 2); - var exitIndex = 6 + parseInt((keys.length + 1) / 2); - - if (y >= topIndex && y - topIndex < keys.length) { + var topIndex = 6 - parseInt(keys.length / 2); + if (y>=topIndex && ykeys.length) core.status.event.selection=keys.length; + core.ui.drawChoices(core.status.event.ui.text, core.status.event.ui.choices); + } +} + +events.prototype.keyUpQuickShop = function (keycode) { + if (keycode==27 || keycode==75 || keycode==88) { + core.ui.closePanel(); + return; + } + var shopList = core.status.shops, keys = Object.keys(shopList); + if (keycode==13 || keycode==32 || keycode==67) { + var topIndex = 6 - parseInt(keys.length / 2); + this.clickQuickShop(6, topIndex+core.status.event.selection); + } + return; +} + // 工具栏 events.prototype.clickToolbox = function(x,y) { - // 返回 if (x>=10 && x<=12 && y==12) { core.ui.closePanel(false); return; } - - var items = null; - - if (y>=4 && y<=7 && x!=12) - items = Object.keys(core.status.hero.items.tools).sort(); - - if (y>=9 && y<=12 && x!=12) - items = Object.keys(core.status.hero.items.constants).sort(); - - if (items==null) return; var index=0; if (y==4||y==5||y==9||y==10) index=parseInt(x/2); else index=6+parseInt(x/2); + if (y>=9) index+=100; + this.clickToolboxIndex(index); +} - if (index>=items.length) return; - itemId=items[index]; - +events.prototype.clickToolboxIndex = function(index) { + var items = null; + var ii=index; + if (ii<100) + items = Object.keys(core.status.hero.items.tools).sort(); + else { + ii-=100; + items = Object.keys(core.status.hero.items.constants).sort(); + } + if (items==null) return; + if (ii>=items.length) return; + var itemId=items[ii]; if (itemId==core.status.event.data) { core.events.useItem(itemId); } else { - core.ui.drawToolbox(itemId); + core.ui.drawToolbox(index); + } +} + +events.prototype.keyDownToolbox = function (keycode) { + if (!core.isset(core.status.event.data)) return; + + var tools = Object.keys(core.status.hero.items.tools).sort(); + var constants = Object.keys(core.status.hero.items.constants).sort(); + var index=core.status.event.selection; + + if (keycode==37) { // left + if ((index>0 && index<100) || index>100) { + this.clickToolboxIndex(index-1); + return; + } + if (index==100 && tools.length>0) { + this.clickToolboxIndex(tools.length-1); + return; + } + } + if (keycode==38) { // up + if ((index>5 && index<100) || index>105) { + this.clickToolboxIndex(index-6); + return; + } + if (index>=100 && index<=105) { + if (tools.length>6) { + this.clickToolboxIndex(Math.min(tools.length-1, index-100+6)); + } + else if (tools.length>0) { + this.clickToolboxIndex(Math.min(tools.length-1, index-100)); + } + return; + } + } + if (keycode==39) { // right + if ((index=100 && index0) { + this.clickToolboxIndex(100); + return; + } + } + if (keycode==40) { // down + if (index<=5) { + if (tools.length>6) { + this.clickToolboxIndex(Math.min(tools.length-1, index+6)); + } + else if (constants.length>0) { + this.clickToolboxIndex(100+Math.min(constants.length-1, index)); + } + return; + } + if (index>5 && index<100 && constants.length>0) { + this.clickToolboxIndex(100+Math.min(constants.length-1, index-6)); + return; + } + if (index>=100 && index<=105 && constants.length>6) { + this.clickToolboxIndex(Math.min(100+constants.length-1, index+6)); + return; + } + } +} + +events.prototype.keyUpToolbox = function (keycode) { + if (keycode==84 || keycode==27 || keycode==88) { + core.ui.closePanel(); + return; + } + if (!core.isset(core.status.event.data)) return; + + if (keycode==13 || keycode==32 || keycode==67) { + this.clickToolboxIndex(core.status.event.selection); + return; } } @@ -769,11 +1030,11 @@ events.prototype.clickToolbox = function(x,y) { events.prototype.clickSL = function(x,y) { // 上一页 if ((x == 3 || x == 4) && y == 12) { - core.ui.drawSLPanel(core.status.event.data - 1); + core.ui.drawSLPanel(core.status.event.data - 6); } // 下一页 if ((x == 8 || x == 9) && y == 12) { - core.ui.drawSLPanel(core.status.event.data + 1); + core.ui.drawSLPanel(core.status.event.data + 6); } // 返回 if (x>=10 && x<=12 && y==12) { @@ -784,7 +1045,8 @@ events.prototype.clickSL = function(x,y) { return; } - var index=6*core.status.event.data+1; + var page=parseInt((core.status.event.data-1)/6); + var index=6*page+1; if (y>=1 && y<=4) { if (x>=1 && x<=3) core.doSL(index, core.status.event.id); if (x>=5 && x<=7) core.doSL(index+1, core.status.event.id); @@ -797,78 +1059,274 @@ events.prototype.clickSL = function(x,y) { } } -events.prototype.clickSwitchs = function (x,y) { - if (x<5 || x>7) return; - if (y==4) { - if (core.musicStatus.isIOS) { - core.drawTip("iOS设备不支持播放音乐"); - return; - } - core.changeSoundStatus(); - core.ui.drawSwitchs(); +events.prototype.keyDownSL = function(keycode) { + if (keycode==37) { // left + core.ui.drawSLPanel(core.status.event.data - 1); + return; } - if (y==5) { - core.flags.battleAnimate=!core.flags.battleAnimate; - core.ui.drawSwitchs(); + if (keycode==38) { // up + core.ui.drawSLPanel(core.status.event.data - 3); + return; } - if (y==6) { - core.flags.displayEnemyDamage=!core.flags.displayEnemyDamage; - core.updateFg(); - core.ui.drawSwitchs(); + if (keycode==39) { // right + core.ui.drawSLPanel(core.status.event.data + 1); + return; } - if (y==7) { - core.flags.displayExtraDamage=!core.flags.displayExtraDamage; - core.updateFg(); - core.ui.drawSwitchs(); + if (keycode==40) { // down + core.ui.drawSLPanel(core.status.event.data + 3); + return; } - if (y==8) { - core.ui.drawSettings(false); + if (keycode==33) { // PAGEUP + core.ui.drawSLPanel(core.status.event.data - 6); + return; + } + if (keycode==34) { // PAGEDOWN + core.ui.drawSLPanel(core.status.event.data + 6); + return; } } +events.prototype.keyUpSL = function (keycode) { + if (keycode==27 || keycode==88 || (core.status.event.id == 'save' && keycode==83) || (core.status.event.id == 'load' && keycode==68)) { + core.ui.closePanel(); + if (!core.isPlaying()) { + core.showStartAnimate(); + } + return; + } + if (keycode==13 || keycode==32 || keycode==67) { + core.doSL(core.status.event.data, core.status.event.id); + return; + } +} + +events.prototype.clickSwitchs = function (x,y) { + if (x<5 || x>7) return; + var choices = [ + "背景音乐", "战斗动画", "怪物显伤", "领域显伤", "返回主菜单" + ]; + var topIndex = 6 - parseInt((choices.length - 1) / 2); + if (y>=topIndex && y=choices.length) core.status.event.selection=choices.length-1; + core.ui.drawChoices(core.status.event.ui.text, core.status.event.ui.choices); + } +} + +events.prototype.keyUpSwitchs = function (keycode) { + if (keycode==27 || keycode==88) { + core.status.event.selection=0; + core.ui.drawSettings(false); + return; + } + var choices = [ + "背景音乐", "战斗动画", "怪物显伤", "领域显伤", "返回主菜单" + ]; + if (keycode==13 || keycode==32 || keycode==67) { + var topIndex = 6 - parseInt((choices.length - 1) / 2); + this.clickSwitchs(6, topIndex+core.status.event.selection); + } +} + + // 菜单栏 events.prototype.clickSettings = function (x,y) { if (x<5 || x>7) return; - if (y == 3) { - core.ui.drawSwitchs(); + var choices = [ + "系统设置", "快捷商店", "同步存档", "重新开始", "操作帮助", "关于本塔", "返回游戏" + ]; + var topIndex = 6 - parseInt((choices.length - 1) / 2); + if (y>=topIndex && y=choices.length) core.status.event.selection=choices.length-1; + core.ui.drawChoices(core.status.event.ui.text, core.status.event.ui.choices); + } +} + +events.prototype.keyUpSettings = function (keycode) { + if (keycode==27 || keycode==88) { + core.ui.closePanel(); + return; + } + var choices = [ + "系统设置", "快捷商店", "同步存档", "重新开始", "操作帮助", "关于本塔", "返回游戏" + ]; + if (keycode==13 || keycode==32 || keycode==67) { + var topIndex = 6 - parseInt((choices.length - 1) / 2); + this.clickSettings(6, topIndex+core.status.event.selection); + } +} + +events.prototype.clickSyncSave = function (x,y) { + if (x<5 || x>7) return; + var choices = [ + "同步存档到服务器", "从服务器加载存档", "清空本地存档", "返回主菜单" + ]; + var topIndex = 6 - parseInt((choices.length - 1) / 2); + if (y>=topIndex && y=choices.length) core.status.event.selection=choices.length-1; + core.ui.drawChoices(core.status.event.ui.text, core.status.event.ui.choices); + } +} + +events.prototype.keyUpSyncSave = function (keycode) { + if (keycode==27 || keycode==88) { + core.status.event.selection=2; + core.ui.drawSettings(false); + return; + } + var choices = [ + "同步存档到服务器", "从服务器加载存档", "清空本地存档", "返回主菜单" + ]; + if (keycode==13 || keycode==32 || keycode==67) { + var topIndex = 6 - parseInt((choices.length - 1) / 2); + this.clickSyncSave(6, topIndex+core.status.event.selection); + } +} + +events.prototype.clickAbout = function () { + if (core.isPlaying()) + core.ui.closePanel(false); + else + core.showStartAnimate(); +} + /*********** 点击事件 END ***************/ diff --git a/libs/floors/MT0.js b/libs/floors/MT0.js index 32000498..c8d90ad4 100644 --- a/libs/floors/MT0.js +++ b/libs/floors/MT0.js @@ -4,9 +4,10 @@ main.floors.MT0 = { "floorId": "MT0", // 楼层唯一标识符,需要和名字完全一致 "title": "主塔 0 层", // 楼层中文名 - "name": 0, // 显示在状态栏中的层数 + "name": "0", // 显示在状态栏中的层数 "canFlyTo": true, // 该楼能否被楼传器飞到(不能的话在该楼也不允许使用楼传器) "canUseQuickShop": true, // 该层是否允许使用快捷商店 + "defaultGround": "ground", // 默认地面的图块ID(terrains中) "map": [ // 地图数据,需要是13x13,建议使用地图生成器来生成 ], diff --git a/libs/floors/sample0.js b/libs/floors/sample0.js index 0b730b25..a32e0d7d 100644 --- a/libs/floors/sample0.js +++ b/libs/floors/sample0.js @@ -4,9 +4,10 @@ main.floors.sample0 = { "floorId": "sample0", // 楼层唯一标识符,需要和名字完全一致 "title": "样板 0 层", // 楼层中文名 - "name": 0, // 显示在状态栏中的层数 + "name": "0", // 显示在状态栏中的层数 "canFlyTo": true, // 该楼能否被楼传器飞到(不能的话在该楼也不允许使用楼传器) "canUseQuickShop": true, // 该层是否允许使用快捷商店 + "defaultGround": "ground", // 默认地面的图块ID(terrains中) "map": [ // 地图数据,需要是13x13,建议使用地图生成器来生成 [0, 0, 220, 0, 0, 20, 87, 3, 65, 64, 44, 43, 42], [0, 246, 0, 246, 0, 20, 0, 3, 58, 59, 60, 61, 41], diff --git a/libs/floors/sample1.js b/libs/floors/sample1.js index 9a29892b..b28c41d1 100644 --- a/libs/floors/sample1.js +++ b/libs/floors/sample1.js @@ -4,23 +4,24 @@ main.floors.sample1 = { "floorId": "sample1", // 楼层唯一标识符,需要和名字完全一致 "title": "样板 1 层", // 楼层中文名 - "name": 1, // 显示在状态栏中的层数 + "name": "1", // 显示在状态栏中的层数 "canFlyTo": true, // 该楼能否被楼传器飞到(不能的话在该楼也不允许使用楼传器) "canUseQuickShop": true, // 该层是否允许使用快捷商店 + "defaultGround": "grass", // 默认地面的图块ID(terrains中) "map": [ // 地图数据,需要是13x13,建议使用地图生成器来生成 - [7, 131, 8, 2, 9, 130, 10, 2, 166, 165, 132, 165, 166], - [0, 0, 0, 0, 0, 0, 0, 2, 165, 164, 0, 162, 165], - [2, 2, 2, 2, 121, 2, 2, 2, 0, 0, 229, 0, 0], - [43, 33, 44, 1, 0, 0, 0, 2, 165, 161, 0, 163, 165], - [21, 22, 21, 1, 0, 0, 0, 2, 166, 165, 0, 165, 166], - [1, 245, 1, 1, 0, 87, 0, 2, 2, 2, 85, 2, 2], - [0, 246, 0, 1, 0, 0, 0, 2, 2, 221, 0, 221, 2], - [246, 0, 246, 1, 0, 0, 0, 121, 85, 0, 0, 0, 2], - [1, 246, 1, 1, 0, 2, 2, 2, 2, 2, 2, 2, 2], + [7, 131, 8, 152, 9, 130, 10, 152, 166, 165, 132, 165, 166], + [0, 0, 0, 0, 0, 0, 0, 152, 165, 164, 0, 162, 165], + [152, 152, 152, 152, 121, 152, 152, 152, 0, 0, 229, 0, 0], + [43, 33, 44, 151, 0, 0, 0, 152, 165, 161, 0, 163, 165], + [21, 22, 21, 151, 0, 0, 0, 152, 166, 165, 0, 165, 166], + [151, 245, 151, 151, 0, 87, 0, 152, 152, 152, 85, 153, 153], + [0, 246, 0, 151, 0, 0, 0, 152, 152, 221, 0, 221, 153], + [246, 0, 246, 151, 0, 0, 0, 121, 85, 0, 0, 0, 153], + [151, 246, 151, 151, 0, 153, 153, 153, 153, 153, 153, 153, 153], [0, 0, 0, 0, 0, 0, 0, 164, 0, 0, 163, 0, 0], - [1, 1, 1, 1, 0, 3, 0, 0, 0, 162, 0, 161, 0], - [1, 0, 123, 1, 0, 3, 124, 0, 121, 0, 122, 0, 126], - [1, 0, 0, 1, 88, 3, 86, 0, 0, 0, 0, 0, 0], + [1, 1, 1, 1, 0, 20, 0, 0, 0, 162, 0, 161, 0], + [1, 0, 123, 1, 0, 20, 124, 0, 121, 0, 122, 0, 126], + [1, 0, 0, 1, 88, 20, 86, 0, 0, 0, 0, 0, 0], ], "firstArrive": [ // 第一次到该楼层触发的事件 @@ -272,7 +273,7 @@ main.floors.sample1 = { }, "changeFloor": { // 楼层转换事件;该事件不能和上面的events有冲突(同位置点),否则会被覆盖 "4,12": {"floorId": "sample0", "loc": [6,0]}, // 由于楼下有多个上楼梯,所以需指定位置而不是简单地写"stair": "upFloor" - "5,5": {"floorId": "sample2", "stair": "downFloor"} + "5,5": {"floorId": "sample2", "stair": "downFloor", "direction": "up"} }, "afterBattle": { // 战斗后可能触发的事件列表 "9,6": [ // 初级卫兵1 diff --git a/libs/floors/sample2.js b/libs/floors/sample2.js index 9dfe71b5..32d227ff 100644 --- a/libs/floors/sample2.js +++ b/libs/floors/sample2.js @@ -4,9 +4,10 @@ main.floors.sample2 = { "floorId": "sample2", // 楼层唯一标识符,需要和名字完全一致 "title": "主塔 40 层", // 楼层中文名 - "name": 40, // 显示在状态栏中的层数 + "name": "40", // 显示在状态栏中的层数 "canFlyTo": false, // 该楼能否被楼传器飞到(不能的话在该楼也不允许使用楼传器) "canUseQuickShop": true, // 该层是否允许使用快捷商店 + "defaultGround": "snowGround", // 默认地面的图块ID(terrains中) "map": [ // 地图数据,需要是13x13,建议使用地图生成器来生成 [5, 5, 5, 5, 5, 5, 87, 5, 5, 5, 5, 5, 5], [5, 4, 4, 4, 4, 1, 0, 1, 4, 4, 4, 4, 5], diff --git a/libs/floors/test.js b/libs/floors/test.js new file mode 100644 index 00000000..c125ab71 --- /dev/null +++ b/libs/floors/test.js @@ -0,0 +1,45 @@ +// 这里需要改楼层名,请和文件名及下面的floorId保持完全一致 +// 楼层唯一标识符仅能由字母、数字、下划线组成,且不能由数字开头 +// 推荐用法:第20层就用MT20,第38层就用MT38,地下6层就用MT_6(用下划线代替负号),隐藏3层用MT3h(h表示隐藏),等等 +main.floors.test = { + "floorId": "test", // 楼层唯一标识符,需要和名字完全一致 + "title": "test", // 楼层中文名 + "name": "", // 显示在状态栏中的层数 + "canFlyTo": true, // 该楼能否被楼传器飞到(不能的话在该楼也不允许使用楼传器) + "canUseQuickShop": true, // 该层是否允许使用快捷商店 + "defaultGround": "ground", // 默认地面的图块ID(terrains中) + "map": [ // 地图数据,需要是13x13,建议使用地图生成器来生成 + [201,201,201,201,201,201,201,201,201,201,201,201,201], + [201,201,201,201,201,201,201,201,201,201,201,201,201], + [201,201,201,201,201,201,201,201,201,201,201,201,201], + [201,201,201,201,201,201,201,201,201,201,201,201,201], + [201,201,201,201,201,201,201,201,201,201,201,201,201], + [201,201,201,201,201,201,201,201,201,201,201,201,201], + [201,201,201,201,201,201,201,201,201,201,201,201,201], + [201,201,201,201,201,201,201,201,201,201,201,201,201], + [201,201,201,201,201,201,201,201,201,201,201,201,201], + [201,201,201,201,201,201,201,201,201,201,201,201,201], + [201,201,201,201,201,201,201,201,201,201,201,201,201], + [201,201,201,201,201,201, 45,201,201,201,201,201,201], + [201,201,201,201,201,201, 0,201,201,201,201,201,201] + ], + "firstArrive": [ // 第一次到该楼层触发的事件 + + ], + "events": { // 该楼的所有可能事件列表 + + }, + "changeFloor": { // 楼层转换事件;该事件不能和上面的events有冲突(同位置点),否则会被覆盖 + + }, + "afterBattle": { // 战斗后可能触发的事件列表 + + }, + "afterGetItem": { // 获得道具后可能触发的事件列表 + + }, + "afterOpenDoor": { // 开完门后可能触发的事件列表 + + } +} + diff --git a/libs/icons.js b/libs/icons.js index 48750086..4aced479 100644 --- a/libs/icons.js +++ b/libs/icons.js @@ -12,30 +12,46 @@ icons.prototype.init = function () { }, 'terrains': { 'ground': 0, - 'yellowWall': 1, - 'whiteWall': 2, - 'blueWall': 3, - 'star': 4, - 'lava': 5, - 'ice': 6, - 'downFloor': 7, - 'upFloor': 8, - 'yellowDoor': 9, - 'blueDoor': 10, - 'redDoor': 11, - 'greenDoor': 12, - 'specialDoor': 13, - 'steelDoor': 14, - 'blueShop-left': 15, - 'blueShop-right': 16, - 'pinkShop-left': 17, - 'pinkShop-right': 18, - 'arrowUp': 19, - 'arrowDown': 20, - 'arrowLeft': 21, - 'arrowRight': 22, - 'light': 23, - 'darkLight': 24 + 'grass': 1, + 'grass2': 2, + 'snowGround': 3, + 'ground2': 4, + 'ground3': 5, + 'ground4': 6, + 'sand': 7, + 'ground5': 8, + 'yellowWall2': 9, + 'whiteWall2': 10, + 'blueWall2': 11, + 'blockWall': 12, + 'grayWall': 13, + 'white': 14, + 'ground6': 15, + 'soil': 16, + 'yellowWall': 17, + 'whiteWall': 18, + 'blueWall': 19, + 'star': 20, + 'lava': 21, + 'ice': 22, + 'downFloor': 23, + 'upFloor': 24, + 'yellowDoor': 25, + 'blueDoor': 26, + 'redDoor': 27, + 'greenDoor': 28, + 'specialDoor': 29, + 'steelDoor': 30, + 'blueShop-left': 31, + 'blueShop-right': 32, + 'pinkShop-left': 33, + 'pinkShop-right': 34, + 'arrowUp': 35, + 'arrowDown': 36, + 'arrowLeft': 37, + 'arrowRight': 38, + 'light': 39, + 'darkLight': 40 }, 'animates': { 'star': 0, @@ -193,6 +209,12 @@ icons.prototype.init = function () { 'moneyPocket': 46, 'shoes': 47, 'hammer': 48 + }, + 'autotile': { // 所有的Autotile列表;后面的index简单取0即可 + 'autotile': 0, + 'autotile1': 0, + 'autotile2': 0, + 'autotile3': 0, } } } diff --git a/libs/maps.js b/libs/maps.js index f03c634f..0557f07a 100644 --- a/libs/maps.js +++ b/libs/maps.js @@ -34,7 +34,7 @@ maps.prototype.loadFloor = function (floorId, map) { } } } - this.addEvent(block,j,i,floor.events[j+","+i]) + this.addEvent(block,j,i,floor.events[j+","+i],floor.defaultGround || "ground") this.addChangeFloor(block,j,i,floor.changeFloor[j+","+i]); if (core.isset(block.event)) blocks.push(block); } @@ -61,6 +61,8 @@ maps.prototype.getBlock = function (x, y, id) { var tmp = {'x': x, 'y': y, 'id': id}; if (enable!=null) tmp.enable = enable; + ////////////////////////// 地形部分 ////////////////////////// + // 0-20 地形 if (id == 1) tmp.event = {'cls': 'terrains', 'id': 'yellowWall'}; // 黄墙 if (id == 2) tmp.event = {'cls': 'terrains', 'id': 'whiteWall'}; // 白墙 @@ -77,9 +79,18 @@ maps.prototype.getBlock = function (x, y, id) { if (id == 13) tmp.event = {'cls': 'animates', 'id': 'weakNet', 'noPass': false, 'trigger': 'passNet'}; // 衰网 if (id == 14) tmp.event = {'cls': 'animates', 'id': 'curseNet', 'noPass': false, 'trigger': 'passNet'}; // 咒网 if (id == 15) tmp.event = {'cls': 'animates', 'id': 'water', 'noPass': true}; // 水 + // 在这里添加更多地形 + // 如果空地不足,可以从180以后开始继续放,只要不和现有的数字冲突即可 - // autotile: 20 + // Autotile if (id == 20) tmp.event = {'cls': 'autotile', 'id': 'autotile', 'noPass': true}; // autotile + // 更多的autotile从151到160,只要不和现有的数字冲突即可 + if (id == 151) tmp.event = {'cls': 'autotile', 'id': 'autotile1', 'noPass': true}; + if (id == 152) tmp.event = {'cls': 'autotile', 'id': 'autotile2', 'noPass': true}; + if (id == 153) tmp.event = {'cls': 'autotile', 'id': 'autotile3', 'noPass': true}; + + + ////////////////////////// 物品部分 ////////////////////////// // 21-80 物品 if (id == 21) tmp.event = {'cls': 'items', 'id': 'yellowKey'}; // 黄钥匙 @@ -128,6 +139,9 @@ maps.prototype.getBlock = function (x, y, id) { if (id == 64) tmp.event = {'cls': 'items', 'id': 'shoes'} // 绿鞋 if (id == 65) tmp.event = {'cls': 'items', 'id': 'hammer'} // 圣锤 + + ////////////////////////// 门、楼梯、传送点部分 ////////////////////////// + // 81-100 门 if (id == 81) tmp.event = {'cls': 'terrains', 'id': 'yellowDoor', 'trigger': 'openDoor'}; // 黄门 if (id == 82) tmp.event = {'cls': 'terrains', 'id': 'blueDoor', 'trigger': 'openDoor'}; // 蓝门 @@ -145,6 +159,8 @@ maps.prototype.getBlock = function (x, y, id) { if (id == 94) tmp.event = {'cls': 'animates', 'id': 'rightPortal', 'noPass': false}; // 右箭头 + ////////////////////////// NPC部分 ////////////////////////// + // 121-150 NPC if (id == 121) tmp.event = {'cls': 'npcs', 'id': 'man'}; if (id == 122) tmp.event = {'cls': 'npcs', 'id': 'woman'}; @@ -159,6 +175,8 @@ maps.prototype.getBlock = function (x, y, id) { if (id == 131) tmp.event = {'cls': 'npcs', 'id': 'blueShop'}; if (id == 132) tmp.event = {'cls': 'npcs', 'id': 'princess'}; + ////////////////////////// 其他部分 ////////////////////////// + // 161-200 其他(单向箭头、灯、箱子等等) if (id == 161) tmp.event = {'cls': 'terrains', 'id': 'arrowUp', 'noPass': false}; // 单向上箭头 if (id == 162) tmp.event = {'cls': 'terrains', 'id': 'arrowDown', 'noPass': false}; // 单向下箭头 @@ -167,6 +185,9 @@ maps.prototype.getBlock = function (x, y, id) { if (id == 165) tmp.event = {'cls': 'terrains', 'id': 'light', 'trigger': 'changeLight', 'noPass': false}; // 灯 if (id == 166) tmp.event = {'cls': 'terrains', 'id': 'darkLight', 'noPass': true}; // 暗灯 + + ////////////////////////// 怪物部分 ////////////////////////// + // 201-300 怪物 if (id == 201) tmp.event = {'cls': 'enemys', 'id': 'greenSlime'}; if (id == 202) tmp.event = {'cls': 'enemys', 'id': 'redSlime'}; @@ -229,13 +250,16 @@ maps.prototype.getBlock = function (x, y, id) { if (id == 259) tmp.event = {'cls': 'enemys', 'id': 'darkFairy'}; if (id == 260) tmp.event = {'cls': 'enemys', 'id': 'greenKnight'}; + ////////////////////////// 待定... ////////////////////////// + // 目前ID暂时不要超过400 + return tmp; } -maps.prototype.addEvent = function (block, x, y, event) { +maps.prototype.addEvent = function (block, x, y, event, ground) { if (!core.isset(event)) return; if (!core.isset(block.event)) { // 本身是空地? - block.event = {'cls': 'terrains', 'id': 'ground', 'noPass': false}; + block.event = {'cls': 'terrains', 'id': ground, 'noPass': false}; } // event是字符串或数组? if (typeof event == "string") { @@ -267,9 +291,9 @@ maps.prototype.addEvent = function (block, x, y, event) { } } -maps.prototype.addChangeFloor = function (block, x, y, event) { +maps.prototype.addChangeFloor = function (block, x, y, event, ground) { if (!core.isset(event)) return; - this.addEvent(block, x, y, {"trigger": "changeFloor", "data": event}); + this.addEvent(block, x, y, {"trigger": "changeFloor", "data": event}, ground); } maps.prototype.initMaps = function (floorIds) { diff --git a/libs/ui.js b/libs/ui.js index 0acbb2b3..62ef59e8 100644 --- a/libs/ui.js +++ b/libs/ui.js @@ -26,6 +26,8 @@ ui.prototype.closePanel = function (clearData) { core.unLockControl(); core.status.event.data = null; core.status.event.id = null; + core.status.event.selection = null; + core.status.event.ui = null; } @@ -144,6 +146,8 @@ ui.prototype.drawChoices = function(content, choices) { core.setAlpha('ui', 1); core.setFillStyle('ui', background); + core.status.event.ui = {"text": content, "choices": choices}; + // Step 1: 计算长宽高 var length = choices.length; var left=85, width = 416-2*left; // 宽度 @@ -258,10 +262,15 @@ ui.prototype.drawChoices = function(content, choices) { // 选项 core.canvas.ui.textAlign = "center"; for (var i = 0; i < choices.length; i++) { - core.fillText('ui', core.replaceText(choices[i].text), 208, choice_top + 32 * i, "#FFFFFF", "bold 17px Verdana"); + core.fillText('ui', core.replaceText(choices[i].text || choices[i]), 208, choice_top + 32 * i, "#FFFFFF", "bold 17px Verdana"); + } + + if (choices.length>0) { + if (!core.isset(core.status.event.selection)) core.status.event.selection=0; + var len = core.canvas.ui.measureText(core.replaceText(choices[core.status.event.selection].text || choices[core.status.event.selection])).width; + core.strokeRect('ui', 208-len/2-5, choice_top + 32 * core.status.event.selection - 20, len+10, 28, "#FFD700", 2); } return; - } /** @@ -271,8 +280,13 @@ ui.prototype.drawChoices = function(content, choices) { * @param noCallback */ ui.prototype.drawConfirmBox = function (text, yesCallback, noCallback) { + core.lockControl(); + core.status.event.id = 'confirmBox'; core.status.event.data = {'yes': yesCallback, 'no': noCallback}; + core.status.event.ui = text; + + if (!core.isset(core.status.event.selection)) core.status.event.selection=1; var background = core.canvas.ui.createPattern(core.material.ground, "repeat"); core.clearMap('ui', 0, 0, 416, 416); @@ -291,8 +305,10 @@ ui.prototype.drawConfirmBox = function (text, yesCallback, noCallback) { var top = 140 - (lines-1)*30; var right = 416 - 2 * left, bottom = 416 - 140 - top; - core.fillRect('ui', left, top, right, bottom, background); - core.strokeRect('ui', left - 1, top - 1, right + 1, bottom + 1, '#FFFFFF', 2); + if (core.isPlaying()) + core.fillRect('ui', left, top, right, bottom, background); + if (core.isPlaying()) + core.strokeRect('ui', left - 1, top - 1, right + 1, bottom + 1, '#FFFFFF', 2); core.canvas.ui.textAlign = "center"; for (var i in contents) { core.fillText('ui', contents[i], 208, top + 50 + i*30, "#FFFFFF"); @@ -300,6 +316,15 @@ ui.prototype.drawConfirmBox = function (text, yesCallback, noCallback) { core.fillText('ui', "确定", 208 - 38, top + bottom - 35, "#FFFFFF", "bold 17px Verdana"); core.fillText('ui', "取消", 208 + 38, top + bottom - 35); + + var len=core.canvas.ui.measureText("确定").width; + if (core.status.event.selection==0) { + core.strokeRect('ui', 208-38-len/2-5, top+bottom-35-20, len+10, 28, "#FFD700", 2); + } + if (core.status.event.selection==1) { + core.strokeRect('ui', 208+38-len/2-5, top+bottom-35-20, len+10, 28, "#FFD700", 2); + } + } ////// 绘制开关界面 ////// @@ -308,22 +333,15 @@ ui.prototype.drawSwitchs = function() { core.status.event.id = 'switchs'; - var background = core.canvas.ui.createPattern(core.material.ground, "repeat"); - core.clearMap('ui', 0, 0, 416, 416); - core.setAlpha('ui', 1); - core.setFillStyle('ui', background); - var left = 97, top = 64 + 32, 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); + var choices = [ + "背景音乐:"+(core.musicStatus.soundStatus ? "[ON]" : "[OFF]"), + "战斗动画: " + (core.flags.battleAnimate ? "[ON]" : "[OFF]"), + "怪物显伤: " + (core.flags.displayEnemyDamage ? "[ON]" : "[OFF]"), + "领域显伤: " + (core.flags.displayExtraDamage ? "[ON]" : "[OFF]"), + "返回主菜单" + ]; + this.drawChoices(null, choices); - core.canvas.ui.textAlign = "center"; - core.fillText('ui', "背景音乐: " + (core.musicStatus.soundStatus ? "[ON]" : "[OFF]"), 208, top + 56, "#FFFFFF", "bold 17px Verdana"); - // core.fillText('ui', "背景音效" + (core.musicStatus.soundStatus ? "[ON]" : "[OFF]"), 208, top + 88, "#FFFFFF", "bold 17px Verdana") - core.fillText('ui', "战斗动画: " + (core.flags.battleAnimate ? "[ON]" : "[OFF]"), 208, top + 88, "#FFFFFF", "bold 17px Verdana") - core.fillText('ui', "怪物显伤: " + (core.flags.displayEnemyDamage ? "[ON]" : "[OFF]"), 208, top + 120, "#FFFFFF", "bold 17px Verdana") - core.fillText('ui', "领域显伤: " + (core.flags.displayExtraDamage ? "[ON]" : "[OFF]"), 208, top + 152, "#FFFFFF", "bold 17px Verdana") - - core.fillText('ui', "返回上级菜单", 208, top + 184, "#FFFFFF", "bold 17px Verdana"); } /** @@ -334,57 +352,28 @@ ui.prototype.drawSettings = function (need) { if (!core.checkStatus('settings', need)) return; - var background = core.canvas.ui.createPattern(core.material.ground, "repeat"); - 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', "系统设置", 208, top + 56, "#FFFFFF", "bold 17px Verdana"); - core.fillText('ui', "降低难度", 208, top + 88, "#FFFFFF", "bold 17px Verdana") - core.fillText('ui', "快捷商店", 208, top + 120, "#FFFFFF", "bold 17px Verdana"); - core.fillText('ui', "同步存档", 208, top + 152, "#FFFFFF", "bold 17px Verdana"); - // core.fillText('ui', "清空存档", 208, top + 152, "#FFFFFF", "bold 17px Verdana"); - core.fillText('ui', "重新开始", 208, top + 184, "#FFFFFF", "bold 17px Verdana"); - core.fillText('ui', "关于本塔", 208, top + 216, "#FFFFFF", "bold 17px Verdana"); - core.fillText('ui', "返回游戏", 208, top + 248, "#FFFFFF", "bold 17px Verdana"); - + this.drawChoices(null, [ + "系统设置", "快捷商店", "同步存档", "重新开始", "操作帮助", "关于本塔", "返回游戏" + ]); } -/** - * 绘制“选择商店”窗口 - * @param need - */ ui.prototype.drawQuickShop = function (need) { - if (core.isset(need) && !core.checkStatus('selectShop', need)) return; core.status.event.id = 'selectShop'; - var background = core.canvas.ui.createPattern(core.material.ground, "repeat"); - core.clearMap('ui', 0, 0, 416, 416); - core.setAlpha('ui', 1); - core.setFillStyle('ui', background); var shopList = core.status.shops, keys = Object.keys(shopList); - var len = keys.length + 1; - if (len % 2 == 0) len++; - var left = 97, top = 208 - 32 - 16 * len, 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"; - for (var i = 0; i < keys.length; i++) { - core.fillText('ui', shopList[keys[i]].textInList, 208, top + 56 + 32 * i, "#FFFFFF", "bold 17px Verdana"); + var choices = []; + for (var i=0;i= core.status.hero.hp) color = '#FF0000'; - if (damage == 0) color = '#00FF00'; + if (damage <= 0) color = '#00FF00'; if (damage >= 999999999) damage = '无法战斗'; - var length = core.canvas.ui.measureText(damage).width; - core.fillText('ui', damage, damage_offset, 62 * i + 50, color, 'bold 13px Verdana'); + core.fillText('ui', damage, damageOffet, 62 * i + 50, color, 'bold 13px Verdana'); core.canvas.ui.textAlign = "left"; @@ -876,17 +865,29 @@ ui.prototype.drawFly = function(page) { if (page>0) core.fillText('ui', '▼', 356, 247+64, '#FFFFFF', "17px Verdana"); core.strokeRect('ui', 20, 100, 273, 273, '#FFFFFF', 2); - this.drawThumbnail('ui', core.status.maps[floorId].blocks, 20, 100, 273); + this.drawThumbnail(floorId, 'ui', core.status.maps[floorId].blocks, 20, 100, 273); } -/** - * 绘制工具栏 - * @param selectId - */ -ui.prototype.drawToolbox = function(selectId) { +ui.prototype.drawToolbox = function(index) { - if (!core.hasItem(selectId)) - selectId=null; + var tools = Object.keys(core.status.hero.items.tools).sort(); + var constants = Object.keys(core.status.hero.items.constants).sort(); + + if (!core.isset(index)) { + if (tools.length>0) index=0; + else if (constants.length>0) index=100; + else index=0; + } + + core.status.event.selection=index; + + var selectId; + if (index<100) + selectId = tools[index]; + else + selectId = constants[index-100]; + + if (!core.hasItem(selectId)) selectId=null; core.status.event.data=selectId; core.clearMap('ui', 0, 0, 416, 416); @@ -937,7 +938,7 @@ ui.prototype.drawToolbox = function(selectId) { core.canvas.ui.textAlign = 'right'; var images = core.material.images.items; // 消耗道具 - var tools = Object.keys(core.status.hero.items.tools).sort(); + for (var i=0;i=30) page=29; - core.status.event.data = page; - core.status.savePage = page; +ui.prototype.drawSLPanel = function(index) { + if (!core.isset(index)) index=1; + if (index<=0) index=1; + if (index>180) index=180; + + core.status.event.data=index; + + var page=parseInt((index-1)/6); + + // core.status.event.data = page; + // core.status.savePage = page; core.clearMap('ui', 0, 0, 416, 416); core.setAlpha('ui', 0.85); @@ -1007,9 +1010,9 @@ ui.prototype.drawSLPanel = function(page) { if (i<3) { core.fillText('ui', name+id, (2*i+1)*u, 35, '#FFFFFF', "bold 17px Verdana"); - core.strokeRect('ui', (2*i+1)*u-size/2, 50, size, size, '#FFFFFF', 2); + core.strokeRect('ui', (2*i+1)*u-size/2, 50, size, size, id==index?'#FFD700':'#FFFFFF', id==index?6:2); if (core.isset(data) && core.isset(data.floorId)) { - this.drawThumbnail('ui', core.maps.load(data.maps, data.floorId).blocks, (2*i+1)*u-size/2, 50, size, data.hero.loc); + this.drawThumbnail(data.floorId, 'ui', core.maps.load(data.maps, data.floorId).blocks, (2*i+1)*u-size/2, 50, size, data.hero.loc); core.fillText('ui', core.formatDate(new Date(data.time)), (2*i+1)*u, 65+size, '#FFFFFF', '10px Verdana'); } else { @@ -1019,9 +1022,9 @@ ui.prototype.drawSLPanel = function(page) { } else { core.fillText('ui', name+id, (2*i-5)*u, 230, '#FFFFFF', "bold 17px Verdana"); - core.strokeRect('ui', (2*i-5)*u-size/2, 245, size, size, '#FFFFFF', 2); + core.strokeRect('ui', (2*i-5)*u-size/2, 245, size, size, id==index?'#FFD700':'#FFFFFF', id==index?6:2); if (core.isset(data) && core.isset(data.floorId)) { - this.drawThumbnail('ui', core.maps.load(data.maps, data.floorId).blocks, (2*i-5)*u-size/2, 245, size, data.hero.loc); + this.drawThumbnail(data.floorId, 'ui', core.maps.load(data.maps, data.floorId).blocks, (2*i-5)*u-size/2, 245, size, data.hero.loc); core.fillText('ui', core.formatDate(new Date(data.time)), (2*i-5)*u, 260+size, '#FFFFFF', '10px Verdana'); } else { @@ -1031,16 +1034,16 @@ ui.prototype.drawSLPanel = function(page) { } } this.drawPagination(page+1, 30); - } -ui.prototype.drawThumbnail = function(canvas, blocks, x, y, size, heroLoc) { +ui.prototype.drawThumbnail = function(floorId, canvas, blocks, x, y, size, heroLoc) { core.clearMap(canvas, x, y, size, size); + var groundId = core.floors[floorId].defaultGround || "ground"; + var blockIcon = core.material.icons.terrains[groundId]; + var blockImage = core.material.images.terrains; var persize = size/13; for (var i=0;i<13;i++) { for (var j=0;j<13;j++) { - var blockIcon = core.material.icons.terrains.ground; - var blockImage = core.material.images.terrains; core.canvas[canvas].drawImage(blockImage, 0, blockIcon * 32, 32, 32, x + i * persize, y + j * persize, persize, persize); } } @@ -1050,7 +1053,7 @@ ui.prototype.drawThumbnail = function(canvas, blocks, x, y, size, heroLoc) { if (core.isset(block.event) && !(core.isset(block.enable) && !block.enable)) { if (block.event.cls == 'autotile') { // core.drawAutotile(); - autotileMaps[13*block.x + block.y] = true; + autotileMaps[13*block.x + block.y] = block.event.id; continue; } else { @@ -1060,7 +1063,7 @@ ui.prototype.drawThumbnail = function(canvas, blocks, x, y, size, heroLoc) { } } } - core.drawAutotile('ui', autotileMaps, x, y, persize); + core.drawAutotile(floorId, 'ui', autotileMaps, x, y, persize); if (core.isset(heroLoc)) { var heroIcon = core.material.icons.hero[heroLoc.direction]; @@ -1108,4 +1111,28 @@ ui.prototype.drawAbout = function() { core.fillText('ui', '打Dota的喵', text_start+len, top+272); core.fillText('ui', 'HTML5魔塔交流群:539113091', text_start, top+304); */ +} + +ui.prototype.drawHelp = function () { + core.drawText([ + "\t[键盘快捷键列表]"+ + "[CTRL] 跳过对话\n" + + "[X] 打开/关闭怪物手册\n" + + "[G] 打开/关闭楼层传送器\n" + + "[S/D] 打开/关闭存/读档页面\n" + + "[K] 打开/关闭快捷商店选择列表\n" + + "[T] 打开/关闭工具栏\n" + + "[ESC] 打开/关闭系统菜单\n" + + "[H] 打开帮助页面\n"+ + "[SPACE] 轻按(仅在轻按开关打开时有效)\n" + + "[1] 快捷使用破墙镐\n" + + "[2] 快捷使用炸弹/圣锤\n" + + "[3] 快捷使用中心对称飞行器", + "\t[鼠标操作]"+ + "点状态栏中图标: 进行对应的操作\n"+ + "点任意块: 寻路并移动\n"+ + "点任意块并拖动: 指定寻路路线\n"+ + "单击勇士: 转向\n"+ + "双击勇士: 轻按(仅在轻按开关打开时有效)" + ]); } \ No newline at end of file diff --git a/main.js b/main.js index 2305a77f..fe644e79 100644 --- a/main.js +++ b/main.js @@ -20,6 +20,7 @@ function main() { 'toolBar': document.getElementById('toolBar'), 'tools': document.getElementsByClassName('tools'), 'gameCanvas': document.getElementsByClassName('gameCanvas'), + 'curtain': document.getElementById('curtain'), 'startButtons': document.getElementById('startButtons'), 'playGame': document.getElementById('playGame'), 'loadGame': document.getElementById('loadGame'), @@ -30,17 +31,21 @@ function main() { 'hardLevel': document.getElementById('hardLevel'), 'data': document.getElementById('data'), 'statusLabels': document.getElementsByClassName('statusLabel'), + 'floorCol': document.getElementById('floorCol'), + 'lvCol': document.getElementById('lvCol'), 'mdefCol': document.getElementById('mdefCol'), + 'moneyCol': document.getElementById('moneyCol'), 'expCol': document.getElementById('expCol'), + 'upCol': document.getElementById('upCol'), + 'debuffCol': document.getElementById('debuffCol'), + 'hard': document.getElementById('hard'), }; - // console.log('加载游戏容器和开始界面dom对象完成 如下'); - // console.log(this.dom); this.loadList = [ 'items', 'icons', 'maps', 'enemys', 'events', 'data', 'ui', 'core' ]; - // console.log('加载js文件列表加载完成' + this.loadList); this.images = [ - 'animates', 'enemys', 'hero', 'items', 'npcs', 'terrains', "autotile" + 'animates', 'enemys', 'hero', 'items', 'npcs', 'terrains' + // Autotile 动态添加 ]; this.sounds = { 'mp3': ['bgm-loop', 'floor'], @@ -49,12 +54,14 @@ function main() { this.statusBar = { 'image': { 'floor': document.getElementById('img-floor'), + 'lv': document.getElementById('img-lv'), 'hp': document.getElementById("img-hp"), 'atk': document.getElementById("img-atk"), 'def': document.getElementById("img-def"), 'mdef': document.getElementById("img-mdef"), 'money': document.getElementById("img-money"), 'experience': document.getElementById("img-experience"), + 'up': document.getElementById("img-up"), 'book': document.getElementById("img-book"), 'fly': document.getElementById("img-fly"), 'toolbox': document.getElementById("img-toolbox"), @@ -64,12 +71,14 @@ function main() { 'settings': document.getElementById("img-settings") }, 'floor': document.getElementById('floor'), + 'lv': document.getElementById('lv'), 'hp': document.getElementById('hp'), 'atk': document.getElementById('atk'), 'def': document.getElementById("def"), 'mdef': document.getElementById('mdef'), 'money': document.getElementById("money"), 'experience': document.getElementById("experience"), + 'up': document.getElementById('up'), 'yellowKey': document.getElementById("yellowKey"), 'blueKey': document.getElementById("blueKey"), 'redKey': document.getElementById("redKey"), @@ -78,6 +87,8 @@ function main() { 'curse': document.getElementById('curse'), 'hard': document.getElementById("hard") } + + //------------------------ 用户修改内容 ------------------------// this.version = "0.1"; // 游戏版本号;如果更改了游戏内容建议修改此version以免造成缓存问题。 this.useCompress = false; // 是否使用压缩文件 @@ -86,8 +97,10 @@ function main() { // 如果要进行剧本的修改请务必将其改成false。 this.floorIds = [ // 在这里按顺序放所有的楼层;其顺序直接影响到楼层传送器的顺序和上楼器/下楼器的顺序 - "sample0", "sample1", "sample2" + "sample0", "sample1", "sample2", "test" ] + //------------------------ 用户修改内容 END ------------------------// + this.floors = {} this.instance = {}; this.canvas = {}; @@ -193,14 +206,14 @@ window.onresize = function () { main.dom.body.onkeydown = function(e) { try { - if (main.core.isPlaying()) + if (main.core.isPlaying() || main.core.status.lockControl) main.core.onkeyDown(e); } catch (ee) {} } main.dom.body.onkeyup = function(e) { try { - if (main.core.isPlaying()) + if (main.core.isPlaying() || main.core.status.lockControl) main.core.onkeyUp(e); } catch (ee) {} } diff --git a/styles.css b/styles.css index c63e5e92..6523b3b8 100644 --- a/styles.css +++ b/styles.css @@ -21,7 +21,7 @@ position: fixed; top: 10px; left: 10px; - z-index: 12; + z-index: 13; } #startPanel { @@ -32,7 +32,7 @@ left: 0; background-color: #fff; overflow: hidden; - z-index: 8; + z-index: 9; } #startTop { @@ -42,7 +42,7 @@ top: 0; left: 0; background-color: #000; - z-index: 11; + z-index: 12; } #startTopProgressBar { @@ -52,7 +52,7 @@ position: absolute; top: 5%; background-color: #fff; - z-index: 12; + z-index: 13; } #startTopProgress { @@ -67,7 +67,7 @@ position: absolute; top: 8%; left: 5%; - z-index: 12; + z-index: 13; } #startBackground { @@ -77,12 +77,12 @@ height: 100%; width: auto; transform:translate(-50%,-50%); - z-index: 9; + z-index: 10; } #startLogo { position: absolute; - z-index: 9; + z-index: 10; left: 0; right: 0; margin-left: auto; @@ -95,7 +95,7 @@ #startTitle { position: absolute; - z-index: 10; + z-index: 11; } #startButtonGroup { @@ -106,7 +106,7 @@ background-color: #000; opacity: 0.85; display: none; - z-index: 9; + z-index: 10; bottom: 0; margin-bottom: 7%; } @@ -142,7 +142,7 @@ display: none; color: #fff; background-color: #000; - z-index: 7; + z-index: 8; } #logoLabel { @@ -170,7 +170,7 @@ -moz-box-sizing: border-box; -webkit-box-sizing: border-box; background: url(images/ground.png) round; - z-index: 6; + z-index: 7; display: none; } #statusBar .status{ @@ -180,8 +180,9 @@ } .status img{ vertical-align: middle; - width: 1.6em; - height: 1.6em; + width: auto; + height: 100%; + max-height: 1.6em; } #statusBar span{ color: white; @@ -198,7 +199,7 @@ #toolBar { position: absolute; background: url(images/ground.png) round; - z-index: 5; + z-index: 6; box-sizing: border-box; -moz-box-sizing: border-box; -webkit-box-sizing: border-box; @@ -232,6 +233,13 @@ span#poison, span#weak, span#curse { -webkit-box-sizing: border-box; } +#curtain { + z-index: 5; + position: absolute; + opacity: 0; + background: #000000; +} + #bg { z-index: 1; } @@ -240,20 +248,20 @@ span#poison, span#weak, span#curse { z-index: 2; } -#hero { +#fg { z-index: 3; } -#fg { +#hero { z-index: 4; } #ui { - z-index: 5; + z-index: 6; } #data { - z-index: 6; + z-index: 7; } .clearfix:before, diff --git a/常用工具/便捷PS工具.exe b/常用工具/便捷PS工具.exe index 7ec2fc98..c27e7010 100644 Binary files a/常用工具/便捷PS工具.exe and b/常用工具/便捷PS工具.exe differ diff --git a/常用工具/地图生成器.exe b/常用工具/地图生成器.exe index 541b3626..286aa26b 100644 Binary files a/常用工具/地图生成器.exe and b/常用工具/地图生成器.exe differ diff --git a/快捷键说明.txt b/快捷键说明.txt new file mode 100644 index 00000000..61cb65b4 --- /dev/null +++ b/快捷键说明.txt @@ -0,0 +1,49 @@ +快捷键说明: + +=== 全局 === +[↑][↓][←][→] 移动勇士 +[CTRL] 跳过对话 +[X] 打开/关闭怪物手册 +[G] 打开/关闭楼层传送器 +[S] 打开/关闭存档页面 +[D] 打开/关闭读档页面 +[K] 打开/关闭快捷商店选择列表 +[T] 打开/关闭工具栏 +[ESC] 打开/关闭系统菜单 +[H] 打开帮助页面 +[SPACE] 轻按(仅在轻按开关打开时有效) +[1] 快捷使用破墙镐 +[2] 快捷使用炸弹/圣锤(先检测有没有炸弹,没有再检测圣锤) +[3] 快捷使用中心对称飞行器 + +=== 文本显示界面 === +[SPACE]/[ENTER] 继续 + +=== 选项列表 === +[↑][↓] 移动当前选择项 +[ESC] 返回 +[SPACE]/[ENTER] 确认该选项 + +=== 怪物手册页面 === +[↑][↓][←][→] 翻页 +[ESC]/[X] 关闭怪物手册 + +=== 楼传器页面 === +[↑][↓][←][→] 更改楼层 +[SPACE]/[ENTER] 确认传送 +[ESC]/[G] 关闭楼传器 + +=== 道具栏页面 === +[↑][↓][←][→] 更改当前道具 +[SPACE]/[ENTER] 确认使用道具 +[ESC]/[T] 关闭道具栏 + +=== 存读档页面 === +[↑][↓][←][→] 更改当前存读档位置 +[PAGEUP][PAGEDOWN] 存读档翻页 +[SPACE]/[ENTER] 确认存读档 +[ESC]/[S]/[D] 关闭存读档界面 + +=== 正在使用中心对称飞行器时 === +[3]/[SPACE]/[ENTER] 确认飞行 +其他键 取消飞行 diff --git a/更新说明.txt b/更新说明.txt new file mode 100644 index 00000000..6e9cc527 --- /dev/null +++ b/更新说明.txt @@ -0,0 +1,11 @@ +全键盘操作 √ +进阶 √ +Ctrl快速跳过对话 √ +增加负伤 √ +支持不同层使用不同的地面素材 √ +支持多个Autotile同时存在 √ +直接内嵌了诸多默认的terrains素材 √ +自动定位到上次存/读档位置 √ +设置储存 √ +修改setFg的实现方法 √ +大范围领域伤害 \ No newline at end of file