diff --git a/README.md b/README.md index b81aa04b..da2183a4 100644 --- a/README.md +++ b/README.md @@ -55,6 +55,24 @@ HTML5 canvas制作的魔塔样板,支持全平台游戏! ## 更新说明 +### 2019.4.13 V2.6 + +* [x] 拆分整个项目,大幅重构代码,新增大量API +* [x] 重写文档,尤其是脚本和API列表 +* [x] 现在可以对编辑器的表格的结构进行配置 +* [x] 可以收藏和高亮存档 +* [x] 独立出来的插件编写 +* [x] 新增事件:关门、显示确认框、后置循环处理 +* [x] 剧情文本的绘制可以设置居中选项 +* [x] 选项框的绘制可以增加图标 +* [x] 增加公共事件版的全局商店 +* [x] 公共事件现在可以传入参数 +* [x] 重写滑冰事件,现在滑冰在背景层了 +* [x] 将输入框改成自定义实现,避免部分设备不支持 +* [x] 状态栏文字可以自动放缩 +* [x] 显示图片和对话框立绘可以裁剪图片 +* [x] 修复所有已知bug,大量细节优化 + ### 2019.2.19 V2.5.5 * [x] 现在编辑器修改地图后可以直接读档生效,无需再重置地图或回放录像 diff --git a/_docs/api.md b/_docs/api.md index ee5fbbaf..4194aa66 100644 --- a/_docs/api.md +++ b/_docs/api.md @@ -199,7 +199,7 @@ core.onkeyDown(e) core.onkeyUp(e) 当放开某个键时的操作,e为KeyboardEvent。 -请勿直接覆盖或调用此函数,如有需要请注册一个"onkeyDown"的交互函数。 +请勿直接覆盖或调用此函数,如有需要请注册一个"onkeyUp"的交互函数。 core.pressKey(keyCode) @@ -394,12 +394,12 @@ core.updateViewport() 根据大地图的偏移量来更新窗口的视野范围。 -core.nextX(n) / core.nextY(m) +core.nextX(n) / core.nextY(n) 获得勇士面对的第n个位置的横纵坐标。n可不填,默认为1。 -core.nearHero(x, y) -判定某个点是否和勇士的距离不大于1。 +core.nearHero(x, y, n) +判定某个点是否和勇士的距离不大于n。n可不填,默认为1。 core.gatherFollowers() @@ -1464,6 +1464,7 @@ posX, posY:素材在该素材图片上的位置;height:素材的高度;f core.searchBlock(id, floorId, showDisable) 搜索一个图块出现过的所有位置。id为图块ID,也可以传入图块的数字。 +id支持通配符搜索,比如"*Door"可以搜索所有的门,"unknownEvent*"可以所有所有的unknownEvent。 floorId为要搜索的楼层,可以是一个楼层ID,或者一个楼层数组。如果floorId不填则只搜索当前楼层。 showDisable如果为真,则对于禁用的图块也会返回。 此函数将返回一个数组,每一项为一个搜索到的结果: @@ -1912,9 +1913,17 @@ errorCallback可选,如果失败,则会将错误信息传入errorCallback() 此函数是异步的,只能通过回调函数来获得读取的结果或错误信息。 -core.clone(data) +core.clone(data, filter, recursion) 深拷贝一个对象。有关浅拷贝,深拷贝,基本类型和引用类型等相关知识可参见: https://zhuanlan.zhihu.com/p/26282765 +filter为过滤函数,如果设置且不为null则需传递一个可接受(name, value)的函数, +并返回true或false,表示该项是否应该被深拷贝。 +recursion表示该filter是否应递归向下传递,如果为true则递归函数也将传该filter。 +例如: +core.clone(core.status.hero, function(name, value) { + return name == 'items' || typeof value == 'number'; +}, false); +这个例子将会深拷贝勇士的属性和道具。 core.splitImage(image, width, height) @@ -1997,6 +2006,10 @@ core.reverseDirection(direction) 翻转方向,即"up"转成"down", "left"转成"right"等。 +core.matchWildcard(pattern, string) +进行通配符的匹配判定,目前仅支持*(可匹配0或任意个字符)。比如"a*b*c"可以匹配"aa012bc"。 + + core.encodeBase64(str) / core.decodeBase64(str) 将字符串进行base64加密或解密。 diff --git a/_docs/event.md b/_docs/event.md index e5a2b7b9..866a771c 100644 --- a/_docs/event.md +++ b/_docs/event.md @@ -655,8 +655,9 @@ revisit常常使用在一些商人之类的地方,当用户购买物品后不 ``` js [ {"type": "setBlock", "floorId": "MT1", "loc": [3,3], "number": 233}, // 将MT1层的(3,3)点变成数字233 - {"type": "setBlock", "loc": [2,1], "number": 121}, // 省略floorId则默认为本层 + {"type": "setBlock", "loc": [2,1],setVa "number": 121}, // 省略floorId则默认为本层 {"type": "setBlock", "number": 57}, // loc也可省略,默认为当前点 + {"type": "setBlock", "number": "yellowDoor"}, // 从V2.6开始也允许写图块ID ] ``` @@ -666,6 +667,8 @@ loc为可选的,表示要更改地图块的坐标。如果忽略此项,则 number为**要更改到的数字**,有关“数字”的定义详见参见[素材的机制](personalization#素材的机制)。 +从V2.6开始,number也允许写图块的ID,将自动转成对应的数字。 + 图块更改后: - 其启用/禁用状态不会发生任何改变。原来是启用还是启用,原来是禁用还是禁用。 @@ -1381,6 +1384,10 @@ async可选,如果为true则会异步执行(即不等待当前事件执行 该事件会显示失败页面,并重新开始游戏。 +### restart:直接回到标题界面 + +`{"type": "restart"}` 会中断一切执行的事件,并直接直接返回标题界面。 + ### callBook:呼出怪物手册 `{"type": "callBook"}` 可以呼出怪物手册,玩家可以自由查看当前楼层怪物数据和详细信息。 @@ -1642,7 +1649,7 @@ default可选,如果为true则显示选择项时默认选中【确定】,否 yes和no均为必填项,即用户点击确认或取消后执行的事件。 -### while:循环处理 +### while:前置条件循环 从2.2.1样板开始,我们提供了循环处理(while事件)。 @@ -1678,6 +1685,12 @@ yes和no均为必填项,即用户点击确认或取消后执行的事件。 ] ``` +### dowhile:后置条件循环 + +`type:dowhile`可以制作一个后置条件循环。 + +其写法与参数和`type:while`完全一致,不过与其不同的是,会先执行一次事件列表,再对条件进行判定,就和C/C++中的 `do {...} while (...);` 语法一样。 + ### break:跳出循环 使用 `{"type": "break"}` 可以跳出当前循环。 diff --git a/_server/MotaAction.g4 b/_server/MotaAction.g4 index a8741045..6906166b 100644 --- a/_server/MotaAction.g4 +++ b/_server/MotaAction.g4 @@ -228,7 +228,8 @@ default : [null,"MT1",null,0,0,null,500,null] var toFloorId = IdString_0; if (Floor_List_0!='floorId') toFloorId = Floor_List_0; var loc = ', "loc": ['+Number_0+', '+Number_1+']'; -if (Stair_List_0!=='loc')loc = ', "stair": "'+Stair_List_0+'"'; +if (Stair_List_0==='now')loc = ''; +else if (Stair_List_0!=='loc')loc = ', "stair": "'+Stair_List_0+'"'; DirectionEx_List_0 = DirectionEx_List_0 && (', "direction": "'+DirectionEx_List_0+'"'); Int_0 = (Int_0!=='') ?(', "time": '+Int_0):''; Bool_0 = Bool_0 ?'':(', "ignoreChangeFloor": false'); @@ -323,10 +324,12 @@ action | setVolume_s | win_s | lose_s + | restart_s | if_s | if_1_s | switch_s | while_s + | dowhile_s | break_s | continue_s | input_s @@ -579,7 +582,7 @@ show_s tooltip : show: 将禁用事件启用,楼层和动画时间可不填,xy可用逗号分隔表示多个点 helpUrl : https://h5mota.com/games/template/docs/#/event?id=show%EF%BC%9A%E5%B0%86%E4%B8%80%E4%B8%AA%E7%A6%81%E7%94%A8%E4%BA%8B%E4%BB%B6%E5%90%AF%E7%94%A8 default : ["","","",500,false] -colour : this.eventColor +colour : this.mapColor var floorstr = ''; if (EvalString_0 && EvalString_1) { var pattern1 = /^flag:[0-9a-zA-Z_][0-9a-zA-Z_\-:]*$/; @@ -612,7 +615,7 @@ hide_s tooltip : hide: 将一个启用事件禁用,所有参数均可不填,代表禁用事件自身,xy可用逗号分隔表示多个点 helpUrl : https://h5mota.com/games/template/docs/#/event?id=hide%EF%BC%9A%E5%B0%86%E4%B8%80%E4%B8%AA%E5%90%AF%E7%94%A8%E4%BA%8B%E4%BB%B6%E7%A6%81%E7%94%A8 default : ["","","",500,false] -colour : this.eventColor +colour : this.mapColor var floorstr = ''; if (EvalString_0 && EvalString_1) { var pattern1 = /^flag:[0-9a-zA-Z_][0-9a-zA-Z_\-:]*$/; @@ -728,20 +731,20 @@ return code; */; setBlock_s - : '转变图块为' Int 'x' PosString? ',' 'y' PosString? '楼层' IdString? Newline + : '转变图块为' EvalString 'x' PosString? ',' 'y' PosString? '楼层' IdString? Newline /* setBlock_s tooltip : setBlock:设置某个图块,忽略坐标楼层则为当前事件 helpUrl : https://h5mota.com/games/template/docs/#/event?id=setblock%EF%BC%9A%E8%AE%BE%E7%BD%AE%E6%9F%90%E4%B8%AA%E5%9B%BE%E5%9D%97 -colour : this.dataColor -default : [0,"","",""] +colour : this.mapColor +default : ["yellowDoor","","",""] var floorstr = ''; if (PosString_0 && PosString_1) { floorstr = ', "loc": ['+PosString_0+','+PosString_1+']'; } IdString_0 = IdString_0 && (', "floorId": "'+IdString_0+'"'); -var code = '{"type": "setBlock", "number":'+Int_0+floorstr+IdString_0+'},\n'; +var code = '{"type": "setBlock", "number": "'+EvalString_0+'"'+floorstr+IdString_0+'},\n'; return code; */; @@ -753,7 +756,7 @@ showFloorImg_s tooltip : showFloorImg: 显示一个贴图,xy为左上角坐标,可用逗号分隔表示多个点 helpUrl : https://h5mota.com/games/template/docs/#/event?id=showFloorImg%ef%bc%9a%e6%98%be%e7%a4%ba%e8%b4%b4%e5%9b%be default : ["","",""] -colour : this.eventColor +colour : this.mapColor var floorstr = ''; if (EvalString_0 && EvalString_1) { var pattern1 = /^flag:[0-9a-zA-Z_][0-9a-zA-Z_\-:]*$/; @@ -784,7 +787,7 @@ hideFloorImg_s tooltip : hideFloorImg: 隐藏一个贴图,xy为左上角坐标,可用逗号分隔表示多个点 helpUrl : https://h5mota.com/games/template/docs/#/event?id=hideFloorImg%ef%bc%9a%e9%9a%90%e8%97%8f%e8%b4%b4%e5%9b%be default : ["","",""] -colour : this.eventColor +colour : this.mapColor var floorstr = ''; if (EvalString_0 && EvalString_1) { var pattern1 = /^flag:[0-9a-zA-Z_][0-9a-zA-Z_\-:]*$/; @@ -815,7 +818,7 @@ showBgFgMap_s tooltip : showBgFgMap: 显示图层块,即背景图层/前景图层的某些图块,xy为左上角坐标,可用逗号分隔表示多个点 helpUrl : https://h5mota.com/games/template/docs/#/event?id=showFloorImg%ef%bc%9a%e6%98%be%e7%a4%ba%e8%b4%b4%e5%9b%be default : ["bg","","",""] -colour : this.eventColor +colour : this.mapColor var floorstr = ''; if (EvalString_0 && EvalString_1) { var pattern1 = /^flag:[0-9a-zA-Z_][0-9a-zA-Z_\-:]*$/; @@ -846,7 +849,7 @@ hideBgFgMap_s tooltip : hideBgFgMap: 隐藏图层块,即背景图层/前景图层的某些图块,xy为左上角坐标,可用逗号分隔表示多个点 helpUrl : https://h5mota.com/games/template/docs/#/event?id=hideFloorImg%ef%bc%9a%e9%9a%90%e8%97%8f%e8%b4%b4%e5%9b%be default : ["bg","","",""] -colour : this.eventColor +colour : this.mapColor var floorstr = ''; if (EvalString_0 && EvalString_1) { var pattern1 = /^flag:[0-9a-zA-Z_][0-9a-zA-Z_\-:]*$/; @@ -870,20 +873,20 @@ return code; */; setBgFgBlock_s - : '转变图层块' Bg_Fg_List '为' Int 'x' PosString? ',' 'y' PosString? '楼层' IdString? Newline + : '转变图层块' Bg_Fg_List '为' EvalString 'x' PosString? ',' 'y' PosString? '楼层' IdString? Newline /* setBgFgBlock_s tooltip : setBgFgBlock:设置某个图层块,忽略坐标楼层则为当前点 helpUrl : https://h5mota.com/games/template/docs/#/event?id=setblock%EF%BC%9A%E8%AE%BE%E7%BD%AE%E6%9F%90%E4%B8%AA%E5%9B%BE%E5%9D%97 -colour : this.dataColor -default : ["bg",0,"","",""] +colour : this.mapColor +default : ["bg","yellowDoor","","",""] var floorstr = ''; if (PosString_0 && PosString_1) { floorstr = ', "loc": ['+PosString_0+','+PosString_1+']'; } IdString_0 = IdString_0 && (', "floorId": "'+IdString_0+'"'); -var code = '{"type": "setBgFgBlock", "name": "' + Bg_Fg_List_0 + '", "number":'+Int_0+floorstr+IdString_0+'},\n'; +var code = '{"type": "setBgFgBlock", "name": "' + Bg_Fg_List_0 + '", "number": "'+EvalString_0+'"'+floorstr+IdString_0+'},\n'; return code; */; @@ -987,7 +990,7 @@ openDoor_s tooltip : openDoor: 开门,楼层可不填表示当前层 helpUrl : https://h5mota.com/games/template/docs/#/event?id=opendoor%EF%BC%9A%E5%BC%80%E9%97%A8 default : ["","","",false] -colour : this.dataColor +colour : this.mapColor IdString_0 = IdString_0 && (', "floorId": "'+IdString_0+'"'); var floorstr = ''; if (PosString_0 && PosString_1) { @@ -1006,7 +1009,7 @@ closeDoor_s tooltip : closeDoor: 关门事件,需要该点本身无事件 helpUrl : https://h5mota.com/games/template/docs/#/event?id=opendoor%EF%BC%9A%E5%BC%80%E9%97%A8 default : ["","","yellowDoor"] -colour : this.dataColor +colour : this.mapColor var floorstr = ''; if (PosString_0 && PosString_1) { floorstr = ', "loc": ['+PosString_0+','+PosString_1+']'; @@ -1095,7 +1098,7 @@ disableShop_s tooltip : 全局商店 helpUrl : https://h5mota.com/games/template/docs/#/event?id=disableshop%EF%BC%9A%E7%A6%81%E7%94%A8%E4%B8%80%E4%B8%AA%E5%85%A8%E5%B1%80%E5%95%86%E5%BA%97 default : ["shop1"] -colour : this.eventColor +colour : this.dataColor var code = '{"type": "disableShop", "id": "'+IdString_0+'"},\n'; return code; */; @@ -1350,7 +1353,7 @@ move_s tooltip : move: 让某个NPC/怪物移动,位置可不填代表当前事件 helpUrl : https://h5mota.com/games/template/docs/#/event?id=move%EF%BC%9A%E8%AE%A9%E6%9F%90%E4%B8%AAnpc%E6%80%AA%E7%89%A9%E7%A7%BB%E5%8A%A8 default : ["","",500,false,false,"上右3下2左上左2"] -colour : this.eventColor +colour : this.mapColor var floorstr = ''; if (PosString_0 && PosString_1) { floorstr = ', "loc": ['+PosString_0+','+PosString_1+']'; @@ -1385,7 +1388,7 @@ jump_s tooltip : jump: 让某个NPC/怪物跳跃 helpUrl : https://h5mota.com/games/template/docs/#/event?id=jump%EF%BC%9A%E8%AE%A9%E6%9F%90%E4%B8%AANPC%2F%E6%80%AA%E7%89%A9%E8%B7%B3%E8%B7%83 default : ["","","","",500,true,false] -colour : this.eventColor +colour : this.mapColor var floorstr = ''; if (PosString_0 && PosString_1) { floorstr += ', "from": ['+PosString_0+','+PosString_1+']'; @@ -1548,6 +1551,17 @@ var code = '{"type": "lose", "reason": "'+EvalString_0+'"},\n'; return code; */; +restart_s + : '直接回到标题界面' Newline + + +/* restart_s +tooltip : restart: 直接回到标题界面 +helpUrl : https://h5mota.com/games/template/docs/#/event?id=restart%ef%bc%9a%e7%9b%b4%e6%8e%a5%e5%9b%9e%e5%88%b0%e6%a0%87%e9%a2%98%e7%95%8c%e9%9d%a2 +var code = '{"type": "restart"},\n'; +return code; +*/; + input_s : '接受用户输入数字,提示' ':' EvalString Newline @@ -1693,11 +1707,11 @@ return code; */; while_s - : '循环处理' ':' '当' expression '时' BGNL? Newline action+ BEND Newline + : '前置条件循环' ':' '当' expression '时' BGNL? Newline action+ BEND Newline /* while_s -tooltip : while:循环处理 -helpUrl : https://h5mota.com/games/template/docs/#/event?id=while%EF%BC%9A%E5%BE%AA%E7%8E%AF%E5%A4%84%E7%90%86 +tooltip : while:前置条件循环 +helpUrl : https://h5mota.com/games/template/docs/#/event?id=while%ef%bc%9a%e5%89%8d%e7%bd%ae%e6%9d%a1%e4%bb%b6%e5%be%aa%e7%8e%af colour : this.eventColor var code = ['{"type": "while", "condition": "',expression_0,'",\n', '"data": [\n',action_0,'],\n', @@ -1705,6 +1719,19 @@ var code = ['{"type": "while", "condition": "',expression_0,'",\n', return code; */; +dowhile_s + : '后置条件循环' ':' BGNL? Newline action+ BEND '当' expression '时' Newline + +/* dowhile_s +tooltip : dowhile:后置条件循环 +helpUrl : https://h5mota.com/games/template/docs/#/event?id=dowhile%ef%bc%9a%e5%90%8e%e7%bd%ae%e6%9d%a1%e4%bb%b6%e5%be%aa%e7%8e%af +colour : this.eventColor +var code = ['{"type": "dowhile", "condition": "',expression_0,'",\n', + '"data": [\n',action_0,'],\n', +'},\n'].join(''); +return code; +*/; + break_s : '跳出循环' Newline @@ -1968,8 +1995,8 @@ Floor_List /*Floor_List ['floorId',':before',':next']*/; Stair_List - : '坐标'|'上楼梯'|'下楼梯' - /*Stair_List ['loc','upFloor','downFloor']*/; + : '坐标'|'上楼梯'|'下楼梯'|'保持不变' + /*Stair_List ['loc','upFloor','downFloor','now']*/; SetTextPosition_List : '不改变'|'距离顶部'|'居中'|'距离底部' @@ -2021,8 +2048,8 @@ Global_Value_List Global_Flag_List - : '显示当前楼层'|'显示勇士图标'|'显示当前等级'|'启用生命上限'|'显示魔力值'|'显示魔防值'|'显示金币值'|'显示经验值'|'允许等级提升'|'升级扣除模式'|'显示钥匙数量'|'显示破炸飞'|'显示毒衰咒'|'显示当前技能'|'楼梯边才能楼传'|'开启加点'|'开启负伤'|'仇恨怪战后扣减一半'|'夹击是否上整'|'循环计算临界'|'允许轻按'|'寻路算法不绕血瓶'|'允许走到将死领域'|'允许瞬间移动'|'允许查看禁用商店'|'阻激夹域后禁用快捷商店'|'检查控制台' - /*Global_Flag_List ['enableFloor','enableName','enableLv', 'enableHPMax', 'enableMana', 'enableMDef', 'enableMoney', 'enableExperience', 'enableLevelUp', 'levelUpLeftMode', 'enableKeys', 'enablePZF', 'enableDebuff', 'enableSkill', 'flyNearStair', 'enableAddPoint', 'enableNegativeDamage', 'hatredDecrease', 'betweenAttackCeil', 'useLoop', 'enableGentleClick', 'potionWhileRouting', 'canGoDeadZone', 'enableMoveDirectly', 'enableDisabledShop', 'disableShopOnDamage', 'checkConsole']*/; + : '显示当前楼层'|'显示勇士图标'|'显示当前等级'|'启用生命上限'|'显示魔力值'|'显示魔防值'|'显示金币值'|'显示经验值'|'允许等级提升'|'升级扣除模式'|'显示钥匙数量'|'显示破炸飞'|'显示毒衰咒'|'显示当前技能'|'楼梯边才能楼传'|'破墙镐四方向'|'炸弹四方向'|'冰冻徽章四方向'|'铁门不需要钥匙'|'开启加点'|'开启负伤'|'仇恨怪战后扣减一半'|'夹击是否上整'|'夹击不超伤害值'|'循环计算临界'|'允许轻按'|'寻路算法不绕血瓶'|'允许走到将死领域'|'允许瞬间移动'|'允许查看禁用商店'|'阻激夹域后禁用快捷商店'|'检查控制台' + /*Global_Flag_List ['enableFloor','enableName','enableLv', 'enableHPMax', 'enableMana', 'enableMDef', 'enableMoney', 'enableExperience', 'enableLevelUp', 'levelUpLeftMode', 'enableKeys', 'enablePZF', 'enableDebuff', 'enableSkill', 'flyNearStair', 'pickaxeFourDirections', 'bombFourDirections', 'snowFourDirections', 'steelDoorWithoutKey', 'enableAddPoint', 'enableNegativeDamage', 'hatredDecrease', 'betweenAttackCeil', 'betweenAttackMax', 'useLoop', 'enableGentleClick', 'potionWhileRouting', 'canGoDeadZone', 'enableMoveDirectly', 'enableDisabledShop', 'disableShopOnDamage', 'checkConsole']*/; Colour : 'sdeirughvuiyasdeb'+ //为了被识别为复杂词法规则 @@ -2127,6 +2154,7 @@ this.evisitor.dataColor=130; this.evisitor.eventColor=220; this.evisitor.soundColor=20; this.evisitor.commentColor=285; +this.evisitor.mapColor=175; */ /* Function_1 @@ -2153,7 +2181,10 @@ ActionParser.prototype.parse = function (obj,type) { case 'changeFloor': if(!obj)obj={}; - if(!this.isset(obj.loc))obj.loc=[0,0]; + if(!this.isset(obj.loc)) { + obj.loc=[0,0]; + if (!this.isset(obj.stair)) obj.stair='now'; + } if (obj.floorId==':before'||obj.floorId==':next') { obj.floorType=obj.floorId; delete obj.floorId; @@ -2639,13 +2670,20 @@ ActionParser.prototype.parseAction = function() { this.next = MotaActionBlocks['choices_s'].xmlText([ this.isset(data.text)?this.EvalString(data.text):null,'','',text_choices,this.next]); break; - case "while": // 循环处理 + case "while": // 前置条件循环处理 this.next = MotaActionBlocks['while_s'].xmlText([ // MotaActionBlocks['evalString_e'].xmlText([data.condition]), this.tryToUseEvFlag_e('evalString_e', [data.condition]), this.insertActionList(data["data"]), this.next]); break; + case "dowhile": // 后置条件循环处理 + this.next = MotaActionBlocks['dowhile_s'].xmlText([ + this.insertActionList(data["data"]), + // MotaActionBlocks['evalString_e'].xmlText([data.condition]), + this.tryToUseEvFlag_e('evalString_e', [data.condition]), + this.next]); + break; case "break": // 跳出循环 this.next = MotaActionBlocks['break_s'].xmlText([ this.next]); @@ -2662,6 +2700,10 @@ ActionParser.prototype.parseAction = function() { this.next = MotaActionBlocks['lose_s'].xmlText([ data.reason,this.next]); break; + case "restart": + this.next = MotaActionBlocks['restart_s'].xmlText([ + this.next]); + break; case "function": var func = data["function"]; func=func.split('{').slice(1).join('{').split('}').slice(0,-1).join('}').trim().split('\n').join('\\n'); diff --git a/_server/editor_blockly.js b/_server/editor_blockly.js index 2a641312..ee3b9550 100644 --- a/_server/editor_blockly.js +++ b/_server/editor_blockly.js @@ -68,6 +68,8 @@ editor_blockly = function () { MotaActionBlocks['tip_s'].xmlText(), MotaActionBlocks['win_s'].xmlText(), MotaActionBlocks['lose_s'].xmlText(), + MotaActionBlocks['restart_s'].xmlText(), + MotaActionBlocks['confirm_s'].xmlText(), MotaActionBlocks['choices_s'].xmlText([ '选择剑或者盾','流浪者','man',MotaActionBlocks['choicesContext'].xmlText([ '剑','','',null,MotaActionFunctions.actionParser.parseList([{"type": "openDoor", "loc": [3,3]}]), @@ -76,7 +78,6 @@ editor_blockly = function () { ]) ]) ]), - MotaActionBlocks['confirm_s'].xmlText(), ], '数据相关':[ MotaActionBlocks['setValue_s'].xmlText([ @@ -99,16 +100,27 @@ editor_blockly = function () { MotaActionBlocks['changePos_0_s'].xmlText(), MotaActionBlocks['changePos_1_s'].xmlText(), MotaActionBlocks['battle_s'].xmlText(), - MotaActionBlocks['openDoor_s'].xmlText(), - MotaActionBlocks['closeDoor_s'].xmlText(), MotaActionBlocks['useItem_s'].xmlText(), MotaActionBlocks['openShop_s'].xmlText(), - MotaActionBlocks['setBlock_s'].xmlText(), - MotaActionBlocks['setBgFgBlock_s'].xmlText(), + MotaActionBlocks['disableShop_s'].xmlText(), MotaActionBlocks['setHeroIcon_s'].xmlText(), MotaActionBlocks['follow_s'].xmlText(), MotaActionBlocks['unfollow_s'].xmlText(), ], + '地图处理':[ + MotaActionBlocks['openDoor_s'].xmlText(), + MotaActionBlocks['closeDoor_s'].xmlText(), + MotaActionBlocks['show_s'].xmlText(), + MotaActionBlocks['hide_s'].xmlText(), + MotaActionBlocks['setBlock_s'].xmlText(), + MotaActionBlocks['move_s'].xmlText(), + MotaActionBlocks['jump_s'].xmlText(), + MotaActionBlocks['showBgFgMap_s'].xmlText(), + MotaActionBlocks['hideBgFgMap_s'].xmlText(), + MotaActionBlocks['setBgFgBlock_s'].xmlText(), + MotaActionBlocks['showFloorImg_s'].xmlText(), + MotaActionBlocks['hideFloorImg_s'].xmlText(), + ], '事件控制':[ MotaActionBlocks['if_s'].xmlText(), MotaActionBlocks['if_1_s'].xmlText(), @@ -118,22 +130,14 @@ editor_blockly = function () { {"case": "default", "action": [{"type": "comment", "text": "当没有符合的值的场合执行default事件"}]}, ]}), MotaActionBlocks['while_s'].xmlText(), + MotaActionBlocks['dowhile_s'].xmlText(), MotaActionBlocks['break_s'].xmlText(), MotaActionBlocks['continue_s'].xmlText(), MotaActionBlocks['revisit_s'].xmlText(), MotaActionBlocks['exit_s'].xmlText(), - MotaActionBlocks['show_s'].xmlText(), - MotaActionBlocks['hide_s'].xmlText(), - MotaActionBlocks['showFloorImg_s'].xmlText(), - MotaActionBlocks['hideFloorImg_s'].xmlText(), - MotaActionBlocks['showBgFgMap_s'].xmlText(), - MotaActionBlocks['hideBgFgMap_s'].xmlText(), MotaActionBlocks['trigger_s'].xmlText(), MotaActionBlocks['insert_1_s'].xmlText(), MotaActionBlocks['insert_2_s'].xmlText(), - MotaActionBlocks['move_s'].xmlText(), - MotaActionBlocks['jump_s'].xmlText(), - MotaActionBlocks['disableShop_s'].xmlText(), ], '特效/声音':[ MotaActionBlocks['sleep_s'].xmlText(), diff --git a/_server/table/data.comment.js b/_server/table/data.comment.js index 026ab732..6b98a633 100644 --- a/_server/table/data.comment.js +++ b/_server/table/data.comment.js @@ -536,6 +536,12 @@ var data_comment_c456ea59_6018_45ef_8bcc_211a24c627dc = { "_bool": "bool", "_data": "如果此项为true,则视为钥匙盒,红黄蓝钥匙+1;若为false,则视为大黄门钥匙" }, + "steelDoorWithoutKey": { + "_left": true, + "_type": "checkbox", + "_bool": "bool", + "_data": "铁门是否不需要钥匙开启。如果此项为true,则无需钥匙也可以开铁门。" + }, "equipment": { "_leaf": true, "_type": "checkbox", @@ -548,6 +554,12 @@ var data_comment_c456ea59_6018_45ef_8bcc_211a24c627dc = { "_bool": "bool", "_data": "状态栏的装备按钮。若此项为true则将状态栏中的楼层转换器按钮换为装备栏按钮" }, + "iconInEquipbox": { + "_leaf": true, + "_type": "checkbox", + "_bool": "bool", + "_data": "在装备栏中的属性变化,是否绘制图标;如果此项开启,则会绘制图标而不是文字" + }, "enableAddPoint": { "_leaf": true, "_type": "checkbox", @@ -570,7 +582,13 @@ var data_comment_c456ea59_6018_45ef_8bcc_211a24c627dc = { "_leaf": true, "_type": "checkbox", "_bool": "bool", - "_data": "夹击方式是向上取整还是向下取整。如果此项为true则为向上取整,为false则为向下取整" + "_data": "夹击上整还是下整。如果此项为true则夹击伤害值向上取整,为false则为向下取整" + }, + "betweenAttackMax": { + "_leaf": true, + "_type": "checkbox", + "_bool": "bool", + "_data": "夹击伤害是否不超过怪物伤害值。" }, "useLoop": { "_leaf": true, diff --git a/editor-mobile.html b/editor-mobile.html index e77a286f..0e4fde1f 100644 --- a/editor-mobile.html +++ b/editor-mobile.html @@ -120,7 +120,7 @@
- +
diff --git a/editor.html b/editor.html index 58ea0a1c..75b7856a 100644 --- a/editor.html +++ b/editor.html @@ -116,7 +116,7 @@
- +
diff --git a/libs/actions.js b/libs/actions.js index c4388106..e64fb01e 100644 --- a/libs/actions.js +++ b/libs/actions.js @@ -777,7 +777,7 @@ actions.prototype._sys_longClick = function (x, y, fromEvent) { // 数字键快速选择选项 actions.prototype._selectChoices = function (length, keycode, callback) { - var topIndex = this.HSIZE - parseInt((length - 1) / 2); + var topIndex = this.HSIZE - parseInt((length - 1) / 2) + (core.status.event.ui.offset || 0); if (keycode == 13 || keycode == 32 || keycode == 67) { callback.apply(this, [this.HSIZE, topIndex + core.status.event.selection]); } @@ -883,7 +883,7 @@ actions.prototype._clickAction = function (x, y) { var choices = data.choices; if (choices.length == 0) return; if (x >= this.CHOICES_LEFT && x <= this.CHOICES_RIGHT) { - var topIndex = this.HSIZE - parseInt((choices.length - 1) / 2); + var topIndex = this.HSIZE - parseInt((choices.length - 1) / 2) + (core.status.event.ui.offset || 0); if (y >= topIndex && y < topIndex + choices.length) { // 选择 core.status.route.push("choices:" + (y - topIndex)); @@ -1207,7 +1207,7 @@ actions.prototype._clickShop = function (x, y) { var shop = core.status.event.data.shop; var choices = shop.choices; if (x >= this.CHOICES_LEFT && x <= this.CHOICES_RIGHT) { - var topIndex = this.HSIZE - parseInt(choices.length / 2); + var topIndex = this.HSIZE - parseInt(choices.length / 2) + (core.status.event.ui.offset || 0); if (y >= topIndex && y < topIndex + choices.length) { return core.events._useShop(shop, y - topIndex); } @@ -1237,7 +1237,7 @@ actions.prototype._clickQuickShop = function (x, y) { }); if (x >= this.CHOICES_LEFT && x <= this.CHOICES_RIGHT) { - var topIndex = this.HSIZE - parseInt(keys.length / 2); + var topIndex = this.HSIZE - parseInt(keys.length / 2) + (core.status.event.ui.offset || 0); if (y >= topIndex && y < topIndex + keys.length) { var reason = core.events.canUseQuickShop(keys[y - topIndex]); if (!core.flags.enableDisabledShop && reason) { @@ -1830,7 +1830,7 @@ actions.prototype._keyUpSL = function (keycode) { actions.prototype._clickSwitchs = function (x, y) { if (x < this.CHOICES_LEFT || x > this.CHOICES_RIGHT) return; var choices = core.status.event.ui.choices; - var topIndex = this.HSIZE - parseInt((choices.length - 1) / 2); + var topIndex = this.HSIZE - parseInt((choices.length - 1) / 2) + (core.status.event.ui.offset || 0); if (y >= topIndex && y < topIndex + choices.length) { var selection = y - topIndex; core.status.event.selection = selection; @@ -1927,7 +1927,7 @@ actions.prototype._keyUpSwitchs = function (keycode) { actions.prototype._clickSettings = function (x, y) { if (x < this.CHOICES_LEFT || x > this.CHOICES_RIGHT) return; var choices = core.status.event.ui.choices; - var topIndex = this.HSIZE - parseInt((choices.length - 1) / 2); + var topIndex = this.HSIZE - parseInt((choices.length - 1) / 2) + (core.status.event.ui.offset || 0); if (y >= topIndex && y < topIndex + choices.length) { var selection = y - topIndex; core.status.event.selection = selection; @@ -1978,7 +1978,7 @@ actions.prototype._keyUpSettings = function (keycode) { actions.prototype._clickSyncSave = function (x, y) { if (x < this.CHOICES_LEFT || x > this.CHOICES_RIGHT) return; var choices = core.status.event.ui.choices; - var topIndex = this.HSIZE - parseInt((choices.length - 1) / 2); + var topIndex = this.HSIZE - parseInt((choices.length - 1) / 2) + (core.status.event.ui.offset || 0); if (y >= topIndex && y < topIndex + choices.length) { var selection = y - topIndex; core.status.event.selection = selection; @@ -2061,7 +2061,7 @@ actions.prototype._clickSyncSelect = function (x, y) { if (x < this.CHOICES_LEFT || x > this.CHOICES_RIGHT) return; var choices = core.status.event.ui.choices; - var topIndex = this.HSIZE - parseInt((choices.length - 1) / 2); + var topIndex = this.HSIZE - parseInt((choices.length - 1) / 2) + (core.status.event.ui.offset || 0); if (y >= topIndex && y < topIndex + choices.length) { var selection = y - topIndex; core.status.event.selection = selection; @@ -2095,7 +2095,7 @@ actions.prototype._clickLocalSaveSelect = function (x, y) { if (x < this.CHOICES_LEFT || x > this.CHOICES_RIGHT) return; var choices = core.status.event.ui.choices; - var topIndex = this.HSIZE - parseInt((choices.length - 1) / 2); + var topIndex = this.HSIZE - parseInt((choices.length - 1) / 2) + (core.status.event.ui.offset || 0); if (y >= topIndex && y < topIndex + choices.length) { var selection = y - topIndex; @@ -2135,7 +2135,7 @@ actions.prototype._clickStorageRemove = function (x, y) { if (x < this.CHOICES_LEFT || x > this.CHOICES_RIGHT) return; var choices = core.status.event.ui.choices; - var topIndex = this.HSIZE - parseInt((choices.length - 1) / 2); + var topIndex = this.HSIZE - parseInt((choices.length - 1) / 2) + (core.status.event.ui.offset || 0); if (y >= topIndex && y < topIndex + choices.length) { var selection = y - topIndex; @@ -2224,7 +2224,7 @@ actions.prototype._clickReplay = function (x, y) { if (x < this.CHOICES_LEFT || x > this.CHOICES_RIGHT) return; var choices = core.status.event.ui.choices; - var topIndex = this.HSIZE - parseInt((choices.length - 1) / 2); + var topIndex = this.HSIZE - parseInt((choices.length - 1) / 2) + (core.status.event.ui.offset || 0); if (y >= topIndex && y < topIndex + choices.length) { var selection = y - topIndex; @@ -2278,7 +2278,7 @@ actions.prototype._clickGameInfo = function (x, y) { if (x < this.CHOICES_LEFT || x > this.CHOICES_RIGHT) return; var choices = core.status.event.ui.choices; - var topIndex = this.HSIZE - parseInt((choices.length - 1) / 2); + var topIndex = this.HSIZE - parseInt((choices.length - 1) / 2) + (core.status.event.ui.offset || 0); if (y >= topIndex && y < topIndex + choices.length) { var selection = y - topIndex; diff --git a/libs/control.js b/libs/control.js index 5f38acfd..4288890f 100644 --- a/libs/control.js +++ b/libs/control.js @@ -798,8 +798,8 @@ control.prototype._drawHero_getDrawObjs = function (direction, x, y, status, off }); (core.status.hero.followers||[]).forEach(function (t) { drawObjs.push({ - "img": t.img, - "height": t.img.height/4, + "img": core.material.images.images[t.name], + "height": core.material.images.images[t.name].height/4, "heroIcon": heroIconArr[t.direction], "posx": 32*t.x - core.bigmap.offsetX + (t.stop?0:core.utils.scan[t.direction].x*offset), "posy": 32*t.y - core.bigmap.offsetY + (t.stop?0:core.utils.scan[t.direction].y*offset), @@ -856,17 +856,20 @@ control.prototype.updateViewport = function() { ////// 获得勇士面对位置的x坐标 ////// control.prototype.nextX = function(n) { - return core.getHeroLoc('x')+core.utils.scan[core.getHeroLoc('direction')].x*(n||1); + if (n == null) n = 1; + return core.getHeroLoc('x')+core.utils.scan[core.getHeroLoc('direction')].x*n; } ////// 获得勇士面对位置的y坐标 ////// control.prototype.nextY = function (n) { - return core.getHeroLoc('y')+core.utils.scan[core.getHeroLoc('direction')].y*(n||1); + if (n == null) n = 1; + return core.getHeroLoc('y')+core.utils.scan[core.getHeroLoc('direction')].y*n; } ////// 某个点是否在勇士旁边 ////// -control.prototype.nearHero = function (x, y) { - return Math.abs(x-core.getHeroLoc('x'))+Math.abs(y-core.getHeroLoc('y'))<=1; +control.prototype.nearHero = function (x, y, n) { + if (n == null) n = 1; + return Math.abs(x-core.getHeroLoc('x'))+Math.abs(y-core.getHeroLoc('y'))<=n; } ////// 聚集跟随者 ////// @@ -916,6 +919,8 @@ control.prototype.checkBlock = function () { core.status.hero.hp -= damage; core.drawTip("受到"+(core.status.checkBlock.type[loc]||"伤害")+damage+"点"); this._checkBlock_soundAndAnimate(x, y); + this._checkBlock_disableQuickShop(); + core.status.hero.statistics.extraDamage += damage; if (core.status.hero.hp <= 0) { core.status.hero.hp=0; core.updateStatusBar(); @@ -932,6 +937,15 @@ control.prototype._checkBlock_soundAndAnimate = function (x,y) { core.drawAnimate("zone", x, y); } +control.prototype._checkBlock_disableQuickShop = function () { + // 禁用快捷商店 + if (core.flags.disableShopOnDamage) { + for (var shopId in core.status.shops) { + core.status.shops[shopId].visited = false; + } + } +} + ////// 阻击 ////// control.prototype._checkBlock_snipe = function (snipe) { if (!snipe || snipe.length == 0) return; @@ -1879,6 +1893,15 @@ control.prototype.getHeroLoc = function (name) { return core.status.hero.loc[name]; } +////// 获得某个属性的中文名 ////// +control.prototype.getStatusName = function (name) { + var map = { + name: "名称", lv: "等级", hpmax: "生命上限", hp: "生命", manamax: "魔力上限", mana: "魔力", + atk: "攻击", def: "防御", mdef: "魔防", money: "金币", exp: "经验", experience: "经验", steps: "步数" + }; + return map[name] || name; +} + ////// 获得某个等级的名称 ////// control.prototype.getLvName = function (lv) { if (!core.status.hero) return null; @@ -2637,7 +2660,7 @@ control.prototype._resize_toolBar = function (obj) { } control.prototype._resize_tools = function (obj) { - var toolsHeight = 32 * core.domStyle.scale * (core.domStyle.isVertical ? 0.95 : 1); + var toolsHeight = 32 * core.domStyle.scale * (core.domStyle.isVertical && !obj.is15x15 ? 0.95 : 1); var toolsMarginLeft; if (core.domStyle.isVertical) toolsMarginLeft = (core.__HALF_SIZE__ - 3) * 3 * core.domStyle.scale; diff --git a/libs/events.js b/libs/events.js index 814afc2b..7adeffb3 100644 --- a/libs/events.js +++ b/libs/events.js @@ -70,7 +70,7 @@ events.prototype._startGame_start = function (hard, seed, route, callback) { events.prototype._startGame_afterStart = function (nowLoc, callback) { core.ui.closePanel(); - core.showStatusBar(); + this._startGame_statusBar(); core.dom.musicBtn.style.display = 'none'; core.changeFloor(core.firstData.floorId, null, nowLoc, null, function () { // 插入一个空事件避免直接回放录像出错 @@ -80,6 +80,14 @@ events.prototype._startGame_afterStart = function (nowLoc, callback) { this._startGame_upload(); } +// 开始游戏时是否显示状态栏 +events.prototype._startGame_statusBar = function () { + if (core.flags.startUsingCanvas) + core.hideStatusBar(); + else + core.showStatusBar(); +} + events.prototype._startGame_upload = function () { // Upload var formData = new FormData(); @@ -382,6 +390,9 @@ events.prototype._openDoor_check = function (id, x, y, needKey) { return false; } + if (id == 'steelDoor' && core.flags.steelDoorWithoutKey) + needKey = false; + if (needKey && id.endsWith("Door")) { var key = id.replace("Door", "Key"); if (!core.hasItem(key)) { @@ -431,6 +442,7 @@ events.prototype._sys_getItem = function (data, callback) { ////// 获得某个物品 ////// events.prototype.getItem = function (id, num, x, y, callback) { + if (num == null) num = 1; num = num || 1; var itemCls = core.material.items[id].cls; core.items.getItemEffect(id, num); @@ -772,6 +784,8 @@ events.prototype.startEvents = function (list, x, y, callback) { events.prototype.doAction = function () { // 清空boxAnimate和UI层 core.clearUI(); + clearInterval(core.status.event.interval); + core.status.event.interval = null; // 判定是否执行完毕 if (this._doAction_finishEvents()) return; // 当前点坐标和前缀 @@ -1404,6 +1418,13 @@ events.prototype._action_while = function (data, x, y, prefix) { core.doAction(); } +events.prototype._action_dowhile = function (data, x, y, prefix) { + core.unshift(core.status.event.data.list, + {"todo": core.clone(data.data), "total": core.clone(data.data), "condition": data.condition} + ); + core.doAction(); +} + events.prototype._action_break = function (data, x, y, prefix) { core.status.event.data.list.shift(); core.doAction(); @@ -1427,6 +1448,10 @@ events.prototype._action_lose = function (data, x, y, prefix) { this.lose(data.reason); } +events.prototype._action_restart = function (data, x, y, prefix) { + core.restart(); +} + events.prototype._action_function = function (data, x, y, prefix) { var func = data["function"]; try { @@ -1714,7 +1739,7 @@ events.prototype.follow = function (name) { core.status.hero.followers = core.status.hero.followers || []; if (core.material.images.images[name] && core.material.images.images[name].width == 128) { - core.status.hero.followers.push({"name": name, "img": core.material.images.images[name]}); + core.status.hero.followers.push({"name": name}); core.gatherFollowers(); core.clearMap('hero'); core.drawHero(); diff --git a/libs/maps.js b/libs/maps.js index f03bfe60..52b540b4 100644 --- a/libs/maps.js +++ b/libs/maps.js @@ -977,10 +977,10 @@ maps.prototype._drawAutotileAnimate = function (block, animate) { if (block.name) { if (block.name == 'bg') core.drawImage('bg', core.material.groundCanvas.canvas, 32 * x, 32 * y); - this.drawAutotile(cv, core.status.autotileAnimateObjs[block.name+"map"], block, 32, 0, 0, animate); + this._drawAutotile(cv, core.status.autotileAnimateObjs[block.name+"map"], block, 32, 0, 0, animate); } else { - this.drawAutotile(cv, core.status.autotileAnimateObjs.map, block, 32, 0, 0, animate); + this._drawAutotile(cv, core.status.autotileAnimateObjs.map, block, 32, 0, 0, animate); } } @@ -1239,8 +1239,9 @@ maps.prototype.searchBlock = function (id, floorId, showDisable) { } for (var i = 0; i < core.status.maps[floorId].blocks.length; ++i) { var block = core.status.maps[floorId].blocks[i]; - if (block.event.id == id && (showDisable || !block.disable)) + if ((showDisable || !block.disable) && core.matchWildcard(id, block.event.id)) { result.push({floorId: floorId, index: i, block: block, x: block.x, y: block.y}); + } } return result; } @@ -1425,7 +1426,10 @@ maps.prototype.setBlock = function (number, x, y, floorId) { floorId = floorId || core.status.floorId; if (!floorId || number == null || x == null || y == null) return; if (x < 0 || x >= core.floors[floorId].width || y < 0 || y >= core.floors[floorId].height) return; - if (typeof number == 'string') number = core.getNumberById(number); + if (typeof number == 'string') { + if (/^\d+$/.test(number)) number = parseInt(number); + else number = core.getNumberById(number); + } var originBlock = core.getBlock(x, y, floorId, true); var block = this.initBlock(x, y, number, true, core.floors[floorId]); @@ -1479,6 +1483,10 @@ maps.prototype.setBgFgBlock = function (name, number, x, y, floorId) { if (!floorId || number == null || x == null || y == null) return; if (x < 0 || x >= core.floors[floorId].width || y < 0 || y >= core.floors[floorId].height) return; if (name != 'bg' && name != 'fg') return; + if (typeof number == 'string') { + if (/^\d+$/.test(number)) number = parseInt(number); + else number = core.getNumberById(number); + } var vFlag = "__" + name + "Value__" + floorId + "_" + x + "_" + y; core.setFlag(vFlag, number); diff --git a/libs/ui.js b/libs/ui.js index 9d63d8d0..e689ef59 100644 --- a/libs/ui.js +++ b/libs/ui.js @@ -261,8 +261,6 @@ ui.prototype.closePanel = function () { } ui.prototype.clearUI = function () { - clearInterval(core.status.event.interval); - core.status.event.interval = null; core.status.boxAnimateObjs = []; if (core.dymCanvas._selector) core.deleteCanvas("_selector"); core.clearMap('ui'); @@ -405,9 +403,9 @@ ui.prototype._getPosition = function (content) { py = core.status.event.data.y; } content = content.replace("\b", "\\b") - .replace(/\\b\[(up|center|down)(,(hero|null|\d+,\d+))?]/g, function (s0, s1, s2, s3) { + .replace(/\\b\[(up|center|down|hero|null)(,(hero|null|\d+,\d+))?]/g, function (s0, s1, s2, s3) { pos = s1; - if (s3 == 'hero') { + if (s3 == 'hero' || s1=='hero') { px = core.status.hero.loc.x; py = core.status.hero.loc.y; } @@ -419,6 +417,9 @@ ui.prototype._getPosition = function (content) { px = parseInt(str[0]); py = parseInt(str[1]); } + if(pos=='hero' || pos=='null'){ + pos = py==null?'center':(py>=core.__HALF_SIZE__? 'up':'down'); + } return ""; }); return {content: content, position: pos, px: px, py: py}; @@ -557,6 +558,9 @@ ui.prototype._calTextBoxWidth = function (ctx, content, min_width, max_width, fo ////// 处理 \i[xxx] 的问题 ui.prototype._getDrawableIconInfo = function (id) { + if (id && id.indexOf('flag:') === 0) { + id = core.getFlag(id.substring(5), id); + } var image = null, icon = null; ["terrains","animates","items","npcs","enemys"].forEach(function (v) { if (core.material.icons[v][id] != null) { @@ -588,14 +592,15 @@ ui.prototype.drawTextContent = function (ctx, content, config) { ctx = core.getContextByName(ctx); if (!ctx) return; // 设置默认配置项 + var textAttribute = core.status.textAttribute || core.initStatus.textAttribute; config = core.clone(config || {}); config.left = config.left || 0; config.right = config.left + (config.maxWidth == null ? ctx.canvas.width : config.maxWidth); config.top = config.top || 0; - config.color = config.color || core.arrayToRGBA(core.status.textAttribute.text); - config.bold = config.bold || false; - config.align = config.align || core.status.textAttribute.align || "left"; - config.fontSize = config.fontSize || core.status.textAttribute.textfont; + config.color = config.color || core.arrayToRGBA(textAttribute.text); + if (config.bold == null) config.bold = textAttribute.bold; + config.align = config.align || textAttribute.align || "left"; + config.fontSize = config.fontSize || textAttribute.textfont; config.lineHeight = config.lineHeight || (config.fontSize * 1.3); config.time = config.time || 0; @@ -769,8 +774,8 @@ ui.prototype.drawTextBox = function(content, showAll) { var textAttribute = core.status.textAttribute; var titleInfo = this._getTitleAndIcon(content); var posInfo = this._getPosition(titleInfo.content); - if (!posInfo.position) posInfo.position = textAttribute.position; if (posInfo.position != 'up' && posInfo.position != 'down') posInfo.px = posInfo.py = null; + if (!posInfo.position) posInfo.position = textAttribute.position; content = this._drawTextBox_drawImages(posInfo.content); // Step 2: 计算对话框的矩形位置 @@ -783,7 +788,7 @@ ui.prototype.drawTextBox = function(content, showAll) { var isWindowSkin = this.drawBackground(hPos.left, vPos.top, hPos.right, vPos.bottom, pInfo); var alpha = isWindowSkin ? 0.85 : textAttribute.background[3]; - // Step 4: 绘制标题、头像、 + // Step 4: 绘制标题、头像、动画 var content_top = this._drawTextBox_drawTitleAndIcon(titleInfo, hPos, vPos, alpha); // Step 5: 绘制正文 @@ -969,8 +974,10 @@ ui.prototype.drawChoices = function(content, choices) { content = core.replaceText(content || ""); var titleInfo = this._getTitleAndIcon(content); + titleInfo.content = this._drawTextBox_drawImages(titleInfo.content); var hPos = this._drawChoices_getHorizontalPosition(titleInfo, choices); var vPos = this._drawChoices_getVerticalPosition(titleInfo, choices, hPos); + core.status.event.ui.offset = vPos.offset; var isWindowSkin = this.drawBackground(hPos.left, vPos.top, hPos.right, vPos.bottom); this._drawChoices_drawTitle(titleInfo, hPos, vPos); @@ -999,14 +1006,22 @@ ui.prototype._drawChoices_getVerticalPosition = function (titleInfo, choices, hP var length = choices.length; var height = 32 * (length + 2), bottom = this.HPIXEL + height / 2; if (length % 2 == 0) bottom += 16; + var offset = 0; var choice_top = bottom - height + 56; if (titleInfo.content) { + var headHeight = 0; var realContent = this._getRealContent(titleInfo.content); var lines = core.splitLines('ui', realContent, hPos.validWidth, this._buildFont(15, true)); - if (titleInfo.title) height += 25; - height += lines.length * 20; + if (titleInfo.title) headHeight += 25; + headHeight += lines.length * 20; + height += headHeight; + if (bottom - height <= 32) { + offset = Math.floor(headHeight / 64); + bottom += 32 * offset; + choice_top += 32 * offset; + } } - return {top: bottom - height, height: height, bottom: bottom, choice_top: choice_top }; + return {top: bottom - height, height: height, bottom: bottom, choice_top: choice_top, offset: offset }; } ui.prototype._drawChoices_drawTitle = function (titleInfo, hPos, vPos) { @@ -1957,7 +1972,7 @@ ui.prototype._drawEquipbox_description = function (info, max_height) { this._drawEquipbox_drawStatusChanged(info, curr, equip, equipType); } -ui.prototype._drawEquipbox_drawStatusChanged = function (info, y, equip, equipType) { +ui.prototype._drawEquipbox_getStatusChanged = function (info, equip, equipType) { var compare, differentMode = null; if (info.index < this.LAST) compare = core.compareEquipment(null, info.selectId); else { @@ -1974,18 +1989,25 @@ ui.prototype._drawEquipbox_drawStatusChanged = function (info, y, equip, equipTy core.fillText('ui', differentMode, 10, y, '#CCCCCC', this._buildFont(14, false)); return; } + return compare; +} + +ui.prototype._drawEquipbox_drawStatusChanged = function (info, y, equip, equipType) { + var compare = this._drawEquipbox_getStatusChanged(info, equip, equipType); + if (compare == null) return; var drawOffset = 10; // --- 变化值... core.setFont('ui', this._buildFont(14, true)); for (var name in compare) { var img = core.statusBar.icons[name]; - if (img) { // 绘制图标 + var text = core.getStatusName(name); + if (img && core.flags.iconInEquipbox) { // 绘制图标 core.drawImage('ui', img, 0, 0, 32, 32, drawOffset, y - 13, 16, 16); drawOffset += 20; } else { // 绘制文字 - core.fillText('ui', name + " ", drawOffset, y, '#CCCCCC'); - drawOffset += core.calWidth('ui', name + " "); + core.fillText('ui', text + " ", drawOffset, y, '#CCCCCC'); + drawOffset += core.calWidth('ui', text + " "); } var nowValue = core.getStatus(name) * core.getBuff(name), newValue = (nowValue + compare[name]) * core.getBuff(name); if (equip.equip.percentage) { @@ -2003,13 +2025,14 @@ ui.prototype._drawEquipbox_drawStatusChanged = function (info, y, equip, equipTy } ui.prototype._drawEquipbox_drawEquiped = function (info, line) { - core.setTextAlign('ui', 'right'); + core.setTextAlign('ui', 'center'); var per_line = this.HSIZE - 3, width = Math.floor(this.PIXEL / (per_line + 0.25)); // 当前装备 for (var i = 0; i < info.equipLength ; i++) { var equipId = info.equipEquipment[i] || null; - var offset_text = width * (i % per_line) + 56; + // var offset_text = width * (i % per_line) + 56; var offset_image = width * (i % per_line) + width * 2 / 3; + var offset_text = offset_image - (width - 32) / 2; var y = line + 54 * Math.floor(i / per_line) + 19; if (equipId) { var icon = core.material.icons.items[equipId]; diff --git a/libs/utils.js b/libs/utils.js index d491197e..9260a9c7 100644 --- a/libs/utils.js +++ b/libs/utils.js @@ -247,7 +247,7 @@ utils.prototype.removeLocalForage = function (key, successCallback, errorCallbac } ////// 深拷贝一个对象 ////// -utils.prototype.clone = function (data) { +utils.prototype.clone = function (data, filter, recursion) { if (!core.isset(data)) return null; // date if (data instanceof Date) { @@ -258,10 +258,9 @@ utils.prototype.clone = function (data) { // array if (data instanceof Array) { var copy = []; - // for (var i=0;i threshold diff --git a/project/data.js b/project/data.js index ba2c9d99..d8d9ccae 100644 --- a/project/data.js +++ b/project/data.js @@ -12,7 +12,9 @@ var data_a1e2fb4a_e986_4524_b0da_9b7ba7c0874d = "bg.jpg", "winskin.png" ], - "tilesets": [], + "tilesets": [ + "magictower.png" + ], "animates": [ "hand", "sword", @@ -387,12 +389,15 @@ var data_a1e2fb4a_e986_4524_b0da_9b7ba7c0874d = "bombFourDirections": false, "snowFourDirections": false, "bigKeyIsBox": false, + "steelDoorWithoutKey": false, "equipment": false, "equipboxButton": false, + "iconInEquipbox": false, "enableAddPoint": false, "enableNegativeDamage": false, "hatredDecrease": true, "betweenAttackCeil": false, + "betweenAttackMax": false, "useLoop": false, "startUsingCanvas": false, "startDirectly": false, diff --git a/project/functions.js b/project/functions.js index 4e4c0762..1cee5278 100644 --- a/project/functions.js +++ b/project/functions.js @@ -522,6 +522,8 @@ var functions_d6ad677b_427a_4623_b50f_a445a3b0ef8a = var guards = []; // 检查光环缓存 var index = x != null && y != null ? (x + "," + y) : "floor"; + if (!core.status.checkBlock) core.status.checkBlock = {}; + if (!core.status.checkBlock.cache) core.status.checkBlock.cache = {}; var cache = core.status.checkBlock.cache[index]; if (!cache) { // 没有该点的缓存,则遍历每个图块 @@ -553,7 +555,6 @@ var functions_d6ad677b_427a_4623_b50f_a445a3b0ef8a = } }); - // 放入缓存中 core.status.checkBlock.cache[index] = { "hp_buff": hp_buff, "atk_buff": atk_buff, "def_buff": def_buff, "guards": guards }; } else { // 直接使用缓存数据 @@ -1202,10 +1203,16 @@ var functions_d6ad677b_427a_4623_b50f_a445a3b0ef8a = } if (enemyId != null) { - var leftHp = core.status.hero.hp - (damage[x + "," + y] || 0); + var leftHp = core.status.hero.hp - (damage[loc] || 0); if (leftHp > 1) { // 上整/下整 - var value = Math.floor((leftHp + (core.flags.betweenAttackCeil ? 0 : 1)) / 2); + var value = Math.floor((leftHp + (core.flags.betweenAttackCeil ? 1 : 0)) / 2); + // 是否不超过怪物伤害值 + if (core.flags.betweenAttackMax) { + var enemyDamage = core.getDamage(enemyId, x, y, floorId); + if (enemyDamage != null && enemyDamage < value) + value = enemyDamage; + } damage[loc] = (damage[loc] || 0) + value; type[loc] = "夹击伤害"; } @@ -1219,7 +1226,7 @@ var functions_d6ad677b_427a_4623_b50f_a445a3b0ef8a = type: type, snipe: snipe, ambush: ambush, - cache: {} + cache: {} // clear cache }; }, "moveOneStep": function (x, y) { diff --git a/project/images/autotile1.png b/project/images/autotile1.png index 2dacd883..37a0b271 100644 Binary files a/project/images/autotile1.png and b/project/images/autotile1.png differ diff --git a/project/images/magictower.png b/project/images/magictower.png new file mode 100644 index 00000000..8e0a90d3 Binary files /dev/null and b/project/images/magictower.png differ diff --git a/更新说明.txt b/更新说明.txt index 4bf78891..ec9833e3 100644 --- a/更新说明.txt +++ b/更新说明.txt @@ -1,4 +1,24 @@ -HTML5魔塔样板V2.5.5 +HTML5魔塔样板V2.6 + +拆分整个项目,大幅重构代码,新增大量API +重写文档,尤其是脚本和API列表 +现在可以对编辑器的表格的结构进行配置 +可以收藏和高亮存档 +独立出来的插件编写 +新增事件:关门、显示确认框、后置循环处理 +剧情文本的绘制可以设置居中选项 +选项框的绘制可以增加图标 +增加公共事件版的全局商店 +公共事件现在可以传入参数 +重写滑冰事件,现在滑冰在背景层了 +将输入框改成自定义实现,避免部分设备不支持 +状态栏文字可以自动放缩 +显示图片和对话框立绘可以裁剪图片 +修复所有已知bug,大量细节优化 + +----------------------------------------------------------------------- + +HTML5魔塔样板V2.5.5 现在编辑器修改地图后可以直接读档生效,无需再重置地图或回放录像 存档方式优化,大幅降低单个存档的占用空间