diff --git a/_server/table/data.comment.js b/_server/table/data.comment.js index 0ebe2a8..04067f5 100644 --- a/_server/table/data.comment.js +++ b/_server/table/data.comment.js @@ -259,11 +259,21 @@ var data_comment_c456ea59_6018_45ef_8bcc_211a24c627dc = { "_type": "textarea", "_data": "初始攻击" }, + "atk2": { + "_leaf": true, + "_type": "textarea", + "_data": "初始攻速" + }, "def": { "_leaf": true, "_type": "textarea", "_data": "初始防御" }, + "def2": { + "_leaf": true, + "_type": "textarea", + "_data": "初始护甲" + }, "mdef": { "_leaf": true, "_type": "textarea", diff --git a/libs/control.js b/libs/control.js index c6e4f30..bf2080b 100644 --- a/libs/control.js +++ b/libs/control.js @@ -3269,7 +3269,7 @@ control.prototype._doResize = function (obj) { control.prototype.resize = function () { if (main.mode == 'editor') return; var clientWidth = main.dom.body.clientWidth, clientHeight = main.dom.body.clientHeight; - var BORDER = 3; + var BORDER = 0; var extendToolbar = core.flags.extendToolbar; let hideLeftStatusBar = core.flags.hideLeftStatusBar; var BAR_WIDTH = hideLeftStatusBar ? 0 : Math.round(core._PY_ * 0.31); @@ -3297,7 +3297,7 @@ control.prototype.resize = function () { core.domStyle.availableScale = []; extendToolbar = false; hideLeftStatusBar = false; - BAR_WIDTH = Math.round(core._PX_ * 0.3); + BAR_WIDTH = 0//Math.round(core._PX_ * 0.3); } var statusDisplayArr = this._shouldDisplayStatus(), count = statusDisplayArr.length; @@ -3314,16 +3314,16 @@ control.prototype.resize = function () { clientHeight: clientHeight, BORDER: BORDER, BAR_WIDTH: BAR_WIDTH, - TOOLBAR_HEIGHT: 38, + TOOLBAR_HEIGHT: 0, outerWidth: core._PX_ * core.domStyle.scale + 2 * BORDER, outerHeight: core._PY_ * core.domStyle.scale + 2 * BORDER, globalAttribute: globalAttribute, - border: '3px ' + core.arrayToRGBA(globalAttribute.borderColor) + ' solid', + border: '0px ' + core.arrayToRGBA(globalAttribute.borderColor) + ' solid', statusDisplayArr: statusDisplayArr, count: count, col: col, - statusBarHeightInVertical: core.domStyle.isVertical ? (32 * col + 6) * core.domStyle.scale + 2 * BORDER : 0, - toolbarHeightInVertical: core.domStyle.isVertical ? 38 * core.domStyle.scale + 2 * BORDER : 0, + statusBarHeightInVertical: 0,//core.domStyle.isVertical ? (32 * col + 6) * core.domStyle.scale + 2 * BORDER : 0, + toolbarHeightInVertical: 0,//core.domStyle.isVertical ? 38 * core.domStyle.scale + 2 * BORDER : 0, extendToolbar: extendToolbar, is15x15: false, hideLeftStatusBar @@ -3332,6 +3332,7 @@ control.prototype.resize = function () { this._doResize(obj); this.setToolbarButton(); core.updateStatusBar(); + core.AllSprites(); } control.prototype._resize_gameGroup = function (obj) { @@ -3353,7 +3354,7 @@ control.prototype._resize_gameGroup = function (obj) { } gameGroup.style.width = totalWidth + "px"; gameGroup.style.height = totalHeight + "px"; - gameGroup.style.left = (obj.clientWidth - totalWidth) / 2 + "px"; + gameGroup.style.left = (obj.clientWidth - totalWidth) / 2-((main.replayChecking || !core.status.played||core.domStyle.isVertical)?0:48) + "px"; gameGroup.style.top = (obj.clientHeight - totalHeight) / 2 + "px"; // floorMsgGroup var floorMsgGroup = core.dom.floorMsgGroup; diff --git a/project/autotiles/autotile.png b/project/autotiles/autotile.png index 18e92ec..d43e16d 100644 Binary files a/project/autotiles/autotile.png and b/project/autotiles/autotile.png differ diff --git a/project/autotiles/autotile2.png b/project/autotiles/autotile2.png index 496bdc9..001845f 100644 Binary files a/project/autotiles/autotile2.png and b/project/autotiles/autotile2.png differ diff --git a/project/autotiles/autotile3.png b/project/autotiles/autotile3.png index c7a9179..c45108c 100644 Binary files a/project/autotiles/autotile3.png and b/project/autotiles/autotile3.png differ diff --git a/project/data.js b/project/data.js index 98877e7..2d7ccaa 100644 --- a/project/data.js +++ b/project/data.js @@ -5,14 +5,56 @@ var data_a1e2fb4a_e986_4524_b0da_9b7ba7c0874d = "sample0", "sample1", "sample2", - "MT0" + "MT0", + "MT1", + "MT2" ], "floorPartitions": [], "images": [ + "0.png", + "1.png", + "2.png", + "3.png", + "4.png", + "5.png", + "6.png", + "7.png", + "8.png", + "9.png", + "Actor05-Strange05.png", + "Star.png", + "a.png", + "atk.png", + "atk2.png", + "b.png", + "backg.png", + "backl.png", + "backl2.png", + "backw.png", "bear.png", "bg.jpg", + "box1.png", + "box1Light.png", + "box2.png", + "box2Light.png", + "boxLight.png", + "brave.png", + "c.png", + "def.png", + "def2.png", "dragon.png", + "exp.png", + "expL.png", + "expLt.png", "hero.png", + "hp.png", + "key.png", + "lv.png", + "mana.png", + "manaL.png", + "manaLt.png", + "mdef.png", + "money.png", "winskin.png" ], "tilesets": [ @@ -121,7 +163,11 @@ var data_a1e2fb4a_e986_4524_b0da_9b7ba7c0874d = ], "equipName": [ "武器", - "盾牌" + "盾牌", + "饰品", + "饰品", + "饰品", + "饰品" ], "startBgm": null, "styles": { @@ -132,26 +178,26 @@ var data_a1e2fb4a_e986_4524_b0da_9b7ba7c0874d = "statusLeftBackground": "url(project/materials/ground.png) repeat", "statusTopBackground": "url(project/materials/ground.png) repeat", "toolsBackground": "black", - "borderColor": [ - 0, - 0, - 0, - 1 - ], + "floorChangingStyle": "background-color: black; color: white", "statusBarColor": [ 255, 255, 255, 1 ], + "borderColor": [ + 0, + 0, + 0, + 1 + ], "selectColor": [ 255, 215, 0, 1 ], - "floorChangingStyle": "background-color: black; color: white", - "font": "Verdana" + "font": "Zpix" }, "splitImages": [ { @@ -165,8 +211,8 @@ var data_a1e2fb4a_e986_4524_b0da_9b7ba7c0874d = "firstData": { "title": "魔塔样板", "name": "template", - "version": "Ver 2.10.3", - "floorId": "sample0", + "version": "Ver 2.10.0", + "floorId": "MT2", "hero": { "image": "hero.png", "animate": false, @@ -174,8 +220,8 @@ var data_a1e2fb4a_e986_4524_b0da_9b7ba7c0874d = "lv": 1, "hpmax": 9999, "hp": 1000, - "manamax": -1, - "mana": 0, + "manamax": 100, + "mana": 90, "atk": 100, "def": 100, "mdef": 0, @@ -189,12 +235,14 @@ var data_a1e2fb4a_e986_4524_b0da_9b7ba7c0874d = }, "loc": { "direction": "up", - "x": 6, - "y": 10 + "x": 7, + "y": 11 }, "flags": {}, "followers": [], - "steps": 0 + "steps": 0, + "atk2": 0, + "def2": 10 }, "startCanvas": [ { @@ -549,12 +597,22 @@ var data_a1e2fb4a_e986_4524_b0da_9b7ba7c0874d = } ], "startText": [ + { + "type": "function", + "function": "function(){\nflags._statusgry_ =100;core.createSpr0();core.createSprBack();\n}" + }, + { + "type": "function", + "function": "function(){\ncore.addItem('book')\n}" + }, + { + "type": "function", + "function": "function(){\ncore.addItem('fly')\n}" + }, { "type": "comment", "text": "初始剧情" - }, - "Hi,欢迎来到 HTML5 魔塔样板!\n\n本样板由艾之葵制作,可以让你在不会写任何代码\n的情况下也能做出属于自己的H5魔塔!", - "这里游戏开始时的剧情。\n\n你可以在这里写上自己的内容。\n赶快来试一试吧!" + } ], "shops": [ { @@ -705,6 +763,42 @@ var data_a1e2fb4a_e986_4524_b0da_9b7ba7c0874d = } ] }, + { + "need": "100", + "title": "", + "action": [ + { + "type": "setValue", + "name": "status:atk", + "operator": "+=", + "value": "10" + }, + { + "type": "setValue", + "name": "status:def", + "operator": "+=", + "value": "10" + } + ] + }, + { + "need": "1000", + "title": "", + "action": [ + { + "type": "setValue", + "name": "status:atk", + "operator": "+=", + "value": "10" + }, + { + "type": "setValue", + "name": "status:def", + "operator": "+=", + "value": "10" + } + ] + }, { "need": "40", "title": "", @@ -735,7 +829,7 @@ var data_a1e2fb4a_e986_4524_b0da_9b7ba7c0874d = "animateSpeed": 300, "moveSpeed": 100, "statusCanvasRowsOnMobile": 3, - "floorChangeTime": 100 + "floorChangeTime": 0 }, "flags": { "statusBarItems": [ @@ -748,6 +842,8 @@ var data_a1e2fb4a_e986_4524_b0da_9b7ba7c0874d = "enableMDef", "enableMoney", "enableExp", + "enableLevelUp", + "levelUpLeftMode", "enableKeys", "enablePZF", "enableSkill" diff --git a/project/floors/MT0.js b/project/floors/MT0.js index 454a01b..06ee2c9 100644 --- a/project/floors/MT0.js +++ b/project/floors/MT0.js @@ -11,35 +11,371 @@ main.floors.MT0= "images": [], "ratio": 1, "map": [ - [ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], - [ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], - [ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], - [ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], - [ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], - [ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], - [ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], - [ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], - [ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], - [ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], - [ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], - [ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], - [ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0] + [10136,10137,10138, 0, 0, 0, 0, 0, 20, 20, 20, 20, 20], + [10144,10145,10146, 0, 0, 0, 0, 0, 20,10199,10199,10199, 20], + [10152,10153,10154, 0, 0,10207,10207,10207, 20,10199,10199,10199, 20], + [ 0, 0, 0, 0, 0, 0, 0, 0, 20,10199,10199,10199, 20], + [ 0, 20, 20,10157,10157,10157, 20, 0, 0,10207, 0, 0, 20], + [ 20, 20, 20, 20, 20, 20, 20, 0, 0, 0, 0, 0, 20], + [ 20, 0,10149, 20,10110,10110, 20, 0, 0, 0,10149, 0,10165], + [ 20, 0, 0, 20,152,152, 20,10156, 0, 0, 0, 0,10173], + [ 20, 0, 0, 20, 20, 20, 20, 20, 0,10238, 0, 0,10165], + [ 20, 0,10161,10162, 0, 0, 0, 0, 0, 0, 0, 0,10173], + [ 0, 0, 0, 0, 0, 0, 0, 0, 87, 0, 0, 0, 20], + [ 20, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 20], + [ 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20] ], - "firstArrive": [], + "firstArrive": [ + { + "type": "setText", + "background": "winskin.png", + "time": 0 + } + ], "parallelDo": "", - "events": {}, - "changeFloor": {}, + "events": { + "3,4": { + "trigger": null, + "enable": true, + "noPass": null, + "displayDamage": true, + "opacity": 1, + "filter": { + "blur": 0, + "hue": 0, + "grayscale": 1, + "invert": false, + "shadow": 0 + }, + "data": [ + { + "type": "choices", + "text": "\t[执杖伯伯]修改状态栏灰度/亮度", + "choices": [ + { + "text": "亮度+0.1", + "need": "!flags._statusbrg_||flags._statusbrg_<1.5", + "action": [ + { + "type": "function", + "function": "function(){\nflags._statusbrg_ = flags._statusbrg_ + 0.1 || 1.1 ;core.createSpr0();core.createSprBack();\n}" + }, + { + "type": "insert", + "loc": [ + 7, + 11 + ], + "floorId": "sample0" + } + ] + }, + { + "text": "亮度-0.1", + "need": "!flags._statusbrg_||flags._statusbrg_>0.1", + "action": [ + { + "type": "function", + "function": "function(){\nflags._statusbrg_ = flags._statusbrg_ - 0.1 || 0.9 ;core.createSpr0();core.createSprBack();\n}" + }, + { + "type": "insert", + "loc": [ + 7, + 11 + ], + "floorId": "sample0" + } + ] + }, + { + "text": "灰度+10", + "need": "!flags._statusgry_||flags._statusgry_<100", + "action": [ + { + "type": "function", + "function": "function(){\nflags._statusgry_ = flags._statusgry_ + 10 || 10 ;core.createSpr0();core.createSprBack();\n}" + }, + { + "type": "insert", + "loc": [ + 7, + 11 + ], + "floorId": "sample0" + } + ] + }, + { + "text": "灰度-10", + "need": "flags._statusgry_>10", + "action": [ + { + "type": "function", + "function": "function(){\nflags._statusgry_ = flags._statusgry_ - 10 || 0 ;core.createSpr0();core.createSprBack();\n}" + }, + { + "type": "insert", + "loc": [ + 7, + 11 + ], + "floorId": "sample0" + } + ] + }, + { + "text": "爬", + "color": [ + 162, + 162, + 162, + 1 + ], + "action": [] + } + ] + } + ] + }, + "4,4": { + "trigger": null, + "enable": true, + "noPass": null, + "displayDamage": true, + "opacity": 1, + "filter": { + "blur": 0, + "hue": 240, + "grayscale": 0, + "invert": false, + "shadow": 0 + }, + "data": [ + { + "type": "choices", + "text": "\t[执杖伯伯]修改状态栏色相", + "choices": [ + { + "text": "+20", + "action": [ + { + "type": "function", + "function": "function(){\nflags._statuscol_ = flags._statuscol_ + 20 || 0 ;core.createSpr0();core.createSprBack();\n}" + }, + { + "type": "insert", + "loc": [ + 8, + 11 + ], + "floorId": "sample0" + } + ] + }, + { + "text": "-20", + "action": [ + { + "type": "function", + "function": "function(){\nflags._statuscol_ = flags._statuscol_ - 20 || 0 ;core.createSpr0();core.createSprBack();\n}" + }, + { + "type": "insert", + "loc": [ + 8, + 11 + ], + "floorId": "sample0" + } + ] + }, + { + "text": "炫彩", + "condition": "!flags._coltrue_", + "action": [ + { + "type": "function", + "function": "function(){\nflags._coltrue_=true\n}" + }, + { + "type": "insert", + "loc": [ + 8, + 11 + ], + "floorId": "sample0" + } + ] + }, + { + "text": "关闭炫彩", + "condition": "flags._coltrue_", + "action": [ + { + "type": "function", + "function": "function(){\nflags._coltrue_=false\n}" + }, + { + "type": "insert", + "loc": [ + 8, + 11 + ], + "floorId": "sample0" + } + ] + }, + { + "text": "爬", + "color": [ + 162, + 162, + 162, + 1 + ], + "action": [] + } + ] + } + ] + }, + "5,4": [ + { + "type": "choices", + "text": "\t[执杖伯伯]换个背景", + "choices": [ + { + "text": "透明+0.1", + "need": "!flags._backalp_||flags._backalp_>0.1", + "action": [ + { + "type": "function", + "function": "function(){\nflags._backalp_= flags._backalp_- 0.1 || 0.4;core.createSprBack();\n}" + }, + { + "type": "insert", + "loc": [ + 9, + 11 + ], + "floorId": "sample0" + } + ] + }, + { + "text": "透明-0.1", + "need": "!flags._backalp_||flags._backalp_<0.9", + "action": [ + { + "type": "function", + "function": "function(){\nflags._backalp_= flags._backalp_+ 0.1 || 0.6;core.createSprBack();\n}" + }, + { + "type": "insert", + "loc": [ + 9, + 11 + ], + "floorId": "sample0" + } + ] + }, + { + "text": "去掉星空", + "condition": "!flags.starOff", + "action": [ + { + "type": "function", + "function": "function(){\nflags.starOff=true\n}" + }, + { + "type": "function", + "function": "function(){\ncore.createSprBack();\n}" + }, + { + "type": "insert", + "loc": [ + 9, + 11 + ], + "floorId": "sample0" + } + ] + }, + { + "text": "加上星空", + "condition": "flags.starOff", + "action": [ + { + "type": "function", + "function": "function(){\nflags.starOff=false\n}" + }, + { + "type": "function", + "function": "function(){\ncore.createSprBack();\n}" + }, + { + "type": "insert", + "loc": [ + 9, + 11 + ], + "floorId": "sample0" + } + ] + }, + { + "text": "换个图", + "action": [ + "\t[执杖伯伯,wizard]你为什么不自己找一张" + ] + }, + { + "text": "爬", + "color": [ + 162, + 162, + 162, + 1 + ], + "action": [] + } + ] + } + ] + }, + "changeFloor": { + "8,10": { + "floorId": ":next", + "stair": "downFloor" + } + }, "afterBattle": {}, "afterGetItem": {}, "afterOpenDoor": {}, "cannotMove": {}, "bgmap": [ - + [153,153,153,153,153,153,153,153,153,153,153,153,153], + [153,153,153,153,153,153,153,153,153,153,153,153,153], + [153,153,153,153,153,153,153,153,153,153,153,153,153], + [153,153,153,153,153,153,153,153,153,153,153,153,153], + [153,153,153,153,153,153,153,153,153,153,153,153,153], + [153,153,153,153,153,153,153,153,153,153,153,153,153], + [153,153,153,153,153,153,153,153,153,153,153,153,153], + [153,153,153,153,153,153,153,153,153,153,153,153,153], + [153,153,153,153,153,153,153,153,153,153,153,153,153], + [153,153,153,153,153,153,153,153,153,153,153,153,153], + [153,153,153,153,153,153,153,153,153,153,153,153,153], + [153,153,153,153,153,153,153,153,153,153,153,153,153], + [153,153,153,153,153,153,153,153,153,153,153,153,153] ], "fgmap": [ ], "width": 13, "height": 13, - "autoEvent": {} + "autoEvent": {}, + "beforeBattle": {}, + "cannotMoveIn": {} } \ No newline at end of file diff --git a/project/floors/MT1.js b/project/floors/MT1.js new file mode 100644 index 0000000..198126f --- /dev/null +++ b/project/floors/MT1.js @@ -0,0 +1,65 @@ +main.floors.MT1= +{ + "floorId": "MT1", + "title": "主塔 1 层", + "name": "1", + "width": 13, + "height": 13, + "canFlyTo": true, + "canFlyFrom": true, + "canUseQuickShop": true, + "cannotViewMap": false, + "images": [], + "ratio": 1, + "defaultGround": "ground", + "firstArrive": [], + "eachArrive": [], + "parallelDo": "", + "events": {}, + "changeFloor": { + "7,11": { + "floorId": ":next", + "stair": "downFloor" + } + }, + "beforeBattle": {}, + "afterBattle": {}, + "afterGetItem": {}, + "afterOpenDoor": {}, + "autoEvent": {}, + "cannotMove": {}, + "cannotMoveIn": {}, + "map": [ + [ 2,152, 2,152, 2,152, 2,152, 2,152,152,152, 2], + [ 2, 28, 21,152, 27, 27, 27,152, 0, 0, 0, 0, 2], + [ 2, 0, 0,152, 28, 28, 28,152, 81, 2,152, 0, 2], + [ 2, 81, 2,152, 2, 83, 2,152, 31, 31,152, 0, 2], + [ 2, 0, 0, 0, 0, 0, 0, 2,152, 2,152, 0, 2], + [ 2, 2, 2,152, 0, 0, 0, 0,152, 21,152, 0, 2], + [ 2, 21, 21,152, 81, 2, 2, 81,152, 0, 0, 0, 2], + [ 2, 2, 81,152, 0, 0, 0, 0,152, 82, 2, 81, 2], + [ 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2], + [ 2, 0, 2,152, 84,152, 2, 0, 2, 2, 2, 0, 2], + [ 2, 0,152, 22, 21, 21,152, 0, 2, 22, 2, 0, 2], + [ 2, 34,152, 21, 21, 21,152, 87, 81, 0, 0, 0, 2], + [152,152, 2,152,152,152, 2,152,152,152,152,152, 2] +], + "bgmap": [ + [10001,10001,10001,10001,10001,10001,10001,10001,10001,10001,10001,10001,10001], + [10001,10001,10001,10001,10001,10001,10001,10001,10001,10001,10001,10001,10001], + [10001,10001,10001,10001,10001,10001,10001,10001,10001,10001,10001,10001,10001], + [10001,10001,10001,10001,10001,10001,10001,10001,10001,10001,10001,10001,10001], + [10001,10001,10001,10001,10001,10001,10001,10001,10001,10001,10001,10001,10001], + [10001,10001,10001,10001,10001,10001,10001,10001,10001,10001,10001,10001,10001], + [10001,10001,10001,10001,10001,10001,10001,10001,10001,10001,10001,10001,10001], + [10001,10001,10001,10001,10001,10001,10001,10001,10001,10001,10001,10001,10001], + [10001,10001,10001,10001,10001,10001,10001,10001,10001,10001,10001,10001,10001], + [10001,10001,10001,10001,10001,10001,10001,10001,10001,10001,10001,10001,10001], + [10001,10001,10001,10001,10001,10001,10001,10001,10001,10001,10001,10001,10001], + [10001,10001,10001,10001,10001,10001,10001,10001,10001,10001,10001,10001,10001], + [10001,10001,10001,10001,10001,10001,10001,10001,10001,10001,10001,10001,10001] +], + "fgmap": [ + +] +} \ No newline at end of file diff --git a/project/floors/MT2.js b/project/floors/MT2.js new file mode 100644 index 0000000..2633f46 --- /dev/null +++ b/project/floors/MT2.js @@ -0,0 +1,60 @@ +main.floors.MT2= +{ + "floorId": "MT2", + "title": "主塔 2 层", + "name": "2", + "width": 13, + "height": 13, + "canFlyTo": true, + "canFlyFrom": true, + "canUseQuickShop": true, + "cannotViewMap": false, + "images": [], + "ratio": 1, + "defaultGround": "ground", + "firstArrive": [], + "eachArrive": [], + "parallelDo": "", + "events": {}, + "changeFloor": {}, + "beforeBattle": {}, + "afterBattle": {}, + "afterGetItem": {}, + "afterOpenDoor": {}, + "autoEvent": {}, + "cannotMove": {}, + "cannotMoveIn": {}, + "map": [ + [153,153,153,153,153,153,153,153,153,153,153,153,153], + [153, 28, 21,153, 27, 27, 27,153, 0, 0, 0, 0,153], + [153, 0, 27,153, 28, 28, 28,153, 81,153,153, 0,153], + [153, 81,153,153,153, 83,153,153, 31, 31,153, 0,153], + [153, 0, 0, 0, 0, 0, 0,153,153,153,153, 0,153], + [153,153,153,153, 81,153, 0, 0,153, 23,153, 0,153], + [153, 21, 21,153, 0,153,153, 81,153, 0, 0, 0,153], + [153,153, 81,153, 0,153,201, 0,153, 82,153, 81,153], + [153, 0, 0, 0, 0,153, 0, 0, 86,201, 0, 0,153], + [153, 0,153,153, 84,153,153, 0,153,153,153, 0,153], + [153, 0,153, 22, 21, 21,153, 0,153, 22,153, 0,153], + [153, 34,153, 21, 21, 21, 86, 0, 81, 28,153, 32,153], + [153,153,153,153,153,153,153,153,153,153,153,153,153] +], + "bgmap": [ + [305,305,305,305,305,305,305,305,305,305,305,305,305], + [305,305,305,305,305,305,305,305,311,305,305,305,305], + [305,305,308,305,305,305,305,305,305,305,305,308,305], + [305,305,305,305,305,305,305,305,305,305,305,305,305], + [305,311,305,305,305,305,308,305,305,305,305,305,305], + [305,305,305,305,311,305,305,305,305,305,305,305,305], + [305,305,305,305,305,305,305,305,305,311,305,305,305], + [305,305,305,305,305,305,311,305,305,305,305,305,305], + [305,311,305,305,305,305,308,305,305,305,305,311,305], + [305,305,305,305,305,305,305,305,305,305,305,305,305], + [305,305,305,305,311,305,305,305,305,305,305,305,305], + [305,305,305,305,305,305,305,305,305,311,305,305,305], + [305,305,305,305,305,305,305,305,305,305,305,305,305] +], + "fgmap": [ + +] +} \ No newline at end of file diff --git a/project/floors/sample0.js b/project/floors/sample0.js index 7ffc756..4120673 100644 --- a/project/floors/sample0.js +++ b/project/floors/sample0.js @@ -13,16 +13,16 @@ main.floors.sample0= "map": [ [ 0, 0,220, 0, 0, 20, 87, 3, 58, 59, 60, 61, 64], [ 0,246, 0,246, 0, 20, 0, 3, 57, 72, 63, 43, 44], - [219, 0, 0, 0,219, 20, 0, 3, 53, 54, 55, 56, 69], - [ 20, 20,125, 20, 20, 20, 0, 3, 49, 50, 51, 52, 68], - [251,247,256,234,248, 6, 0, 3, 35, 36, 46, 47, 48], - [ 6, 6,125, 6, 6, 6, 0, 3, 0, 0, 0, 0, 0], - [208,227,212,216,278, 5, 0, 1, 1, 1,319, 1, 1], - [201,205,217,215,224, 5, 0, 1, 27, 28, 29, 30, 31], - [ 5, 5,125, 5, 5, 5, 0, 1, 21, 22, 23, 24, 26], + [219, 0, 0, 0,219, 20, 54, 3, 53, 54, 55, 56, 69], + [ 20, 20,125, 20, 20, 20, 69, 3, 49, 50, 51, 52, 68], + [251,247,256,234,248, 6, 62, 3, 35, 36, 46, 47, 48], + [ 6, 6,125, 6, 6, 6, 55, 3, 0, 0, 0, 0, 0], + [208,227,212,216,278, 5, 64, 1, 1, 1,319, 1, 1], + [201,205,217,215,224, 5, 42, 1, 27, 28, 29, 30, 31], + [ 5, 5,125, 5, 5, 5, 41, 1, 21, 22, 23, 24, 26], [ 0, 0,263, 0, 0, 0, 45, 1, 1, 1,121, 1, 1], - [ 4, 4,133, 4, 4, 4, 0, 0, 0, 0, 0, 85,124], - [ 87, 11, 12, 13, 14, 4, 4, 2, 2,122, 2, 2, 2], + [ 4, 4,133, 4, 4,10303, 0, 0, 0, 0, 0, 85,124], + [ 87, 11, 12, 13, 14,10303,10303,125,125,125, 2, 2, 2], [ 88, 89, 90, 91, 92, 93, 94, 2, 81, 82, 83, 84, 86] ], "firstArrive": [ @@ -84,11 +84,107 @@ main.floors.sample0= } ], "9,11": [ - "\t[老人,trader]\b[this]这些是门,需要对应的钥匙打开。\n机关门必须使用特殊的开法。", - "\t[老人,trader]\b[this]开门后可触发 afterOpenDoor 事件。\n\n有关事件的各种信息在下一层会有更为详细的说明。", { - "type": "hide", - "time": 500 + "type": "choices", + "text": "\t[执杖伯伯]换个背景", + "choices": [ + { + "text": "透明+0.1", + "need": "!flags._backalp_||flags._backalp_>0.1", + "action": [ + { + "type": "function", + "function": "function(){\nflags._backalp_= flags._backalp_- 0.1 || 0.4;core.createSprBack();\n}" + }, + { + "type": "insert", + "loc": [ + 9, + 11 + ], + "floorId": "sample0" + } + ] + }, + { + "text": "透明-0.1", + "need": "!flags._backalp_||flags._backalp_<0.9", + "action": [ + { + "type": "function", + "function": "function(){\nflags._backalp_= flags._backalp_+ 0.1 || 0.6;core.createSprBack();\n}" + }, + { + "type": "insert", + "loc": [ + 9, + 11 + ], + "floorId": "sample0" + } + ] + }, + { + "text": "去掉星空", + "condition": "!flags.starOff", + "action": [ + { + "type": "function", + "function": "function(){\nflags.starOff=true\n}" + }, + { + "type": "function", + "function": "function(){\ncore.createSprBack();\n}" + }, + { + "type": "insert", + "loc": [ + 9, + 11 + ], + "floorId": "sample0" + } + ] + }, + { + "text": "加上星空", + "condition": "flags.starOff", + "action": [ + { + "type": "function", + "function": "function(){\nflags.starOff=false\n}" + }, + { + "type": "function", + "function": "function(){\ncore.createSprBack();\n}" + }, + { + "type": "insert", + "loc": [ + 9, + 11 + ], + "floorId": "sample0" + } + ] + }, + { + "text": "换个图", + "action": [ + "\t[执杖伯伯,wizard]你为什么不自己找一张" + ] + }, + { + "text": "爬", + "color": [ + 162, + 162, + 162, + 1 + ], + "action": [] + } + ] } ], "10,9": [ @@ -99,7 +195,213 @@ main.floors.sample0= "type": "hide", "time": 500 } - ] + ], + "8,11": { + "trigger": null, + "enable": true, + "noPass": null, + "displayDamage": true, + "opacity": 1, + "filter": { + "blur": 0, + "hue": 240, + "grayscale": 0, + "invert": false, + "shadow": 0 + }, + "data": [ + { + "type": "choices", + "text": "\t[执杖伯伯]修改状态栏色相", + "choices": [ + { + "text": "+20", + "action": [ + { + "type": "function", + "function": "function(){\nflags._statuscol_ = flags._statuscol_ + 20 || 0 ;core.createSpr0();core.createSprBack();\n}" + }, + { + "type": "insert", + "loc": [ + 8, + 11 + ], + "floorId": "sample0" + } + ] + }, + { + "text": "-20", + "action": [ + { + "type": "function", + "function": "function(){\nflags._statuscol_ = flags._statuscol_ - 20 || 0 ;core.createSpr0();core.createSprBack();\n}" + }, + { + "type": "insert", + "loc": [ + 8, + 11 + ], + "floorId": "sample0" + } + ] + }, + { + "text": "炫彩", + "condition": "!flags._coltrue_", + "action": [ + { + "type": "function", + "function": "function(){\nflags._coltrue_=true\n}" + }, + { + "type": "insert", + "loc": [ + 8, + 11 + ], + "floorId": "sample0" + } + ] + }, + { + "text": "关闭炫彩", + "condition": "flags._coltrue_", + "action": [ + { + "type": "function", + "function": "function(){\nflags._coltrue_=false\n}" + }, + { + "type": "insert", + "loc": [ + 8, + 11 + ], + "floorId": "sample0" + } + ] + }, + { + "text": "爬", + "color": [ + 162, + 162, + 162, + 1 + ], + "action": [] + } + ] + } + ] + }, + "7,11": { + "trigger": null, + "enable": true, + "noPass": null, + "displayDamage": true, + "opacity": 1, + "filter": { + "blur": 0, + "hue": 0, + "grayscale": 1, + "invert": false, + "shadow": 0 + }, + "data": [ + { + "type": "choices", + "text": "\t[执杖伯伯]修改状态栏灰度/亮度", + "choices": [ + { + "text": "亮度+0.1", + "need": "!flags._statusbrg_||flags._statusbrg_<1.5", + "action": [ + { + "type": "function", + "function": "function(){\nflags._statusbrg_ = flags._statusbrg_ + 0.1 || 1.1 ;core.createSpr0();core.createSprBack();\n}" + }, + { + "type": "insert", + "loc": [ + 7, + 11 + ], + "floorId": "sample0" + } + ] + }, + { + "text": "亮度-0.1", + "need": "!flags._statusbrg_||flags._statusbrg_>0.1", + "action": [ + { + "type": "function", + "function": "function(){\nflags._statusbrg_ = flags._statusbrg_ - 0.1 || 0.9 ;core.createSpr0();core.createSprBack();\n}" + }, + { + "type": "insert", + "loc": [ + 7, + 11 + ], + "floorId": "sample0" + } + ] + }, + { + "text": "灰度+10", + "need": "!flags._statusgry_||flags._statusgry_<100", + "action": [ + { + "type": "function", + "function": "function(){\nflags._statusgry_ = flags._statusgry_ + 10 || 10 ;core.createSpr0();core.createSprBack();\n}" + }, + { + "type": "insert", + "loc": [ + 7, + 11 + ], + "floorId": "sample0" + } + ] + }, + { + "text": "灰度-10", + "need": "flags._statusgry_>10", + "action": [ + { + "type": "function", + "function": "function(){\nflags._statusgry_ = flags._statusgry_ - 10 || 0 ;core.createSpr0();core.createSprBack();\n}" + }, + { + "type": "insert", + "loc": [ + 7, + 11 + ], + "floorId": "sample0" + } + ] + }, + { + "text": "爬", + "color": [ + 162, + 162, + 162, + 1 + ], + "action": [] + } + ] + } + ] + } }, "changeFloor": { "6,0": { diff --git a/project/floors/sample1.js b/project/floors/sample1.js index 2d3f74a..896e0b6 100644 --- a/project/floors/sample1.js +++ b/project/floors/sample1.js @@ -348,7 +348,7 @@ main.floors.sample1= "operator": "+=", "value": "10*(status:atk+status:def)" }, - "\t[老人,man]\b[this]再送你500金币,1000经验,1破2炸3飞!", + "\t[老人,man]\b[this]再送你500金币,200经验,1破2炸3飞!", { "type": "setValue", "name": "status:money", @@ -359,7 +359,7 @@ main.floors.sample1= "type": "setValue", "name": "status:exp", "operator": "+=", - "value": "1000" + "value": "200" }, { "type": "setValue", @@ -626,5 +626,6 @@ main.floors.sample1= }, "width": 13, "height": 13, - "beforeBattle": {} + "beforeBattle": {}, + "cannotMoveIn": {} } \ No newline at end of file diff --git a/project/functions.js b/project/functions.js index 299ae53..2306f06 100644 --- a/project/functions.js +++ b/project/functions.js @@ -1,8 +1,7 @@ -/// -var functions_d6ad677b_427a_4623_b50f_a445a3b0ef8a = +var functions_d6ad677b_427a_4623_b50f_a445a3b0ef8a = { - "events": { - "resetGame": function (hero, hard, floorId, maps, values) { + "events": { + "resetGame": function (hero, hard, floorId, maps, values) { // 重置整个游戏;此函数将在游戏开始时,或者每次读档时最先被调用 // hero:勇士信息;hard:难度;floorId:当前楼层ID;maps:地图信息;values:全局数值信息 @@ -52,7 +51,7 @@ var functions_d6ad677b_427a_4623_b50f_a445a3b0ef8a = // 隐藏右下角的音乐按钮 core.dom.musicBtn.style.display = 'none'; }, - "win": function (reason, norank, noexit) { + "win": function (reason, norank, noexit) { // 游戏获胜事件 // 请注意,成绩统计时是按照hp进行上传并排名 // 可以先在这里对最终分数进行计算,比如将2倍攻击和5倍黄钥匙数量加到分数上 @@ -81,7 +80,7 @@ var functions_d6ad677b_427a_4623_b50f_a445a3b0ef8a = }) }); }, - "lose": function (reason) { + "lose": function (reason) { // 游戏失败事件 core.ui.closePanel(); var replaying = core.isReplaying(); @@ -94,7 +93,7 @@ var functions_d6ad677b_427a_4623_b50f_a445a3b0ef8a = }); }) }, - "changingFloor": function (floorId, heroLoc) { + "changingFloor": function (floorId, heroLoc) { // 正在切换楼层过程中执行的操作;此函数的执行时间是“屏幕完全变黑“的那一刻 // floorId为要切换到的楼层ID;heroLoc表示勇士切换到的位置 @@ -162,7 +161,7 @@ var functions_d6ad677b_427a_4623_b50f_a445a3b0ef8a = // ...可以新增一些其他内容,比如创建个画布在右上角显示什么内容等等 }, - "afterChangeFloor": function (floorId) { + "afterChangeFloor": function (floorId) { // 转换楼层结束的事件;此函数会在整个楼层切换完全结束后再执行 // floorId是切换到的楼层 @@ -181,7 +180,7 @@ var functions_d6ad677b_427a_4623_b50f_a445a3b0ef8a = } } }, - "flyTo": function (toId, callback) { + "flyTo": function (toId, callback) { // 楼层传送器的使用,从当前楼层飞往toId // 如果不能飞行请返回false @@ -224,7 +223,7 @@ var functions_d6ad677b_427a_4623_b50f_a445a3b0ef8a = return true; }, - "beforeBattle": function (enemyId, x, y) { + "beforeBattle": function (enemyId, x, y) { // 战斗前触发的事件,可以加上一些战前特效(详见下面支援的例子) // 此函数在“检测能否战斗和自动存档”【之后】执行。如果需要更早的战前事件,请在插件中覆重写 core.events.doSystemEvent 函数。 // 返回true则将继续战斗,返回false将不再战斗。 @@ -255,7 +254,7 @@ var functions_d6ad677b_427a_4623_b50f_a445a3b0ef8a = return true; }, - "afterBattle": function (enemyId, x, y) { + "afterBattle": function (enemyId, x, y) { // 战斗结束后触发的事件 var enemy = core.material.enemys[enemyId]; @@ -426,7 +425,7 @@ var functions_d6ad677b_427a_4623_b50f_a445a3b0ef8a = core.clearContinueAutomaticRoute(); }, - "afterOpenDoor": function (doorId, x, y) { + "afterOpenDoor": function (doorId, x, y) { // 开一个门后触发的事件 var todo = []; @@ -447,7 +446,7 @@ var functions_d6ad677b_427a_4623_b50f_a445a3b0ef8a = else core.clearContinueAutomaticRoute(); }, - "afterGetItem": function (itemId, x, y, isGentleClick) { + "afterGetItem": function (itemId, x, y, isGentleClick) { // 获得一个道具后触发的事件 // itemId:获得的道具ID;x和y是该道具所在的坐标 // isGentleClick:是否是轻按触发的 @@ -469,7 +468,7 @@ var functions_d6ad677b_427a_4623_b50f_a445a3b0ef8a = if (todo.length > 0) core.insertAction(todo, x, y); }, - "afterPushBox": function () { + "afterPushBox": function () { // 推箱子后的事件 if (core.searchBlock('box').length == 0) { // 可以通过if语句来进行开门操作 @@ -482,9 +481,9 @@ var functions_d6ad677b_427a_4623_b50f_a445a3b0ef8a = */ } } - }, - "enemys": { - "getSpecials": function () { + }, + "enemys": { + "getSpecials": function () { // 获得怪物的特殊属性,每一行定义一个特殊属性。 // 分为五项,第一项为该特殊属性的数字,第二项为特殊属性的名字,第三项为特殊属性的描述 // 第四项为该特殊属性的颜色,可以写十六进制 #RRGGBB 或者 [r,g,b,a] 四元数组 @@ -520,7 +519,7 @@ var functions_d6ad677b_427a_4623_b50f_a445a3b0ef8a = [27, "捕捉", function (enemy) { return "当走到怪物周围" + (enemy.zoneSquare ? "九宫格" : "十字") + "时会强制进行战斗。"; }, "#c0ddbb"] ]; }, - "getEnemyInfo": function (enemy, hero, x, y, floorId) { + "getEnemyInfo": function (enemy, hero, x, y, floorId) { // 获得某个怪物变化后的数据;该函数将被伤害计算和怪物手册使用 // 例如:坚固、模仿、仿攻等等 // @@ -643,7 +642,7 @@ var functions_d6ad677b_427a_4623_b50f_a445a3b0ef8a = "guards": guards, // 返回支援情况 }; }, - "getDamageInfo": function (enemy, hero, x, y, floorId) { + "getDamageInfo": function (enemy, hero, x, y, floorId) { // 获得战斗伤害信息(实际伤害计算函数) // // 参数说明: @@ -801,9 +800,9 @@ var functions_d6ad677b_427a_4623_b50f_a445a3b0ef8a = "damage": Math.floor(damage) }; } - }, - "actions": { - "onKeyUp": function (keyCode, altKey) { + }, + "actions": { + "onKeyUp": function (keyCode, altKey) { // 键盘按键处理,可以在这里自定义快捷键列表 // keyCode:当前按键的keyCode(每个键的keyCode自行百度) // altKey:Alt键是否被按下,为true代表同时按下了Alt键 @@ -954,7 +953,7 @@ var functions_d6ad677b_427a_4623_b50f_a445a3b0ef8a = } }, - "onStatusBarClick": function (px, py, vertical) { + "onStatusBarClick": function (px, py, vertical) { // 点击状态栏时触发的事件,仅在自绘状态栏开启时生效 // px和py为点击的像素坐标 // vertical为录像播放过程中的横竖屏信息 @@ -1022,9 +1021,9 @@ var functions_d6ad677b_427a_4623_b50f_a445a3b0ef8a = */ } - }, - "control": { - "saveData": function () { + }, + "control": { + "saveData": function () { // 存档操作,此函数应该返回“具体要存档的内容” // 差异化存储values @@ -1049,7 +1048,7 @@ var functions_d6ad677b_427a_4623_b50f_a445a3b0ef8a = return data; }, - "loadData": function (data, callback) { + "loadData": function (data, callback) { // 读档操作;从存储中读取了内容后的行为 // 重置游戏和路线 @@ -1088,7 +1087,7 @@ var functions_d6ad677b_427a_4623_b50f_a445a3b0ef8a = if (callback) callback(); }); }, - "getStatusLabel": function (name) { + "getStatusLabel": function (name) { // 返回某个状态英文名的对应中文标签,如atk -> 攻击,def -> 防御等。 // 请注意此项仅影响 libs/ 下的内容(如绘制怪物手册、数据统计等) // 自行定义的(比如获得道具效果)中用到的“攻击+3”等需要自己去对应地方修改 @@ -1109,7 +1108,7 @@ var functions_d6ad677b_427a_4623_b50f_a445a3b0ef8a = steps: "步数", }[name] || name; }, - "triggerDebuff": function (action, type) { + "triggerDebuff": function (action, type) { // 毒衰咒效果的获得与解除 // action:获得还是解除;'get'表示获得,'remove'表示解除 // type:一个数组表示获得了哪些毒衰咒效果;poison, weak,curse @@ -1166,90 +1165,92 @@ var functions_d6ad677b_427a_4623_b50f_a445a3b0ef8a = if (success) core.playSound('回血'); } }, - "updateStatusBar": function () { - // 更新状态栏 + "updateStatusBar": function () { + // 更新状态栏 - // 检查等级 - core.events.checkLvUp(); + // 检查等级 + core.events.checkLvUp(); - // 检查HP上限 - if (core.flags.statusBarItems.indexOf('enableHPMax') >= 0) { - core.setStatus('hp', Math.min(core.getRealStatus('hpmax'), core.getStatus('hp'))); - } + // 检查HP上限 + if (core.flags.statusBarItems.indexOf('enableHPMax') >= 0) { + core.setStatus('hp', Math.min(core.getRealStatus('hpmax'), core.getStatus('hp'))); + } - // 设置楼层名 - if (core.status.floorId) { - core.setStatusBarInnerHTML('floor', core.status.maps[core.status.floorId].name); - } + // 设置楼层名 + if (core.status.floorId) { + //core.setStatusBarInnerHTML('floor', core.status.maps[core.status.floorId].name); + } - // 设置勇士名字和图标 - core.setStatusBarInnerHTML('name', core.getStatus('name')); - // 设置等级名称 - core.setStatusBarInnerHTML('lv', core.getLvName()); + // 设置勇士名字和图标 + //core.setStatusBarInnerHTML('name', core.getStatus('name')); + // 设置等级名称 + //core.setStatusBarInnerHTML('lv', core.getLvName()); - // 设置生命上限、生命值、攻防护盾金币和经验值 - var statusList = ['hpmax', 'hp', 'mana', 'atk', 'def', 'mdef', 'money', 'exp']; - statusList.forEach(function (item) { - // 向下取整 - core.status.hero[item] = Math.floor(core.status.hero[item]); - // 大数据格式化 - core.setStatusBarInnerHTML(item, core.getRealStatus(item)); - }); + // 设置生命上限、生命值、攻防护盾金币和经验值 + var statusList = ['hpmax', 'hp', 'mana', 'atk', 'def', 'mdef', 'money', 'exp']; + statusList.forEach(function (item) { + // 向下取整 + core.status.hero[item] = Math.floor(core.status.hero[item]); + // 大数据格式化 + //core.setStatusBarInnerHTML(item, core.getRealStatus(item)); + }); - // 设置魔力值; status:manamax 只有在非负时才生效。 - if (core.status.hero.manamax != null && core.getRealStatus('manamax') >= 0) { - core.status.hero.mana = Math.min(core.status.hero.mana, core.getRealStatus('manamax')); - core.setStatusBarInnerHTML('mana', core.status.hero.mana + "/" + core.getRealStatus('manamax')); - } else { - core.setStatusBarInnerHTML("mana", core.status.hero.mana); - } - // 设置技能栏 - // 可以用flag:skill表示当前开启的技能类型,flag:skillName显示技能名;详见文档-个性化-技能塔的支持 - core.setStatusBarInnerHTML('skill', core.getFlag('skillName', '无')); + // 设置魔力值; status:manamax 只有在非负时才生效。 + if (core.status.hero.manamax != null && core.getRealStatus('manamax') >= 0) { + core.status.hero.mana = Math.min(core.status.hero.mana, core.getRealStatus('manamax')); + //core.setStatusBarInnerHTML('mana', core.status.hero.mana + "/" + core.getRealStatus('manamax')); + } else { + //core.setStatusBarInnerHTML("mana", core.status.hero.mana); + } + // 设置技能栏 + // 可以用flag:skill表示当前开启的技能类型,flag:skillName显示技能名;详见文档-个性化-技能塔的支持 + //core.setStatusBarInnerHTML('skill', core.getFlag('skillName', '无')); - // 可以在这里添加自己额外的状态栏信息,比如想攻击显示 +0.5 可以这么写: - // if (core.hasFlag('halfAtk')) core.setStatusBarInnerHTML('atk', core.statusBar.atk.innerText + "+0.5"); + // 可以在这里添加自己额外的状态栏信息,比如想攻击显示 +0.5 可以这么写: + // if (core.hasFlag('halfAtk')) core.setStatusBarInnerHTML('atk', core.statusBar.atk.innerText + "+0.5"); - // 如果是自定义添加的状态栏,也需要在这里进行设置显示的数值 + // 如果是自定义添加的状态栏,也需要在这里进行设置显示的数值 - // 进阶 - if (core.flags.statusBarItems.indexOf('enableLevelUp') >= 0) { - core.setStatusBarInnerHTML('up', core.formatBigNumber(core.getNextLvUpNeed()) || ""); - } else core.setStatusBarInnerHTML('up', ""); + // 进阶 + if (core.flags.statusBarItems.indexOf('enableLevelUp') >= 0) { + //core.setStatusBarInnerHTML('up', core.formatBigNumber(core.getNextLvUpNeed()) || ""); + } else; //core.setStatusBarInnerHTML('up', ""); - // 钥匙 - var keys = ['yellowKey', 'blueKey', 'redKey', 'greenKey']; - keys.forEach(function (key) { - core.setStatusBarInnerHTML(key, core.setTwoDigits(core.itemCount(key))); - }); - // 毒衰咒 - core.setStatusBarInnerHTML('poison', core.hasFlag('poison') ? "毒" : ""); - core.setStatusBarInnerHTML('weak', core.hasFlag('weak') ? "衰" : ""); - core.setStatusBarInnerHTML('curse', core.hasFlag('curse') ? "咒" : ""); - // 破炸飞 - core.setStatusBarInnerHTML('pickaxe', "破" + core.itemCount('pickaxe')); - core.setStatusBarInnerHTML('bomb', "炸" + core.itemCount('bomb')); - core.setStatusBarInnerHTML('fly', "飞" + core.itemCount('centerFly')); + // 钥匙 + var keys = ['yellowKey', 'blueKey', 'redKey', 'greenKey']; + keys.forEach(function (key) { + //core.setStatusBarInnerHTML(key, core.setTwoDigits(core.itemCount(key))); + }); + // 毒衰咒 + //core.setStatusBarInnerHTML('poison', core.hasFlag('poison') ? "毒" : ""); + //core.setStatusBarInnerHTML('weak', core.hasFlag('weak') ? "衰" : ""); + //core.setStatusBarInnerHTML('curse', core.hasFlag('curse') ? "咒" : ""); + // 破炸飞 + //core.setStatusBarInnerHTML('pickaxe', "破" + core.itemCount('pickaxe')); + //core.setStatusBarInnerHTML('bomb', "炸" + core.itemCount('bomb')); + //core.setStatusBarInnerHTML('fly', "飞" + core.itemCount('centerFly')); - // 难度 - if (core.statusBar.hard.innerText != core.status.hard) { - core.statusBar.hard.innerText = core.status.hard; - } - var hardColor = core.getFlag('__hardColor__'); - if (hardColor == null) core.statusBar.hard.innerText = ''; - if (core.statusBar.hard.getAttribute('_style') != hardColor) { - core.statusBar.hard.style.color = hardColor; - core.statusBar.hard.setAttribute('_style', hardColor); - } - // 自定义状态栏绘制 - core.drawStatusBar(); - - // 更新阻激夹域的伤害值 - core.updateCheckBlock(); - // updateDamage只能在此处执行!!更新全地图显伤 - core.updateDamage(); - }, - "updateCheckBlock": function (floorId) { + // 难度 + if (core.statusBar.hard.innerText != core.status.hard) { + core.statusBar.hard.innerText = core.status.hard; + } + var hardColor = core.getFlag('__hardColor__'); + if (hardColor == null) core.statusBar.hard.innerText = ''; + if (core.statusBar.hard.getAttribute('_style') != hardColor) { + core.statusBar.hard.style.color = hardColor; + core.statusBar.hard.setAttribute('_style', hardColor); + } + // 自定义状态栏绘制 + core.drawStatusBar(); + //core.createSpr0(); + //core.createSpr1(); + core.createSpr2(); + // 更新阻激夹域的伤害值 + core.updateCheckBlock(); + // updateDamage只能在此处执行!!更新全地图显伤 + core.updateDamage(); +}, + "updateCheckBlock": function (floorId) { // 领域、夹击、阻击等的伤害值计算 floorId = floorId || core.status.floorId; if (!floorId || !core.status.maps) return; @@ -1460,70 +1461,73 @@ var functions_d6ad677b_427a_4623_b50f_a445a3b0ef8a = cache: {} // clear cache }; }, - "moveOneStep": function (callback) { - // 勇士每走一步后执行的操作。callback为行走完毕后的回调 - // 这个函数执行在“刚走完”的时候,即还没有检查该点的事件和领域伤害等。 - // 请注意:瞬间移动不会执行该函数。如果要控制能否瞬间移动有三种方法: - // 1. 将全塔属性中的cannotMoveDirectly这个开关勾上,即可在全塔中全程禁止使用瞬移。 - // 2, 将楼层属性中的cannotMoveDirectly这个开关勾上,即禁止在该层楼使用瞬移。 - // 3. 将flag:cannotMoveDirectly置为true,即可使用flag控制在某段剧情范围内禁止瞬移。 + "moveOneStep": function (callback) { + // 勇士每走一步后执行的操作。callback为行走完毕后的回调 + // 这个函数执行在“刚走完”的时候,即还没有检查该点的事件和领域伤害等。 + // 请注意:瞬间移动不会执行该函数。如果要控制能否瞬间移动有三种方法: + // 1. 将全塔属性中的cannotMoveDirectly这个开关勾上,即可在全塔中全程禁止使用瞬移。 + // 2, 将楼层属性中的cannotMoveDirectly这个开关勾上,即禁止在该层楼使用瞬移。 + // 3. 将flag:cannotMoveDirectly置为true,即可使用flag控制在某段剧情范围内禁止瞬移。 - // 增加步数 - core.status.hero.steps++; - // 更新跟随者状态,并绘制 - core.updateFollowers(); - core.drawHero(); - // 检查中毒状态的扣血和死亡 - if (core.hasFlag('poison')) { - core.status.hero.statistics.poisonDamage += core.values.poisonDamage; - core.status.hero.hp -= core.values.poisonDamage; - if (core.status.hero.hp <= 0) { - core.status.hero.hp = 0; - core.updateStatusBar(false, true); - core.events.lose(); - return; - } else { - core.updateStatusBar(false, true); - } - } + // 增加步数 + core.status.hero.steps++; + // 更新跟随者状态,并绘制 + core.updateFollowers(); + core.drawHero(); + // 检查中毒状态的扣血和死亡 + //hero.mana-- + //core.updateStatusBar() + if (core.hasFlag('poison')) { + core.status.hero.statistics.poisonDamage += core.values.poisonDamage; + core.status.hero.hp -= core.values.poisonDamage; + if (core.status.hero.hp <= 0) { + core.status.hero.hp = 0; + core.updateStatusBar(false, true); + core.events.lose(); + return; + } else { + core.updateStatusBar(false, true); + } + } - // 从v2.7开始,每一步行走不会再刷新状态栏。 - // 如果有特殊要求(如每走一步都加buff之类),可手动取消注释下面这一句: - // core.updateStatusBar(true, true); + // 从v2.7开始,每一步行走不会再刷新状态栏。 + // 如果有特殊要求(如每走一步都加buff之类),可手动取消注释下面这一句: + // core.updateStatusBar(true, true); + //flags._statuscol_ = flags._statuscol_ + 5 || 0 + //core.createSpr0(); + // 检查自动事件 + core.checkAutoEvents(); - // 检查自动事件 - core.checkAutoEvents(); + // ------ 检查目标点事件 ------ // + // 无事件的道具(如血瓶)需要优先于阻激夹域判定 + var nowx = core.getHeroLoc('x'), + nowy = core.getHeroLoc('y'); + var block = core.getBlock(nowx, nowy); + var hasTrigger = false; + if (block != null && block.event.trigger == 'getItem' && + !core.floors[core.status.floorId].afterGetItem[nowx + "," + nowy]) { + hasTrigger = true; + core.trigger(nowx, nowy, callback); + } + // 执行目标点的阻激夹域事件 + core.checkBlock(); - // ------ 检查目标点事件 ------ // - // 无事件的道具(如血瓶)需要优先于阻激夹域判定 - var nowx = core.getHeroLoc('x'), - nowy = core.getHeroLoc('y'); - var block = core.getBlock(nowx, nowy); - var hasTrigger = false; - if (block != null && block.event.trigger == 'getItem' && - !core.floors[core.status.floorId].afterGetItem[nowx + "," + nowy]) { - hasTrigger = true; - core.trigger(nowx, nowy, callback); - } - // 执行目标点的阻激夹域事件 - core.checkBlock(); + // 执行目标点的script和事件 + if (!hasTrigger) + core.trigger(nowx, nowy, callback); - // 执行目标点的script和事件 - if (!hasTrigger) - core.trigger(nowx, nowy, callback); + // 检查该点是否是滑冰 + if (core.onSki()) { + // 延迟到事件最后执行,因为这之前可能有阻激夹域动画 + core.insertAction({ "type": "moveAction" }, null, null, null, true); + } - // 检查该点是否是滑冰 - if (core.onSki()) { - // 延迟到事件最后执行,因为这之前可能有阻激夹域动画 - core.insertAction({ "type": "moveAction" }, null, null, null, true); - } + // ------ 检查目标点事件 END ------ // - // ------ 检查目标点事件 END ------ // - - // 如需强行终止行走可以在这里条件判定: - // core.stopAutomaticRoute(); - }, - "moveDirectly": function (x, y, ignoreSteps) { + // 如需强行终止行走可以在这里条件判定: + // core.stopAutomaticRoute(); +}, + "moveDirectly": function (x, y, ignoreSteps) { // 瞬间移动;x,y为要瞬间移动的点;ignoreSteps为减少的步数,可能之前已经被计算过 // 返回true代表成功瞬移,false代表没有成功瞬移 @@ -1562,26 +1566,32 @@ var functions_d6ad677b_427a_4623_b50f_a445a3b0ef8a = } return false; }, - "parallelDo": function (timestamp) { - // 并行事件处理,可以在这里写任何需要并行处理的脚本或事件 - // 该函数将被系统反复执行,每次执行间隔视浏览器或设备性能而定,一般约为16.6ms一次 - // 参数timestamp为“从游戏资源加载完毕到当前函数执行时”的时间差,以毫秒为单位 + "parallelDo": function (timestamp) { + // 并行事件处理,可以在这里写任何需要并行处理的脚本或事件 + // 该函数将被系统反复执行,每次执行间隔视浏览器或设备性能而定,一般约为16.6ms一次 + // 参数timestamp为“从游戏资源加载完毕到当前函数执行时”的时间差,以毫秒为单位 - // 检查当前是否处于游戏开始状态 - if (!core.isPlaying()) return; + // 检查当前是否处于游戏开始状态 + if (!core.isPlaying()) return; - // 执行当前楼层的并行事件处理 - if (core.status.floorId) { - try { - eval(core.floors[core.status.floorId].parallelDo); - } catch (e) { - console.error(e); - } - } + // 执行当前楼层的并行事件处理 + if (core.status.floorId) { + try { + eval(core.floors[core.status.floorId].parallelDo); + } catch (e) { + console.error(e); } - }, - "ui": { - "getToolboxItems": function (cls) { + } + if ((!main.replayChecking && core.status.played) && flags._coltrue_) { + flags._statuscol_ = flags._statuscol_ + 5 || 0 + core.createSpr0(); + core.createSprBack(); + } + +} + }, + "ui": { + "getToolboxItems": function (cls) { // 获得道具栏中当前某类型道具的显示项和显示顺序 // cls为道具类型,只可能是 tools, constants 和 equips // 返回一个数组,代表当前某类型道具的显示内容和顺序 @@ -1591,7 +1601,7 @@ var functions_d6ad677b_427a_4623_b50f_a445a3b0ef8a = .filter(function (id) { return !core.material.items[id].hideInToolbox; }) .sort( /*function (id1, id2) { return core.material.items[id1].name <= core.material.items[id2].name ? -1 : 1 }*/); }, - "drawStatusBar": function () { + "drawStatusBar": function () { // 这真的是人能写出来的东西? var ctx, fill = function (text, x, y, style) { core.ui.setFont(ctx, (/\w+/.test(text) ? 'italic ' : '') + 'bold 18px Verdana'); @@ -1662,7 +1672,7 @@ var functions_d6ad677b_427a_4623_b50f_a445a3b0ef8a = fill(core.setTwoDigits(core.itemCount('redKey')), 81 + offset, 267, '#FF8888'); } }, - "drawStatistics": function () { + "drawStatistics": function () { // 浏览地图时参与的统计项目 return [ @@ -1678,7 +1688,7 @@ var functions_d6ad677b_427a_4623_b50f_a445a3b0ef8a = // 在这里可以增加新的ID来进行统计个数,只能增加道具ID ]; }, - "drawAbout": function () { + "drawAbout": function () { // 绘制“关于”界面 core.ui.closePanel(); core.lockControl(); @@ -1706,5 +1716,5 @@ var functions_d6ad677b_427a_4623_b50f_a445a3b0ef8a = // TODO: 写自己的“关于”页面,每次增加32像素即可 core.playSound('打开界面'); } - } + } } \ No newline at end of file diff --git a/project/images/0.png b/project/images/0.png new file mode 100644 index 0000000..5922fba Binary files /dev/null and b/project/images/0.png differ diff --git a/project/images/1.png b/project/images/1.png new file mode 100644 index 0000000..a4d639d Binary files /dev/null and b/project/images/1.png differ diff --git a/project/images/2.png b/project/images/2.png new file mode 100644 index 0000000..4ec5546 Binary files /dev/null and b/project/images/2.png differ diff --git a/project/images/3.png b/project/images/3.png new file mode 100644 index 0000000..7b4a035 Binary files /dev/null and b/project/images/3.png differ diff --git a/project/images/4.png b/project/images/4.png new file mode 100644 index 0000000..0739e9d Binary files /dev/null and b/project/images/4.png differ diff --git a/project/images/5.png b/project/images/5.png new file mode 100644 index 0000000..eae236a Binary files /dev/null and b/project/images/5.png differ diff --git a/project/images/6.png b/project/images/6.png new file mode 100644 index 0000000..f8122d5 Binary files /dev/null and b/project/images/6.png differ diff --git a/project/images/7.png b/project/images/7.png new file mode 100644 index 0000000..c3f5020 Binary files /dev/null and b/project/images/7.png differ diff --git a/project/images/8.png b/project/images/8.png new file mode 100644 index 0000000..1003803 Binary files /dev/null and b/project/images/8.png differ diff --git a/project/images/9.png b/project/images/9.png new file mode 100644 index 0000000..5178c3e Binary files /dev/null and b/project/images/9.png differ diff --git a/project/images/Actor05-Strange05.png b/project/images/Actor05-Strange05.png new file mode 100644 index 0000000..731f64e Binary files /dev/null and b/project/images/Actor05-Strange05.png differ diff --git a/project/images/Star.png b/project/images/Star.png new file mode 100644 index 0000000..e0c0cf1 Binary files /dev/null and b/project/images/Star.png differ diff --git a/project/images/a.png b/project/images/a.png new file mode 100644 index 0000000..5ff65b4 Binary files /dev/null and b/project/images/a.png differ diff --git a/project/images/atk.png b/project/images/atk.png new file mode 100644 index 0000000..471b90d Binary files /dev/null and b/project/images/atk.png differ diff --git a/project/images/atk2.png b/project/images/atk2.png new file mode 100644 index 0000000..ad2f970 Binary files /dev/null and b/project/images/atk2.png differ diff --git a/project/images/b.png b/project/images/b.png new file mode 100644 index 0000000..9d59afb Binary files /dev/null and b/project/images/b.png differ diff --git a/project/images/backg.png b/project/images/backg.png new file mode 100644 index 0000000..ec36681 Binary files /dev/null and b/project/images/backg.png differ diff --git a/project/images/backl.png b/project/images/backl.png new file mode 100644 index 0000000..378fa67 Binary files /dev/null and b/project/images/backl.png differ diff --git a/project/images/backl2.png b/project/images/backl2.png new file mode 100644 index 0000000..c8a27f0 Binary files /dev/null and b/project/images/backl2.png differ diff --git a/project/images/backw.png b/project/images/backw.png new file mode 100644 index 0000000..bc62bee Binary files /dev/null and b/project/images/backw.png differ diff --git a/project/images/box1.png b/project/images/box1.png new file mode 100644 index 0000000..918b023 Binary files /dev/null and b/project/images/box1.png differ diff --git a/project/images/box1Light.png b/project/images/box1Light.png new file mode 100644 index 0000000..ed2b06f Binary files /dev/null and b/project/images/box1Light.png differ diff --git a/project/images/box2.png b/project/images/box2.png new file mode 100644 index 0000000..8f818e2 Binary files /dev/null and b/project/images/box2.png differ diff --git a/project/images/box2Light.png b/project/images/box2Light.png new file mode 100644 index 0000000..15cb904 Binary files /dev/null and b/project/images/box2Light.png differ diff --git a/project/images/boxLight.png b/project/images/boxLight.png new file mode 100644 index 0000000..61fbefc Binary files /dev/null and b/project/images/boxLight.png differ diff --git a/project/images/c.png b/project/images/c.png new file mode 100644 index 0000000..9acf61f Binary files /dev/null and b/project/images/c.png differ diff --git a/project/images/def.png b/project/images/def.png new file mode 100644 index 0000000..7d34f81 Binary files /dev/null and b/project/images/def.png differ diff --git a/project/images/def2.png b/project/images/def2.png new file mode 100644 index 0000000..9efb925 Binary files /dev/null and b/project/images/def2.png differ diff --git a/project/images/exp.png b/project/images/exp.png new file mode 100644 index 0000000..56d99c8 Binary files /dev/null and b/project/images/exp.png differ diff --git a/project/images/expL.png b/project/images/expL.png new file mode 100644 index 0000000..14f22ea Binary files /dev/null and b/project/images/expL.png differ diff --git a/project/images/expLt.png b/project/images/expLt.png new file mode 100644 index 0000000..3e826d4 Binary files /dev/null and b/project/images/expLt.png differ diff --git a/project/images/hp.png b/project/images/hp.png new file mode 100644 index 0000000..67eeea9 Binary files /dev/null and b/project/images/hp.png differ diff --git a/project/images/key.png b/project/images/key.png new file mode 100644 index 0000000..712b127 Binary files /dev/null and b/project/images/key.png differ diff --git a/project/images/lv.png b/project/images/lv.png new file mode 100644 index 0000000..cd6e7fa Binary files /dev/null and b/project/images/lv.png differ diff --git a/project/images/mana.png b/project/images/mana.png new file mode 100644 index 0000000..07ae7ac Binary files /dev/null and b/project/images/mana.png differ diff --git a/project/images/manaL.png b/project/images/manaL.png new file mode 100644 index 0000000..8fd6af9 Binary files /dev/null and b/project/images/manaL.png differ diff --git a/project/images/manaLt.png b/project/images/manaLt.png new file mode 100644 index 0000000..9cd2052 Binary files /dev/null and b/project/images/manaLt.png differ diff --git a/project/images/mdef.png b/project/images/mdef.png new file mode 100644 index 0000000..c30f273 Binary files /dev/null and b/project/images/mdef.png differ diff --git a/project/images/money.png b/project/images/money.png new file mode 100644 index 0000000..f73f6fd Binary files /dev/null and b/project/images/money.png differ diff --git a/project/images/winskin.png b/project/images/winskin.png index f314453..297920c 100644 Binary files a/project/images/winskin.png and b/project/images/winskin.png differ diff --git a/project/images/未标题-1.png b/project/images/未标题-1.png new file mode 100644 index 0000000..3516836 Binary files /dev/null and b/project/images/未标题-1.png differ diff --git a/project/items.js b/project/items.js index d7ba487..35b979a 100644 --- a/project/items.js +++ b/project/items.js @@ -186,7 +186,7 @@ var items_296f5d02_12fd_4166_a7c1_b5e830c9ee3a = "itemEffectTip": ",攻击+40" }, "sword4": { - "cls": "items", + "cls": "equips", "name": "圣剑", "text": "一把很普通的圣剑", "equip": { @@ -266,7 +266,7 @@ var items_296f5d02_12fd_4166_a7c1_b5e830c9ee3a = "itemEffectTip": ",防御+40" }, "shield4": { - "cls": "items", + "cls": "equips", "name": "圣盾", "text": "一个很普通的圣盾", "equip": { @@ -324,26 +324,46 @@ var items_296f5d02_12fd_4166_a7c1_b5e830c9ee3a = "text": "持有时打败怪物可得双倍金币" }, "freezeBadge": { - "cls": "constants", + "cls": "equips", "name": "冰冻徽章", "text": "可以将面前的熔岩变成平地", "useItemEffect": "(function () {\n\tvar success = false;\n\n\tvar snowFourDirections = false; // 是否多方向雪花;如果是将其改成true\n\tif (snowFourDirections) {\n\t\t// 多方向雪花\n\t\tfor (var direction in core.utils.scan) { // 多方向雪花默认四方向,如需改为八方向请将这两个scan改为scan2\n\t\t\tvar delta = core.utils.scan[direction];\n\t\t\tvar nx = core.getHeroLoc('x') + delta.x,\n\t\t\t\tny = core.getHeroLoc('y') + delta.y;\n\t\t\tif (core.getBlockId(nx, ny) == 'lava') {\n\t\t\t\tcore.removeBlock(nx, ny);\n\t\t\t\tsuccess = true;\n\t\t\t}\n\t\t}\n\t} else {\n\t\tif (core.getBlockId(core.nextX(), core.nextY()) == 'lava') {\n\t\t\tcore.removeBlock(core.nextX(), core.nextY());\n\t\t\tsuccess = true;\n\t\t}\n\t}\n\n\tif (success) {\n\t\tcore.playSound('打开界面');\n\t\tcore.drawTip(core.material.items[itemId].name + '使用成功', itemId);\n\t} else {\n\t\tcore.playSound('操作失败');\n\t\tcore.drawTip(\"当前无法使用\" + core.material.items[itemId].name, itemId);\n\t\tcore.addItem(itemId, 1);\n\t\treturn;\n\t}\n})();", - "canUseItemEffect": "true" + "canUseItemEffect": "true", + "equip": { + "type": "饰品", + "value": {}, + "percentage": {} + } }, "cross": { - "cls": "constants", + "cls": "equips", "name": "十字架", - "text": "持有后无视怪物的无敌属性" + "text": "持有后无视怪物的无敌属性", + "equip": { + "type": "饰品", + "value": {}, + "percentage": {} + } }, "dagger": { - "cls": "constants", + "cls": "equips", "name": "屠龙匕首", - "text": "该道具尚未被定义" + "text": "该道具尚未被定义", + "equip": { + "type": "饰品", + "value": {}, + "percentage": {} + } }, "amulet": { - "cls": "constants", + "cls": "equips", "name": "护符", - "text": "持有时无视负面地形" + "text": "持有时无视负面地形", + "equip": { + "type": "饰品", + "value": {}, + "percentage": {} + } }, "bigKey": { "cls": "tools", @@ -386,7 +406,7 @@ var items_296f5d02_12fd_4166_a7c1_b5e830c9ee3a = "canUseItemEffect": "true" }, "centerFly": { - "cls": "tools", + "cls": "constants", "name": "中心对称飞行器", "text": "可以飞向当前楼层中心对称的位置", "useItemEffect": "core.playSound('centerFly.mp3');\ncore.clearMap('hero');\ncore.setHeroLoc('x', core.bigmap.width - 1 - core.getHeroLoc('x'));\ncore.setHeroLoc('y', core.bigmap.height - 1 - core.getHeroLoc('y'));\ncore.drawHero();\ncore.drawTip(core.material.items[itemId].name + '使用成功');", @@ -505,11 +525,16 @@ var items_296f5d02_12fd_4166_a7c1_b5e830c9ee3a = "canUseItemEffect": "true" }, "jumpShoes": { - "cls": "tools", + "cls": "equips", "name": "跳跃靴", "text": "能跳跃到前方两格处", "useItemEffect": "core.playSound(\"跳跃\");\ncore.insertAction({ \"type\": \"jumpHero\", \"loc\": [core.nextX(2), core.nextY(2)] });", - "canUseItemEffect": "(function () {\n\tvar nx = core.nextX(2),\n\t\tny = core.nextY(2);\n\treturn nx >= 0 && nx < core.bigmap.width && ny >= 0 && ny < core.bigmap.height && core.getBlockId(nx, ny) == null;\n})();" + "canUseItemEffect": "(function () {\n\tvar nx = core.nextX(2),\n\t\tny = core.nextY(2);\n\treturn nx >= 0 && nx < core.bigmap.width && ny >= 0 && ny < core.bigmap.height && core.getBlockId(nx, ny) == null;\n})();", + "equip": { + "type": "饰品", + "value": {}, + "percentage": {} + } }, "skill1": { "cls": "constants", diff --git a/project/maps.js b/project/maps.js index fbf881c..9e39462 100644 --- a/project/maps.js +++ b/project/maps.js @@ -73,7 +73,7 @@ var maps_90f36752_8815_4be8_b32b_d7fad1d0542e = "83": {"cls":"animates","id":"redDoor","trigger":"openDoor","animate":1,"doorInfo":{"time":160,"openSound":"door.mp3","closeSound":"door.mp3","keys":{"redKey":1}},"name":"红门"}, "84": {"cls":"animates","id":"greenDoor","trigger":"openDoor","animate":1,"doorInfo":{"time":160,"openSound":"door.mp3","closeSound":"door.mp3","keys":{"greenKey":1}},"name":"绿门"}, "85": {"cls":"animates","id":"specialDoor","trigger":"openDoor","animate":1,"doorInfo":{"time":160,"openSound":"door.mp3","closeSound":"door.mp3","keys":{"specialKey":1}},"name":"机关门"}, - "86": {"cls":"animates","id":"steelDoor","trigger":"openDoor","animate":1,"doorInfo":{"time":160,"openSound":"door.mp3","closeSound":"door.mp3","keys":{"steelKey":1}},"name":"铁门"}, + "86": {"cls":"animates","id":"steelDoor","trigger":"openDoor","animate":1,"doorInfo":{"time":160,"openSound":"door.mp3","closeSound":"door.mp3","keys":{}},"name":"铁门"}, "87": {"cls":"terrains","id":"upFloor","canPass":true}, "88": {"cls":"terrains","id":"downFloor","canPass":true}, "89": {"cls":"animates","id":"portal","canPass":true}, diff --git a/project/materials/animates.png b/project/materials/animates.png index 89d8789..d1b8121 100644 Binary files a/project/materials/animates.png and b/project/materials/animates.png differ diff --git a/project/materials/icons.png b/project/materials/icons.png index 9e17e78..efb9f2e 100644 Binary files a/project/materials/icons.png and b/project/materials/icons.png differ diff --git a/project/materials/items.png b/project/materials/items.png index 04dc29b..60ff113 100644 Binary files a/project/materials/items.png and b/project/materials/items.png differ diff --git a/project/materials/terrains.png b/project/materials/terrains.png index 6d96b93..8fcebb4 100644 Binary files a/project/materials/terrains.png and b/project/materials/terrains.png differ diff --git a/project/plugins.js b/project/plugins.js index 93e3b92..9ef8cce 100644 --- a/project/plugins.js +++ b/project/plugins.js @@ -1,12 +1,11 @@ -/// -var plugins_bb40132b_638b_4a9f_b028_d3fe47acc8d1 = +var plugins_bb40132b_638b_4a9f_b028_d3fe47acc8d1 = { - "init": function () { + "init": function () { this._afterLoadResources = function () { // 本函数将在所有资源加载完毕后,游戏开启前被执行 } }, - "drawLight": function () { + "drawLight": function () { // 绘制灯光/漆黑层效果。调用方式 core.plugin.drawLight(...) // 【参数说明】 @@ -67,7 +66,7 @@ var plugins_bb40132b_638b_4a9f_b028_d3fe47acc8d1 = // 可以在任何地方(如afterXXX或自定义脚本事件)调用函数,方法为 core.plugin.xxx(); } }, - "shop": function () { + "shop": function () { // 【全局商店】相关的功能 // // 打开一个全局商店 @@ -262,7 +261,7 @@ var plugins_bb40132b_638b_4a9f_b028_d3fe47acc8d1 = return false; }, 60); }, - "removeMap": function () { + "removeMap": function () { // 高层塔砍层插件,删除后不会存入存档,不可浏览地图也不可飞到。 // 推荐用法: // 对于超高层或分区域塔,当在1区时将2区以后的地图删除;1区结束时恢复2区,进二区时删除1区地图,以此类推 @@ -349,7 +348,7 @@ var plugins_bb40132b_638b_4a9f_b028_d3fe47acc8d1 = }); } }, - "fiveLayers": function () { + "fiveLayers": function () { // 是否启用五图层(增加背景2层和前景2层) 将__enable置为true即会启用;启用后请保存后刷新编辑器 // 背景层2将会覆盖背景层 被事件层覆盖 前景层2将会覆盖前景层 // 另外 请注意加入两个新图层 会让大地图的性能降低一些 @@ -503,7 +502,7 @@ var plugins_bb40132b_638b_4a9f_b028_d3fe47acc8d1 = }; } }, - "itemShop": function () { + "itemShop": function () { // 道具商店相关的插件 // 可在全塔属性-全局商店中使用「道具商店」事件块进行编辑(如果找不到可以在入口方块中找) @@ -809,7 +808,7 @@ var plugins_bb40132b_638b_4a9f_b028_d3fe47acc8d1 = } }, - "enemyLevel": function () { + "enemyLevel": function () { // 此插件将提供怪物手册中的怪物境界显示 // 使用此插件需要先给每个怪物定义境界,方法如下: // 点击怪物的【配置表格】,找到“【怪物】相关的表格配置”,然后在【名称】仿照增加境界定义: @@ -895,7 +894,7 @@ var plugins_bb40132b_638b_4a9f_b028_d3fe47acc8d1 = core.fillText('ui', core.formatBigNumber(enemy.def || 0), col3 + 30, position, /* [255, 0, 0, 1] */ null, b13); } }, - "multiHeros": function () { + "multiHeros": function () { // 多角色插件 // Step 1: 启用本插件 // Step 2: 定义每个新的角色各项初始数据(参见下方注释) @@ -1041,7 +1040,7 @@ var plugins_bb40132b_638b_4a9f_b028_d3fe47acc8d1 = core.setFlag("heroId", toHeroId); // 保存切换到的角色ID } }, - "heroFourFrames": function () { + "heroFourFrames": function () { // 样板的勇士/跟随者移动时只使用2、4两帧,观感较差。本插件可以将四帧全用上。 // 是否启用本插件 @@ -1094,7 +1093,7 @@ var plugins_bb40132b_638b_4a9f_b028_d3fe47acc8d1 = return false; } }, - "routeFixing": function () { + "routeFixing": function () { // 是否开启本插件,true 表示启用,false 表示禁用。 var __enable = true; if (!__enable) return; @@ -1185,7 +1184,7 @@ var plugins_bb40132b_638b_4a9f_b028_d3fe47acc8d1 = } }, 100); }, - "numpad": function () { + "numpad": function () { // 样板自带的整数输入事件为白屏弹窗且可以误输入任意非法内容但不支持负整数,观感较差。本插件可以将其美化成仿RM样式,使其支持负整数同时带有音效 // 另一方面,4399等第三方平台不允许使用包括 core.myprompt() 和 core.myconfirm() 在内的弹窗,因此也需要此插件来替代,不然类似生命魔杖的道具就不好实现了 // 关于负整数输入,V2.8.2原生支持其录像的压缩和解压,只是默认的 core.events._action_input() 函数将负数取了绝对值,可以只复写下面的 core.isReplaying() 部分来取消 @@ -1360,460 +1359,905 @@ var plugins_bb40132b_638b_4a9f_b028_d3fe47acc8d1 = } } }, - "sprites": function () { - // 基于canvas的sprite化,摘编整理自万宁魔塔 - // - // ---------------------------------------- 第一部分 js代码 (必装) --------------------------------------- // + "sprites": function () { + // 在此增加新插件 + // 基于canvas的sprite化,摘编整理自万宁魔塔 + // + // ----------------------------------- 第一部分 必装 js代码 ----------------------------------- // + // + // 关于新增的on方法说明: + // 该方法类似与样板的registerAction,它允许你能够使用与样板类似的api对sprite进行操作 + // on(type, handler) + // 其中type为操作类型,常见的有click mousedown mouseup mousemove mouseenter mouseleave wheel keydown keyup touchstart touchend touchmove + // 这些操作类型分为四类,第一类是鼠标事件,上述的操作中wheel之前的事件均为鼠标事件,它的监听形式为 + // sprite.on(type, (px, py) => { code }); 其中px, py为参数,为点击的横纵坐标(相对sprite左上角) + // 第二类是滚轮事件,只有一个事件wheel,它的监听形式为 + // sprite.on('wheel', (dy, dx, dz) => { code }); dy为滚轮的纵向滑动量,dx为滚轮的横向滑动量,dz为滚轮在垂直屏幕方向上的滑动量(?很奇怪,但是html确实提供了这个东西 + // 第三类是键盘事件,keydown和keyup都是键盘事件,它的监听形式为 + // sprite.on(type, (key, keyCode, altKey, ctrlKey, shiftKey) => { code }); + // 其中key为按键名称,可以通过console.log自行尝试,需要注意的是这个东西是区分大小写的,keyCode是与样板相同的keycode,可自行在网上查询 + // 后面三个都是布尔值(true or false)分别为alt键、ctrl键、shift键是否被按下 + // 第四类是触摸屏操作(注意click可能不会被触屏触发),包括touchstart touchend touchmove,有两种使用方法 + // 第一种:sprite.on(type, ([px, py]) => { code }); px py是点击的坐标,相对于sprite左上角 + // 第二种:sprite.on(type, (...locs) => { code }); locs是由[px, py]组成的数组,比如locs[0][0]就是第一个点击点的横坐标,locs[2][1]就是第三个点击点的纵坐标 - /* ---------------- 用法说明 ---------------- * - * 1. 创建sprite: var sprite = new Sprite(x, y, w, h, z, reference, name); - * 其中x y w h为画布的横纵坐标及长宽,reference为参考系,只能填game(相对于游戏画面)和window(相对于窗口) - * 且当为相对游戏画面时,长宽与坐标将会乘以放缩比例(相当于用createCanvas创建) - * z为纵深,表示不同元素之间的覆盖关系,大的覆盖小的 - * name为自定义名称,可以不填 - * 2. 删除: sprite.destroy(); - * 3. 设置css特效: sprite.setCss(css); - * 其中css直接填 box-shadow: 0px 0px 10px black;的形式即可,与style标签与css文件内写法相同 - * 对于已设置的特效,如果之后不需要再次设置,可以不填 - * 4. 添加事件监听器: sprite.addEventListener(); 用法与html元素的addEventListener完全一致 - * 5. 移除事件监听器: sprite.removeEventListener(); 用法与html元素的removeEventListener完全一致 - * 6. 属性列表 - * (1) sprite.x | sprite.y | sprite.width | sprite.height | sprite.zIndex | sprite.reference 顾名思义 - * (2) sprite.canvas 该sprite的画布 - * (3) sprite.context 该画布的CanvasRenderingContext2d对象,即样板中常见的ctx - * (4) sprite.count 不要改这个玩意 - * 7. 使用样板api进行绘制 - * 示例: - * var ctx = sprite.context; - * core.fillText(ctx, 'xxx', 100, 100); - * core.fillRect(ctx, 0, 0, 50, 50); - * 当然也可以使用原生js - * ctx.moveTo(0, 0); - * ctx.bezierCurveTo(50, 50, 100, 0, 100, 50); - * ctx.stroke(); - * ---------------- 用法说明 ---------------- */ + /* ---------------- 用法说明 ---------------- * + * 1. 创建sprite: const sprite = new Sprite(x, y, w, h, z, reference, name); + * 其中x y w h为画布的横纵坐标及长宽,reference为参考系,只能填game(相对于游戏画面)和window(相对于窗口) + * 且当为相对游戏画面时,长宽与坐标将会乘以放缩比例(相当于用createCanvas创建) + * z为纵深,表示不同元素之间的覆盖关系,大的覆盖小的 + * name为自定义名称,可以不填 + * 2. 删除: sprite.destroy(); + * 3. 设置css特效: sprite.setCss(css); + * 其中css直接填 box-shadow: 0px 0px 10px black;的形式即可,与style标签与css文件内写法相同 + * 对于已设置的特效,如果之后不需要再次设置,可以不填 + * 4. 添加事件监听器: sprite.addEventListener(); 用法与html元素的addEventListener完全一致 + * 5. 移除事件监听器: sprite.removeEventListener(); 用法与html元素的removeEventListener完全一致 + * 6. 属性列表 + * (1) sprite.x | sprite.y | sprite.width | sprite.height | sprite.zIndex | sprite.reference 顾名思义 + * (2) sprite.canvas 该sprite的画布 + * (3) sprite.context 该画布的CanvasRenderingContext2d对象,即样板中常见的ctx + * (4) sprite.count 不要改这个玩意 + * 7. 使用样板api进行绘制 + * 示例: + * var ctx = sprite.context; + * core.fillText(ctx, 'xxx', 100, 100); + * core.fillRect(ctx, 0, 0, 50, 50); + * 当然也可以使用原生js + * ctx.moveTo(0, 0); + * ctx.bezierCurveTo(50, 50, 100, 0, 100, 50); + * ctx.stroke(); + * ---------------- 用法说明 ---------------- */ - var count = 0; + const sprites = {}; - /** 创建一个sprite画布 - * @param {number} x - * @param {number} y - * @param {number} w - * @param {number} h - * @param {number} z - * @param {'game' | 'window'} reference 参考系,游戏画面或者窗口 - * @param {string} name 可选,sprite的名称,方便通过core.dymCanvas获取 - */ - function Sprite (x, y, w, h, z, reference, name) { + // 终于能用es6了(恼 + class Sprite { + constructor(x, y, w, h, z, reference, name) { this.x = x; this.y = y; this.width = w; this.height = h; this.zIndex = z; this.reference = reference; + /** @type {HTMLCanvasElement} */ this.canvas = null; + /** @type {CanvasRenderingContext2D} */ this.context = null; this.count = 0; - this.name = name || '_sprite_' + count; - this.style = null; - /** 初始化 */ - this.init = function () { - if (reference === 'window') { - var canvas = document.createElement('canvas'); - this.canvas = canvas; - this.context = canvas.getContext('2d'); - canvas.width = w; - canvas.height = h; - canvas.style.width = w + 'px'; - canvas.style.height = h + 'px'; - canvas.style.position = 'absolute'; - canvas.style.top = y + 'px'; - canvas.style.left = x + 'px'; - canvas.style.zIndex = z.toString(); - document.body.appendChild(canvas); - this.style = canvas.style; - } else { - this.context = core.createCanvas(this.name || '_sprite_' + count, x, y, w, h, z); - this.canvas = this.context.canvas; - this.canvas.style.pointerEvents = 'auto'; - this.style = this.canvas.style; - } - this.count = count; - count++; - } + this.name = name; + this.key = []; this.init(); - - /** 设置css特效 - * @param {string} css - */ - this.setCss = function (css) { - css = css.replace('\n', ';').replace(';;', ';'); - var effects = css.split(';'); - var self = this; - effects.forEach(function (v) { - var content = v.split(':'); - var name = content[0]; - var value = content[1]; - name = name.trim().split('-').reduce(function (pre, curr, i, a) { - if (i === 0 && curr !== '') return curr; - if (a[0] === '' && i === 1) return curr; - return pre + curr.toUpperCase()[0] + curr.slice(1); - }, ''); - var canvas = self.canvas; - if (name in canvas.style) canvas.style[name] = value; - }); - return this; - } - - /** - * 移动sprite - * @param {boolean} isDelta 是否是相对位置,如果是,那么sprite会相对于原先的位置进行移动 - */ - this.move = function (x, y, isDelta) { - if (x !== undefined && x !== null) this.x = x; - if (y !== undefined && y !== null) this.y = y; - if (this.reference === 'window') { - var ele = this.canvas; - ele.style.left = x + (isDelta ? parseFloat(ele.style.left) : 0) + 'px'; - ele.style.top = y + (isDelta ? parseFloat(ele.style.top) : 0) + 'px'; - } else core.relocateCanvas(this.context, x, y, isDelta); - return this; - } - - /** - * 重新设置sprite的大小 - * @param {boolean} styleOnly 是否只修改css效果,如果是,那么将会不高清,如果不是,那么会清空画布 - */ - this.resize = function (w, h, styleOnly) { - if (w !== undefined && w !== null) this.w = w; - if (h !== undefined && h !== null) this.h = h; - if (reference === 'window') { - var ele = this.canvas; - ele.style.width = w + 'px'; - ele.style.height = h + 'px'; - if (!styleOnly) { - ele.width = w; - ele.height = h; - } - } else core.resizeCanvas(this.context, w, h, styleOnly); - return this; - } - - /** - * 旋转画布 - */ - this.rotate = function (angle, cx, cy) { - if (this.reference === 'window') { - var left = this.x; - var top = this.y; - this.canvas.style.transformOrigin = (cx - left) + 'px ' + (cy - top) + 'px'; - if (angle === 0) { - canvas.style.transform = ''; - } else { - canvas.style.transform = 'rotate(' + angle + 'deg)'; - } - } else { - core.rotateCanvas(this.context, angle, cx, cy); - } - return this; - } - - /** - * 清除sprite - */ - this.clear = function (x, y, w, h) { - if (this.reference === 'window') { - this.context.clearRect(x, y, w, h); - } else { - core.clearMap(this.context, x, y, w, h); - } - return this; - } - - /** 删除 */ - this.destroy = function () { - if (this.reference === 'window') { - if (this.canvas) document.body.removeChild(this.canvas); - } else { - core.deleteCanvas(this.name || '_sprite_' + this.count); - } - } - - /** 添加事件监听器 */ - this.addEventListener = function () { - this.canvas.addEventListener.apply(this.canvas, arguments); - } - - /** 移除事件监听器 */ - this.removeEventListener = function () { - this.canvas.removeEventListener.apply(this.canvas, arguments); - } } - window.Sprite = Sprite; - }, - "hotReload": function () { - /* ---------- 功能说明 ---------- * - - 1. 当 libs/ main.js index.html 中的任意一个文件被更改后,会自动刷新塔的页面 - 2. 修改楼层文件后自动在塔的页面上显示出来,不需要刷新 - 3. 修改脚本编辑或插件编写后也能自动更新更改的插件或脚本,但不保证不会出问题(一般都不会有问题的 - 4. 修改图块属性、怪物属性等后会自动更新 - 5. 当全塔属性被修改时,会自动刷新塔的页面 - 6. 样板的 styles.css 被修改后也可以直接显示,不需要刷新 - 7. 其余内容修改后不会自动更新也不会刷新 - - /* ---------- 使用方式 ---------- * - - 1. 前往 https://nodejs.org/en/ 下载node.js的LTS版本(点左边那个绿色按钮)并安装 - 2. 将该插件复制到插件编写中 - 3. 在造塔群的群文件-魔塔样板·改中找到server.js,下载并放到塔的根目录(与启动服务同一级) - 4. 在该目录下按下shift+鼠标右键(win11只按右键即可),选择在终端打开或在powershell打开 - 5. 运行node server.js即可 - - */ - - if (main.mode !== 'play' || main.replayChecking) return; - - /** - * 发送请求 - * @param {string} url - * @param {string} type - * @param {string} data - * @returns {Promise} - */ - async function post(url, type, data) { - const xhr = new XMLHttpRequest(); - xhr.open(type, url); - xhr.send(data); - const res = await new Promise(res => { - xhr.onload = e => { - if (xhr.status !== 200) { - console.error(`hot reload: http ${xhr.status}`); - res('@error'); - } else res('success'); - }; - xhr.onerror = e => { - res('@error'); - console.error(`hot reload: error on connection`); - }; - }); - if (res === 'success') return xhr.response; - else return '@error'; - } - - /** - * 热重载css - * @param {string} data - */ - function reloadCss(data) { - const all = Array.from(document.getElementsByTagName('link')); - all.forEach(v => { - if (v.rel !== 'stylesheet') return; - if (v.href === `http://127.0.0.1:3000/${data}`) { - v.remove(); - const link = document.createElement('link'); - link.rel = 'stylesheet'; - link.type = 'text/css'; - link.href = data; - document.head.appendChild(link); - console.log(`css hot reload: ${data}`); - } - }); - } - - /** - * 热重载楼层 - * @param {string} data - */ - async function reloadFloor(data) { - // 首先重新加载main.floors对应的楼层 - await import(`/project/floors/${data}.js?v=${Date.now()}`); - // 然后写入core.floors并解析 - core.floors[data] = main.floors[data]; - const floor = core.loadFloor(data); - if (core.isPlaying()) { - core.status.maps[data] = floor; - delete core.status.mapBlockObjs[data]; - core.extractBlocks(data); - if (data === core.status.floorId) { - core.drawMap(data); - core.setWeather( - core.animateFrame.weather.type, - core.animateFrame.weather.level - ); - } - core.updateStatusBar(true, true); - } - console.log(`floor hot reload: ${data}`); - } - - /** - * 热重载脚本编辑及插件编写 - * @param {string} data - */ - async function reloadScript(data) { - if (data === 'plugins') { - // 插件编写比较好办 - const before = plugins_bb40132b_638b_4a9f_b028_d3fe47acc8d1; - // 这里不能用动态导入,因为动态导入会变成模块,变量就不是全局的了 - const script = document.createElement('script'); - script.src = `/project/plugins.js?v=${Date.now()}`; - document.body.appendChild(script); - await new Promise(res => { - script.onload = () => res('success'); - }); - const after = plugins_bb40132b_638b_4a9f_b028_d3fe47acc8d1; - // 找到差异的函数 - for (const id in before) { - const fn = before[id]; - if (typeof fn !== 'function') continue; - if (fn.toString() !== after[id]?.toString()) { - try { - core.plugin[id] = after[id]; - core.plugin[id].call(core.plugin); - core.updateStatusBar(true, true); - console.log(`plugin hot reload: ${id}`); - } catch (e) { - console.error(e); - } - } - } - } else if (data === 'functions') { - // 脚本编辑略微麻烦点 - const before = functions_d6ad677b_427a_4623_b50f_a445a3b0ef8a; - // 这里不能用动态导入,因为动态导入会变成模块,变量就不是全局的了 - const script = document.createElement('script'); - script.src = `/project/functions.js?v=${Date.now()}`; - document.body.appendChild(script); - await new Promise(res => { - script.onload = () => res('success'); - }); - const after = functions_d6ad677b_427a_4623_b50f_a445a3b0ef8a; - // 找到差异的函数 - for (const mod in before) { - const fns = before[mod]; - for (const id in fns) { - const fn = fns[id]; - if (typeof fn !== 'function' || id === 'hasSpecial') - continue; - const now = after[mod][id]; - if (fn.toString() !== now.toString()) { - try { - if (mod === 'events') { - core.events.eventdata[id] = now; - } else if (mod === 'enemys') { - core.enemys.enemydata[id] = now; - } else if (mod === 'actions') { - core.actions.actionsdata[id] = now; - } else if (mod === 'control') { - core.control.controldata[id] = now; - } else if (mod === 'ui') { - core.ui.uidata[id] = now; - } - core.updateStatusBar(true, true); - console.log( - `function hot reload: ${mod}.${id}` - ); - } catch (e) { - console.error(e); - } - } - } - } - } - } - - /** - * 属性热重载,包括全塔属性等 - * @param {string} data - */ - async function reloadData(data) { - const script = document.createElement('script'); - script.src = `/project/${data}.js?v=${Date.now()}`; - document.body.appendChild(script); - await new Promise(res => { - script.onload = () => res('success'); - }); - - let after; - if (data === 'data') - after = data_a1e2fb4a_e986_4524_b0da_9b7ba7c0874d; - if (data === 'enemys') - after = enemys_fcae963b_31c9_42b4_b48c_bb48d09f3f80; - if (data === 'icons') - after = icons_4665ee12_3a1f_44a4_bea3_0fccba634dc1; - if (data === 'items') - after = items_296f5d02_12fd_4166_a7c1_b5e830c9ee3a; - if (data === 'maps') - after = maps_90f36752_8815_4be8_b32b_d7fad1d0542e; - if (data === 'events') - after = events_c12a15a8_c380_4b28_8144_256cba95f760; - - if (data === 'enemys') { - core.enemys.enemys = after; - for (var enemyId in after) { - core.enemys.enemys[enemyId].id = enemyId; - } - core.material.enemys = core.getEnemys(); - } else if (data === 'icons') { - core.icons.icons = after; - core.material.icons = core.getIcons(); - } else if (data === 'items') { - core.items.items = after; - for (var itemId in after) { - core.items.items[itemId].id = itemId; - } - core.material.items = core.getItems(); - } else if (data === 'maps') { - core.maps.blocksInfo = after; - core.status.mapBlockObjs = {}; - core.status.number2block = {}; - Object.values(core.status.maps).forEach(v => delete v.blocks); - core.extractBlocks(); - core.setWeather( - core.animateFrame.weather.type, - core.animateFrame.weather.level - ); - core.drawMap(); - } else if (data === 'events') { - core.events.commonEvent = after.commonEvent; - } else if (data === 'data') { - location.reload(); - } - core.updateStatusBar(true, true); - console.log(`data hot reload: ${data}`); - } - - // 初始化 - (async function () { - const data = await post('/reload', 'POST', 'test'); - if (data === '@error') { - console.log(`未检测到node服务,热重载插件将无法使用`); + init() { + const name = this.name || `_sprite_${Sprite.count}`; + this.name = name; + if (this.reference === 'window') { + const canvas = document.createElement('canvas'); + this.canvas = canvas; + this.context = canvas.getContext('2d'); + canvas.width = this.width; + canvas.height = this.height; + canvas.style.width = this.width + 'px'; + canvas.style.height = this.height + 'px'; + canvas.style.position = 'absolute'; + canvas.style.top = this.y + 'px'; + canvas.style.left = this.x + 'px'; + canvas.style.zIndex = this.zIndex.toString(); + document.body.appendChild(canvas); } else { - console.log(`热重载插件加载成功`); - // reload - setInterval(async () => { - const res = await post('/reload', 'POST'); - if (res === '@error') return; - if (res === 'true') location.reload(); - else return; - }, 1000); - - // hot reload - setInterval(async () => { - const res = await post('/hotReload', 'POST'); - const data = res.split('@@'); - data.forEach(v => { - if (v === '') return; - const [type, file] = v.split(':'); - if (type === 'css') reloadCss(file); - if (type === 'data') reloadData(file); - if (type === 'floor') reloadFloor(file); - if (type === 'script') reloadScript(file); - }); - }, 1000); + this.context = core.createCanvas(name, this.x, this.y, this.width, this.height, this.zIndex); + this.canvas = this.context.canvas; + this.count = Sprite.count; + this.canvas.style.pointerEvents = 'auto'; } - })(); + Sprite.count++; + sprites[this.name] = this; + } + + setCss(css) { + css = css.replace('\n', ';').replace(';;', ';'); + const effects = css.split(';'); + const canvas = this.canvas; + effects.forEach(v => { + const content = v.split(':'); + let name = content[0]; + let value = content[1]; + name = name.trim().split('-').reduce((pre, curr, i, a) => { + if (i === 0 && curr !== '') + return curr; + if (a[0] === '' && i === 1) + return curr; + return pre + curr.toUpperCase()[0] + curr.slice(1); + }, ''); + if (name in canvas.style) + canvas.style[name] = value; + }); + return this; + } + + move(x, y, isDelta) { + if (x !== undefined && x !== null) + this.x = x; + if (y !== undefined && y !== null) + this.y = y; + if (this.reference === 'window') { + var ele = this.canvas; + ele.style.left = x + (isDelta ? parseFloat(ele.style.left) : 0) + 'px'; + ele.style.top = y + (isDelta ? parseFloat(ele.style.top) : 0) + 'px'; + } else + core.relocateCanvas(this.context, x, y, isDelta); + return this; + } + + resize(w, h, styleOnly) { + if (w !== undefined && w !== null) + this.width = w; + if (h !== undefined && h !== null) + this.height = h; + if (this.reference === 'window') { + const ele = this.canvas; + ele.style.width = w + 'px'; + ele.style.height = h + 'px'; + if (!styleOnly) { + ele.width = w; + ele.height = h; + } + } else + core.resizeCanvas(this.context, w, h, styleOnly); + return this; + } + + rotate(angle, cx, cy) { + if (this.reference === 'window') { + const left = this.x; + const top = this.y; + this.canvas.style.transformOrigin = (cx - left) + 'px ' + (cy - top) + 'px'; + if (angle === 0) { + canvas.style.transform = ''; + } else { + canvas.style.transform = 'rotate(' + angle + 'deg)'; + } + } else { + core.rotateCanvas(this.context, angle, cx, cy); + } + return this; + } + + destroy() { + if (this.reference === 'window') { + if (this.canvas) + document.body.removeChild(this.canvas); + } else { + core.deleteCanvas(this.name); + } + this.key.forEach(v => document.removeEventListener(v[0], v[1])); + sprites[this.name] = void 0; + } + + /** + * 类似样板registerAction接口,但是是以该sprite的左上角为(0,0)计算的 + * @param {keyof HTMLElementEventMap} type + * @param {(...param: any[]) => void} handler + */ + on(type, handler) { + if (this.reference !== 'game') throw new ReferenceError(`当sprite的reference为window时,不可使用该函数`); + const mouse = [ + 'auxclick', 'click', 'contextmenu', 'dblclick', 'mousedown', 'mouseup', + 'mouseenter', 'mouseleave', 'mousemove', 'mouseout', 'mouseover' + ]; + const key = [ + 'keydown', 'keypress', 'keyup' + ]; + const touch = [ + 'touchstart', 'touchend', 'touchcancel', 'touchmove' + ] + if (mouse.includes(type)) { + this.addEventListener(type, e => { + const px = e.offsetX / core.domStyle.scale, + py = e.offsetY / core.domStyle.scale; + handler(px, py); + }) + } else if (type === 'wheel') { + this.addEventListener('wheel', e => { + handler(e.deltaY, e.deltaX, e.deltaZ); + }); + } else if (key.includes(type)) { + // 键盘事件只能加到document上 + const listener = e => { + handler(e.key, e.keyCode, e.altKey, e.ctrlKey, e.shiftKey); + } + this.key.push([type, listener]); + document.addEventListener(type, listener) + } else if (touch.includes(type)) { + this.addEventListener(type, e => { + /** @type {TouchList} */ + const touches = e.touches; + const locs = []; + for (let i = 0; i < touches.length; i++) { + const t = touches[i]; + const { x, y } = core.actions._getClickLoc(t.clientX, t.clientY); + const px = x / core.domStyle.scale, + py = y / core.domStyle.scale; + locs.push([px, py]); + } + handler(...locs); + }) + } + } + + addEventListener() { + this.canvas.addEventListener.apply(this.canvas, arguments); + } + + removeEventListener() { + this.canvas.removeEventListener.apply(this.canvas, arguments); + } } + + this.getSprite = function (name) { + const s = sprites[name]; + //if (!s) throw new ReferenceError(`不能获得不存在的sprite`); + return sprites[name]; + } + + Sprite.count = 0; + + window.Sprite = Sprite; +}, + "hotReload": function () { + + +}, + "状态栏": function () { + // 在此增加新插件 + // + + core.mystatusNumber = function (ctx, name, num, x, y, col2) { + var m = ''; + if (hero[name] < 0) + m = 'invert(100%)'; + core.setFilter(ctx, 'hue-rotate(' + (col2 || 0) + 'deg)' + m) + + + + if (!num && name != 'key1' && name != 'key2') { + num = hero[name] + num = num.toString() + if (name === 'atk2') { + num = Math.max(0, (hero[name] * 0.01 + 1)).toFixed(2); + } + if (name === 'def2') { + var k = 3; + num = ((1 - 100 / (100 + k * Math.abs(hero[name]))) * 100).toFixed(2) + '%' + if (hero[name] < 0) + num = '-'.concat(num) + } + for (var i in num) { + core.drawIcon(ctx, 'X' + (10288), x + 5 + 10 * Number(i), y, 16, 16) + if (num[i] === '.') + core.drawIcon(ctx, 'X' + (10300), x + 5 + 10 * Number(i), y, 16, 16) + else if (num[i] === '%') + core.drawIcon(ctx, 'X' + (10301), x + 5 + 10 * Number(i), y, 16, 16) + else if (num[i] === '-') + core.drawIcon(ctx, 'X' + (10302), x + 5 + 10 * Number(i), y, 16, 16) + else + core.drawIcon(ctx, 'X' + (10289 + Number(num[i])), x + 5 + 10 * Number(i), y, 16, 16) + } + } + if (name === 'key1' || name === 'key2') { + var num = [hero.items.tools.yellowKey || 0, hero.items.tools.blueKey || 0]; + var keyCol = [170, 0] + if (name === 'key2') { + num = [hero.items.tools.redKey || 0, hero.items.tools.greenKey || 0]; + keyCol = [140, 250] + } + for (var k in num) { + var numk = num[k] + numk = numk.toString() + core.setFilter(ctx, 'hue-rotate(' + keyCol[k] + 'deg)') + for (var i in numk) { + core.drawIcon(ctx, 'X' + (10288), x + 5 + 10 * Number(i) + 30 * Number(k), y, 16, 16) + core.drawIcon(ctx, 'X' + (10289 + Number(numk[i])), x + 5 + 10 * Number(i) + 30 * Number(k), y, 16, 16) + } + } + core.setFilter(ctx, '') + name = 'key' + } + } + + core.mystatusbox = function (ctx, name, num, x, y, col2) { + + var m = ''; + if (hero[name] < 0) + m = 'invert(100%)'; + core.setFilter(ctx, 'hue-rotate(' + (col2 || 0) + 'deg)' + m) + + core.drawImage(ctx, 'b.png', 0, 0, 32, 32, x - 40, y - 10, 32, 32) + core.drawImage(ctx, name + '.png', 0, 0, 32, 32, x - 40, y - 10, 32, 32) + core.drawImage(ctx, 'c.png', 0, 0, 32, 32, x - 40, y - 10, 32, 32) + core.drawIcon(ctx, 'X' + (10299), x - 40 + 32, y - 10, 32, 32) + + //core.setFilter(ctx, 'hue-rotate(' + (col2 || 0) + 'deg)brightness(1.5)' + m) + + } + + core.createSprBack = function (des) { + if (main.replayChecking || !core.status.played) + return; + var left = parseInt(core.dom.gameGroup.style.left); + var top_up = parseInt(core.dom.gameGroup.style.top); + var width = 1300 //748 + 100; + var height = 1200 // 560; + + if (core.getSprite('SprBack') && des) { + core.getSprite('SprBack').destroy(); + const sprite = new Sprite(left - 280, top_up - 350, 1300, 1200, 1, 'window', 'SprBack'); + //const sprite = new Sprite(core.domStyle.isVertical ? 0 : Math.floor(left - (16 - 129 + 172 - 0) * core.domStyle.scale), Math.floor(top_up - (64 + 0) * core.domStyle.scale), width, height, 9, 'window', 'SprBack'); + } else if (core.getSprite('SprBack')) { + core.clearMap(core.getSprite('SprBack').context); + + } else { + const sprite = new Sprite(left - 280, top_up - 350, 1300, 1200, 1, 'window', 'SprBack'); + //const sprite = new Sprite(core.domStyle.isVertical ? 0 : Math.floor(left - (16 - 129 + 172 - 0) * core.domStyle.scale), Math.floor(top_up - (64 + 0) * core.domStyle.scale), width, height, 9, 'window', 'SprBack'); + } + + var ctx = core.getSprite('SprBack').context; + + core.clearMap(ctx); + //core.fillRect(ctx, 0, 0, width, height, '#000000'); + + var col = flags._statuscol_; + var brg = flags._statusbrg_; + var gry = flags._statusgry_; + + core.setFilter(ctx, 'hue-rotate(' + (col || 0) + 'deg)brightness(' + (brg || 1) + ')grayscale(' + (gry || 0) + '%)') + var alp = flags._backalp_ || 0.5; + core.setAlpha(ctx, alp) + if (!flags.starOff) + core.drawImage(ctx, 'Star.png', 0, 0, 1300, 1200); + + core.setFilter(ctx, '') + // core.getSprite('SprBack').canvas.style.width = core.getSprite('SprBack').canvas.width * core.domStyle.scale + 'px'; + // core.getSprite('SprBack').canvas.style.height = core.getSprite('SprBack').canvas.height * core.domStyle.scale + 'px'; + + } + + core.createSpr0 = function (des) { + if (main.replayChecking || !core.status.played) + return; + var left = parseInt(core.dom.gameGroup.style.left); + var top_up = parseInt(core.dom.gameGroup.style.top); + var width = 748 + 100; + var height = 560; + if (core.domStyle.isVertical) { + top_up += core.domStyle.scale * (102 - 16); + } else { + top_up -= 16 * core.domStyle.scale; + } + if (core.getSprite('Spr0') && des) { + core.getSprite('Spr0').destroy(); + const sprite = new Sprite(core.domStyle.isVertical ? 0 : Math.floor(left - (16 - 129 + 172 - 0) * core.domStyle.scale), Math.floor(top_up - (64 + 0) * core.domStyle.scale), width, height, 10, 'window', 'Spr0'); + } else if (core.getSprite('Spr0')) { + core.clearMap(core.getSprite('Spr0').context); + + } else { const sprite = new Sprite(core.domStyle.isVertical ? 0 : Math.floor(left - (16 - 129 + 172 - 0) * core.domStyle.scale), Math.floor(top_up - (64 + 0) * core.domStyle.scale), width, height, 10, 'window', 'Spr0'); } + + var ctx = core.getSprite('Spr0').context; + + core.clearMap(ctx); + //core.fillRect(ctx, 0, 0, width, height, '#000000'); + var col = flags._statuscol_; + var brg = flags._statusbrg_; + var gry = flags._statusgry_; + + var fil = 'hue-rotate(' + (col || 0) + 'deg)brightness(' + (brg || 1) + ')grayscale(' + (gry || 0) + '%)' + + core.setFilter(ctx, fil) + + + //core.drawImage(ctx, 'backg.png', 0, 0, 448, 448, 0, 64, 448, 448); + //core.drawImage(ctx, 'backw.png', 0, 0, 448, 448, 0, 64, 448, 448); + core.drawImage(ctx, 'backg.png', 0, 0, 448, 448, 20, 64, 448, 448); + core.drawImage(ctx, 'backw.png', 0, 0, 448, 448, 20, 64, 448, 448); + core.drawImage(ctx, 'backl2.png', 0, 0, 149, 20, 20 + 16, 64 + 16 + 85, 149, 20); + core.drawImage(ctx, 'backl2.png', 0, 0, 149, 20, 20 + 16, 64 + 16 + 90 + 200, 149, 20); + core.drawImage(ctx, 'backl.png', 0, 0, 149, 416, 20 + 16, 64 + 16, 149, 416); + + + core.drawImage(ctx, 'backg.png', 0, 0, 448, 448, 172 + 152, 64, 448, 448); + core.drawImage(ctx, 'backw.png', 0, 0, 448, 448, 172 + 152, 64, 448, 448); + core.drawImage(ctx, 'backl2.png', 0, 0, 149, 20, 172 + 416 + 3 + 16, 64 + 16 + 90 + 200, 149, 20); + core.drawImage(ctx, 'backl.png', 0, 0, 149, 416, 172 + 416 + 3 + 16, 64 + 16, 149, 416); + + core.drawImage(ctx, 'backg.png', 0, 0, 448, 448, 172, 64, 448, 448); + + + + //按钮 + core.drawImage(ctx, 'box1.png', 0, 0, 144, 96, 38, 384, 144, 96); + + var btn = ['book', 'fly', 'toolbox', 'save', 'load', 'settings'] + for (var i in btn) { + var h = 0 + if (flags._Spr1Move_ && flags._Spr1Move_ < 7 && flags._Spr1Move_ === Number(i) + 1) { + h = 3 + core.drawImage(ctx, 'boxLight.png', 0, 0, 48, 48, 38 - 8 + 24 + 32 * ((flags._Spr1Move_ - 1) % 3), 384 - 8 + 16 + 32 * Math.floor((flags._Spr1Move_ - 1) / 3), 48, 48) + core.setFilter(ctx, 'hue-rotate(' + (col || 0) + 'deg)brightness(2)grayscale(' + (gry || 0) + '%)') + } else + core.setFilter(ctx, 'hue-rotate(' + (col || 0) + 'deg)grayscale(' + (gry || 0) + '%)') + core.drawIcon(ctx, btn[i], 38 + 24 + 32 * (i % 3), 384 + 16 + 32 * Math.floor(i / 3) - h, 32, 32) + + } + core.setFilter(ctx, fil) + + //技能栏 + core.drawImage(ctx, 'box2.png', 0, 0, 144, 96, 38 + 152 + 422, 166, 144, 96); + //装备栏 + core.drawImage(ctx, 'box1.png', 0, 0, 144, 96, 38 + 152 + 422, 384, 144, 96); + core.setFilter(ctx, '') + core.getSprite('Spr0').canvas.style.width = core.getSprite('Spr0').canvas.width * core.domStyle.scale + 'px'; + core.getSprite('Spr0').canvas.style.height = core.getSprite('Spr0').canvas.height * core.domStyle.scale + 'px'; + + //console.log(0) + } + + core.createSpr1 = function (des) { + if (main.replayChecking || !core.status.played) + return; + var left = parseInt(core.dom.gameGroup.style.left); + var top_up = parseInt(core.dom.gameGroup.style.top); + var width = 748 + 100; + var height = 560; + if (core.domStyle.isVertical) { + top_up += core.domStyle.scale * (102 - 16); + } else { + top_up -= 16 * core.domStyle.scale; + } + if (core.getSprite('Spr1') && des) { + core.getSprite('Spr1').destroy(); + const sprite = new Sprite(core.domStyle.isVertical ? 0 : Math.floor(left - (16 - 129 + 172 - 0) * core.domStyle.scale), Math.floor(top_up - (64 + 0) * core.domStyle.scale), width, height, 12, 'window', 'Spr1'); + } else if (core.getSprite('Spr1')) { + core.clearMap(core.getSprite('Spr1').context); + + } else { const sprite = new Sprite(core.domStyle.isVertical ? 0 : Math.floor(left - (16 - 129 + 172 - 0) * core.domStyle.scale), Math.floor(top_up - (64 + 0) * core.domStyle.scale), width, height, 12, 'window', 'Spr1'); } + + var ctx = core.getSprite('Spr1').context; + + core.clearMap(ctx); + + var col = flags._statuscol_; + var brg = flags._statusbrg_; + var gry = flags._statusgry_; + + var fil = 'hue-rotate(' + (col || 0) + 'deg)brightness(' + (brg || 1) + ')grayscale(' + (gry || 0) + '%)' + + var need = core.firstData.levelUp[core.status.hero.lv].need; + + //等级 + core.mystatusbox(ctx, 'lv', null, 80, 100, 160); + core.mystatusbox(ctx, 'exp', null, 80 + 22, 122, 210); + //var need = core.firstData.levelUp[core.status.hero.lv].need; + core.drawImage(ctx, 'expLt.png', 0, 0, 128 * hero.exp / need, 32, 60 - 16 + 4, 142, 128 * hero.exp / need, 32) + core.drawImage(ctx, 'expL.png', 0, 0, 128, 32, 60 - 16 + 4, 142, 128, 32) + //状态 + var heroStatus = ['hp', 'atk', 'def'] + var Scol = [250, 140, 0] + var heroStatus2 = ['mdef', 'atk2', 'def2'] + var Scol2 = [280, 170, 30, 330] + for (var i in heroStatus2) + if (heroStatus2[i] != null) + core.mystatusbox(ctx, heroStatus2[i], null, 80 + 22, 100 + 122 + 60 * Number(i), Scol2[i]); + for (var i in heroStatus) + core.mystatusbox(ctx, heroStatus[i], null, 80, 100 + 100 + 60 * Number(i), Scol[i]); + //魔力 + core.mystatusbox(ctx, 'mana', null, 80 + 152 + 422, 122, 20); + core.setAlpha(ctx, 0.4) + core.drawImage(ctx, 'manaLt.png', 0, 0, 128 * hero.mana / hero.manamax, 32, 60 - 16 + 4 + 152 + 422, 142, 128 * hero.mana / hero.manamax, 32) + core.setAlpha(ctx, 1) + core.drawImage(ctx, 'manaLt.png', 0, 0, 128 * (hero.mana - (flags.skillmana || 0)) / hero.manamax, 32, 60 - 16 + 4 + 152 + 422, 142, 128 * (hero.mana - (flags.skillmana || 0)) / hero.manamax, 32) + core.drawImage(ctx, 'manaL.png', 0, 0, 128, 32, 60 - 16 + 4 + 152 + 422, 142, 128, 32) + //钥匙/金币 + core.mystatusbox(ctx, 'key', null, 80 + 152 + 422, 60 * 4, 180); + core.mystatusbox(ctx, 'key', null, 80 + 22 + 152 + 422, 22 + 60 * 4, 300); + core.mystatusbox(ctx, 'money', null, 80 + 152 + 422, 60 * 5, 180); + + + var btn = ['book', 'fly', 'toolbox', 'save', 'load', 'settings'] + for (var i in btn) { + if (core.getEquip(i)) + core.drawIcon(ctx, core.getEquip(i), 38 + 152 + 422 + 24 + 32 * (i % 3), 384 + 16 + 32 * Math.floor(i / 3), 32, 32) + } + var leveltext = [ + ['新兵', '+2攻击,2防御'], + ['老兵', '+3攻击,3防御'], + ['老兵', '+3攻击,3防御'], + ['老兵', '+3攻击,3防御'], + ['老兵', '+3攻击,3防御'], + ['老兵', '+3攻击,3防御'], + ['老兵', '+3攻击,3防御'], + ['老兵', '+3攻击,3防御'], + ['老兵', '+3攻击,3防御'], + ['老兵', '+3攻击,3防御'], + ['老兵', '+3攻击,3防御'], + ] + var text = [ + ['等级', hero.lv + ' ' + leveltext[hero.lv - 1][0]], + ['经验', hero.exp + '/' + need], + ['生命', (hero.mdef < 0 ? '\r[red]' : '') + hero.mdef + '\r'], + ['护盾', (hero.mdef < 0 ? '\r[red]' : '') + hero.mdef + '\r'], + ['攻击', (hero.atk < 0 ? '\r[red]' : '') + hero.atk + '\r'], + ['攻速', (hero.atk2 < 0 ? '\r[red]' : '') + hero.atk2 + '\r'], + ['防御', (hero.def < 0 ? '\r[red]' : '') + hero.def + '\r'], + ['护甲', (hero.def2 < 0 ? '\r[red]' : '') + hero.def2 + '\r'], + ['魔量', hero.mana + '/' + hero.manamax], + ['钥匙', core.itemCount('yellowKey') + '黄/' + core.itemCount('blueKey') + '蓝'], + ['钥匙', core.itemCount('redKey') + '红/' + core.itemCount('greenKey') + '绿'], + ['金币', (hero.money < 0 ? '\r[red]' : '') + hero.money + '\r'], + ] + var text2 = [ + ['等级', '下级' + leveltext[hero.lv - 1][1]], + ['经验', '积累达到最大时角色升级'], + ['生命', '生命不足时游戏结束'], + ['护盾', '每次战斗会抵挡伤害'], + ['攻击', '影响角色每次普攻伤害'], + ['攻速', '每回合普攻伤害×' + Math.max(0, (hero.atk2 * 0.01 + 1)).toFixed(2)], + ['防御', '影响角色受到攻击的直接减伤'], + ['护甲', '受到伤害' + (hero.def2 < 0 ? '\r[red]增加\r' : '减免') + ':' + ((1 - 100 / (100 + 3 * Math.abs(hero.def2))) * 100).toFixed(2) + '%'], + ['魔量', '用于施放技能的消耗'], + ['钥匙', '用于开启黄/蓝门'], + ['钥匙', '用于开启红/绿门'], + ['金币', '用于商店购买的货币'], + ] + + core.setFilter(ctx, 'hue-rotate(' + (col || 0) + 'deg)grayscale(' + (gry || 0) + '%)') + + if (flags._Spr1Move2_) { + core.drawImage(ctx, 'boxLight.png', 0, 0, 48, 48, flags._Spr1Move2_[0] - 24, flags._Spr1Move2_[1] - 24, 48, 48); + var h = 20; + var list = flags._Spr1Move2_[2] + + core.drawWindowSkin('winskin.png', ctx, flags._Spr1Move2_[0], flags._Spr1Move2_[1] - 40, 100, 40) + core.drawWindowSkin('winskin.png', ctx, flags._Spr1Move2_[0], flags._Spr1Move2_[1] - 40 - h, 100, 20) + + + core.setFilter(ctx, '') + + var config = { left: flags._Spr1Move2_[0] + 4, top: flags._Spr1Move2_[1] - 25 - h - 12, fontSize: 12, maxWidth: 95, bold: false, color: "white" }; + core.drawTextContent(ctx, text[list][0] + ':' + text[list][1], config); + var config = { left: flags._Spr1Move2_[0] + 4, top: flags._Spr1Move2_[1] - 25 - 12, fontSize: 12, maxWidth: 95, bold: false, color: "white" }; + core.drawTextContent(ctx, text2[list][1], config); + + + core.setFilter(ctx, fil) + + } + + if (flags._Spr1Move_ == 7) { + core.drawImage(ctx, 'box2Light.png', 0, 0, 144, 96, 38 + 152 + 422, 166, 144, 96); + } + if (flags._Spr1Move_ == 8) { + core.drawImage(ctx, 'box1Light.png', 0, 0, 144, 96, 38 + 152 + 422, 384, 144, 96); + } + + core.setFilter(ctx, '') + + core.getSprite('Spr1').canvas.style.width = core.getSprite('Spr1').canvas.width * core.domStyle.scale + 'px'; + core.getSprite('Spr1').canvas.style.height = core.getSprite('Spr1').canvas.height * core.domStyle.scale + 'px'; + + if (core.getSprite('Spr1')) { + if (core.platform.isPC) { + core.getSprite('Spr1').addEventListener("click", core.Spr1Click, false) ///监听点击 + core.getSprite('Spr1').addEventListener("mousemove", core.Spr1Move, false) ///监听移动 + } else { + core.getSprite('Spr1').addEventListener("touchstart", core.Spr1TS, false) ///监听点击 + core.getSprite('Spr1').addEventListener("touchend", core.Spr1TE, false) ///监听移动 + } + + } + //console.log(1) + } + + core.createSpr2 = function (des) { + if (main.replayChecking || !core.status.played) + return; + var left = parseInt(core.dom.gameGroup.style.left); + var top_up = parseInt(core.dom.gameGroup.style.top); + var width = 748 + 100; + var height = 560; + if (core.domStyle.isVertical) { + top_up += core.domStyle.scale * (102 - 16); + } else { + top_up -= 16 * core.domStyle.scale; + } + if (core.getSprite('Spr2') && des) { + core.getSprite('Spr2').destroy(); + const sprite = new Sprite(core.domStyle.isVertical ? 0 : Math.floor(left - (16 - 129 + 172 - 0) * core.domStyle.scale), Math.floor(top_up - (64 + 0) * core.domStyle.scale), width, height, 10, 'window', 'Spr2'); + } else if (core.getSprite('Spr2')) { + core.clearMap(core.getSprite('Spr2').context); + + } else { const sprite = new Sprite(core.domStyle.isVertical ? 0 : Math.floor(left - (16 - 129 + 172 - 0) * core.domStyle.scale), Math.floor(top_up - (64 + 0) * core.domStyle.scale), width, height, 10, 'window', 'Spr2'); } + + var ctx = core.getSprite('Spr2').context; + + core.clearMap(ctx); + + //等级 + core.mystatusNumber(ctx, 'lv', null, 80, 100, 160); + core.mystatusNumber(ctx, 'exp', null, 80 + 22, 122, 210); + var need = core.firstData.levelUp[core.status.hero.lv].need; + core.drawImage(ctx, 'expLt.png', 0, 0, 128 * hero.exp / need, 32, 60 - 16 + 4, 142, 128 * hero.exp / need, 32) + core.drawImage(ctx, 'expL.png', 0, 0, 128, 32, 60 - 16 + 4, 142, 128, 32) + //状态 + var heroStatus = ['hp', 'atk', 'def'] + var Scol = [250, 140, 0] + var heroStatus2 = ['mdef', 'atk2', 'def2'] + var Scol2 = [280, 170, 30, 330] + for (var i in heroStatus2) + if (heroStatus2[i] != null) + core.mystatusNumber(ctx, heroStatus2[i], null, 80 + 22, 100 + 122 + 60 * Number(i), Scol2[i]); + for (var i in heroStatus) + core.mystatusNumber(ctx, heroStatus[i], null, 80, 100 + 100 + 60 * Number(i), Scol[i]); + //魔力 + core.mystatusNumber(ctx, 'mana', null, 80 + 152 + 422, 122, 20); + core.setAlpha(ctx, 0.4) + core.drawImage(ctx, 'manaLt.png', 0, 0, 128 * hero.mana / hero.manamax, 32, 60 - 16 + 4 + 152 + 422, 142, 128 * hero.mana / hero.manamax, 32) + core.setAlpha(ctx, 1) + core.drawImage(ctx, 'manaLt.png', 0, 0, 128 * (hero.mana - (flags.skillmana || 0)) / hero.manamax, 32, 60 - 16 + 4 + 152 + 422, 142, 128 * (hero.mana - (flags.skillmana || 0)) / hero.manamax, 32) + core.drawImage(ctx, 'manaL.png', 0, 0, 128, 32, 60 - 16 + 4 + 152 + 422, 142, 128, 32) + //钥匙/金币 + core.mystatusNumber(ctx, 'key1', null, 80 + 152 + 422, 60 * 4, 180); + core.mystatusNumber(ctx, 'key2', null, 80 + 22 + 152 + 422, 22 + 60 * 4, 300); + core.mystatusNumber(ctx, 'money', null, 80 + 152 + 422, 60 * 5, 180); + + core.getSprite('Spr2').canvas.style.width = core.getSprite('Spr2').canvas.width * core.domStyle.scale + 'px'; + core.getSprite('Spr2').canvas.style.height = core.getSprite('Spr2').canvas.height * core.domStyle.scale + 'px'; + + + //console.log(2) + } + + core.Spr1Click = function (e) { + if (main.replayChecking || !core.status.played) + return; + e.stopPropagation(); + + var x = e.clientX, ///获取鼠标点击位置 + y = e.clientY; + x = Math.round((x - core.getSprite('Spr1').canvas.offsetLeft) / core.domStyle.scale); + y = Math.round((y - core.getSprite('Spr1').canvas.offsetTop) / core.domStyle.scale); + + var i = flags._Spr1Move_ - 1 + switch (i) { + case 0: + main.statusBar.image.book.onclick(e); + break; + case 1: + main.statusBar.image.fly.onclick(e); + break; + case 2: + main.statusBar.image.toolbox.onclick(e); + break; + case 3: + main.statusBar.image.save.onclick(e); + break; + case 4: + main.statusBar.image.load.onclick(e); + break; + case 5: + main.statusBar.image.settings.onclick(e); + break; + case 7: + main.core.openEquipbox(true) + break; + } + //console.log("点击的位置合法,x:" + x + 'y:' + y); + + } + + core.Spr1Move = function (e) { + if (main.replayChecking || !core.status.played) + return; + e.stopPropagation(); + var x = e.clientX, ///获取鼠标点击位置 + y = e.clientY; + x = Math.round((x - core.getSprite('Spr1').canvas.offsetLeft) / core.domStyle.scale); + y = Math.round((y - core.getSprite('Spr1').canvas.offsetTop) / core.domStyle.scale); + + //方按钮 + var i = flags._Spr1Move_; + var j; + + for (var nx = 0; nx < 3; nx++) + for (var ny = 0; ny < 2; ny++) { + if (x >= 62 + 32 * nx && x < 94 + 32 * nx && y >= 400 + 32 * ny && y < 432 + 32 * ny) + j = nx + 3 * ny + 1 + } + if (x >= 636 && x < 732 && y >= 180 && y < 212) + j = 7 + if (x >= 636 && x < 732 && y >= 400 && y < 464) + j = 8 + + if (i !== j) { + flags._Spr1Move_ = j; + core.createSpr0(); + core.createSpr1(); + } + //圆按钮 + var ri = 0; + var rj2 = 0; + var rj + var rx = [80, 102, 80, 102, 80, 102, 80, 102, 654, 654, 676, 654] + var ry = [100, 122, 200, 222, 260, 282, 320, 342, 122, 240, 262, 300] + for (var r in rx) { + if ((rx[r] - 24 - x) * (rx[r] - 24 - x) + (ry[r] + 6 - y) * (ry[r] + 6 - y) <= 16 * 16) + rj = [rx[r] - 24, ry[r] + 6, r]; + + } + if (flags._Spr1Move2_) + ri = flags._Spr1Move2_[2]; + if (rj) + rj2 = rj[2]; + //console.log(rj2 + "点" + rj); + if (ri !== rj2) { + flags._Spr1Move2_ = rj; + core.createSpr1(); + } + } + + core.AllSprites = function () { + + { + core.createSprBack(true); + core.createSpr0(true); + core.createSpr1(true); + core.createSpr2(true); + } + + } +}, + "对话框": function () { + ui.prototype.drawWindowSkin = function (background, ctx, x, y, w, h, direction, px, py) { + var col = flags._statuscol_; + var brg = flags._statusbrg_; + var gry = flags._statusgry_; + + var fil = 'hue-rotate(' + (col || 0) + 'deg)brightness(' + (brg || 1) + ')grayscale(' + (gry || 0) + '%)' + + core.setFilter(ctx, fil) + + background = background || core.status.textAttribute.background; + // 仿RM窗口皮肤 ↓ + // 绘制背景 + core.drawImage(ctx, background, 0, 0, 128, 128, x + 2, y + 2, w - 4, h - 4); + // 绘制边框 + // 上方 + core.drawImage(ctx, background, 128, 0, 16, 16, x, y, 16, 16); + for (var dx = 0; dx < w - 64; dx += 32) { + core.drawImage(ctx, background, 144, 0, 32, 16, x + dx + 16, y, 32, 16); + core.drawImage(ctx, background, 144, 48, 32, 16, x + dx + 16, y + h - 16, 32, 16); + } + core.drawImage(ctx, background, 144, 0, w - dx - 32, 16, x + dx + 16, y, w - dx - 32, 16); + core.drawImage(ctx, background, 144, 48, w - dx - 32, 16, x + dx + 16, y + h - 16, w - dx - 32, 16); + core.drawImage(ctx, background, 176, 0, 16, 16, x + w - 16, y, 16, 16); + // 左右 + for (var dy = 0; dy < h - 64; dy += 32) { + core.drawImage(ctx, background, 128, 16, 16, 32, x, y + dy + 16, 16, 32); + core.drawImage(ctx, background, 176, 16, 16, 32, x + w - 16, y + dy + 16, 16, 32); + } + core.drawImage(ctx, background, 128, 16, 16, h - dy - 32, x, y + dy + 16, 16, h - dy - 32); + core.drawImage(ctx, background, 176, 16, 16, h - dy - 32, x + w - 16, y + dy + 16, 16, h - dy - 32); + // 下方 + core.drawImage(ctx, background, 128, 48, 16, 16, x, y + h - 16, 16, 16); + core.drawImage(ctx, background, 176, 48, 16, 16, x + w - 16, y + h - 16, 16, 16); + + // arrow + if (px != null && py != null) { + if (direction == 'up') { + core.drawImage(ctx, background, 128, 96, 32, 32, px, y + h - 3, 32, 32); + } else if (direction == 'down') { + core.drawImage(ctx, background, 160, 96, 32, 32, px, y - 29, 32, 32); + } + } + core.setFilter(ctx, null) + // 仿RM窗口皮肤 ↑ + } + + + ui.prototype._drawTextBox_drawTitleAndIcon = function (titleInfo, hPos, vPos, alpha, ctx) { + ctx = ctx || 'ui'; + core.setTextAlign(ctx, 'left'); + var textAttribute = core.status.textAttribute; + var content_top = vPos.top + 15; + var image_top = vPos.top + 15; + if (titleInfo.title != null) { + var titlefont = textAttribute.titlefont; + content_top += titlefont + 5; + image_top = vPos.top + 40; + core.setFillStyle(ctx, core.arrayToRGB(textAttribute.title)); + core.setStrokeStyle(ctx, core.arrayToRGB(textAttribute.title)); + + // --- title也要居中或者右对齐? + var title_width = core.calWidth(ctx, titleInfo.title, this._buildFont(titlefont, true)); + var title_left = hPos.content_left; + if (textAttribute.align == 'center') + title_left = hPos.left + (hPos.width - title_width) / 2; + else if (textAttribute.align == 'right') + title_left = hPos.right - title_width - 12; + + core.fillText(ctx, titleInfo.title, title_left, vPos.top + 8 + titlefont); + } + if (titleInfo.icon != null) { + core.setAlpha(ctx, alpha); + core.strokeRect(ctx, hPos.left + 15 - 1, image_top - 1, 34, titleInfo.height + 2, null, 2); + core.setAlpha(ctx, 1); + core.status.boxAnimateObjs = []; + // --- 勇士 + if (titleInfo.image == core.material.images.hero) { + if (core.status.hero.animate) { + var direction = core.getHeroLoc('direction'); + if (direction == 'up') direction = 'down'; + core.status.boxAnimateObjs.push({ + 'bgx': hPos.left + 15, + 'bgy': image_top, + 'bgWidth': 32, + 'bgHeight': titleInfo.height, + 'x': hPos.left + 15, + 'y': image_top, + 'height': titleInfo.height, + 'animate': 4, + 'image': titleInfo.image, + 'pos': core.material.icons.hero[direction].loc * titleInfo.height, + ctx: ctx, + }) + } else { + core.clearMap(ctx, hPos.left + 15, image_top, 32, titleInfo.height); + core.fillRect(ctx, hPos.left + 15, image_top, 32, titleInfo.height, core.material.groundPattern); + core.drawImage(ctx, titleInfo.image, 0, 0, core.material.icons.hero.width || 32, core.material.icons.hero.height, + hPos.left + 15, image_top, 32, titleInfo.height); + } + } else { + if (titleInfo.bigImage) { + core.status.boxAnimateObjs.push({ + bigImage: titleInfo.bigImage, + face: titleInfo.face, + centerX: hPos.left + 15 + 16, + centerY: image_top + titleInfo.height / 2, + max_width: 50, + ctx: ctx + }); + } else { + core.status.boxAnimateObjs.push({ + 'bgx': hPos.left + 15, + 'bgy': image_top, + 'bgWidth': 32, + 'bgHeight': titleInfo.height, + 'x': hPos.left + 15, + 'y': image_top, + 'height': titleInfo.height, + 'animate': titleInfo.animate, + 'image': titleInfo.image, + 'pos': titleInfo.icon * titleInfo.height, + ctx: ctx, + }); + } + } + core.drawBoxAnimate(); + } + if (titleInfo.image != null && titleInfo.icon == null) { // 头像图 + console.log(titleInfo.image) + core.strokeRect(ctx, hPos.left + 10 - 5, vPos.top + 10 - 5, 70 + 10, 70 + 10, '#cccccc', 3) + core.drawImage(ctx, titleInfo.image, 0, 0, titleInfo.image.width, titleInfo.image.height, + hPos.left + 10, vPos.top + 10, 70, 70); + } + return content_top; + } +}, + "插件1": function () { + +}, + "插件2": function () { + +} } \ No newline at end of file diff --git a/project/tilesets/magictower.png b/project/tilesets/magictower.png index dfca877..c48f1c2 100644 Binary files a/project/tilesets/magictower.png and b/project/tilesets/magictower.png differ diff --git a/styles.css b/styles.css index 1d84860..e1e1020 100644 --- a/styles.css +++ b/styles.css @@ -201,7 +201,7 @@ -moz-box-sizing: border-box; -webkit-box-sizing: border-box; background: url(project/materials/ground.png) repeat; - z-index: 185; + z-index: 1; display: none; top: 0; left: 0; @@ -238,7 +238,7 @@ #toolBar { position: absolute; background: url(project/materials/ground.png) repeat; - z-index: 210; + z-index: 1; box-sizing: border-box; -moz-box-sizing: border-box; -webkit-box-sizing: border-box;