diff --git a/API列表.txt b/API列表.txt index 4a12de10..6140cf9e 100644 --- a/API列表.txt +++ b/API列表.txt @@ -685,10 +685,6 @@ core.updateHeroIcon() 更新状态栏上的勇士图标。 -core.updateGlobalAttribute() -更新全局属性,例如状态栏的背景图等。 - - core.setToolbarButton(useButtom) 设置工具栏是否是拓展键盘。 diff --git a/_docs/api.md b/_docs/api.md index 0519a600..badadd59 100644 --- a/_docs/api.md +++ b/_docs/api.md @@ -684,10 +684,6 @@ core.updateHeroIcon() 更新状态栏上的勇士图标。 -core.updateGlobalAttribute() -更新全局属性,例如状态栏的背景图等。 - - core.setToolbarButton(useButtom) 设置工具栏是否是拓展键盘。 diff --git a/_docs/element.md b/_docs/element.md index 3b622883..099a9fca 100644 --- a/_docs/element.md +++ b/_docs/element.md @@ -139,7 +139,7 @@ N连击怪物的special是6,且我们可以为它定义n代表实际连击数 领域怪还可以设置`range`选项代表该领域怪的范围,不写则默认为1。
**将 `flags.no_zone` 设置为 `true` 可以免疫领域效果。**
阻击怪同样需要设置value,代表阻击伤害的数值。如果勇士生命值扣减到0,则直接死亡触发lose事件。 -
**将`flags.no_snipe`设置为true可以免疫阻击效果(包括伤害和移动!)。**
+
**将`flags.no_repulse`设置为true可以免疫阻击效果(包括伤害和移动!)。**
!> 阻击怪后退的地点不能有任何事件存在,即使是已经被禁用的红绿事件或重生怪!(会导致此事件意外被重新启用)
激光怪同样需要设置value,代表激光伤害的数值。
请注意如果吸血、领域、阻击、生命光环中任何两个同时存在,则 `value` 会冲突。**因此请勿将吸血、领域、阻击或激光放置在同一个怪物身上。退化和攻防光环同理!
** diff --git a/_docs/event.md b/_docs/event.md index 87fab1b2..03d00562 100644 --- a/_docs/event.md +++ b/_docs/event.md @@ -383,7 +383,7 @@ value为必填项,代表要修改到的内容。对于修改名称的,必须 {"type": "setFloor", "name": "title", "value": "'主塔 0 层'" } // 设置当前楼层的中文名为主塔0层 {"type": "setFloor", "name": "canFlyTo", "floorId": "MT2", "value": "false" } // 设置MT2层不可飞行 {"type": "setFloor", "name": "cannotViewMap", "floorId": "MT0", "value": "true" } // 设置MT0层不可被浏览地图 - {"type": "setFloor", "name": "item_ratio", "value": "5" } // 设置当前楼层的宝石血瓶属性加成为5 + {"type": "setFloor", "name": "ratio", "value": "5" } // 设置当前楼层的宝石血瓶属性加成为5 {"type": "setFloor", "name": "images", "value": "[[0,0,'tree.png',2]]" } // 设置当前楼层的楼层贴图 {"type": "setFloor", "name": "upFloor", "value": "[2,3]" } // 设置当前楼层的上楼梯 {"type": "setFloor", "name": "bgm", "floorId": "MT10", "value": "'233.mp3'" } // 设置当前楼层的背景音乐 @@ -2174,7 +2174,7 @@ if (core.flags.enableAddPoint && point > 0) { ``` json "shops": [{ "id": "shop1", - "text": "\t[贪婪之神,blueShop]勇敢的武士啊, 给我${20+2*flag:shop1}金币就可以:", + "text": "\t[贪婪之神,moneyShop]勇敢的武士啊, 给我${20+2*flag:shop1}金币就可以:", "textInList": "1F金币商店", "mustEnable": false, "disablePreview": false, diff --git a/_docs/personalization.md b/_docs/personalization.md index e49bde8a..c554b497 100644 --- a/_docs/personalization.md +++ b/_docs/personalization.md @@ -236,7 +236,7 @@ ID必须由数字字母下划线组成,数字在1000以内,且均不能和 除此之外,额外素材在游戏中的使用和正式素材都是一致的,也能在前景或背景图层绘制。 -额外素材可以使用“tileset贴图”的方式进行绘制,一次绘制一个矩形区域。 +额外素材可以使用“tileset平铺”的方式进行绘制,一次绘制一个矩形区域。 “辅助工具”中提供了“额外素材合并”,如果使用此功能,请不要对额外素材进行基于ID、索引和数字的判定和读写等操作,如确有此需求,可以创建一些玩家不可达也不可预览的隐藏样板层,然后用等量代换的办法去从样板层取用。 ## 自定义道具效果 @@ -249,21 +249,18 @@ ID必须由数字字母下划线组成,数字在1000以内,且均不能和 如果你想要同种宝石在不同层效果不同的话,可以进行如下操作: -1. 在楼层的item_ratio中定义宝石的比率(比如1-10的写1,11-20层写2等) +1. 在楼层的ratio中定义宝石的比率(比如1-10的写1,11-20层写2等) 2. 修改获得道具的itemEffect函数(编辑器中双击进行编辑) ``` js -// ratio为楼层的item_ratio值,可以进行翻倍宝石属性 -core.status.hero.atk += core.values.redJewel * ratio +core.status.hero.atk += core.values.redGem * core.status.thisMap.ratio ``` -这里我们可以直接写ratio来取用该楼层中定义的`item_ratio`的值。 - 如果不是倍数增加(比如线性增加)也可以类似来写 ``` js // 一个二倍线性增加的例子 -core.status.hero.atk += core.values.redJewel + 2*ratio +core.status.hero.atk += core.values.redGem + 2*core.status.thisMap.ratio ``` ### 消耗类道具(cls: tools);永久类道具(cls: constants) @@ -308,11 +305,11 @@ function (enemy, hero_hp, hero_atk, hero_def, hero_mdef, x, y, floorId) { [ // 写在获得道具后事件 // 设置不同的flag可以分别无视对应的阻激夹域效果 {"type": "setValue", "name": "flag:no_zone", "value": "true"}, // 免疫领域 - {"type": "setValue", "name": "flag:no_snipe", "value": "true"}, // 免疫阻击 + {"type": "setValue", "name": "flag:no_repulse", "value": "true"}, // 免疫阻击 {"type": "setValue", "name": "flag:no_laser", "value": "true"}, // 免疫激光 {"type": "setValue", "name": "flag:no_betweenAttack", "value": "true"}, // 免疫夹击 {"type": "setValue", "name": "flag:no_ambush", "value": "true"}, // 免疫捕捉 - {"type": "setValue", "name": "item:shoes", "value": "1"} // 免疫路障 + {"type": "setValue", "name": "item:amulet", "value": "1"} // 免疫路障 ] ``` 4. 如果有更高的需求,例如想让吸血效果变成一半,则还是在上面这些地方进行对应的修改即可。 @@ -666,7 +663,7 @@ if (core.flags.statusBarItems.indexOf('enableSkill')>=0) { - **`flag:hard`**: 当前的难度标志;此flag变量在setInitData中被定义,可以直接取用来判定当前难度分歧。上传成绩时将根据此flag来对不同难度进行排序。 - **`flag:posion`**, **`flag:weak`**, **`flag:curse`**: 中毒、衰弱、诅咒状态。 -- **`flag:no_zone`**, **`flag:no_snipe`**, **`flag:no_laser`**, **`flag:no_betweenAttack`**: 是否分别免疫领域、阻击、激光、夹击效果。 +- **`flag:no_zone`**, **`flag:no_repulse`**, **`flag:no_laser`**, **`flag:no_betweenAttack`**: 是否分别免疫领域、阻击、激光、夹击效果。 - **`flag:hatred`**: 当前的仇恨数值。 - **`flag:commonTimes`**: 全局商店共用次数时的访问次数。 - **`flag:input`**: 接受用户输入的事件后,存放用户输入的结果。 diff --git a/_server/MotaAction.g4 b/_server/MotaAction.g4 index 54c2834a..7497c0c3 100644 --- a/_server/MotaAction.g4 +++ b/_server/MotaAction.g4 @@ -1,4 +1,25 @@ // 编辑此文件用的vscode插件: https://marketplace.visualstudio.com/items?itemName=zhaouv.vscode-mota-js-extension +// 此文件通过antlr-blockly生成编辑器中的图块, 相关帮助说明: https://zhaouv.github.io/antlr-blockly/docs/#/README + + +/* +特殊注入demo +doubleclicktext : EvalString_1 +previewBlock : true +// [x, y, floorId, forceFloor] +selectPoint : ["PosString_0", "PosString_1", "IdString_0", true] +// 自动补全 +allIds : ['EvalString_1'] +allEnemys : ['EvalString_1'] +allItems : ['EvalString_1'] +allImages : ['EvalString_1'] +allAnimates : ['EvalString_1'] +allBgms : ['EvalString_1'] +allSounds : ['EvalString_1'] +allShops : ['EvalString_1'] +allFloorIds : ['EvalString_1'] +*/ + grammar MotaAction; @@ -109,7 +130,9 @@ shopsub /* shopsub tooltip : 全局商店 helpUrl : https://h5mota.com/games/template/_docs/#/event?id=%e5%85%a8%e5%b1%80%e5%95%86%e5%ba%97 -default : ["shop1","贪婪之神","blueShop","勇敢的武士啊, 给我${20+2*flag:shop1}金币就可以:","金币商店",false,false] +doubleclicktext : EvalString_1 +allIds : ['IdString_1'] +default : ["shop1","贪婪之神","moneyShop","勇敢的武士啊, 给我${20+2*flag:shop1}金币就可以:","金币商店",false,false] var title=''; if (EvalString_0==''){ if (IdString_1=='') title=''; @@ -138,6 +161,7 @@ shopChoices tooltip : 商店选项,商店消耗是-1时,这里的消耗对应各自选项的消耗,商店消耗不是-1时这里的消耗不填 helpUrl : https://h5mota.com/games/template/_docs/#/event?id=%e5%85%a8%e5%b1%80%e5%95%86%e5%ba%97 default : ["攻击+1","status:money>=20+2*flag:shop1","","","rgba(255,255,255,1)",""] +allIds : ['IdString_0'] colour : this.subColor ColorString_0 = ColorString_0 ? (', "color": ['+ColorString_0+']') : ''; EvalString_2 = EvalString_2 && (', "condition": "'+EvalString_2+'"') @@ -278,6 +302,8 @@ changeFloor_m tooltip : 楼梯, 传送门, 如果目标楼层有多个楼梯, 写upFloor或downFloor可能会导致到达的楼梯不确定, 这时候请使用loc方式来指定具体的点位置 helpUrl : https://h5mota.com/games/template/_docs/#/element?id=%e8%b7%af%e9%9a%9c%ef%bc%8c%e6%a5%bc%e6%a2%af%ef%bc%8c%e4%bc%a0%e9%80%81%e9%97%a8 default : [null,"MTx",null,"","",null,"",null] +selectPoint : ["PosString_0", "PosString_1", "IdString_0", true] +allFloorIds : ['IdString_0'] var toFloorId = IdString_0; if (Floor_List_0!='floorId') toFloorId = Floor_List_0; var loc = ''; @@ -322,6 +348,244 @@ var code = '[\n'+action_0+']\n'; return code; */; +// levelChoose 事件编辑器入口之一 +levelChoose_m + : '难度分歧' BGNL? levelChooseList+ BEND + + +/* levelChoose_m +tooltip : 难度分歧 +helpUrl : https://h5mota.com/games/template/_docs/#/event +var code = '[\n'+levelChooseList_0+']\n'; +return code; +*/; + +levelChooseList + : levelChooseChoice + | levelChooseEmpty; + +levelChooseEmpty + : Newline + +/* levelChooseEmpty +var code = ' \n'; +return code; +*/; + +levelChooseChoice + : '难度分歧项' '名称' EvalString '简写' EvalString '变量:hard值' Int '颜色' ColorString? Colour BGNL Newline action+ BEND + +/* levelChooseChoice +tooltip : 难度分歧项 +helpUrl : https://h5mota.com/games/template/_docs/#/event +default : ['简单','Easy',1,''] +ColorString_0 = ColorString_0 ? (', "color": [' + ColorString_0 + ']') : ''; +var code = '{"title": "'+EvalString_0+'", "name": "'+EvalString_1+'", "hard": '+Int_0+ColorString_0+', "action": [\n'+action_0+']},\n'; +return code; +*/; + +// equip 事件编辑器入口之一 +equip_m + : '装备' '类型' EvalString '装备动画(第一个装备格有效)' IdString? BGNL? '数值提升项' equipList+ '百分比提升项' equipList+ BEND + + +/* equip_m +tooltip : 装备 +default : ['0', ''] +helpUrl : https://h5mota.com/games/template/_docs/#/event +allAnimates : ['IdString_0'] +if (!/^\d+$/.test(EvalString_0)) { + EvalString_0 = '"' + EvalString_0 + '"'; +} +IdString_0 = IdString_0 && (', "animate": "'+IdString_0+'"'); +var code = '{"type": '+EvalString_0+IdString_0+', "value": {\n'+equipList_0+'\n}, "percentage": {\n'+equipList_1+'\n}}'; +return code; +*/; + +equipList + : equipKnown + | equipUnknown + | equipEmpty; + + +equipKnown + : Equip_List ':' Number BEND + + +/* equipKnown +tooltip : 装备项 +default : ['atk', 10] +helpUrl : https://h5mota.com/games/template/_docs/#/event +return '"'+Equip_List_0+'": '+Number_0+', '; +*/; + +equipUnknown + : EvalString ':' Number BEND + + +/* equipUnknown +tooltip : 装备项 +default : ['speed', 10] +helpUrl : https://h5mota.com/games/template/_docs/#/event +return '"'+EvalString_0+'": '+Number_0+', '; +*/; + + +equipEmpty + : Newline + +/* equipEmpty +var code = ' \n'; +return code; +*/; + +floorImage_m + : '楼层贴图' BGNL? Newline floorImageList+ BEND + + +/* floorImage_m +tooltip : 楼层贴图 +helpUrl : https://h5mota.com/games/template/_docs/#/event +var code = '[\n'+floorImageList_0+']\n'; +return code; +*/; + +floorImageList + : floorOneImage + | floorEmptyImage; + +floorOneImage + : '图片名' EvalString '翻转' Reverse_List '图层' Bg_Fg2_List '绘制坐标' 'x' Int 'y' Int '初始禁用' Bool BGNL? Newline + '裁剪起点坐标' 'x' IntString? 'y' IntString? '宽' IntString? '高' IntString? '帧数' IntString? BEND + + +/* floorOneImage +tooltip : 楼层贴图 +default : ["bg.jpg","null","bg",0,0,false,"","","","",""] +helpUrl : https://h5mota.com/games/template/_docs/#/event +allImages : ['EvalString_0'] +if (Reverse_List_0 && Reverse_List_0 != 'null') { + Reverse_List_0 = ', "reverse": "' + Reverse_List_0 + '"'; +} else Reverse_List_0 = ''; +Bool_0 = Bool_0 ? (', "disable": true') : ''; +IntString_0 = IntString_0 && (', "sx": '+IntString_0); +IntString_1 = IntString_1 && (', "sy": '+IntString_1); +IntString_2 = IntString_2 && (', "w": '+IntString_2); +IntString_3 = IntString_3 && (', "h": '+IntString_3); +IntString_4 = IntString_4 && (', "frame": '+IntString_4); +return '{"name": "'+EvalString_0+'"'+Reverse_List_0+', "canvas": "'+Bg_Fg2_List_0+'", "x": '+Int_0+', "y": '+Int_1+Bool_0+IntString_0+IntString_1+IntString_2+IntString_3+IntString_4+'},\n'; +*/; + +floorEmptyImage + : Newline + +/* floorEmptyImage +var code = ' \n'; +return code; +*/; + + +// doorInfo 事件编辑器入口之一 +doorInfo_m + : '门信息' '开关门时间' Int '开门音效' EvalString? '关门音效' EvalString? BGNL? Newline '需要钥匙' doorKeyList+ BEND + + +/* doorInfo_m +tooltip : 开门信息 +default : [160, 'door.mp3', 'door.mp3'] +helpUrl : https://h5mota.com/games/template/_docs/#/event +EvalString_0 = EvalString_0 && (', "openSound": "' + EvalString_0 + '"'); +EvalString_1 = EvalString_1 && (', "closeSound": "' + EvalString_1 + '"'); +var code = '{"time": '+Int_0+EvalString_0+EvalString_1+', "keys": {\n'+doorKeyList_0+'\n}}'; +return code; +*/; + +doorKeyList + : doorKeyKnown + | doorKeyUnknown + | doorKeyEmpty; + + +doorKeyKnown + : Key_List ':' Int BEND + + +/* doorKeyKnown +tooltip : 需要钥匙 +default : ['yellowKey', 1] +helpUrl : https://h5mota.com/games/template/_docs/#/event +return '"'+Key_List_0+'": '+Int_0+', '; +*/; + +doorKeyUnknown + : IdString ':' Int BEND + + +/* doorKeyUnknown +tooltip : 需要钥匙 +default : ['orangeKey', 1] +helpUrl : https://h5mota.com/games/template/_docs/#/event +allItems : ['IdString_0'] +return '"'+IdString_0+'": '+Int_0+', '; +*/; + + +doorKeyEmpty + : Newline + +/* doorKeyEmpty +var code = ' \n'; +return code; +*/; + + +faceIds_m + : '行走图朝向:' BGNL? Newline '向上ID' IdString? '向下ID' IdString? '向左ID' IdString? '向右ID' IdString? BEND + + +/* faceIds_m +tooltip : 行走图朝向 +default : ["","","",""] +allIds : ['IdString_0','IdString_1','IdString_2','IdString_3'] +helpUrl : https://h5mota.com/games/template/_docs/#/event +return '{' + [ + IdString_0 && ('"up": "' + IdString_0 +'"'), + IdString_1 && ('"down": "' + IdString_1 +'"'), + IdString_2 && ('"left": "' + IdString_2 +'"'), + IdString_3 && ('"right": "' + IdString_3 +'"'), +].filter(function (x) { return x; }).join(', ') + '}\n'; +*/; + + +mainStyle_m + : '主要样式设置:' '标题界面背景图(全路径):' EvalString BGNL? Newline + '标题样式;可写 display: none 隐藏标题' EvalString BGNL? Newline + '标题按钮样式:' EvalString BGNL? Newline + '横屏状态栏背景;url(...) 0 0/100% 100% no-repeat 可将图片拉伸自适配' BGNL? Newline EvalString BGNL? Newline + '竖屏状态栏背景:' EvalString BGNL? Newline + '竖屏工具栏背景:' EvalString BGNL? Newline + '楼层切换样式:' EvalString BGNL? Newline + '状态栏颜色' ColorString Colour '边框颜色' ColorString Colour '全局字体' EvalString BEND + +/* mainStyle_m +tooltip : 主要样式设置 +default : ["project/images/bg.jpg", "color: black", "background-color: #32369F; opacity: 0.85; color: #FFFFFF; border: #FFFFFF 2px solid; caret-color: #FFD700;", "url(project/materials/ground.png) repeat", "url(project/materials/ground.png) repeat", "url(project/materials/ground.png) repeat", "background-color: black; color: white", "255,255,255,1", "rgba(255,255,255,1)", "204,204,204,1", "rgba(204,204,204,1)", "Verdana"] +helpUrl : https://h5mota.com/games/template/_docs/#/event +var code = { + startBackground: EvalString_0, + startLogoStyle: EvalString_1, + startButtonsStyle: EvalString_2, + statusLeftBackground: EvalString_3, + statusTopBackground: EvalString_4, + toolsBackground: EvalString_5, + floorChangingStyle: EvalString_6, + statusBarColor: JSON.parse('['+ColorString_0+']'), + borderColor: JSON.parse('['+ColorString_1+']'), + font: EvalString_7 +}; +return JSON.stringify(code); +*/; + //为了避免关键字冲突,全部加了_s //动作 action @@ -455,6 +719,7 @@ text_0_s /* text_0_s tooltip : text:显示一段文字(剧情) helpUrl : https://h5mota.com/games/template/_docs/#/event?id=text%EF%BC%9A%E6%98%BE%E7%A4%BA%E4%B8%80%E6%AE%B5%E6%96%87%E5%AD%97%EF%BC%88%E5%89%A7%E6%83%85%EF%BC%89 +doubleclicktext : EvalString_0 default : ["欢迎使用事件编辑器(双击方块进入多行编辑)"] var code = '"'+EvalString_0+'",\n'; return code; @@ -467,6 +732,8 @@ text_1_s /* text_1_s tooltip : text:显示一段文字(剧情),选项较多请右键点击帮助 helpUrl : https://h5mota.com/games/template/_docs/#/event?id=text%EF%BC%9A%E6%98%BE%E7%A4%BA%E4%B8%80%E6%AE%B5%E6%96%87%E5%AD%97%EF%BC%88%E5%89%A7%E6%83%85%EF%BC%89 +doubleclicktext : EvalString_3 +allIds : ['EvalString_1'] default : ["小妖精","fairy","","欢迎使用事件编辑器(双击方块进入多行编辑)"] var title=''; if (EvalString_0==''){ @@ -476,7 +743,7 @@ if (EvalString_0==''){ if (EvalString_1=='')title='\\t['+EvalString_0+']'; else title='\\t['+EvalString_0+','+EvalString_1+']'; } -if(EvalString_2 && !(/^(up|center|down|hero|null)(,(hero|null|\d+,\d+|\d+))?$/.test(EvalString_2))) { +if(EvalString_2 && !(/^(up|center|down|hero|this)(,(hero|null|\d+,\d+|\d+))?$/.test(EvalString_2))) { throw new Error('对话框效果的用法请右键点击帮助'); } EvalString_2 = EvalString_2 && ('\\b['+EvalString_2+']'); @@ -491,6 +758,7 @@ comment_s /* comment_s tooltip : comment:添加一段会被游戏跳过的注释内容 helpUrl : https://h5mota.com/games/template/_docs/#/event?id=comment%ef%bc%9a%e6%b7%bb%e5%8a%a0%e6%b3%a8%e9%87%8a +doubleclicktext : EvalString_0 default : ["可以在这里写添加任何注释内容"] colour : this.commentColor var code = '{"type": "comment", "text": "'+EvalString_0+'"},\n'; @@ -504,6 +772,8 @@ autoText_s /* autoText_s tooltip : autoText:自动剧情文本,用户无法跳过自动剧情文本,大段剧情文本请添加“是否跳过剧情”的提示 helpUrl : https://h5mota.com/games/template/_docs/#/event?id=autotext%EF%BC%9A%E8%87%AA%E5%8A%A8%E5%89%A7%E6%83%85%E6%96%87%E6%9C%AC +doubleclicktext : EvalString_2 +allIds : ['EvalString_1'] default : ["小妖精","fairy","",3000,"用户无法跳过自动剧情文本,大段剧情文本请添加“是否跳过剧情”的提示"] var title=''; if (EvalString_0==''){ @@ -513,7 +783,7 @@ if (EvalString_0==''){ if (EvalString_1=='')title='\\t['+EvalString_0+']'; else title='\\t['+EvalString_0+','+EvalString_1+']'; } -if(EvalString_2 && !(/^(up|down)(,hero)?(,([+-]?\d+),([+-]?\d+))?$/.test(EvalString_2))) { +if(EvalString_2 && !(/^(up|center|down|hero|this)(,(hero|null|\d+,\d+|\d+))?$/.test(EvalString_2))) { throw new Error('对话框效果的用法请右键点击帮助'); } EvalString_2 = EvalString_2 && ('\\b['+EvalString_2+']'); @@ -528,6 +798,7 @@ scrollText_s /* scrollText_s tooltip : scrollText:滚动剧情文本,将从下到上进行滚动显示。 helpUrl : https://h5mota.com/games/template/_docs/#/event?id=scrollText%ef%bc%9a%e6%bb%9a%e5%8a%a8%e5%89%a7%e6%83%85%e6%96%87%e6%9c%ac +doubleclicktext : EvalString_0 default : [5000,1.4,false,"时间是总时间,可以使用setText事件来控制字体、颜色、大小、偏移量等"] Bool_0 = Bool_0?', "async": true':''; var code = '{"type": "scrollText", "text": "'+EvalString_0+'"'+Bool_0+', "time" :'+Int_0+', "lineHeight": '+Number_0+'},\n'; @@ -576,6 +847,7 @@ tip_s /* tip_s tooltip : tip:显示一段提示文字 helpUrl : https://h5mota.com/games/template/_docs/#/event?id=tip%EF%BC%9A%E6%98%BE%E7%A4%BA%E4%B8%80%E6%AE%B5%E6%8F%90%E7%A4%BA%E6%96%87%E5%AD%97 +allIds : ['IdString_0'] default : ["这段话将在左上角以气泡形式显示",""] IdString_0 = IdString_0 && (', "icon": "' + IdString_0 + '"'); var code = '{"type": "tip", "text": "'+EvalString_0+'"'+IdString_0+'},\n'; @@ -605,8 +877,9 @@ setEnemy_s /* setEnemy_s tooltip : setEnemy:设置某个怪物的属性 -default : ["greenSlime", "atk", "0"] helpUrl : https://h5mota.com/games/template/_docs/#/event?id=setEnemy%ef%bc%9a%e5%a2%9e%e5%87%8f%e5%8b%87%e5%a3%ab%e7%9a%84%e6%9f%90%e4%b8%aa%e5%b1%9e%e6%80%a7%e3%80%81%e9%81%93%e5%85%b7%e4%b8%aa%e6%95%b0%ef%bc%8c%e6%88%96%e6%9f%90%e4%b8%aa%e5%8f%98%e9%87%8f%2fFlag%e7%9a%84%e5%80%bc +default : ["greenSlime", "atk", "0"] +allEnemys : ['IdString_0'] colour : this.dataColor var code = '{"type": "setEnemy", "id": "'+IdString_0+'", "name": "'+EnemyId_List_0+'", "value": "'+expression_0+'"},\n'; return code; @@ -614,16 +887,17 @@ return code; setFloor_s - : '设置楼层属性' ':' Floor_Meta_List '楼层名' IdString? '值' EvalString Newline + : '设置楼层属性' ':' Floor_Meta_List '楼层名' IdString? '值' JsonEvalString Newline /* setFloor_s tooltip : setFloor:设置楼层属性;该楼层属性和编辑器中的楼层属性一一对应 helpUrl : https://h5mota.com/games/template/_docs/#/event?id=setFloor%ef%bc%9a%e8%ae%be%e7%bd%ae%e6%a5%bc%e5%b1%82%e5%b1%9e%e6%80%a7 -default : ["title","","'字符串类型的值要加引号,其他类型则不用'"] +default : ["title","","\"新楼层名\""] +allFloorIds : ['IdString_0'] colour : this.dataColor IdString_0 = IdString_0 && (', "floorId": "'+IdString_0+'"'); -var code = '{"type": "setFloor", "name": "'+Floor_Meta_List_0+'"'+IdString_0+', "value": "'+EvalString_0+'"},\n'; +var code = '{"type": "setFloor", "name": "'+Floor_Meta_List_0+'"'+IdString_0+', "value": '+JsonEvalString_0+'},\n'; return code; */; @@ -678,6 +952,8 @@ 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 : ["","","","",false] +selectPoint : ["EvalString_0", "EvalString_1", "IdString_0"] +allFloorIds : ['IdString_0'] colour : this.mapColor var floorstr = ''; if (EvalString_0 && EvalString_1) { @@ -711,6 +987,8 @@ hide_s tooltip : hide: 隐藏事件,同时可删除 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 : ["","","",true,"",false] +selectPoint : ["EvalString_0", "EvalString_1", "IdString_0"] +allFloorIds : ['IdString_0'] colour : this.mapColor var floorstr = ''; if (EvalString_0 && EvalString_1) { @@ -745,6 +1023,7 @@ trigger_s tooltip : trigger: 立即触发另一个地点的事件 helpUrl : https://h5mota.com/games/template/_docs/#/event?id=trigger%EF%BC%9A%E7%AB%8B%E5%8D%B3%E8%A7%A6%E5%8F%91%E5%8F%A6%E4%B8%80%E4%B8%AA%E5%9C%B0%E7%82%B9%E7%9A%84%E4%BA%8B%E4%BB%B6 default : ["",""] +selectPoint : ["PosString_0", "PosString_1"] colour : this.eventColor var floorstr = ''; if (PosString_0 && PosString_1) { @@ -781,6 +1060,8 @@ tooltip : insert: 立即插入另一个地点的事件执行,当前事件不 helpUrl : https://h5mota.com/games/template/_docs/#/event?id=insert%ef%bc%9a%e6%8f%92%e5%85%a5%e5%85%ac%e5%85%b1%e4%ba%8b%e4%bb%b6%e6%88%96%e5%8f%a6%e4%b8%80%e4%b8%aa%e5%9c%b0%e7%82%b9%e7%9a%84%e4%ba%8b%e4%bb%b6%e5%b9%b6%e6%89%a7%e8%a1%8c default : ["0","0",null,"",""] colour : this.eventColor +allFloorIds : ['IdString_0'] +selectPoint : ["PosString_0", "PosString_1", "IdString_0"] IdString_0 = IdString_0 && (', "floorId": "'+IdString_0+'"'); if (JsonEvalString_0) { if (!(JSON.parse(JsonEvalString_0) instanceof Array)) @@ -811,14 +1092,17 @@ return code; */; setBlock_s - : '转变图块为' EvalString 'x' EvalString? ',' 'y' EvalString? '楼层' IdString? Newline + : '转变图块为' EvalString 'x' EvalString? ',' 'y' EvalString? '楼层' IdString? '动画时间' IntString? '不等待执行完毕' Bool 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.mapColor -default : ["yellowDoor","","",""] +allFloorIds : ['IdString_0'] +allIds : ['EvalString_0'] +default : ["yellowDoor","","","","",false] +selectPoint : ["EvalString_1", "EvalString_2", "IdString_0"] var floorstr = ''; if (EvalString_1 && EvalString_2) { var pattern1 = MotaActionFunctions.pattern.id; @@ -837,7 +1121,9 @@ if (EvalString_1 && EvalString_2) { floorstr = ', "loc": ['+EvalString_1.join(',')+']'; } IdString_0 = IdString_0 && (', "floorId": "'+IdString_0+'"'); -var code = '{"type": "setBlock", "number": "'+EvalString_0+'"'+floorstr+IdString_0+'},\n'; +IntString_0 = IntString_0 && (', "time": ' + IntString_0); +Bool_0 = Bool_0 ? (', "async": true') : ''; +var code = '{"type": "setBlock", "number": "'+EvalString_0+'"'+floorstr+IdString_0+IntString_0+Bool_0+'},\n'; return code; */; @@ -849,7 +1135,9 @@ turnBlock_s tooltip : turnBlock:事件转向;自动检索faceIds 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.mapColor +allFloorIds : ['IdString_0'] default : [null,"","",""] +selectPoint : ["EvalString_1", "EvalString_2", "IdString_0"] var floorstr = ''; if (EvalString_0 && EvalString_1) { var pattern1 = MotaActionFunctions.pattern.id; @@ -882,6 +1170,8 @@ 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 : ["","",""] +allFloorIds : ['IdString_0'] +selectPoint : ["EvalString_0", "EvalString_1", "IdString_0"] colour : this.mapColor var floorstr = ''; if (EvalString_0 && EvalString_1) { @@ -913,7 +1203,9 @@ 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 : ["","",""] +allFloorIds : ['IdString_0'] colour : this.mapColor +selectPoint : ["EvalString_0", "EvalString_1", "IdString_0"] var floorstr = ''; if (EvalString_0 && EvalString_1) { var pattern1 = MotaActionFunctions.pattern.id; @@ -944,6 +1236,8 @@ 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","","",""] +selectPoint : ["EvalString_0", "EvalString_1", "IdString_0"] +allFloorIds : ['IdString_0'] colour : this.mapColor var floorstr = ''; if (EvalString_0 && EvalString_1) { @@ -975,7 +1269,9 @@ 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","","",""] +allFloorIds : ['IdString_0'] colour : this.mapColor +selectPoint : ["EvalString_0", "EvalString_1", "IdString_0"] var floorstr = ''; if (EvalString_0 && EvalString_1) { var pattern1 = MotaActionFunctions.pattern.id; @@ -1006,6 +1302,9 @@ 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.mapColor +selectPoint : ["EvalString_1", "EvalString_2", "IdString_0"] +allIds : ['EvalString_0'] +allFloorIds : ['IdString_0'] default : ["bg","yellowDoor","","",""] var floorstr = ''; if (EvalString_1 && EvalString_2) { @@ -1038,6 +1337,7 @@ tooltip : setHeroIcon:更改角色行走图 helpUrl : https://h5mota.com/games/template/_docs/#/event?id=setheroicon%EF%BC%9A%E6%9B%B4%E6%94%B9%E8%A7%92%E8%89%B2%E8%A1%8C%E8%B5%B0%E5%9B%BE colour : this.dataColor default : ["hero.png"] +allImages : ['EvalString_0'] EvalString_0 = EvalString_0 && (', "name": "'+EvalString_0+'"'); var code = '{"type": "setHeroIcon"'+EvalString_0+'},\n'; return code; @@ -1084,26 +1384,32 @@ return code; */; showHero_s - : '显示勇士' Newline + : '显示勇士' '动画时间' IntString? '不等待执行完毕' Bool Newline /* showHero_s tooltip : showHero: 显示勇士 helpUrl : https://h5mota.com/games/template/_docs/#/event?id=showHero%3a+%e6%98%be%e7%a4%ba%e5%8b%87%e5%a3%ab +default : ['',false] colour : this.soundColor -var code = '{"type": "showHero"},\n'; +IntString_0 = IntString_0 && (', "time": ' + IntString_0); +Bool_0 = Bool_0 ? (', "async": true') : ''; +var code = '{"type": "showHero"'+IntString_0+Bool_0+'},\n'; return code; */; hideHero_s - : '隐藏勇士' Newline + : '隐藏勇士' '动画时间' IntString? '不等待执行完毕' Bool Newline /* hideHero_s tooltip : hideHero: 隐藏勇士 helpUrl : https://h5mota.com/games/template/_docs/#/event?id=hideHero%ef%bc%9a%e9%9a%90%e8%97%8f%e5%8b%87%e5%a3%ab +default : ['',false] colour : this.soundColor -var code = '{"type": "hideHero"},\n'; +IntString_0 = IntString_0 && (', "time": ' + IntString_0); +Bool_0 = Bool_0 ? (', "async": true') : ''; +var code = '{"type": "hideHero"'+IntString_0+Bool_0+'},\n'; return code; */; @@ -1130,6 +1436,7 @@ battle_s tooltip : battle: 强制战斗 helpUrl : https://h5mota.com/games/template/_docs/#/event?id=battle%EF%BC%9A%E5%BC%BA%E5%88%B6%E6%88%98%E6%96%97 default : ["greenSlime"] +allEnemys : ['IdString_0'] colour : this.dataColor var code = '{"type": "battle", "id": "'+IdString_0+'"},\n'; return code; @@ -1161,6 +1468,8 @@ 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,false] +selectPoint : ["PosString_0", "PosString_1", "IdString_0"] +allFloorIds : ['IdString_0'] colour : this.mapColor IdString_0 = IdString_0 && (', "floorId": "'+IdString_0+'"'); var floorstr = ''; @@ -1181,6 +1490,8 @@ 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",false] +selectPoint : ["PosString_0", "PosString_1"] +allIds : ['IdString_0'] colour : this.mapColor var floorstr = ''; if (PosString_0 && PosString_1) { @@ -1199,6 +1510,8 @@ changeFloor_s tooltip : changeFloor: 楼层切换,动画时间可不填 helpUrl : https://h5mota.com/games/template/_docs/#/event?id=changefloor%EF%BC%9A%E6%A5%BC%E5%B1%82%E5%88%87%E6%8D%A2 default : [null,"",null,"","",null,"",null] +selectPoint : ["PosString_0", "PosString_1", "IdString_0", true] +allFloorIds : ['IdString_0'] colour : this.dataColor var toFloorId = IdString_0; if (Floor_List_0!='floorId') toFloorId = Floor_List_0; @@ -1224,6 +1537,7 @@ changePos_s tooltip : changePos: 当前位置切换 helpUrl : https://h5mota.com/games/template/_docs/#/event?id=changepos%EF%BC%9A%E5%BD%93%E5%89%8D%E4%BD%8D%E7%BD%AE%E5%88%87%E6%8D%A2%E5%8B%87%E5%A3%AB%E8%BD%AC%E5%90%91 default : ["","",null] +selectPoint : ["PosString_0", "PosString_1"] colour : this.dataColor var loc = (PosString_0 && PosString_1) ? (', "loc": ['+PosString_0+','+PosString_1+']') : ''; if (DirectionEx_List_0 == 'null') DirectionEx_List_0 = ''; @@ -1240,6 +1554,7 @@ useItem_s tooltip : useItem: 使用道具 helpUrl : https://h5mota.com/games/template/_docs/#/event?id=useItem%ef%bc%9a%e4%bd%bf%e7%94%a8%e9%81%93%e5%85%b7 colour : this.dataColor +allItems : ['IdString_0'] default : ["pickaxe"] var code = '{"type": "useItem", "id": "'+IdString_0+'"},\n'; return code; @@ -1254,6 +1569,7 @@ tooltip : loadEquip: 装上装备 helpUrl : https://h5mota.com/games/template/_docs/#/event?id=useItem%ef%bc%9a%e4%bd%bf%e7%94%a8%e9%81%93%e5%85%b7 colour : this.dataColor default : ["sword1"] +allItems : ['IdString_0'] var code = '{"type": "loadEquip", "id": "'+IdString_0+'"},\n'; return code; */; @@ -1280,6 +1596,7 @@ tooltip : 全局商店 helpUrl : https://h5mota.com/games/template/_docs/#/event?id=openshop%EF%BC%9A%E6%89%93%E5%BC%80%E4%B8%80%E4%B8%AA%E5%85%A8%E5%B1%80%E5%95%86%E5%BA%97 colour : this.dataColor default : ["shop1", true] +allShops : ['IdString_0'] Bool_0 = Bool_0 ? (', "open": true') : ''; var code = '{"type": "openShop", "id": "'+IdString_0+'"'+Bool_0+'},\n'; return code; @@ -1293,6 +1610,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"] +allShops : ['IdString_0'] colour : this.dataColor var code = '{"type": "disableShop", "id": "'+IdString_0+'"},\n'; return code; @@ -1306,6 +1624,7 @@ follow_s tooltip : follow: 跟随勇士 helpUrl : https://h5mota.com/games/template/_docs/#/event?id=follow%ef%bc%9a%e8%b7%9f%e9%9a%8f%e5%8b%87%e5%a3%ab default : ["npc.png"] +allImages : ['EvalString_0'] colour : this.dataColor var code = '{"type": "follow", "name": "'+EvalString_0+'"},\n'; return code; @@ -1319,6 +1638,7 @@ unfollow_s tooltip : unfollow: 取消跟随 helpUrl : https://h5mota.com/games/template/_docs/#/event?id=unfollow%ef%bc%9a%e5%8f%96%e6%b6%88%e8%b7%9f%e9%9a%8f default : [""] +allImages : ['EvalString_0'] colour : this.dataColor EvalString_0 = EvalString_0 ? (', "name": "' + EvalString_0 + '"') : ""; var code = '{"type": "unfollow"' + EvalString_0 + '},\n'; @@ -1348,6 +1668,8 @@ animate_s tooltip : animate:显示动画,位置填hero或者1,2形式的位置,或者不填代表当前事件点 helpUrl : https://h5mota.com/games/template/_docs/#/event?id=animate%EF%BC%9A%E6%98%BE%E7%A4%BA%E5%8A%A8%E7%94%BB default : ["zone","hero",false,false] +allAnimates : ['IdString_0'] +selectPoint : ["EvalString_0", "EvalString_0"] colour : this.soundColor if (EvalString_0) { if(MotaActionFunctions.pattern.id2.test(EvalString_0)) { @@ -1374,6 +1696,7 @@ setViewport_s tooltip : setViewport: 设置视角 helpUrl : https://h5mota.com/games/template/_docs/#/event?id=changepos%EF%BC%9A%E5%BD%93%E5%89%8D%E4%BD%8D%E7%BD%AE%E5%88%87%E6%8D%A2%E5%8B%87%E5%A3%AB%E8%BD%AC%E5%90%91 default : ["",""] +selectPoint : ["PosString_0", "PosString_1"] colour : this.soundColor var loc = ''; if (PosString_0 && PosString_1) { @@ -1399,23 +1722,27 @@ return code; */; showImage_s - : '显示图片' '图片编号' Int '图片' EvalString BGNL? + : '显示图片' '图片编号' Int '图片' EvalString '翻转' Reverse_List BGNL? '绘制的起点像素' 'x' PosString 'y' PosString '不透明度' Number '时间' Int '不等待执行完毕' Bool Newline /* showImage_s tooltip : showImage:显示图片 helpUrl : https://h5mota.com/games/template/_docs/#/event?id=showImage%ef%bc%9a%e6%98%be%e7%a4%ba%e5%9b%be%e7%89%87 -default : [1,"bg.jpg","0","0",1,0,false] +default : [1,"bg.jpg","null","0","0",1,0,false] +allImages : ['EvalString_0'] colour : this.printColor if(Int_0<=0 || Int_0>50) throw new Error('图片编号在1~50之间'); +if (Reverse_List_0 && Reverse_List_0 != 'null') { + Reverse_List_0 = ', "reverse": "' + Reverse_List_0 + '"'; +} else Reverse_List_0 = ''; var async = Bool_0?', "async": true':''; -var code = '{"type": "showImage", "code": '+Int_0+', "image": "'+EvalString_0+'", "loc": ['+PosString_0+','+PosString_1+'], "opacity": '+Number_0+', "time": '+Int_1+async+'},\n'; +var code = '{"type": "showImage", "code": '+Int_0+', "image": "'+EvalString_0+'"'+Reverse_List_0+', "loc": ['+PosString_0+','+PosString_1+'], "opacity": '+Number_0+', "time": '+Int_1+async+'},\n'; return code; */; showImage_1_s - : '显示图片' '图片编号' Int '图片' EvalString BGNL? + : '显示图片' '图片编号' Int '图片' EvalString '翻转' Reverse_List BGNL? '裁剪的起点像素' 'x' PosString 'y' PosString '宽' PosString? '高' PosString? '不透明度' Number BGNL? '绘制的起点像素' 'x' PosString 'y' PosString '宽' PosString? '高' PosString? '时间' Int '不等待执行完毕' Bool Newline @@ -1423,11 +1750,15 @@ showImage_1_s /* showImage_1_s tooltip : showImage_1:显示图片 helpUrl : https://h5mota.com/games/template/_docs/#/event?id=showImage%ef%bc%9a%e6%98%be%e7%a4%ba%e5%9b%be%e7%89%87 -default : [1,"bg.jpg","0","0","","",1,"0","0","","",0,false] +default : [1,"bg.jpg","null","0","0","","",1,"0","0","","",0,false] +allImages : ['EvalString_0'] colour : this.printColor if(Int_0<=0 || Int_0>50) throw new Error('图片编号在1~50之间'); +if (Reverse_List_0 && Reverse_List_0 != 'null') { + Reverse_List_0 = ', "reverse": "' + Reverse_List_0 + '"'; +} else Reverse_List_0 = ''; var async = Bool_0?', "async": true':''; -var code = '{"type": "showImage", "code": '+Int_0+', "image": "'+EvalString_0+'", '+ +var code = '{"type": "showImage", "code": '+Int_0+', "image": "'+EvalString_0+'"'+Reverse_List_0+', '+ '"sloc": ['+PosString_0+','+PosString_1+','+PosString_2+','+PosString_3+'], '+ '"loc": ['+PosString_4+','+PosString_5+','+PosString_6+','+PosString_7+'], '+ '"opacity": '+Number_0+', "time": '+Int_1+async+'},\n'; @@ -1442,6 +1773,7 @@ showTextImage_s /* showTextImage_s tooltip : showTextImage:显示图片化文本 helpUrl : https://h5mota.com/games/template/_docs/#/event?id=showTextImage%ef%bc%9a%e6%98%be%e7%a4%ba%e6%96%87%e6%9c%ac%e5%8c%96%e5%9b%be%e7%89%87 +doubleclicktext : EvalString_0 colour : this.printColor default : ["可以使用setText事件来控制字体、颜色、大小、偏移量等",1,"0","0",1.4,1,0,false] if(Int_0<=0 || Int_0>50) throw new Error('图片编号在1~50之间'); @@ -1473,6 +1805,7 @@ showGif_s tooltip : showGif:显示动图 helpUrl : https://h5mota.com/games/template/_docs/#/event?id=showgif%EF%BC%9A%E6%98%BE%E7%A4%BA%E5%8A%A8%E5%9B%BE default : ["","",""] +allImages : ['EvalString_0'] colour : this.printColor EvalString_0 = EvalString_0 ? (', "name": "'+EvalString_0+'"') : ''; var loc = (PosString_0 && PosString_1) ? (', "loc": ['+PosString_0+','+PosString_1+']') : ''; @@ -1570,6 +1903,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后4左前2"] +selectPoint : ["PosString_0", "PosString_1"] colour : this.mapColor var floorstr = ''; if (PosString_0 && PosString_1) { @@ -1618,7 +1952,10 @@ 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] +selectPoint : ["PosString_2", "PosString_3"] colour : this.mapColor + +// selectPoint 跳跃暂时只考虑终点 var floorstr = ''; if (PosString_0 && PosString_1) { floorstr += ', "from": ['+PosString_0+','+PosString_1+']'; @@ -1641,6 +1978,7 @@ jumpHero_s tooltip : jumpHero: 跳跃勇士 helpUrl : https://h5mota.com/games/template/_docs/#/event?id=jumpHero%EF%BC%9A%E8%B7%B3%E8%B7%83%E5%8B%87%E5%A3%AB default : ["","",500,false] +selectPoint : ["PosString_0", "PosString_1"] colour : this.dataColor var floorstr = ''; if (PosString_0 && PosString_1) { @@ -1660,6 +1998,7 @@ playBgm_s tooltip : playBgm: 播放背景音乐 helpUrl : https://h5mota.com/games/template/_docs/#/event?id=playbgm%EF%BC%9A%E6%92%AD%E6%94%BE%E8%83%8C%E6%99%AF%E9%9F%B3%E4%B9%90 default : ["bgm.mp3", 0, true] +allBgms : ['EvalString_0'] colour : this.soundColor Int_0 = Int_0 ? (', "startTime": '+Int_0) : ''; Bool_0 = Bool_0 ? ', "keep": true' : ''; @@ -1700,6 +2039,7 @@ loadBgm_s tooltip : loadBgm: 预加载某个背景音乐,之后可以直接播放 helpUrl : https://h5mota.com/games/template/_docs/#/event?id=loadBgm%ef%bc%9a%e9%a2%84%e5%8a%a0%e8%bd%bd%e4%b8%80%e4%b8%aa%e8%83%8c%e6%99%af%e9%9f%b3%e4%b9%90 default : ["bgm.mp3"] +allBgms : ['EvalString_0'] colour : this.soundColor var code = '{"type": "loadBgm", "name": "'+EvalString_0+'"},\n'; return code; @@ -1713,6 +2053,7 @@ freeBgm_s tooltip : freeBgm: 释放背景音乐的缓存 helpUrl : https://h5mota.com/games/template/_docs/#/event?id=freeBgm%ef%bc%9a%e9%87%8a%e6%94%be%e4%b8%80%e4%b8%aa%e8%83%8c%e6%99%af%e9%9f%b3%e4%b9%90%e7%9a%84%e7%bc%93%e5%ad%98 default : ["bgm.mp3"] +allBgms : ['EvalString_0'] colour : this.soundColor var code = '{"type": "freeBgm", "name": "'+EvalString_0+'"},\n'; return code; @@ -1727,6 +2068,7 @@ tooltip : playSound: 播放音效 helpUrl : https://h5mota.com/games/template/_docs/#/event?id=playsound%EF%BC%9A%E6%92%AD%E6%94%BE%E9%9F%B3%E6%95%88 default : ["item.mp3",false] colour : this.soundColor +allSounds : ['EvalString_0'] Bool_0 = Bool_0 ? ', "stop": true' : ''; var code = '{"type": "playSound", "name": "'+EvalString_0+'"'+Bool_0+'},\n'; return code; @@ -1887,7 +2229,9 @@ choices_s /* choices_s tooltip : choices: 给用户提供选项 helpUrl : https://h5mota.com/games/template/_docs/#/event?id=choices%EF%BC%9A%E7%BB%99%E7%94%A8%E6%88%B7%E6%8F%90%E4%BE%9B%E9%80%89%E9%A1%B9 -default : ["","流浪者","woman",0] +doubleclicktext : EvalString_0 +default : ["","流浪者","trader",0] +allIds : ['IdString_0'] var title=''; if (EvalString_1==''){ if (IdString_0=='')title=''; @@ -1913,6 +2257,7 @@ choicesContext tooltip : 选项的选择 helpUrl : https://h5mota.com/games/template/_docs/#/event?id=choices%EF%BC%9A%E7%BB%99%E7%94%A8%E6%88%B7%E6%8F%90%E4%BE%9B%E9%80%89%E9%A1%B9 default : ["提示文字:红钥匙","","",""] +allIds : ['IdString_0'] colour : this.subColor ColorString_0 = ColorString_0 ? (', "color": ['+ColorString_0+']') : ''; EvalString_1 = EvalString_1 && (', "condition": "'+EvalString_1+'"') @@ -1928,6 +2273,7 @@ confirm_s tooltip : 弹出确认框 helpUrl : https://h5mota.com/games/template/_docs/#/ default : ["确认要xxx吗?",0,false] +doubleclicktext : EvalString_0 Bool_0 = Bool_0?', "default": true':'' Int_0 = Int_0 ? (', "timeout": '+Int_0) : ''; var code = ['{"type": "confirm"'+Int_0+Bool_0+', "text": "',EvalString_0,'",\n', @@ -2059,6 +2405,7 @@ waitContext_2 tooltip : wait: 等待用户操作并获得按键或点击信息 helpUrl : https://h5mota.com/games/template/_docs/#/event?id=wait%EF%BC%9A%E7%AD%89%E5%BE%85%E7%94%A8%E6%88%B7%E6%93%8D%E4%BD%9C default : [0,32,0,32] +previewBlock : true colour : this.subColor var code = '{"case": "mouse", "px": [' + PosString_0 + ',' + PosString_1 + '], "py": [' + PosString_2 + ',' + PosString_3 + '], "action": [\n' + action_0 + ']},\n'; return code; @@ -2145,6 +2492,7 @@ previewUI_s /* previewUI_s tooltip : previewUI: ui绘制并预览 helpUrl : https://h5mota.com/games/template/_docs/#/event?id=previewUI%ef%bc%9aUI%e7%bb%98%e5%88%b6%e5%b9%b6%e9%a2%84%e8%a7%88 +previewBlock : true var code = ['{"type": "previewUI", "action": [\n', action_0,']},\n'].join(''); return code; */; @@ -2158,6 +2506,7 @@ tooltip : clearMap: 清除画布 helpUrl : https://h5mota.com/games/template/_docs/#/event?id=clearMap%ef%bc%9a%e6%b8%85%e9%99%a4%e7%94%bb%e5%b8%83 colour : this.subColor default : ["0", "0", "100", "100"] +previewBlock : true var code = '{"type": "clearMap", "x": ' + PosString_0 + ', "y": ' + PosString_1 + ', "width": ' + PosString_2 + ', "height": ' + PosString_3 + '},\n'; return code; @@ -2170,6 +2519,7 @@ clearMap_1_s /* clearMap_1_s tooltip : clearMap: 清除画布 helpUrl : https://h5mota.com/games/template/_docs/#/event?id=clearMap%ef%bc%9a%e6%b8%85%e9%99%a4%e7%94%bb%e5%b8%83 +previewBlock : true colour : this.subColor var code = '{"type": "clearMap"},\n'; return code; @@ -2182,6 +2532,7 @@ setAttribute_s /* setAttribute_s tooltip : setAttribute:设置画布属性 helpUrl : https://h5mota.com/games/template/_docs/#/event?id=setAttribute%ef%bc%9a%e8%ae%be%e7%bd%ae%e7%94%bb%e5%b8%83%e5%b1%9e%e6%80%a7 +previewBlock : true colour : this.subColor default : ["","",'rgba(255,255,255,1)',"",'rgba(255,255,255,1)',"","",null,null,""] TextAlign_List_0 = TextAlign_List_0==='null'?'': ', "align": "'+TextAlign_List_0+'"'; @@ -2208,6 +2559,7 @@ fillText_s tooltip : fillText:绘制一行文本;可以设置最大宽度进行放缩 helpUrl : https://h5mota.com/games/template/_docs/#/event?id=fillText%ef%bc%9a%e7%bb%98%e5%88%b6%e6%96%87%e6%9c%ac colour : this.subColor +previewBlock : true default : ["0","0","",'rgba(255,255,255,1)',"","","绘制一行文本"] ColorString_0 = ColorString_0 ? (', "style": ['+ColorString_0+']') : ''; FontString_0 = FontString_0 ? (', "font": "' + FontString_0 + '"') : ''; @@ -2223,6 +2575,7 @@ fillBoldText_s tooltip : fillBoldText:绘制一行描边文本 helpUrl : https://h5mota.com/games/template/_docs/#/event?id=fillBoldText%ef%bc%9a%e7%bb%98%e5%88%b6%e6%8f%8f%e8%be%b9%e6%96%87%e6%9c%ac colour : this.subColor +previewBlock : true default : ["0","0","",'rgba(255,255,255,1)',"",'rgba(0,0,0,1)',"","绘制一行描边文本"] ColorString_0 = ColorString_0 ? (', "style": ['+ColorString_0+']') : ''; ColorString_1 = ColorString_1 ? (', "strokeStyle": ['+ColorString_1+']') : ''; @@ -2237,6 +2590,7 @@ drawTextContent_s /* drawTextContent_s tooltip : drawTextContent:绘制多行文本 helpUrl : https://h5mota.com/games/template/_docs/#/event?id=drawTextContent%ef%bc%9a%e7%bb%98%e5%88%b6%e5%a4%9a%e8%a1%8c%e6%96%87%e6%9c%ac +doubleclicktext : EvalString_0 colour : this.subColor default : ["绘制多行文本\\n可双击编辑","0","0","","",'rgba(255,255,255,1)',null,"","",false] TextAlign_List_0 = TextAlign_List_0==='null'?'': ', "align": "'+TextAlign_List_0+'"'; @@ -2256,6 +2610,7 @@ fillRect_s tooltip : fillRect:绘制矩形 helpUrl : https://h5mota.com/games/template/_docs/#/event?id=fillRect%ef%bc%9a%e7%bb%98%e5%88%b6%e7%9f%a9%e5%bd%a2 colour : this.subColor +previewBlock : true default : ["0","0","flag:x","300","","",null] ColorString_0 = ColorString_0 ? (', "style": ['+ColorString_0+']') : ''; PosString_4 = PosString_4 ? (', "radius": '+PosString_4) : ''; @@ -2270,6 +2625,7 @@ strokeRect_s tooltip : strokeRect:绘制矩形边框 helpUrl : https://h5mota.com/games/template/_docs/#/event?id=strokeRect%ef%bc%9a%e7%bb%98%e5%88%b6%e7%9f%a9%e5%bd%a2%e8%be%b9%e6%a1%86 colour : this.subColor +previewBlock : true default : ["0","0","flag:x","300","","",null,""] ColorString_0 = ColorString_0 ? (', "style": ['+ColorString_0+']') : ''; IntString_0 = IntString_0 ? (', "lineWidth": '+IntString_0) : ''; @@ -2285,6 +2641,7 @@ drawLine_s tooltip : drawLine:绘制线段 helpUrl : https://h5mota.com/games/template/_docs/#/event?id=drawLine%ef%bc%9a%e7%bb%98%e5%88%b6%e7%ba%bf%e6%ae%b5 colour : this.subColor +previewBlock : true default : ["0","0","flag:x","300","",null,""] ColorString_0 = ColorString_0 ? (', "style": ['+ColorString_0+']') : ''; IntString_0 = IntString_0 ? (', "lineWidth": '+IntString_0) : ''; @@ -2299,6 +2656,7 @@ drawArrow_s tooltip : drawArrow:绘制箭头 helpUrl : https://h5mota.com/games/template/_docs/#/event?id=drawArrow%ef%bc%9a%e7%bb%98%e5%88%b6%e7%ae%ad%e5%a4%b4 colour : this.subColor +previewBlock : true default : ["0","0","flag:x","300","",null,""] ColorString_0 = ColorString_0 ? (', "style": ['+ColorString_0+']') : ''; IntString_0 = IntString_0 ? (', "lineWidth": '+IntString_0) : ''; @@ -2314,6 +2672,7 @@ fillPolygon_s tooltip : fillPolygon:绘制多边形 helpUrl : https://h5mota.com/games/template/_docs/#/event?id=fillPolygon%ef%bc%9a%e7%bb%98%e5%88%b6%e5%a4%9a%e8%be%b9%e5%bd%a2 colour : this.subColor +previewBlock : true default : ["0,0,100","0,100,0","",null] var pattern2 = /^([+-]?\d+)(,[+-]?\d+)*$/; if(!pattern2.test(EvalString_0) || !pattern2.test(EvalString_1))throw new Error('坐标格式错误,请右键点击帮助查看格式'); @@ -2334,6 +2693,7 @@ strokePolygon_s tooltip : strokePolygon:绘制多边形边框 helpUrl : https://h5mota.com/games/template/_docs/#/event?id=strokePolygon%ef%bc%9a%e7%bb%98%e5%88%b6%e5%a4%9a%e8%be%b9%e5%bd%a2%e8%be%b9%e6%a1%86 colour : this.subColor +previewBlock : true default : ["0,0,100","0,100,0","",null,""] var pattern2 = /^([+-]?\d+)(,[+-]?\d+)*$/; if(!pattern2.test(EvalString_0) || !pattern2.test(EvalString_1))throw new Error('坐标格式错误,请右键点击帮助查看格式'); @@ -2354,6 +2714,7 @@ fillEllipse_s tooltip : fillEllipse:绘制椭圆 helpUrl : https://h5mota.com/games/template/_docs/#/event?id=fillEllipse%ef%bc%9a%e7%bb%98%e5%88%b6%e5%9c%86 colour : this.subColor +previewBlock : true default : ["0","0","100","100","0","",null] ColorString_0 = ColorString_0 ? (', "style": ['+ColorString_0+']') : ''; PosString_4 = PosString_4 ? (', "angle": ' + PosString_4) : ''; @@ -2368,6 +2729,7 @@ strokeEllipse_s tooltip : strokeEllipse:绘制椭圆边框 helpUrl : https://h5mota.com/games/template/_docs/#/event?id=strokeEllipse%ef%bc%9a%e7%bb%98%e5%88%b6%e5%9c%86%e8%be%b9%e6%a1%86 colour : this.subColor +previewBlock : true default : ["0","0","100","100","0","",null,""] ColorString_0 = ColorString_0 ? (', "style": ['+ColorString_0+']') : ''; IntString_0 = IntString_0 ? (', "lineWidth": '+IntString_0) : ''; @@ -2407,22 +2769,27 @@ return code; drawImage_s - : '绘制图片' EvalString '起点像素' 'x' PosString 'y' PosString '宽' PosString? '高' PosString? Newline + : '绘制图片' EvalString '翻转' Reverse_List '起点像素' 'x' PosString 'y' PosString '宽' PosString? '高' PosString? Newline /* drawImage_s tooltip : drawImage:绘制图片 helpUrl : https://h5mota.com/games/template/_docs/#/event?id=drawImage%ef%bc%9a%e7%bb%98%e5%88%b6%e5%9b%be%e7%89%87 -default : ["bg.jpg","0","0","",""] +previewBlock : true +allImages : ['EvalString_0'] +default : ["bg.jpg","null","0","0","",""] colour : this.subColor +if (Reverse_List_0 && Reverse_List_0 != 'null') { + Reverse_List_0 = ', "reverse": "' + Reverse_List_0 + '"'; +} else Reverse_List_0 = ''; PosString_2 = PosString_2 ? (', "w": '+PosString_2) : ''; PosString_3 = PosString_3 ? (', "h": '+PosString_3) : ''; -var code = '{"type": "drawImage", "image": "'+EvalString_0+'", "x": '+PosString_0+', "y": '+PosString_1+PosString_2+PosString_3+'},\n'; +var code = '{"type": "drawImage", "image": "'+EvalString_0+'"'+Reverse_List_0+', "x": '+PosString_0+', "y": '+PosString_1+PosString_2+PosString_3+'},\n'; return code; */; drawImage_1_s - : '绘制图片' EvalString '裁剪的起点像素' 'x' PosString 'y' PosString '宽' PosString '高' PosString BGNL? + : '绘制图片' EvalString '翻转' Reverse_List '裁剪的起点像素' 'x' PosString 'y' PosString '宽' PosString '高' PosString BGNL? '绘制的起点像素' 'x' PosString 'y' PosString '宽' PosString '高' PosString Newline @@ -2431,7 +2798,12 @@ tooltip : drawImage:绘制图片 helpUrl : https://h5mota.com/games/template/_docs/#/event?id=drawImage%ef%bc%9a%e7%bb%98%e5%88%b6%e5%9b%be%e7%89%87 default : ["bg.jpg","0","0","32","32","0","0","32","32"] colour : this.subColor -var code = '{"type": "drawImage", "image": "'+EvalString_0+'"'+ +allImages : ['EvalString_0'] +previewBlock : true +if (Reverse_List_0 && Reverse_List_0 != 'null') { + Reverse_List_0 = ', "reverse": "' + Reverse_List_0 + '"'; +} else Reverse_List_0 = ''; +var code = '{"type": "drawImage", "image": "'+EvalString_0+'"'+Reverse_List_0+ ', "x": '+PosString_0+', "y": '+PosString_1+', "w": '+PosString_2+', "h": '+PosString_3+ ', "x1": '+PosString_4+', "y1": '+PosString_5+', "w1": '+PosString_6+', "h1": '+PosString_7+'},\n'; return code; @@ -2445,6 +2817,8 @@ drawIcon_s tooltip : drawIcon:绘制图标 helpUrl : https://h5mota.com/games/template/_docs/#/event?id=drawIcon%ef%bc%9a%e7%bb%98%e5%88%b6%e5%9b%be%e6%a0%87 default : ["yellowKey",0,"0","0","",""] +previewBlock : true +allIds : ['IdString_0'] colour : this.subColor Int_0 = Int_0 ? (', "frame": '+Int_0) : ''; PosString_2 = PosString_2 ? (', "width": '+PosString_2) : ''; @@ -2462,6 +2836,7 @@ tooltip : drawBackground:绘制背景 helpUrl : https://h5mota.com/games/template/_docs/#/event?id=drawBackground%ef%bc%9a%e7%bb%98%e5%88%b6%e8%83%8c%e6%99%af%e5%9b%be default : ["winskin.png",null,"0","0","100","100"] colour : this.subColor +previewBlock : true var colorRe = MotaActionFunctions.pattern.colorRe; if (colorRe.test(EvalString_0)) { EvalString_0 = ', "background": ['+EvalString_0+']'; @@ -2483,6 +2858,7 @@ drawSelector_s /* drawSelector_s tooltip : drawSelector:绘制闪烁光标 helpUrl : https://h5mota.com/games/template/_docs/#/event?id=drawSelector%ef%bc%9a%e7%bb%98%e5%88%b6%e9%97%aa%e7%83%81%e5%85%89%e6%a0%87 +previewBlock : true default : ["winskin.png","1","0","0","100","100"] colour : this.subColor var code = '{"type": "drawSelector", "image": "'+EvalString_0+'", "code": '+Int_0+', "x": '+PosString_0+', "y": '+PosString_1+', "width": '+PosString_2+', "height": '+PosString_3+'},\n'; @@ -2497,6 +2873,7 @@ drawSelector_1_s tooltip : drawSelector:清除闪烁光标 helpUrl : https://h5mota.com/games/template/_docs/#/event?id=showImage%ef%bc%9a%e6%98%be%e7%a4%ba%e5%9b%be%e7%89%87 default : ["1"] +previewBlock : true colour : this.subColor var code = '{"type": "drawSelector", "code": '+Int_0+'},\n'; return code; @@ -2527,6 +2904,7 @@ tooltip : 可双击多行编辑,请勿使用异步代码。常见API参见文 helpUrl : https://h5mota.com/games/template/_docs/#/event?id=function%EF%BC%9A%E8%87%AA%E5%AE%9A%E4%B9%89js%E8%84%9A%E6%9C%AC default : [false,"alert(core.getStatus(\"atk\"));"] colour : this.dataColor +doubleclicktext : RawEvalString_0 Bool_0 = Bool_0?', "async": true':''; var code = '{"type": "function"'+Bool_0+', "function": "function(){\\n'+JSON.stringify(RawEvalString_0).slice(1,-1).split('\\\\n').join('\\n')+'\\n}"},\n'; return code; @@ -2564,9 +2942,7 @@ expression //todo 修改recieveOrder,根据Arithmetic_List_0不同的值设定不同的recieveOrder var code = expression_0 + Arithmetic_List_0 + expression_1; var ops = { - '^': 'Math.pow('+expression_0+','+expression_1+')', - '和': expression_0+' && '+expression_1, - '或': expression_0+' || '+expression_1, + '^': 'Math.pow('+expression_0+','+expression_1+')' } if (ops[Arithmetic_List_0])code = ops[Arithmetic_List_0]; var orders = { @@ -2577,12 +2953,14 @@ var orders = { '^': Blockly.JavaScript.ORDER_MEMBER, //recieveOrder : ORDER_COMMA '==': Blockly.JavaScript.ORDER_EQUALITY, '!=': Blockly.JavaScript.ORDER_EQUALITY, + '===': Blockly.JavaScript.ORDER_EQUALITY, + '!==': Blockly.JavaScript.ORDER_EQUALITY, '>': Blockly.JavaScript.ORDER_RELATIONAL, '<': Blockly.JavaScript.ORDER_RELATIONAL, '>=': Blockly.JavaScript.ORDER_RELATIONAL, '<=': Blockly.JavaScript.ORDER_RELATIONAL, - '和': Blockly.JavaScript.ORDER_LOGICAL_AND, - '或': Blockly.JavaScript.ORDER_LOGICAL_OR + '&&': Blockly.JavaScript.ORDER_LOGICAL_AND, + '||': Blockly.JavaScript.ORDER_LOGICAL_OR } return [code, orders[Arithmetic_List_0]]; */; @@ -2598,10 +2976,11 @@ return [code, Blockly.JavaScript.ORDER_LOGICAL_NOT]; */; bool_e - : Bool + : ':' Bool /* bool_e +tooltip : 逻辑是否 var code = Bool_0; return [code, Blockly.JavaScript.ORDER_ATOMIC]; */; @@ -2646,6 +3025,7 @@ enemyattr_e /* enemyattr_e default : ['greenSlime',"攻击"] +allEnemys : ['IdString_0'] var code = 'enemy:'+IdString_0+':'+EnemyId_List_0; return [code, Blockly.JavaScript.ORDER_ATOMIC]; */; @@ -2768,13 +3148,17 @@ TextBaseline_List : '不改变'|'顶部'|'悬挂'|'居中'|'标准值'|'ideographic'|'底部' /*TextBaseline_List ['null','top','hanging','middle','alphabetic','ideographic','bottom']*/; +Reverse_List + : '不改变'|'左右翻转'|'上下翻转'|'中心翻转' + /*Reverse_List ['null',':x',':y',':o']*/; + ShopUse_List : '金币' | '经验' /*ShopUse_List ['money','exp']*/; Arithmetic_List - : '+'|'-'|'*'|'/'|'^'|'=='|'!='|'>'|'<'|'>='|'<='|'和'|'或' - ; + : '+'|'-'|'*'|'/'|'^'|'=='|'!='|'==='|'!=='|'>'|'<'|'>='|'<='|'且'|'或' + /*Arithmetic_List ['+','-','*','/','^','==','!=','===','!==','>','<','>=','<=','&&','||']*/; AssignOperator_List : '='|'+='|'-='|'*='|'/='|'**='|'//='|'%=' @@ -2796,6 +3180,10 @@ Bg_Fg_List : '背景层'|'前景层' /*Bg_Fg_List ['bg','fg']*/; +Bg_Fg2_List + : '背景层'|'前景层'|'自适配' + /*Bg_Fg2_List ['bg','fg','auto']*/; + IgnoreChangeFloor_List : '全局默认值' | '可穿透' | '不可穿透' /*IgnoreChangeFloor_List ['null','true','false']*/; @@ -2806,15 +3194,15 @@ Event_List Floor_Meta_List : '楼层中文名'|'状态栏名称'|'能否使用楼传'|'能否打开快捷商店'|'是否不可浏览地图'|'是否不可瞬间移动'|'默认地面ID'|'楼层贴图'|'宝石血瓶效果'|'上楼点坐标'|'下楼点坐标'|'背景音乐'|'画面色调'|'天气和强度'|'是否地下层' - /*Floor_Meta_List ['title','name','canFlyTo', 'canUseQuickShop', 'cannotViewMap', 'cannotMoveDirectly', 'defaultGround', 'images', 'item_ratio', 'upFloor', 'downFloor', 'bgm', 'color', 'weather', 'underGround']*/; + /*Floor_Meta_List ['title','name','canFlyTo', 'canUseQuickShop', 'cannotViewMap', 'cannotMoveDirectly', 'defaultGround', 'images', 'ratio', 'upFloor', 'downFloor', 'bgm', 'color', 'weather', 'underGround']*/; Global_Attribute_List - : '全局字体'|'横屏左侧状态栏背景'|'竖屏上方状态栏背景'|'竖屏下方道具栏背景'|'边框颜色'|'状态栏文字色'|'难度显示文字色'|'楼层转换背景'|'楼层转换文字色'|'装备列表' - /*Global_Attribute_List ['font','statusLeftBackground','statusTopBackground', 'toolsBackground', 'borderColor', 'statusBarColor', 'hardLabelColor', 'floorChangingBackground', 'floorChangingTextColor', 'equipName']*/; + : '全局字体'|'横屏左侧状态栏背景'|'竖屏上方状态栏背景'|'竖屏下方道具栏背景'|'边框颜色'|'状态栏文字色'|'楼层转换样式'|'装备列表' + /*Global_Attribute_List ['font','statusLeftBackground','statusTopBackground', 'toolsBackground', 'borderColor', 'statusBarColor', 'floorChangingStyle', 'equipName']*/; Global_Value_List : '血网伤害'|'中毒伤害'|'衰弱效果'|'红宝石效果'|'蓝宝石效果'|'绿宝石效果'|'红血瓶效果'|'蓝血瓶效果'|'黄血瓶效果'|'绿血瓶效果'|'破甲比例'|'反击比例'|'净化比例'|'仇恨增加值'|'动画时间' - /*Global_Value_List ['lavaDamage','poisonDamage','weakValue', 'redJewel', 'blueJewel', 'greenJewel', 'redPotion', 'bluePotion', 'yellowPotion', 'greenPotion', 'breakArmor', 'counterAttack', 'purify', 'hatred', 'animateSpeed']*/; + /*Global_Value_List ['lavaDamage','poisonDamage','weakValue', 'redGem', 'blueGem', 'greenGem', 'redPotion', 'bluePotion', 'yellowPotion', 'greenPotion', 'breakArmor', 'counterAttack', 'purify', 'hatred', 'animateSpeed']*/; Global_Flag_List @@ -2864,8 +3252,8 @@ IdString ; FixedId_List - : '生命'|'攻击'|'防御'|'护盾'|'黄钥匙'|'蓝钥匙'|'红钥匙'|'金币'|'经验' - /*FixedId_List ['status:hp','status:atk','status:def','status:mdef','item:yellowKey','item:blueKey','item:redKey','status:money','status:exp']*/; + : '生命'|'生命上限'|'攻击'|'防御'|'护盾'|'黄钥匙'|'蓝钥匙'|'红钥匙'|'金币'|'经验'|'魔力'|'魔力上限' + /*FixedId_List ['status:hp','status:hpmax','status:atk','status:def','status:mdef','item:yellowKey','item:blueKey','item:redKey','status:money','status:exp','status:mana','status:manamax']*/; Id_List : '变量' | '状态' | '物品' | '独立开关' | '临时变量' |'全局存储' @@ -2873,7 +3261,15 @@ Id_List EnemyId_List : '生命'|'攻击'|'防御'|'金币'|'经验'|'加点'|'属性'|'名称'|'映射名'|'value'|'atkValue'|'defValue'|'notBomb'|'zoneSquare'|'range'|'n'|'add'|'damage' - /*EnemyId_List ['hp','atk','def','money','exp','point','special','name','displayInBook','value','atkValue','defValue','notBomb','zoneSquare','range','n','add','damage']*/; + /*EnemyId_List ['hp','atk','def','money','exp','point','special','name','displayInBook','属性值','退化扣攻','退化扣防','不可炸','九宫格领域','领域范围','连击数','吸血到自身','固伤值']*/; + +Equip_List + : '生命'|'生命上限'|'攻击'|'防御'|'护盾'|'魔力'|'魔力上限' + /*Equip_List ['hp','hpmax','atk','def','mdef','mana','manamax']*/; + +Key_List + : '黄钥匙'|'蓝钥匙'|'红钥匙'|'绿钥匙'|'铁门钥匙' + /*Key_List ['yellowKey','blueKey','redKey','greenKey','steelKey']*/; //转blockly后不保留需要加" EvalString @@ -2941,1225 +3337,6 @@ this.block('idTemp_e').output='idString_e'; /* Functions -function ActionParser(){ -} - -ActionParser.prototype.parse = function (obj,type) { - switch (type) { - case 'event': - if(!obj)obj={}; - if(typeof(obj)===typeof('')) obj={'data':[obj]}; - if(obj instanceof Array) obj={'data':obj}; - return MotaActionBlocks['event_m'].xmlText([ - obj.trigger==='action',obj.enable,obj.noPass,obj.displayDamage,this.parseList(obj.data) - ]); - - case 'autoEvent': - if(!obj)obj={}; - return MotaActionBlocks['autoEvent_m'].xmlText([ - obj.condition,obj.priority,obj.currentFloor,obj.delayExecute,obj.multiExecute,this.parseList(obj.data) - ]); - - case 'changeFloor': - if(!obj)obj={}; - if (!obj.loc) { - obj.loc = obj.loc || ['','']; - obj.stair = obj.stair || ':now'; - } - if (obj.floorId==':before'||obj.floorId==':next'||obj.floorId==':now') { - obj.floorType=obj.floorId; - delete obj.floorId; - } - return MotaActionBlocks['changeFloor_m'].xmlText([ - obj.floorType||'floorId',obj.floorId,obj.stair||'loc',obj.loc[0],obj.loc[1],obj.direction, - obj.time,obj.ignoreChangeFloor - ]); - - case 'afterGetItem': - if (!obj) obj = []; - if (obj instanceof Array) obj = {'data': obj}; - return MotaActionBlocks['afterGetItem_m'].xmlText([ - obj.disableOnGentleClick||false, this.parseList(obj.data) - ]); - - case 'level': - if(!obj)obj={}; - var text_choices = null; - for(var ii=obj.length-1,choice;choice=obj[ii];ii--) { - text_choices=MotaActionBlocks['levelCase'].xmlText([ - this.expandEvalBlock([choice.need]),choice.title,choice.clear||false,this.parseList(choice.action),text_choices]); - } - return MotaActionBlocks['level_m'].xmlText([text_choices]); - - case 'shop': - var buildsub = function(obj,parser,next){ - var text_choices = null; - for(var ii=obj.choices.length-1,choice;choice=obj.choices[ii];ii--) { - text_choices=MotaActionBlocks['shopChoices'].xmlText([ - choice.text,choice.need||'',choice.icon,choice.color,'rgba('+choice.color+')',choice.condition,parser.parseList(choice.action),text_choices]); - } - var info = parser.getTitleAndPosition(obj.text || ''); - return MotaActionBlocks['shopsub'].xmlText([ - obj.id,obj[0],info[1],info[3],obj.textInList,obj.mustEnable,obj.disablePreview,text_choices,next - ]); - } - var buildcommentevent = function(obj,parser,next){ - if (obj.args instanceof Array) { - obj.args = JSON.stringify(obj.args); - } - else obj.args = null; - return MotaActionBlocks['shopcommonevent'].xmlText([ - obj.id,parser.EvalString(obj.textInList),obj.mustEnable,parser.EvalString(obj.commonEvent),obj.args,next - ]); - } - var builditem = function (obj,parser,next){ - var text_choices = null; - for(var ii=obj.choices.length-1,choice;choice=obj.choices[ii];ii--) { - text_choices = MotaActionBlocks['shopItemChoices'].xmlText([ - choice.id, choice.number == null ? "" : (""+choice.number), choice.money == null ? "" : (""+choice.money), - choice.sell == null ? "" : (""+choice.sell), choice.condition || "", text_choices - ]); - } - return MotaActionBlocks['shopitem'].xmlText([ - obj.id,obj.textInList,obj.mustEnable,text_choices,next - ]); - } - var next=null; - if(!obj)obj=[]; - while(obj.length){ - var shopobj=obj.pop() - if(shopobj.item) - next=builditem(shopobj,this,next); - else if(shopobj.choices) - next=buildsub(shopobj,this,next); - else if(shopobj.commonEvent) - next=buildcommentevent(shopobj,this,next); - else - throw new Error("[警告]出错啦!\n"+shopobj.id+" 无效的商店"); - } - return MotaActionBlocks['shop_m'].xmlText([next]); - - default: - return MotaActionBlocks[type+'_m'].xmlText([this.parseList(obj)]); - } -} - -////// 开始解析一系列自定义事件 ////// -ActionParser.prototype.parseList = function (list) { - if (!this.isset(list)) return MotaActionBlocks['pass_s'].xmlText([],true); - if (!(list instanceof Array)) { - list = [list]; - } - if (list.length===0) return MotaActionBlocks['pass_s'].xmlText([],true); - this.event = {'id': 'action', 'data': { - 'list': list - }} - this.next = null; - this.result = null; - this.parseAction(); - return this.result; -} - -////// 解析当前自定义事件列表中的最后一个事件 ////// -ActionParser.prototype.parseAction = function() { - - // 事件处理完毕 - if (this.event.data.list.length==0) { - this.result = this.next; - this.next = null; - return; - } - - var data = this.event.data.list.pop(); - this.event.data.current = data; - - // 不同种类的事件 - - // 如果是文字:显示 - if (typeof data == "string") { - data={"type": "text", "text": data} - } - this.event.data.type=data.type; - switch (data.type) { - case "_next": - this.result = this.next; - this.next = data.next; - return; - case "text": // 文字/对话 - var info = this.getTitleAndPosition(data.text); - if (info[0] || info[1] || info[2]) { - this.next = MotaActionBlocks['text_1_s'].xmlText([ - info[0], info[1], info[2], info[3], this.next]); - } - else { - this.next = MotaActionBlocks['text_0_s'].xmlText([info[3],this.next]); - } - break; - case "autoText": // 自动剧情文本 - var info = this.getTitleAndPosition(data.text); - this.next = MotaActionBlocks['autoText_s'].xmlText([ - info[0],info[1],info[2],data.time,info[3],this.next]); - break; - case "scrollText": - this.next = MotaActionBlocks['scrollText_s'].xmlText([ - data.time, data.lineHeight||1.4, data.async||false, this.EvalString(data.text), this.next]); - break; - case "comment": // 注释 - this.next = MotaActionBlocks['comment_s'].xmlText([this.EvalString(data.text),this.next],null,data.text); - break; - case "setText": // 设置剧情文本的属性 - data.title=this.Colour(data.title); - data.text=this.Colour(data.text); - if (!/^\w+\.png$/.test(data.background)) - data.background=this.Colour(data.background); - this.next = MotaActionBlocks['setText_s'].xmlText([ - data.position,data.offset,data.align,data.title,'rgba('+data.title+')', - data.text,'rgba('+data.text+')',data.background,'rgba('+data.background+')', - data.bold,data.titlefont,data.textfont,data.lineHeight,data.time,data.interval,this.next]); - break; - case "tip": - this.next = MotaActionBlocks['tip_s'].xmlText([ - data.text,data.icon||"",this.next]); - break; - case "show": // 显示 - data.loc=data.loc||[]; - if (!(data.loc[0] instanceof Array)) - data.loc = [data.loc]; - var x_str=[],y_str=[]; - data.loc.forEach(function (t) { - x_str.push(t[0]); - y_str.push(t[1]); - }) - this.next = MotaActionBlocks['show_s'].xmlText([ - x_str.join(','),y_str.join(','),data.floorId||'',data.time,data.async||false,this.next]); - break; - case "hide": // 消失 - data.loc=data.loc||[]; - if (!(data.loc[0] instanceof Array)) - data.loc = [data.loc]; - var x_str=[],y_str=[]; - data.loc.forEach(function (t) { - x_str.push(t[0]); - y_str.push(t[1]); - }) - this.next = MotaActionBlocks['hide_s'].xmlText([ - x_str.join(','),y_str.join(','),data.floorId||'',data.remove||false,data.time,data.async||false,this.next]); - break; - case "setBlock": // 设置图块 - data.loc=data.loc||[]; - if (!(data.loc[0] instanceof Array)) - data.loc = [data.loc]; - var x_str=[],y_str=[]; - data.loc.forEach(function (t) { - x_str.push(t[0]); - y_str.push(t[1]); - }) - this.next = MotaActionBlocks['setBlock_s'].xmlText([ - data.number||0,x_str.join(','),y_str.join(','),data.floorId||'',this.next]); - break; - case "turnBlock": // 事件转向 - data.loc=data.loc||[]; - if (!(data.loc[0] instanceof Array)) - data.loc = [data.loc]; - var x_str=[],y_str=[]; - data.loc.forEach(function (t) { - x_str.push(t[0]); - y_str.push(t[1]); - }) - this.next = MotaActionBlocks['turnBlock_s'].xmlText([ - data.direction,x_str.join(','),y_str.join(','),data.floorId||'',this.next]); - break; - case "showFloorImg": // 显示贴图 - data.loc=data.loc||[]; - if (!(data.loc[0] instanceof Array)) - data.loc = [data.loc]; - var x_str=[],y_str=[]; - data.loc.forEach(function (t) { - x_str.push(t[0]); - y_str.push(t[1]); - }) - this.next = MotaActionBlocks['showFloorImg_s'].xmlText([ - x_str.join(','),y_str.join(','),data.floorId||'',this.next]); - break; - case "hideFloorImg": // 隐藏贴图 - data.loc=data.loc||[]; - if (!(data.loc[0] instanceof Array)) - data.loc = [data.loc]; - var x_str=[],y_str=[]; - data.loc.forEach(function (t) { - x_str.push(t[0]); - y_str.push(t[1]); - }) - this.next = MotaActionBlocks['hideFloorImg_s'].xmlText([ - x_str.join(','),y_str.join(','),data.floorId||'',this.next]); - break; - case "showBgFgMap": // 显示图层块 - data.loc=data.loc||[]; - if (!(data.loc[0] instanceof Array)) - data.loc = [data.loc]; - var x_str=[],y_str=[]; - data.loc.forEach(function (t) { - x_str.push(t[0]); - y_str.push(t[1]); - }) - this.next = MotaActionBlocks['showBgFgMap_s'].xmlText([ - data.name||'bg', x_str.join(','),y_str.join(','),data.floorId||'',this.next]); - break; - case "hideBgFgMap": // 隐藏图层块 - data.loc=data.loc||[]; - if (!(data.loc[0] instanceof Array)) - data.loc = [data.loc]; - var x_str=[],y_str=[]; - data.loc.forEach(function (t) { - x_str.push(t[0]); - y_str.push(t[1]); - }) - this.next = MotaActionBlocks['hideBgFgMap_s'].xmlText([ - data.name||'bg', x_str.join(','),y_str.join(','),data.floorId||'',this.next]); - break; - case "setBgFgBlock": // 设置图块 - data.loc=data.loc||[]; - if (!(data.loc[0] instanceof Array)) - data.loc = [data.loc]; - var x_str=[],y_str=[]; - data.loc.forEach(function (t) { - x_str.push(t[0]); - y_str.push(t[1]); - }) - this.next = MotaActionBlocks['setBgFgBlock_s'].xmlText([ - data.name||'bg', data.number||0, x_str.join(','),y_str.join(','),data.floorId||'',this.next]); - break; - case "setHeroIcon": // 改变勇士 - this.next = MotaActionBlocks['setHeroIcon_s'].xmlText([ - data.name||"",this.next]); - break; - case "move": // 移动事件 - data.loc=data.loc||['','']; - this.next = MotaActionBlocks['move_s'].xmlText([ - data.loc[0],data.loc[1],data.time,data.keep||false,data.async||false,this.StepString(data.steps),this.next]); - break; - case "moveAction": // 前进一格或撞击 - this.next = MotaActionBlocks['moveAction_s'].xmlText([this.next]); - break; - case "moveHero": // 无视地形移动勇士 - this.next = MotaActionBlocks['moveHero_s'].xmlText([ - data.time,data.async||false,this.StepString(data.steps),this.next]); - break; - case "jump": // 跳跃事件 - data.from=data.from||['','']; - data.to=data.to||['','']; - this.next = MotaActionBlocks['jump_s'].xmlText([ - data.from[0],data.from[1],data.to[0],data.to[1],data.time,data.keep||false,data.async||false,this.next]); - break; - case "jumpHero": // 跳跃勇士 - data.loc=data.loc||['',''] - this.next = MotaActionBlocks['jumpHero_s'].xmlText([ - data.loc[0],data.loc[1],data.time,data.async||false,this.next]); - break; - case "changeFloor": // 楼层转换 - if (!data.loc) { - data.loc = data.loc || ['','']; - data.stair = data.stair || ':now'; - } - if (data.floorId==':before'||data.floorId==':next'||data.floorId==':now') { - data.floorType=data.floorId; - delete data.floorId; - } - this.next = MotaActionBlocks['changeFloor_s'].xmlText([ - data.floorType||'floorId',data.floorId,data.stair||'loc',data.loc[0],data.loc[1],data.direction, - data.time, this.next]); - break; - case "changePos": // 直接更换勇士位置, 不切换楼层 - data.loc=data.loc||['',''] - this.next = MotaActionBlocks['changePos_s'].xmlText([ - data.loc[0],data.loc[1],data.direction,this.next]); - break; - case "follow": // 跟随勇士 - this.next = MotaActionBlocks['follow_s'].xmlText([data.name||"", this.next]); - break; - case "unfollow": // 取消跟随 - this.next = MotaActionBlocks['unfollow_s'].xmlText([data.name||"", this.next]); - break; - case "animate": // 显示动画 - var animate_loc = data.loc||''; - if(animate_loc && animate_loc!=='hero')animate_loc = animate_loc[0]+','+animate_loc[1]; - this.next = MotaActionBlocks['animate_s'].xmlText([ - data.name,animate_loc,data.alignWindow||false,data.async||false,this.next]); - break; - case "setViewport": // 设置视角 - data.loc = data.loc||['','']; - this.next = MotaActionBlocks['setViewport_s'].xmlText([ - data.loc[0],data.loc[1],this.next]); - break; - case "moveViewport": // 移动视角 - this.next = MotaActionBlocks['moveViewport_s'].xmlText([ - data.time,data.async||false,this.StepString(data.steps),this.next]); - break; - case "vibrate": // 画面震动 - this.next = MotaActionBlocks['vibrate_s'].xmlText([data.time||0, data.async||false, this.next]); - break; - case "showImage": // 显示图片 - data.loc=data.loc||['',''] - if (data.sloc) { - this.next = MotaActionBlocks['showImage_1_s'].xmlText([ - data.code,data.image||data.name,data.sloc[0],data.sloc[1],data.sloc[2],data.sloc[3],data.opacity, - data.loc[0],data.loc[1],data.loc[2],data.loc[3],data.time||0,data.async||false,this.next - ]); - } - else { - this.next = MotaActionBlocks['showImage_s'].xmlText([ - data.code,data.image||data.name,data.loc[0],data.loc[1],data.opacity,data.time||0,data.async||false,this.next]); - } - break; - case "hideImage": // 清除图片 - this.next = MotaActionBlocks['hideImage_s'].xmlText([ - data.code,data.time||0,data.async||false,this.next]); - break; - case "showTextImage": // 显示图片化文本 - data.loc=data.loc||['',''] - this.next = MotaActionBlocks['showTextImage_s'].xmlText([ - this.EvalString(data.text),data.code,data.loc[0],data.loc[1],data.lineHeight||1.4,data.opacity,data.time||0,data.async||false,this.next]); - break; - case "moveImage": // 移动图片 - data.to=data.to||['',''] - this.next = MotaActionBlocks['moveImage_s'].xmlText([ - data.code, data.to[0], data.to[1], data.opacity, data.time||0, data.async||false, this.next]); - break; - case "showGif": // 显示动图 - data.loc=data.loc||['',''] - this.next = MotaActionBlocks['showGif_s'].xmlText([ - data.name,data.loc[0],data.loc[1],this.next]); - break; - case "setCurtain": // 颜色渐变 - if(this.isset(data.color)){ - data.color = this.Colour(data.color); - this.next = MotaActionBlocks['setCurtain_0_s'].xmlText([ - data.color,'rgba('+data.color+')',data.time,data.keep||false,data.async||false,this.next]); - } else { - this.next = MotaActionBlocks['setCurtain_1_s'].xmlText([ - data.time,data.async||false,this.next]); - } - break; - case "screenFlash": // 画面闪烁 - data.color = this.Colour(data.color); - this.next = MotaActionBlocks['screenFlash_s'].xmlText([ - data.color,'rgba('+data.color+')',data.time||500,data.times,data.async||false,this.next]); - break; - case "setWeather": // 更改天气 - this.next = MotaActionBlocks['setWeather_s'].xmlText([ - data.name,data.level||1,data.keep||false,this.next]); - break; - case "openDoor": // 开一个门, 包括暗墙 - data.loc=data.loc||['',''] - this.next = MotaActionBlocks['openDoor_s'].xmlText([ - data.loc[0],data.loc[1],data.floorId||'',data.needKey||false,data.async||false,this.next]); - break; - case "closeDoor": // 关一个门,需要该点无事件 - data.loc=data.loc||['',''] - this.next = MotaActionBlocks['closeDoor_s'].xmlText([ - data.loc[0],data.loc[1],data.id,data.async||false,this.next]); - break; - case "useItem": // 使用道具 - this.next = MotaActionBlocks['useItem_s'].xmlText([ - data.id,this.next]); - break; - case "loadEquip": // 装上装备 - this.next = MotaActionBlocks['loadEquip_s'].xmlText([ - data.id,this.next]); - break; - case "unloadEquip": // 卸下装备 - this.next = MotaActionBlocks['unloadEquip_s'].xmlText([ - data.pos,this.next]); - break; - case "openShop": // 打开一个全局商店 - this.next = MotaActionBlocks['openShop_s'].xmlText([ - data.id,data.open||false,this.next]); - break; - case "disableShop": // 禁用一个全局商店 - this.next = MotaActionBlocks['disableShop_s'].xmlText([ - data.id,this.next]); - break; - case "battle": // 强制战斗 - if (data.id) { - this.next = MotaActionBlocks['battle_s'].xmlText([ - data.id,this.next]); - } - else { - data.loc = data.loc || []; - this.next = MotaActionBlocks['battle_1_s'].xmlText([ - data.loc[0],data.loc[1],this.next]); - } - break; - case "trigger": // 触发另一个事件 - data.loc = data.loc || []; - this.next = MotaActionBlocks['trigger_s'].xmlText([ - data.loc[0],data.loc[1],this.next]); - break; - case "insert": // 强制插入另一个点的事件在当前事件列表执行,当前坐标和楼层不会改变 - if (data.args instanceof Array) { - data.args = JSON.stringify(data.args); - } - else data.args = null; - if (this.isset(data.name)) { - this.next = MotaActionBlocks['insert_1_s'].xmlText([ - data.name, data.args||"", this.next]); - } - else { - data.loc = data.loc || []; - this.next = MotaActionBlocks['insert_2_s'].xmlText([ - data.loc[0],data.loc[1],data.which,data.floorId||'',data.args||"",this.next]); - } - break; - case "playSound": - this.next = MotaActionBlocks['playSound_s'].xmlText([ - data.name,data.stop,this.next]); - break; - case "playBgm": - this.next = MotaActionBlocks['playBgm_s'].xmlText([ - data.name,data.startTime||0,data.keep||false,this.next]); - break - case "pauseBgm": - this.next = MotaActionBlocks['pauseBgm_s'].xmlText([ - this.next]); - break - case "resumeBgm": - this.next = MotaActionBlocks['resumeBgm_s'].xmlText([ - data.resume||false,this.next]); - break - case "loadBgm": - this.next = MotaActionBlocks['loadBgm_s'].xmlText([ - data.name,this.next]); - break - case "freeBgm": - this.next = MotaActionBlocks['freeBgm_s'].xmlText([ - data.name,this.next]); - break - case "stopSound": - this.next = MotaActionBlocks['stopSound_s'].xmlText([ - this.next]); - break - case "setVolume": - this.next = MotaActionBlocks['setVolume_s'].xmlText([ - data.value, data.time, data.async||false, this.next]); - break - case "setValue": - this.next = MotaActionBlocks['setValue_s'].xmlText([ - this.expandIdBlock([data.name]), data["operator"]||'=', - this.expandEvalBlock([data.value]), - data.norefresh || false, - this.next]); - break; - case "setEnemy": - this.next = MotaActionBlocks['setEnemy_s'].xmlText([ - data.id, data.name, this.expandEvalBlock([data.value]), this.next]); - break; - case "setFloor": - this.next = MotaActionBlocks['setFloor_s'].xmlText([ - data.name, data.floorId||null, data.value, this.next]); - break; - case "setGlobalAttribute": - this.next = MotaActionBlocks['setGlobalAttribute_s'].xmlText([ - data.name, data.value, this.next]); - break; - case "setGlobalValue": - this.next = MotaActionBlocks['setGlobalValue_s'].xmlText([ - data.name, data.value, this.next]); - break; - case "setGlobalFlag": - this.next = MotaActionBlocks['setGlobalFlag_s'].xmlText([ - data.name, data.value, this.next]); - break; - case "input": - this.next = MotaActionBlocks['input_s'].xmlText([ - data.text,this.next]); - break; - case "input2": - this.next = MotaActionBlocks['input2_s'].xmlText([ - data.text,this.next]); - break; - case "if": // 条件判断 - if (data["false"]) { - this.next = MotaActionBlocks['if_s'].xmlText([ - this.expandEvalBlock([data.condition]), - this.insertActionList(data["true"]), - this.insertActionList(data["false"]), - this.next]); - } - else { - this.next = MotaActionBlocks['if_1_s'].xmlText([ - this.expandEvalBlock([data.condition]), - this.insertActionList(data["true"]), - this.next]); - } - break; - case "confirm": // 显示确认框 - this.next = MotaActionBlocks['confirm_s'].xmlText([ - this.EvalString(data.text), data.timeout||0, data["default"], - this.insertActionList(data["yes"]), - this.insertActionList(data["no"]), - this.next]); - break; - case "switch": // 多重条件分歧 - var case_caseList = null; - for(var ii=data.caseList.length-1,caseNow;caseNow=data.caseList[ii];ii--) { - case_caseList=MotaActionBlocks['switchCase'].xmlText([ - this.isset(caseNow.case)?this.expandEvalBlock([caseNow.case]):"值",caseNow.nobreak,this.insertActionList(caseNow.action),case_caseList]); - } - this.next = MotaActionBlocks['switch_s'].xmlText([ - this.expandEvalBlock([data.condition]), - case_caseList,this.next]); - break; - case "choices": // 提供选项 - var text_choices = null; - for(var ii=data.choices.length-1,choice;choice=data.choices[ii];ii--) { - choice.color = this.Colour(choice.color); - text_choices=MotaActionBlocks['choicesContext'].xmlText([ - choice.text,choice.icon,choice.color,'rgba('+choice.color+')',choice.condition||'',this.insertActionList(choice.action),text_choices]); - } - if (!this.isset(data.text)) data.text = ''; - var info = this.getTitleAndPosition(data.text); - this.next = MotaActionBlocks['choices_s'].xmlText([ - info[3],info[0],info[1],data.timeout||0,text_choices,this.next]); - break; - case "for": // 循环遍历 - this.next = MotaActionBlocks['for_s'].xmlText([ - this.expandEvalBlock([data.name]), - data.from || 0, data.to || 0, data.step || 0, - this.insertActionList(data.data), - this.next]); - break; - case "forEach": // 循环遍历列表 - this.next = MotaActionBlocks['forEach_s'].xmlText([ - this.expandEvalBlock([data.name]), - JSON.stringify(data.list), - this.insertActionList(data.data), - this.next]); - break; - case "while": // 前置条件循环处理 - this.next = MotaActionBlocks['while_s'].xmlText([ - this.expandEvalBlock([data.condition]), - this.insertActionList(data.data), - this.next]); - break; - case "dowhile": // 后置条件循环处理 - this.next = MotaActionBlocks['dowhile_s'].xmlText([ - this.insertActionList(data.data), - this.expandEvalBlock([data.condition]), - this.next]); - break; - case "break": // 跳出循环 - this.next = MotaActionBlocks['break_s'].xmlText([ - this.next]); - break; - case "continue": // 继续执行当前循环 - this.next = MotaActionBlocks['continue_s'].xmlText([ - this.next]); - break; - case "win": - this.next = MotaActionBlocks['win_s'].xmlText([ - data.reason,data.norank?true:false,data.noexit?true:false,this.next]); - break; - case "lose": - 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'); - this.next = MotaActionBlocks['function_s'].xmlText([ - data.async||false,func,this.next]); - break; - case "update": - this.next = MotaActionBlocks['update_s'].xmlText([ - this.next, this.doNotCheckAutoEvents||false]); - break; - case "showStatusBar": - this.next = MotaActionBlocks['showStatusBar_s'].xmlText([ - this.next]); - break; - case "hideStatusBar": - this.next = MotaActionBlocks['hideStatusBar_s'].xmlText([ - data.toolbox||false,this.next]); - break; - case "showHero": - this.next = MotaActionBlocks['showHero_s'].xmlText([ - this.next]); - break; - case "hideHero": - this.next = MotaActionBlocks['hideHero_s'].xmlText([ - this.next]); - break; - case "sleep": // 等待多少毫秒 - this.next = MotaActionBlocks['sleep_s'].xmlText([ - data.time||0,data.noSkip||false,this.next]); - break; - case "wait": // 等待用户操作 - var case_waitList = null; - if (data.data) { - for(var ii=data.data.length-1,caseNow;caseNow=data.data[ii];ii--) { - if (caseNow["case"] == "keyboard") { - case_waitList = MotaActionBlocks['waitContext_1'].xmlText([ - caseNow.keycode || "0", this.insertActionList(caseNow.action), case_waitList - ]); - } else if (caseNow["case"] == "mouse") { - case_waitList = MotaActionBlocks['waitContext_2'].xmlText([ - caseNow.px[0], caseNow.px[1], caseNow.py[0], caseNow.py[1], this.insertActionList(caseNow.action), case_waitList - ]); - } - } - } - this.next = MotaActionBlocks['wait_s'].xmlText([ - data.timeout||0,case_waitList, this.next]); - break; - case "waitAsync": // 等待所有异步事件执行完毕 - this.next = MotaActionBlocks['waitAsync_s'].xmlText([ - this.next]); - break; - case "callBook": // 呼出怪物手册 - this.next = MotaActionBlocks['callBook_s'].xmlText([ - this.next]); - break; - case "callSave": // 呼出存档界面 - this.next = MotaActionBlocks['callSave_s'].xmlText([ - this.next]); - break; - case "autoSave": // 自动存档 - this.next = MotaActionBlocks['autoSave_s'].xmlText([ - data.nohint||false, this.next]); - break; - case "callLoad": // 呼出读档界面 - this.next = MotaActionBlocks['callLoad_s'].xmlText([ - this.next]); - break; - case "exit": // 立刻结束事件 - this.next = MotaActionBlocks['exit_s'].xmlText([ - this.next]); - break; - case "previewUI": // UI绘制预览 - this.next = MotaActionBlocks['previewUI_s'].xmlText([ - this.insertActionList(data.action), this.next - ]); - break; - case "clearMap": // 清除画布 - if (data.x != null && data.y != null && data.width != null && data.height != null) { - this.next = MotaActionBlocks['clearMap_s'].xmlText([ - data.x, data.y, data.width, data.height, this.next - ]); - } - else { - this.next = MotaActionBlocks['clearMap_1_s'].xmlText([this.next]); - } - break; - case "setAttribute": // 设置画布属性 - data.fillStyle=this.Colour(data.fillStyle); - data.strokeStyle=this.Colour(data.strokeStyle); - this.next = MotaActionBlocks['setAttribute_s'].xmlText([ - data.font,data.fillStyle,'rgba('+data.fillStyle+')',data.strokeStyle,'rgba('+data.strokeStyle+')', - data.lineWidth,data.alpha,data.align,data.baseline,data.z,this.next]); - break; - case "fillText": // 绘制一行文本 - data.style = this.Colour(data.style); - this.next = MotaActionBlocks['fillText_s'].xmlText([ - data.x, data.y, data.style, 'rgba('+data.style+')', data.font, data.maxWidth, this.EvalString(data.text), this.next - ]); - break; - case "fillBoldText": // 绘制一行描边文本 - data.style = this.Colour(data.style); - this.next = MotaActionBlocks['fillBoldText_s'].xmlText([ - data.x, data.y, data.style, 'rgba('+data.style+')', data.strokeStyle, 'rgba('+(data.strokeStyle||"0,0,0,1")+')', - data.font, this.EvalString(data.text), this.next - ]); - break; - case "drawTextContent": // 绘制多行文本 - data.color = this.Colour(data.color); - this.next = MotaActionBlocks['drawTextContent_s'].xmlText([ - this.EvalString(data.text), data.left, data.top, data.maxWidth, data.color, 'rgba('+data.color+')', - data.align, data.fontSize, data.lineHeight, data.bold, this.next - ]); - break; - case "fillRect": // 绘制矩形 - data.style = this.Colour(data.style); - this.next = MotaActionBlocks['fillRect_s'].xmlText([ - data.x, data.y, data.width, data.height, data.radius, data.style, 'rgba('+data.style+')', this.next - ]); - break; - case "strokeRect": // 绘制矩形边框 - data.style = this.Colour(data.style); - this.next = MotaActionBlocks['strokeRect_s'].xmlText([ - data.x, data.y, data.width, data.height, data.radius, data.style, 'rgba('+data.style+')', data.lineWidth, this.next - ]); - break; - case "drawLine": // 绘制线段 - data.style = this.Colour(data.style); - this.next = MotaActionBlocks['drawLine_s'].xmlText([ - data.x1, data.y1, data.x2, data.y2, data.style, 'rgba('+data.style+')', data.lineWidth, this.next - ]); - break; - case "drawArrow": // 绘制线段 - data.style = this.Colour(data.style); - this.next = MotaActionBlocks['drawArrow_s'].xmlText([ - data.x1, data.y1, data.x2, data.y2, data.style, 'rgba('+data.style+')', data.lineWidth, this.next - ]); - break; - case "fillPolygon": // 绘制多边形 - data.style = this.Colour(data.style); - var x_str=[],y_str=[]; - data.nodes.forEach(function (t) { - x_str.push(t[0]); - y_str.push(t[1]); - }) - this.next = MotaActionBlocks['fillPolygon_s'].xmlText([ - x_str.join(','), y_str.join(','), data.style, 'rgba('+data.style+')', this.next - ]); - break; - case "strokePolygon": // 绘制多边形 - data.style = this.Colour(data.style); - var x_str=[],y_str=[]; - data.nodes.forEach(function (t) { - x_str.push(t[0]); - y_str.push(t[1]); - }) - this.next = MotaActionBlocks['strokePolygon_s'].xmlText([ - x_str.join(','), y_str.join(','), data.style, 'rgba('+data.style+')', data.lineWidth, this.next - ]); - break; - case "fillEllipse": // 绘制椭圆 - data.style = this.Colour(data.style); - this.next = MotaActionBlocks['fillEllipse_s'].xmlText([ - data.x, data.y, data.a, data.b, data.angle, data.style, 'rgba('+data.style+')', this.next - ]); - break; - case "strokeEllipse": // 绘制椭圆边框 - data.style = this.Colour(data.style); - this.next = MotaActionBlocks['strokeEllipse_s'].xmlText([ - data.x, data.y, data.a, data.b, data.angle, data.style, 'rgba('+data.style+')', data.lineWidth, this.next - ]); - break; - case "fillArc": // 绘制弧 - data.style = this.Colour(data.style); - this.next = MotaActionBlocks['fillArc_s'].xmlText([ - data.x, data.y, data.r, data.start, data.end, data.style, 'rgba('+data.style+')', this.next - ]); - break; - case "strokeArc": // 绘制弧 - data.style = this.Colour(data.style); - this.next = MotaActionBlocks['strokeArc_s'].xmlText([ - data.x, data.y, data.r, data.start, data.end, data.style, 'rgba('+data.style+')', data.lineWidth, this.next - ]); - break; - case "drawImage": // 绘制图片 - if (data.x1 != null && data.y1 != null && data.w1 != null && data.h1 != null) { - this.next = MotaActionBlocks['drawImage_1_s'].xmlText([ - data.image, data.x, data.y, data.w, data.h, data.x1, data.y1, data.w1, data.h1, this.next - ]); - } - else { - this.next = MotaActionBlocks['drawImage_s'].xmlText([ - data.image, data.x, data.y, data.w, data.h, this.next - ]); - } - break; - case "drawIcon": // 绘制图标 - this.next = MotaActionBlocks['drawIcon_s'].xmlText([ - data.id, data.frame||0, data.x, data.y, data.width, data.height, this.next - ]); - break; - case "drawBackground": // 绘制背景 - if (!/^\w+\.png$/.test(data.background)) - data.background=this.Colour(data.background); - this.next = MotaActionBlocks['drawBackground_s'].xmlText([ - data.background, 'rgba('+data.background+')', data.x, data.y, data.width, data.height, this.next - ]); - break; - case "drawSelector": // 绘制光标 - if (data.image) { - this.next = MotaActionBlocks['drawSelector_s'].xmlText([ - data.image, data.code, data.x, data.y, data.width, data.height, this.next - ]); - } - else { - this.next = MotaActionBlocks['drawSelector_1_s'].xmlText([data.code, this.next]); - } - case "animateImage": // 兼容 animateImage - break; - default: - this.next = MotaActionBlocks['unknown_s'].xmlText([ - JSON.stringify(data),this.next]); - } - this.parseAction(); - return; -} - -////// 往当前事件列表之后添加一个事件组 ////// -ActionParser.prototype.insertActionList = function (actionList) { - if (actionList.length===0) return null; - this.event.data.list.push({"type": "_next", "next": this.next}); - this.event.data.list=this.event.data.list.concat(actionList); - this.next = null; - this.parseAction(); - return this.result; -} - -////// 判断某对象是否不为undefined也不会null ////// -ActionParser.prototype.isset = function (val) { - if (val === undefined || val === null) { - return false; - } - return true -} - -ActionParser.prototype.StepString = function(steplist) { - var stepchar = { - 'up': '上', - 'down': '下', - 'left': '左', - 'right': '右', - 'forward': '前', - 'backward': '后' - } - var StepString = ''; - var last = null, number = 0; - steplist.forEach(function (v) { - if (v != last) { - if (last != null) { - StepString += stepchar[last]; - if (number > 1) StepString += number; - } - last = v; - number = 1; - } else { - number++; - } - }); - if (last != null) { - StepString += stepchar[last]; - if (number > 1) StepString += number; - } - return StepString; -} - -ActionParser.prototype.EvalString = function(EvalString) { - return EvalString.split('\b').join('\\b').split('\t').join('\\t').split('\n').join('\\n'); -} - -ActionParser.prototype.getTitleAndPosition = function (string) { - string = this.EvalString(string); - var title = '', icon = '', position = ''; - string = string.replace(/\\t\[(([^\],]+),)?([^\],]+)\]/g, function (s0, s1, s2, s3) { - if (s3) title = s3; - if (s2) { icon = s3; title = s2; } - if (icon && !/^(.*)\.(jpg|jpeg|png)$/.test(icon) - && !/^[0-9a-zA-Z_][0-9a-zA-Z_:]*$/.test(icon)) { title += "," + icon; icon = ''; } - return ""; - }).replace(/\\b\[(.*?)\]/g, function (s0, s1) { - position = s1; return ""; - }); - return [title, icon, position, string]; -} - -ActionParser.prototype.Colour = function(color) { - return color?JSON.stringify(color).slice(1,-1):null; -} - -ActionParser.prototype.matchId = function(args, isShadow, comment) { - var rt=function(xml){ - return {xml:xml,ret:true} - } - var match = /nothing/.exec('nothing') - // 固定列表 - var FixedId_List=MotaActionBlocks.idFixedList_e.json.args0[0].options; // [["生命", "status:hp"], ...] - match=new RegExp('^('+FixedId_List.map(function(v){return v[1]}).join('|')+')$').exec(args[0]) - if(match){ - return rt(MotaActionBlocks['idFixedList_e'].xmlText(args, isShadow, comment)); - } - // 独立开关 - match=/^switch:([A-Z])$/.exec(args[0]) - if(match){ - args[0]=match[1] - return rt(MotaActionBlocks['idFlag_e'].xmlText(args, isShadow, comment)); - } - // 临时变量 - match=/^temp:([A-Z])$/.exec(args[0]) - if(match){ - args[0]=match[1] - return rt(MotaActionBlocks['idTemp_e'].xmlText(args, isShadow, comment)); - } - // id列表 - var Id_List = MotaActionBlocks.idIdList_e.json.args0[0].options; // [["变量", "flag"], ...] - match=new RegExp('^('+Id_List.map(function(v){return v[1]}).join('|')+'):([a-zA-Z0-9_\\u4E00-\\u9FCC]+)$').exec(args[0]) - if(match){ - args=[match[1],match[2]].concat(args.slice(1)) - return rt(MotaActionBlocks['idIdList_e'].xmlText(args, isShadow, comment)); - } - return {xml:'',ret:false} -} - -ActionParser.prototype.expandIdBlock = function(args, isShadow, comment) { - var ret=this.matchId(args, isShadow, comment) - if (ret.ret) return ret.xml; - return MotaActionBlocks['idString_e'].xmlText(args, isShadow, comment); -} - -ActionParser.prototype.expandEvalBlock = function(args, isShadow, comment) { - var ret=this.matchId(args, isShadow, comment) - if (ret.ret) return ret.xml; - // todo - // 1. 将「数值设置」的名称尽可能替换掉;如果是 FixedId_List 那就用它;否则如果是 独立开关/临时变量 那就用对应的;否则用 A:B 的那个框 - // 2. 将「值块」尽可能替换掉,主要是「独立开关」,「临时变量」,「非 - 独立开关」,「非-临时变量」;以及true/false替换成勾选框;对于其他变量/属性等之类也尽可能进行替换 - - return MotaActionBlocks['evalString_e'].xmlText(args, isShadow, comment); -} - -MotaActionFunctions.actionParser = new ActionParser(); - -MotaActionFunctions.workspace = function(){return workspace} - -MotaActionFunctions.parse = function(obj,type) { - try { - obj = JSON.parse(MotaActionFunctions.replaceToName(JSON.stringify(obj))); - } catch (e) {} - MotaActionFunctions.workspace().clear(); - xml_text = MotaActionFunctions.actionParser.parse(obj,type||'event'); - xml = Blockly.Xml.textToDom(''+xml_text+''); - Blockly.Xml.domToWorkspace(xml, MotaActionFunctions.workspace()); -} - -MotaActionFunctions.EvalString_pre = function(EvalString){ - if (EvalString.indexOf('__door__')!==-1) throw new Error('请修改开门变量__door__,如door1,door2,door3等依次向后。请勿存在两个门使用相同的开门变量。'); - EvalString = MotaActionFunctions.replaceFromName(EvalString); - return EvalString.replace(/([^\\])"/g,'$1\\"').replace(/^"/g,'\\"').replace(/""/g,'"\\"'); -} - -MotaActionFunctions.JsonEvalString_pre = function (JsonEvalString) { - if (JsonEvalString == '') return ''; - JsonEvalString = MotaActionFunctions.replaceFromName(JsonEvalString); - try { - return JSON.stringify(JSON.parse(JsonEvalString)); - } catch (e) { - throw new Error('此处需要填写一个合法的JSON内容'); - } -} - -MotaActionFunctions.IntString_pre = function (IntString) { - if (!/^\d*$/.test(IntString)) throw new Error('此项必须是整数或不填'); - return IntString; -} - -MotaActionFunctions.IdString_pre = function(IdString){ - if (IdString.indexOf('__door__')!==-1) throw new Error('请修改开门变量__door__,如door1,door2,door3等依次向后。请勿存在两个门使用相同的开门变量。'); - IdString = MotaActionFunctions.replaceFromName(IdString); - if (IdString && !(MotaActionFunctions.pattern.id.test(IdString)) && !(MotaActionFunctions.pattern.idWithoutFlag.test(IdString))) - throw new Error('id: '+IdString+'中包含了0-9 a-z A-Z _ - :之外的字符'); - return IdString; -} - -MotaActionFunctions.PosString_pre = function(PosString){ - if (!PosString || /^-?\d+$/.test(PosString)) return PosString; - //if (!(MotaActionFunctions.pattern.id.test(PosString)))throw new Error(PosString+'中包含了0-9 a-z A-Z _ 和中文之外的字符,或者是没有以flag: 开头'); - return '"'+MotaActionFunctions.replaceFromName(PosString)+'"'; -} - -MotaActionFunctions.StepString_pre = function(StepString){ - //StepString='上右3下2左上左2' - var route = StepString.replace(/上/g,'U').replace(/下/g,'D').replace(/左/g,'L').replace(/右/g,'R').replace(/前/g,'F').replace(/后/g,'B'); - - //copyed from core.js - var ans=[], index=0; - - var isset = function(a) { - if (a == undefined || a == null) { - return false; - } - return true; - } - var getNumber = function (noparse) { - var num=""; - while (index= 0 ? 'equipKnown' : 'equipUnknown'; + text_choices = MotaActionBlocks[one].xmlText([ + key, obj[key], text_choices + ]); + }) + return text_choices; + } + return MotaActionBlocks['equip_m'].xmlText([obj.type, obj.animate, buildEquip(obj.value), buildEquip(obj.percentage)]); + + case 'doorInfo': + if(!obj) obj={}; + var buildKeys = function (obj) { + obj = obj || {}; + var text_choices = null; + var knownListKeys = MotaActionBlocks['Key_List'].options.map(function (one) {return one[1];}) + Object.keys(obj).sort().forEach(function (key) { + var one = knownListKeys.indexOf(key) >= 0 ? 'doorKeyKnown' : 'doorKeyUnknown'; + text_choices = MotaActionBlocks[one].xmlText([ + one == 'doorKeyUnknown' ? MotaActionFunctions.replaceToName_token(key) : key, obj[key], text_choices + ]); + }) + return text_choices; + } + return MotaActionBlocks['doorInfo_m'].xmlText([obj.time || 160, obj.openSound, obj.closeSound, buildKeys(obj.keys)]); + + case 'floorImage': + if(!obj) obj=[]; + var text_choices = null; + for(var ii=obj.length-1,choice;choice=obj[ii];ii--) { + text_choices=MotaActionBlocks['floorOneImage'].xmlText([ + choice.name, choice.reverse, choice.canvas||'bg', choice.x||0, choice.y||0, choice.disable||false, + choice.sx, choice.sy, choice.w, choice.h, choice.frame, text_choices]); + } + return MotaActionBlocks['floorImage_m'].xmlText([text_choices]); + + case 'faceIds': + if(!obj) obj={}; + return MotaActionBlocks['faceIds_m'].xmlText([obj.up||"", obj.down||"", obj.left||"", obj.right||""]); + + case 'mainStyle': + if(!obj) obj={}; + return MotaActionBlocks['mainStyle_m'].xmlText([ + obj.startBackground, obj.startLogoStyle, obj.startButtonsStyle, obj.statusLeftBackground, obj.statusTopBackground, + obj.toolsBackground, obj.floorChangingStyle, + obj.statusBarColor, 'rgba('+obj.statusBarColor+')', obj.borderColor, 'rgba('+obj.borderColor+')', obj.font + ]); + + case 'shop': + var buildsub = function(obj,parser,next){ + var text_choices = null; + for(var ii=obj.choices.length-1,choice;choice=obj.choices[ii];ii--) { + text_choices=MotaActionBlocks['shopChoices'].xmlText([ + choice.text,choice.need||'',choice.icon,choice.color,'rgba('+choice.color+')',choice.condition,parser.parseList(choice.action),text_choices]); + } + var info = parser.getTitleAndPosition(obj.text || ''); + return MotaActionBlocks['shopsub'].xmlText([ + obj.id,obj[0],info[1],info[3],obj.textInList,obj.mustEnable,obj.disablePreview,text_choices,next + ]); + } + var buildcommentevent = function(obj,parser,next){ + if (obj.args instanceof Array) { + obj.args = JSON.stringify(obj.args); + } + else obj.args = null; + return MotaActionBlocks['shopcommonevent'].xmlText([ + obj.id,parser.EvalString(obj.textInList),obj.mustEnable,parser.EvalString(obj.commonEvent),obj.args,next + ]); + } + var builditem = function (obj,parser,next){ + var text_choices = null; + for(var ii=obj.choices.length-1,choice;choice=obj.choices[ii];ii--) { + text_choices = MotaActionBlocks['shopItemChoices'].xmlText([ + choice.id, choice.number == null ? "" : (""+choice.number), choice.money == null ? "" : (""+choice.money), + choice.sell == null ? "" : (""+choice.sell), choice.condition || "", text_choices + ]); + } + return MotaActionBlocks['shopitem'].xmlText([ + obj.id,obj.textInList,obj.mustEnable,text_choices,next + ]); + } + var next=null; + if(!obj)obj=[]; + while(obj.length){ + var shopobj=obj.pop() + if(shopobj.item) + next=builditem(shopobj,this,next); + else if(shopobj.choices) + next=buildsub(shopobj,this,next); + else if(shopobj.commonEvent) + next=buildcommentevent(shopobj,this,next); + else + throw new Error("[警告]出错啦!\n"+shopobj.id+" 无效的商店"); + } + return MotaActionBlocks['shop_m'].xmlText([next]); + + default: + return MotaActionBlocks[type+'_m'].xmlText([this.parseList(obj)]); + } +} + +////// 开始解析一系列自定义事件 ////// +ActionParser.prototype.parseList = function (list) { + if (!this.isset(list)) return MotaActionBlocks['pass_s'].xmlText([],true); + if (!(list instanceof Array)) { + list = [list]; + } + if (list.length===0) return MotaActionBlocks['pass_s'].xmlText([],true); + this.event = {'id': 'action', 'data': { + 'list': list + }} + this.next = null; + this.result = null; + this.parseAction(); + return this.result; +} + +////// 解析当前自定义事件列表中的最后一个事件 ////// +ActionParser.prototype.parseAction = function() { + + // 事件处理完毕 + if (this.event.data.list.length==0) { + this.result = this.next; + this.next = null; + return; + } + + var data = this.event.data.list.pop(); + this.event.data.current = data; + + // 不同种类的事件 + + // 如果是文字:显示 + if (typeof data == "string") { + data={"type": "text", "text": data} + } + this.event.data.type=data.type; + switch (data.type) { + case "_next": + this.result = this.next; + this.next = data.next; + return; + case "text": // 文字/对话 + var info = this.getTitleAndPosition(data.text); + if (info[0] || info[1] || info[2]) { + this.next = MotaActionBlocks['text_1_s'].xmlText([ + info[0], info[1], info[2], info[3], this.next]); + } + else { + this.next = MotaActionBlocks['text_0_s'].xmlText([info[3],this.next]); + } + break; + case "autoText": // 自动剧情文本 + var info = this.getTitleAndPosition(data.text); + this.next = MotaActionBlocks['autoText_s'].xmlText([ + info[0],info[1],info[2],data.time,info[3],this.next]); + break; + case "scrollText": + this.next = MotaActionBlocks['scrollText_s'].xmlText([ + data.time, data.lineHeight||1.4, data.async||false, this.EvalString(data.text), this.next]); + break; + case "comment": // 注释 + this.next = MotaActionBlocks['comment_s'].xmlText([this.EvalString(data.text),this.next],null,data.text); + break; + case "setText": // 设置剧情文本的属性 + data.title=this.Colour(data.title); + data.text=this.Colour(data.text); + if (!/^\w+\.png$/.test(data.background)) + data.background=this.Colour(data.background); + this.next = MotaActionBlocks['setText_s'].xmlText([ + data.position,data.offset,data.align,data.title,'rgba('+data.title+')', + data.text,'rgba('+data.text+')',data.background,'rgba('+data.background+')', + data.bold,data.titlefont,data.textfont,data.lineHeight,data.time,data.interval,this.next]); + break; + case "tip": + this.next = MotaActionBlocks['tip_s'].xmlText([ + data.text,data.icon||"",this.next]); + break; + case "show": // 显示 + data.loc=data.loc||[]; + if (!(data.loc[0] instanceof Array)) + data.loc = [data.loc]; + var x_str=[],y_str=[]; + data.loc.forEach(function (t) { + x_str.push(t[0]); + y_str.push(t[1]); + }) + this.next = MotaActionBlocks['show_s'].xmlText([ + x_str.join(','),y_str.join(','),data.floorId||'',data.time,data.async||false,this.next]); + break; + case "hide": // 消失 + data.loc=data.loc||[]; + if (!(data.loc[0] instanceof Array)) + data.loc = [data.loc]; + var x_str=[],y_str=[]; + data.loc.forEach(function (t) { + x_str.push(t[0]); + y_str.push(t[1]); + }) + this.next = MotaActionBlocks['hide_s'].xmlText([ + x_str.join(','),y_str.join(','),data.floorId||'',data.remove||false,data.time,data.async||false,this.next]); + break; + case "setBlock": // 设置图块 + data.loc=data.loc||[]; + if (!(data.loc[0] instanceof Array)) + data.loc = [data.loc]; + var x_str=[],y_str=[]; + data.loc.forEach(function (t) { + x_str.push(t[0]); + y_str.push(t[1]); + }) + this.next = MotaActionBlocks['setBlock_s'].xmlText([ + data.number||0,x_str.join(','),y_str.join(','),data.floorId||'',data.time,data.async||false,this.next]); + break; + case "turnBlock": // 事件转向 + data.loc=data.loc||[]; + if (!(data.loc[0] instanceof Array)) + data.loc = [data.loc]; + var x_str=[],y_str=[]; + data.loc.forEach(function (t) { + x_str.push(t[0]); + y_str.push(t[1]); + }) + this.next = MotaActionBlocks['turnBlock_s'].xmlText([ + data.direction,x_str.join(','),y_str.join(','),data.floorId||'',this.next]); + break; + case "showFloorImg": // 显示贴图 + data.loc=data.loc||[]; + if (!(data.loc[0] instanceof Array)) + data.loc = [data.loc]; + var x_str=[],y_str=[]; + data.loc.forEach(function (t) { + x_str.push(t[0]); + y_str.push(t[1]); + }) + this.next = MotaActionBlocks['showFloorImg_s'].xmlText([ + x_str.join(','),y_str.join(','),data.floorId||'',this.next]); + break; + case "hideFloorImg": // 隐藏贴图 + data.loc=data.loc||[]; + if (!(data.loc[0] instanceof Array)) + data.loc = [data.loc]; + var x_str=[],y_str=[]; + data.loc.forEach(function (t) { + x_str.push(t[0]); + y_str.push(t[1]); + }) + this.next = MotaActionBlocks['hideFloorImg_s'].xmlText([ + x_str.join(','),y_str.join(','),data.floorId||'',this.next]); + break; + case "showBgFgMap": // 显示图层块 + data.loc=data.loc||[]; + if (!(data.loc[0] instanceof Array)) + data.loc = [data.loc]; + var x_str=[],y_str=[]; + data.loc.forEach(function (t) { + x_str.push(t[0]); + y_str.push(t[1]); + }) + this.next = MotaActionBlocks['showBgFgMap_s'].xmlText([ + data.name||'bg', x_str.join(','),y_str.join(','),data.floorId||'',this.next]); + break; + case "hideBgFgMap": // 隐藏图层块 + data.loc=data.loc||[]; + if (!(data.loc[0] instanceof Array)) + data.loc = [data.loc]; + var x_str=[],y_str=[]; + data.loc.forEach(function (t) { + x_str.push(t[0]); + y_str.push(t[1]); + }) + this.next = MotaActionBlocks['hideBgFgMap_s'].xmlText([ + data.name||'bg', x_str.join(','),y_str.join(','),data.floorId||'',this.next]); + break; + case "setBgFgBlock": // 设置图块 + data.loc=data.loc||[]; + if (!(data.loc[0] instanceof Array)) + data.loc = [data.loc]; + var x_str=[],y_str=[]; + data.loc.forEach(function (t) { + x_str.push(t[0]); + y_str.push(t[1]); + }) + this.next = MotaActionBlocks['setBgFgBlock_s'].xmlText([ + data.name||'bg', data.number||0, x_str.join(','),y_str.join(','),data.floorId||'',this.next]); + break; + case "setHeroIcon": // 改变勇士 + this.next = MotaActionBlocks['setHeroIcon_s'].xmlText([ + data.name||"",this.next]); + break; + case "move": // 移动事件 + data.loc=data.loc||['','']; + this.next = MotaActionBlocks['move_s'].xmlText([ + data.loc[0],data.loc[1],data.time,data.keep||false,data.async||false,this.StepString(data.steps),this.next]); + break; + case "moveAction": // 前进一格或撞击 + this.next = MotaActionBlocks['moveAction_s'].xmlText([this.next]); + break; + case "moveHero": // 无视地形移动勇士 + this.next = MotaActionBlocks['moveHero_s'].xmlText([ + data.time,data.async||false,this.StepString(data.steps),this.next]); + break; + case "jump": // 跳跃事件 + data.from=data.from||['','']; + data.to=data.to||['','']; + this.next = MotaActionBlocks['jump_s'].xmlText([ + data.from[0],data.from[1],data.to[0],data.to[1],data.time,data.keep||false,data.async||false,this.next]); + break; + case "jumpHero": // 跳跃勇士 + data.loc=data.loc||['',''] + this.next = MotaActionBlocks['jumpHero_s'].xmlText([ + data.loc[0],data.loc[1],data.time,data.async||false,this.next]); + break; + case "changeFloor": // 楼层转换 + if (!data.loc) { + data.loc = data.loc || ['','']; + data.stair = data.stair || ':now'; + } + if (data.floorId==':before'||data.floorId==':next'||data.floorId==':now') { + data.floorType=data.floorId; + delete data.floorId; + } + this.next = MotaActionBlocks['changeFloor_s'].xmlText([ + data.floorType||'floorId',data.floorId,data.stair||'loc',data.loc[0],data.loc[1],data.direction, + data.time, this.next]); + break; + case "changePos": // 直接更换勇士位置, 不切换楼层 + data.loc=data.loc||['',''] + this.next = MotaActionBlocks['changePos_s'].xmlText([ + data.loc[0],data.loc[1],data.direction,this.next]); + break; + case "follow": // 跟随勇士 + this.next = MotaActionBlocks['follow_s'].xmlText([data.name||"", this.next]); + break; + case "unfollow": // 取消跟随 + this.next = MotaActionBlocks['unfollow_s'].xmlText([data.name||"", this.next]); + break; + case "animate": // 显示动画 + var animate_loc = data.loc||''; + if(animate_loc && animate_loc!=='hero')animate_loc = animate_loc[0]+','+animate_loc[1]; + this.next = MotaActionBlocks['animate_s'].xmlText([ + data.name,animate_loc,data.alignWindow||false,data.async||false,this.next]); + break; + case "setViewport": // 设置视角 + data.loc = data.loc||['','']; + this.next = MotaActionBlocks['setViewport_s'].xmlText([ + data.loc[0],data.loc[1],this.next]); + break; + case "moveViewport": // 移动视角 + this.next = MotaActionBlocks['moveViewport_s'].xmlText([ + data.time,data.async||false,this.StepString(data.steps),this.next]); + break; + case "vibrate": // 画面震动 + this.next = MotaActionBlocks['vibrate_s'].xmlText([data.time||0, data.async||false, this.next]); + break; + case "showImage": // 显示图片 + data.loc=data.loc||['',''] + if (data.sloc) { + this.next = MotaActionBlocks['showImage_1_s'].xmlText([ + data.code,data.image||data.name,data.reverse,data.sloc[0],data.sloc[1],data.sloc[2],data.sloc[3],data.opacity, + data.loc[0],data.loc[1],data.loc[2],data.loc[3],data.time||0,data.async||false,this.next + ]); + } + else { + this.next = MotaActionBlocks['showImage_s'].xmlText([ + data.code,data.image||data.name,data.reverse,data.loc[0],data.loc[1],data.opacity,data.time||0,data.async||false,this.next]); + } + break; + case "hideImage": // 清除图片 + this.next = MotaActionBlocks['hideImage_s'].xmlText([ + data.code,data.time||0,data.async||false,this.next]); + break; + case "showTextImage": // 显示图片化文本 + data.loc=data.loc||['',''] + this.next = MotaActionBlocks['showTextImage_s'].xmlText([ + this.EvalString(data.text),data.code,data.loc[0],data.loc[1],data.lineHeight||1.4,data.opacity,data.time||0,data.async||false,this.next]); + break; + case "moveImage": // 移动图片 + data.to=data.to||['',''] + this.next = MotaActionBlocks['moveImage_s'].xmlText([ + data.code, data.to[0], data.to[1], data.opacity, data.time||0, data.async||false, this.next]); + break; + case "showGif": // 显示动图 + data.loc=data.loc||['',''] + this.next = MotaActionBlocks['showGif_s'].xmlText([ + data.name,data.loc[0],data.loc[1],this.next]); + break; + case "setCurtain": // 颜色渐变 + if(this.isset(data.color)){ + data.color = this.Colour(data.color); + this.next = MotaActionBlocks['setCurtain_0_s'].xmlText([ + data.color,'rgba('+data.color+')',data.time,data.keep||false,data.async||false,this.next]); + } else { + this.next = MotaActionBlocks['setCurtain_1_s'].xmlText([ + data.time,data.async||false,this.next]); + } + break; + case "screenFlash": // 画面闪烁 + data.color = this.Colour(data.color); + this.next = MotaActionBlocks['screenFlash_s'].xmlText([ + data.color,'rgba('+data.color+')',data.time||500,data.times,data.async||false,this.next]); + break; + case "setWeather": // 更改天气 + this.next = MotaActionBlocks['setWeather_s'].xmlText([ + data.name,data.level||1,data.keep||false,this.next]); + break; + case "openDoor": // 开一个门, 包括暗墙 + data.loc=data.loc||['',''] + this.next = MotaActionBlocks['openDoor_s'].xmlText([ + data.loc[0],data.loc[1],data.floorId||'',data.needKey||false,data.async||false,this.next]); + break; + case "closeDoor": // 关一个门,需要该点无事件 + data.loc=data.loc||['',''] + this.next = MotaActionBlocks['closeDoor_s'].xmlText([ + data.loc[0],data.loc[1],data.id,data.async||false,this.next]); + break; + case "useItem": // 使用道具 + this.next = MotaActionBlocks['useItem_s'].xmlText([ + MotaActionFunctions.replaceToName_token(data.id),this.next]); + break; + case "loadEquip": // 装上装备 + this.next = MotaActionBlocks['loadEquip_s'].xmlText([ + MotaActionFunctions.replaceToName_token(data.id),this.next]); + break; + case "unloadEquip": // 卸下装备 + this.next = MotaActionBlocks['unloadEquip_s'].xmlText([ + data.pos,this.next]); + break; + case "openShop": // 打开一个全局商店 + this.next = MotaActionBlocks['openShop_s'].xmlText([ + data.id,data.open||false,this.next]); + break; + case "disableShop": // 禁用一个全局商店 + this.next = MotaActionBlocks['disableShop_s'].xmlText([ + data.id,this.next]); + break; + case "battle": // 强制战斗 + if (data.id) { + this.next = MotaActionBlocks['battle_s'].xmlText([ + MotaActionFunctions.replaceToName_token(data.id),this.next]); + } + else { + data.loc = data.loc || []; + this.next = MotaActionBlocks['battle_1_s'].xmlText([ + data.loc[0],data.loc[1],this.next]); + } + break; + case "trigger": // 触发另一个事件 + data.loc = data.loc || []; + this.next = MotaActionBlocks['trigger_s'].xmlText([ + data.loc[0],data.loc[1],this.next]); + break; + case "insert": // 强制插入另一个点的事件在当前事件列表执行,当前坐标和楼层不会改变 + if (data.args instanceof Array) { + data.args = JSON.stringify(data.args); + } + else data.args = null; + if (this.isset(data.name)) { + this.next = MotaActionBlocks['insert_1_s'].xmlText([ + data.name, data.args||"", this.next]); + } + else { + data.loc = data.loc || []; + this.next = MotaActionBlocks['insert_2_s'].xmlText([ + data.loc[0],data.loc[1],data.which,data.floorId||'',data.args||"",this.next]); + } + break; + case "playSound": + this.next = MotaActionBlocks['playSound_s'].xmlText([ + data.name,data.stop,this.next]); + break; + case "playBgm": + this.next = MotaActionBlocks['playBgm_s'].xmlText([ + data.name,data.startTime||0,data.keep||false,this.next]); + break + case "pauseBgm": + this.next = MotaActionBlocks['pauseBgm_s'].xmlText([ + this.next]); + break + case "resumeBgm": + this.next = MotaActionBlocks['resumeBgm_s'].xmlText([ + data.resume||false,this.next]); + break + case "loadBgm": + this.next = MotaActionBlocks['loadBgm_s'].xmlText([ + data.name,this.next]); + break + case "freeBgm": + this.next = MotaActionBlocks['freeBgm_s'].xmlText([ + data.name,this.next]); + break + case "stopSound": + this.next = MotaActionBlocks['stopSound_s'].xmlText([ + this.next]); + break + case "setVolume": + this.next = MotaActionBlocks['setVolume_s'].xmlText([ + data.value, data.time, data.async||false, this.next]); + break + case "setValue": + this.next = MotaActionBlocks['setValue_s'].xmlText([ + this.expandIdBlock([data.name]), data["operator"]||'=', + this.expandEvalBlock([data.value]), + data.norefresh || false, + this.next]); + break; + case "setEnemy": + this.next = MotaActionBlocks['setEnemy_s'].xmlText([ + MotaActionFunctions.replaceToName_token(data.id), data.name, this.expandEvalBlock([data.value]), this.next]); + break; + case "setFloor": + this.next = MotaActionBlocks['setFloor_s'].xmlText([ + data.name, data.floorId||null, JSON.stringify(data.value), this.next]); + break; + case "setGlobalAttribute": + this.next = MotaActionBlocks['setGlobalAttribute_s'].xmlText([ + data.name, data.value, this.next]); + break; + case "setGlobalValue": + this.next = MotaActionBlocks['setGlobalValue_s'].xmlText([ + data.name, data.value, this.next]); + break; + case "setGlobalFlag": + this.next = MotaActionBlocks['setGlobalFlag_s'].xmlText([ + data.name, data.value, this.next]); + break; + case "input": + this.next = MotaActionBlocks['input_s'].xmlText([ + data.text,this.next]); + break; + case "input2": + this.next = MotaActionBlocks['input2_s'].xmlText([ + data.text,this.next]); + break; + case "if": // 条件判断 + if (data["false"]) { + this.next = MotaActionBlocks['if_s'].xmlText([ + this.expandEvalBlock([data.condition]), + this.insertActionList(data["true"]), + this.insertActionList(data["false"]), + this.next]); + } + else { + this.next = MotaActionBlocks['if_1_s'].xmlText([ + this.expandEvalBlock([data.condition]), + this.insertActionList(data["true"]), + this.next]); + } + break; + case "confirm": // 显示确认框 + this.next = MotaActionBlocks['confirm_s'].xmlText([ + this.EvalString(data.text), data.timeout||0, data["default"], + this.insertActionList(data["yes"]), + this.insertActionList(data["no"]), + this.next]); + break; + case "switch": // 多重条件分歧 + var case_caseList = null; + for(var ii=data.caseList.length-1,caseNow;caseNow=data.caseList[ii];ii--) { + case_caseList=MotaActionBlocks['switchCase'].xmlText([ + this.isset(caseNow.case)?this.expandEvalBlock([caseNow.case]):"值",caseNow.nobreak,this.insertActionList(caseNow.action),case_caseList]); + } + this.next = MotaActionBlocks['switch_s'].xmlText([ + this.expandEvalBlock([data.condition]), + case_caseList,this.next]); + break; + case "choices": // 提供选项 + var text_choices = null; + for(var ii=data.choices.length-1,choice;choice=data.choices[ii];ii--) { + choice.color = this.Colour(choice.color); + text_choices=MotaActionBlocks['choicesContext'].xmlText([ + choice.text,choice.icon,choice.color,'rgba('+choice.color+')',choice.condition||'',this.insertActionList(choice.action),text_choices]); + } + if (!this.isset(data.text)) data.text = ''; + var info = this.getTitleAndPosition(data.text); + this.next = MotaActionBlocks['choices_s'].xmlText([ + info[3],info[0],info[1],data.timeout||0,text_choices,this.next]); + break; + case "for": // 循环遍历 + this.next = MotaActionBlocks['for_s'].xmlText([ + this.expandEvalBlock([data.name]), + data.from || 0, data.to || 0, data.step || 0, + this.insertActionList(data.data), + this.next]); + break; + case "forEach": // 循环遍历列表 + this.next = MotaActionBlocks['forEach_s'].xmlText([ + this.expandEvalBlock([data.name]), + JSON.stringify(data.list), + this.insertActionList(data.data), + this.next]); + break; + case "while": // 前置条件循环处理 + this.next = MotaActionBlocks['while_s'].xmlText([ + this.expandEvalBlock([data.condition]), + this.insertActionList(data.data), + this.next]); + break; + case "dowhile": // 后置条件循环处理 + this.next = MotaActionBlocks['dowhile_s'].xmlText([ + this.insertActionList(data.data), + this.expandEvalBlock([data.condition]), + this.next]); + break; + case "break": // 跳出循环 + this.next = MotaActionBlocks['break_s'].xmlText([ + this.next]); + break; + case "continue": // 继续执行当前循环 + this.next = MotaActionBlocks['continue_s'].xmlText([ + this.next]); + break; + case "win": + this.next = MotaActionBlocks['win_s'].xmlText([ + data.reason,data.norank?true:false,data.noexit?true:false,this.next]); + break; + case "lose": + 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'); + this.next = MotaActionBlocks['function_s'].xmlText([ + data.async||false,func,this.next]); + break; + case "update": + this.next = MotaActionBlocks['update_s'].xmlText([ + this.next, this.doNotCheckAutoEvents||false]); + break; + case "showStatusBar": + this.next = MotaActionBlocks['showStatusBar_s'].xmlText([ + this.next]); + break; + case "hideStatusBar": + this.next = MotaActionBlocks['hideStatusBar_s'].xmlText([ + data.toolbox||false,this.next]); + break; + case "showHero": + this.next = MotaActionBlocks['showHero_s'].xmlText([ + data.time, data.async||false, this.next]); + break; + case "hideHero": + this.next = MotaActionBlocks['hideHero_s'].xmlText([ + data.time, data.async||false, this.next]); + break; + case "sleep": // 等待多少毫秒 + this.next = MotaActionBlocks['sleep_s'].xmlText([ + data.time||0,data.noSkip||false,this.next]); + break; + case "wait": // 等待用户操作 + var case_waitList = null; + if (data.data) { + for(var ii=data.data.length-1,caseNow;caseNow=data.data[ii];ii--) { + if (caseNow["case"] == "keyboard") { + case_waitList = MotaActionBlocks['waitContext_1'].xmlText([ + caseNow.keycode || "0", this.insertActionList(caseNow.action), case_waitList + ]); + } else if (caseNow["case"] == "mouse") { + case_waitList = MotaActionBlocks['waitContext_2'].xmlText([ + caseNow.px[0], caseNow.px[1], caseNow.py[0], caseNow.py[1], this.insertActionList(caseNow.action), case_waitList + ]); + } + } + } + this.next = MotaActionBlocks['wait_s'].xmlText([ + data.timeout||0,case_waitList, this.next]); + break; + case "waitAsync": // 等待所有异步事件执行完毕 + this.next = MotaActionBlocks['waitAsync_s'].xmlText([ + this.next]); + break; + case "callBook": // 呼出怪物手册 + this.next = MotaActionBlocks['callBook_s'].xmlText([ + this.next]); + break; + case "callSave": // 呼出存档界面 + this.next = MotaActionBlocks['callSave_s'].xmlText([ + this.next]); + break; + case "autoSave": // 自动存档 + this.next = MotaActionBlocks['autoSave_s'].xmlText([ + data.nohint||false, this.next]); + break; + case "callLoad": // 呼出读档界面 + this.next = MotaActionBlocks['callLoad_s'].xmlText([ + this.next]); + break; + case "exit": // 立刻结束事件 + this.next = MotaActionBlocks['exit_s'].xmlText([ + this.next]); + break; + case "previewUI": // UI绘制预览 + this.next = MotaActionBlocks['previewUI_s'].xmlText([ + this.insertActionList(data.action), this.next + ]); + break; + case "clearMap": // 清除画布 + if (data.x != null && data.y != null && data.width != null && data.height != null) { + this.next = MotaActionBlocks['clearMap_s'].xmlText([ + data.x, data.y, data.width, data.height, this.next + ]); + } + else { + this.next = MotaActionBlocks['clearMap_1_s'].xmlText([this.next]); + } + break; + case "setAttribute": // 设置画布属性 + data.fillStyle=this.Colour(data.fillStyle); + data.strokeStyle=this.Colour(data.strokeStyle); + this.next = MotaActionBlocks['setAttribute_s'].xmlText([ + data.font,data.fillStyle,'rgba('+data.fillStyle+')',data.strokeStyle,'rgba('+data.strokeStyle+')', + data.lineWidth,data.alpha,data.align,data.baseline,data.z,this.next]); + break; + case "fillText": // 绘制一行文本 + data.style = this.Colour(data.style); + this.next = MotaActionBlocks['fillText_s'].xmlText([ + data.x, data.y, data.style, 'rgba('+data.style+')', data.font, data.maxWidth, this.EvalString(data.text), this.next + ]); + break; + case "fillBoldText": // 绘制一行描边文本 + data.style = this.Colour(data.style); + this.next = MotaActionBlocks['fillBoldText_s'].xmlText([ + data.x, data.y, data.style, 'rgba('+data.style+')', data.strokeStyle, 'rgba('+(data.strokeStyle||"0,0,0,1")+')', + data.font, this.EvalString(data.text), this.next + ]); + break; + case "drawTextContent": // 绘制多行文本 + data.color = this.Colour(data.color); + this.next = MotaActionBlocks['drawTextContent_s'].xmlText([ + this.EvalString(data.text), data.left, data.top, data.maxWidth, data.color, 'rgba('+data.color+')', + data.align, data.fontSize, data.lineHeight, data.bold, this.next + ]); + break; + case "fillRect": // 绘制矩形 + data.style = this.Colour(data.style); + this.next = MotaActionBlocks['fillRect_s'].xmlText([ + data.x, data.y, data.width, data.height, data.radius, data.style, 'rgba('+data.style+')', this.next + ]); + break; + case "strokeRect": // 绘制矩形边框 + data.style = this.Colour(data.style); + this.next = MotaActionBlocks['strokeRect_s'].xmlText([ + data.x, data.y, data.width, data.height, data.radius, data.style, 'rgba('+data.style+')', data.lineWidth, this.next + ]); + break; + case "drawLine": // 绘制线段 + data.style = this.Colour(data.style); + this.next = MotaActionBlocks['drawLine_s'].xmlText([ + data.x1, data.y1, data.x2, data.y2, data.style, 'rgba('+data.style+')', data.lineWidth, this.next + ]); + break; + case "drawArrow": // 绘制线段 + data.style = this.Colour(data.style); + this.next = MotaActionBlocks['drawArrow_s'].xmlText([ + data.x1, data.y1, data.x2, data.y2, data.style, 'rgba('+data.style+')', data.lineWidth, this.next + ]); + break; + case "fillPolygon": // 绘制多边形 + data.style = this.Colour(data.style); + var x_str=[],y_str=[]; + data.nodes.forEach(function (t) { + x_str.push(t[0]); + y_str.push(t[1]); + }) + this.next = MotaActionBlocks['fillPolygon_s'].xmlText([ + x_str.join(','), y_str.join(','), data.style, 'rgba('+data.style+')', this.next + ]); + break; + case "strokePolygon": // 绘制多边形 + data.style = this.Colour(data.style); + var x_str=[],y_str=[]; + data.nodes.forEach(function (t) { + x_str.push(t[0]); + y_str.push(t[1]); + }) + this.next = MotaActionBlocks['strokePolygon_s'].xmlText([ + x_str.join(','), y_str.join(','), data.style, 'rgba('+data.style+')', data.lineWidth, this.next + ]); + break; + case "fillEllipse": // 绘制椭圆 + data.style = this.Colour(data.style); + this.next = MotaActionBlocks['fillEllipse_s'].xmlText([ + data.x, data.y, data.a, data.b, data.angle, data.style, 'rgba('+data.style+')', this.next + ]); + break; + case "strokeEllipse": // 绘制椭圆边框 + data.style = this.Colour(data.style); + this.next = MotaActionBlocks['strokeEllipse_s'].xmlText([ + data.x, data.y, data.a, data.b, data.angle, data.style, 'rgba('+data.style+')', data.lineWidth, this.next + ]); + break; + case "fillArc": // 绘制弧 + data.style = this.Colour(data.style); + this.next = MotaActionBlocks['fillArc_s'].xmlText([ + data.x, data.y, data.r, data.start, data.end, data.style, 'rgba('+data.style+')', this.next + ]); + break; + case "strokeArc": // 绘制弧 + data.style = this.Colour(data.style); + this.next = MotaActionBlocks['strokeArc_s'].xmlText([ + data.x, data.y, data.r, data.start, data.end, data.style, 'rgba('+data.style+')', data.lineWidth, this.next + ]); + break; + case "drawImage": // 绘制图片 + if (data.x1 != null && data.y1 != null && data.w1 != null && data.h1 != null) { + this.next = MotaActionBlocks['drawImage_1_s'].xmlText([ + data.image, data.reverse, data.x, data.y, data.w, data.h, data.x1, data.y1, data.w1, data.h1, this.next + ]); + } + else { + this.next = MotaActionBlocks['drawImage_s'].xmlText([ + data.image, data.reverse, data.x, data.y, data.w, data.h, this.next + ]); + } + break; + case "drawIcon": // 绘制图标 + this.next = MotaActionBlocks['drawIcon_s'].xmlText([ + data.id, data.frame||0, data.x, data.y, data.width, data.height, this.next + ]); + break; + case "drawBackground": // 绘制背景 + if (!/^\w+\.png$/.test(data.background)) + data.background=this.Colour(data.background); + this.next = MotaActionBlocks['drawBackground_s'].xmlText([ + data.background, 'rgba('+data.background+')', data.x, data.y, data.width, data.height, this.next + ]); + break; + case "drawSelector": // 绘制光标 + if (data.image) { + this.next = MotaActionBlocks['drawSelector_s'].xmlText([ + data.image, data.code, data.x, data.y, data.width, data.height, this.next + ]); + } + else { + this.next = MotaActionBlocks['drawSelector_1_s'].xmlText([data.code, this.next]); + } + case "animateImage": // 兼容 animateImage + break; + default: + this.next = MotaActionBlocks['unknown_s'].xmlText([ + JSON.stringify(data),this.next]); + } + this.parseAction(); + return; +} + +////// 往当前事件列表之后添加一个事件组 ////// +ActionParser.prototype.insertActionList = function (actionList) { + if (actionList.length===0) return null; + this.event.data.list.push({"type": "_next", "next": this.next}); + this.event.data.list=this.event.data.list.concat(actionList); + this.next = null; + this.parseAction(); + return this.result; +} + +////// 判断某对象是否不为undefined也不会null ////// +ActionParser.prototype.isset = function (val) { + if (val === undefined || val === null) { + return false; + } + return true +} + +ActionParser.prototype.StepString = function(steplist) { + var stepchar = { + 'up': '上', + 'down': '下', + 'left': '左', + 'right': '右', + 'forward': '前', + 'backward': '后' + } + var StepString = ''; + var last = null, number = 0; + steplist.forEach(function (v) { + if (v != last) { + if (last != null) { + StepString += stepchar[last]; + if (number > 1) StepString += number; + } + last = v; + number = 1; + } else { + number++; + } + }); + if (last != null) { + StepString += stepchar[last]; + if (number > 1) StepString += number; + } + return StepString; +} + +ActionParser.prototype.EvalString = function(EvalString) { + return EvalString.split('\b').join('\\b').split('\t').join('\\t').split('\n').join('\\n'); +} + +ActionParser.prototype.getTitleAndPosition = function (string) { + string = this.EvalString(string); + var title = '', icon = '', position = ''; + string = string.replace(/\\t\[(([^\],]+),)?([^\],]+)\]/g, function (s0, s1, s2, s3) { + if (s3) title = s3; + if (s2) { icon = s3; title = s2; } + if (icon && !/^(.*)\.(jpg|jpeg|png)$/.test(icon) + && !/^[0-9a-zA-Z_][0-9a-zA-Z_:]*$/.test(icon)) { title += "," + icon; icon = ''; } + return ""; + }).replace(/\\b\[(.*?)\]/g, function (s0, s1) { + position = s1; return ""; + }); + return [title, icon, position, string]; +} + +ActionParser.prototype.Colour = function(color) { + return color?JSON.stringify(color).slice(1,-1):null; +} + +ActionParser.prototype.matchId = function(args) { + var rt=function(xml,args){ + // 此处刻意不写成 xml:MotaActionBlocks[str].xmlText 来方便搜索 + return {ret:true,xml:xml,args:args} + } + var match = /nothing/.exec('nothing') + // 固定列表 + var FixedId_List=MotaActionBlocks['FixedId_List'].options; // [["生命", "status:hp"], ...] + match=new RegExp('^('+FixedId_List.map(function(v){return v[1]}).join('|')+')$').exec(args[0]) + if(match){ + return rt(MotaActionBlocks['idFixedList_e'].xmlText, args); + } + // 独立开关 + match=/^switch:([A-Z])$/.exec(args[0]) + if(match){ + args[0]=match[1] + return rt(MotaActionBlocks['idFlag_e'].xmlText, args); + } + // 临时变量 + match=/^temp:([A-Z])$/.exec(args[0]) + if(match){ + args[0]=match[1] + return rt(MotaActionBlocks['idTemp_e'].xmlText, args); + } + // id列表 + var Id_List = MotaActionBlocks['Id_List'].options; // [["变量", "flag"], ...] + match=new RegExp('^('+Id_List.map(function(v){return v[1]}).join('|')+'):([a-zA-Z0-9_\\u4E00-\\u9FCC]+)$').exec(args[0]) + if(match){ + args=[match[1],MotaActionFunctions.replaceToName_token(match[2])] + return rt(MotaActionBlocks['idIdList_e'].xmlText, args); + } + return {ret:false} +} + +ActionParser.prototype.matchEvalAtom = function(args) { + var rt=function(xml,args){ + // 此处刻意不写成 xml:MotaActionBlocks[str].xmlText 来方便搜索 + return {ret:true,xml:xml,args:args} + } + var match = /nothing/.exec('nothing') + // 勾选框 + match = /^(true|false)$/.exec(args[0]) + if(match){ + return rt(MotaActionBlocks['bool_e'].xmlText, args); + } + // 怪物属性 + var EnemyId_List=MotaActionBlocks['EnemyId_List'].options; // [["生命", "hp"], ...] + match=new RegExp("^enemy:([a-zA-Z0-9_]+):(" + EnemyId_List.map(function(v){return v[1]}).join('|') + ")$").exec(args[0]) + if(match){ + args=[MotaActionFunctions.replaceToName_token(match[1]),match[2]] + return rt(MotaActionBlocks['enemyattr_e'].xmlText, args); + } + // 图块ID + match=/^blockId:(-?\d+),(-?\d+)$/.exec(args[0]) + if(match){ + args=[match[1],match[2]] + return rt(MotaActionBlocks['blockId_e'].xmlText, args); + } + // 图块类别 + match=/^blockCls:(-?\d+),(-?\d+)$/.exec(args[0]) + if(match){ + args=[match[1],match[2]] + return rt(MotaActionBlocks['blockCls_e'].xmlText, args); + } + // 装备孔 + match=/^equip:(-?\d+)$/.exec(args[0]) + if(match){ + args[0]=match[1] + return rt(MotaActionBlocks['equip_e'].xmlText, args); + } + return {ret:false} +} + +ActionParser.prototype.matchEvalCompare=function(args, isShadow){ + if (MotaActionFunctions.disableExpandCompare) return {ret:false}; + var raw=args[0].replace(/>/g,'>').replace(/</g,'<').replace(/"/g,'"').replace(/ /g,' ').replace(/&/g,'&') + if (raw[0]+raw.slice(-1)=='()') raw=raw.slice(1,-1); + var str=raw + var xml=MotaActionBlocks['expression_arithmetic_0'].xmlText + if (!/<=|<|>=|>|==|!=|===|!==|&&|\|\|/.exec(str)) return {ret:false}; + str=str.replace(/[^<>=!()&|]/g,' ') + // 处理括号匹配 + var old; + do { + old=str; + str=str.replace(/\([^()]*\)/g,function(v){return Array.from({length:v.length+1}).join(' ')}) + } while (old!=str); + // 按优先级依次寻找以下符号 + var oplist=['<','<=','>','>=','==','!=','===','!==','&&','||'].reverse() + for (var index = 0,op; op=oplist[index]; index++) { + var match=new RegExp(' '+(op=='||'?'\\|\\|':op)+' ').exec(str) + if (!match) continue; + args=[this.expandEvalBlock([raw.slice(0,match.index+1)],isShadow),op.replace(/&/g,'&').replace(//g,'>'),this.expandEvalBlock([raw.slice(match.index+1+op.length)],isShadow)] + return {ret:true,xml:xml,args:args} + } + return {ret:false} +} + +ActionParser.prototype.expandIdBlock = function(args, isShadow, comment) { + args[0]=MotaActionFunctions.replaceFromName(args[0]) + var xml=MotaActionBlocks['idString_e'].xmlText + var ret=this.matchId(args) + if (ret.ret){ + xml=ret.xml; + args=ret.args; + } else { + for (var index = 0; index < args.length; index++) { + args[index]=MotaActionFunctions.replaceToName(args[index]) + } + } + return xml(args, isShadow, comment); +} + +ActionParser.prototype.expandEvalBlock = function(args, isShadow, comment) { + args[0]=MotaActionFunctions.replaceFromName(args[0]) + var xml=MotaActionBlocks['evalString_e'].xmlText + var ret=this.matchId(args) + if (ret.ret){ + xml=ret.xml; + args=ret.args; + } else if( (ret=this.matchEvalAtom(args)).ret ){ + xml=ret.xml; + args=ret.args; + } else if(/^(!.*|\(!.*\))$/.exec(args[0])){ + // 非 + xml=MotaActionBlocks['negate_e'].xmlText + var content=args[0][0]=='!'?args[0].slice(1):args[0].slice(2,-1) + args[0]=this.expandEvalBlock([content],isShadow) + } else if( (ret=this.matchEvalCompare(args, isShadow)).ret ){ + // 大小比较 + xml=ret.xml; + args=ret.args; + } else { + for (var index = 0; index < args.length; index++) { + args[index]=MotaActionFunctions.replaceToName(args[index]) + } + } + return xml(args, isShadow, comment); +} + +MotaActionFunctions.actionParser = new ActionParser(); + +MotaActionFunctions.workspace = function(){return workspace} + +MotaActionFunctions.parse = function(obj,type) { + try { + obj = JSON.parse(MotaActionFunctions.replaceToName(JSON.stringify(obj))); + } catch (e) {} + MotaActionFunctions.workspace().clear(); + xml_text = MotaActionFunctions.actionParser.parse(obj,type||'event'); + xml = Blockly.Xml.textToDom(''+xml_text+''); + Blockly.Xml.domToWorkspace(xml, MotaActionFunctions.workspace()); +} + +MotaActionFunctions.EvalString_pre = function(EvalString){ + if (EvalString.indexOf('__door__')!==-1) throw new Error('请修改开门变量__door__,如door1,door2,door3等依次向后。请勿存在两个门使用相同的开门变量。'); + EvalString = MotaActionFunctions.replaceFromName(EvalString); + return EvalString.replace(/([^\\])"/g,'$1\\"').replace(/^"/g,'\\"').replace(/""/g,'"\\"'); +} + +MotaActionFunctions.JsonEvalString_pre = function (JsonEvalString) { + if (JsonEvalString == '') return ''; + JsonEvalString = MotaActionFunctions.replaceFromName(JsonEvalString); + try { + return JSON.stringify(JSON.parse(JsonEvalString)); + } catch (e) { + throw new Error('此处需要填写一个合法的JSON内容'); + } +} + +MotaActionFunctions.IntString_pre = function (IntString) { + if (!/^\d*$/.test(IntString)) throw new Error('此项必须是整数或不填'); + return IntString; +} + +MotaActionFunctions.IdString_pre = function(IdString){ + if (IdString.indexOf('__door__')!==-1) throw new Error('请修改开门变量__door__,如door1,door2,door3等依次向后。请勿存在两个门使用相同的开门变量。'); + IdString = MotaActionFunctions.replaceFromName(IdString); + IdString = MotaActionFunctions.replaceFromName_token(IdString); + if (IdString && !(MotaActionFunctions.pattern.id.test(IdString)) && !(MotaActionFunctions.pattern.idWithoutFlag.test(IdString))) + throw new Error('id: '+IdString+'中包含了0-9 a-z A-Z _ - :之外的字符'); + return IdString; +} + +MotaActionFunctions.PosString_pre = function(PosString){ + if (!PosString || /^-?\d+$/.test(PosString)) return PosString; + //if (!(MotaActionFunctions.pattern.id.test(PosString)))throw new Error(PosString+'中包含了0-9 a-z A-Z _ 和中文之外的字符,或者是没有以flag: 开头'); + return '"'+MotaActionFunctions.replaceFromName(PosString)+'"'; +} + +MotaActionFunctions.StepString_pre = function(StepString){ + //StepString='上右3下2左上左2' + var route = StepString.replace(/上/g,'U').replace(/下/g,'D').replace(/左/g,'L').replace(/右/g,'R').replace(/前/g,'F').replace(/后/g,'B'); + + //copyed from core.js + var ans=[], index=0; + + var isset = function(a) { + if (a == undefined || a == null) { + return false; + } + return true; + } + var getNumber = function (noparse) { + var num=""; + while (index>>16)*i&65535)<<16)&4294967295)<<15|s>>>17))*o+(((s>>>16)*o&65535)<<16)&4294967295)<<13|n>>>19))+((5*(n>>>16)&65535)<<16)&4294967295))+((58964+(r>>>16)&65535)<<16);switch(s=0,t){case 3:s^=(255&l.charCodeAt(a+2))<<16;case 2:s^=(255&l.charCodeAt(a+1))<<8;case 1:n^=s=(65535&(s=(s=(65535&(s^=255&l.charCodeAt(a)))*i+(((s>>>16)*i&65535)<<16)&4294967295)<<15|s>>>17))*o+(((s>>>16)*o&65535)<<16)&4294967295}return n^=l.length,n=2246822507*(65535&(n^=n>>>16))+((2246822507*(n>>>16)&65535)<<16)&4294967295,n=3266489909*(65535&(n^=n>>>13))+((3266489909*(n>>>16)&65535)<<16)&4294967295,(n^=n>>>16)>>>0},Object.defineProperty(o.prototype,"length",{get:function(){var t=0;for(var e in this.data)0===e.indexOf("hash_")&&(t+=this.data[e].length);return t}}),o.prototype.add=function(t){var e="hash_"+this.hashFunction(t);if(e in this.data){for(var n=this.data[e],r=0;r>>17,n*=461845907,this.count=this.count+1;var r=this.hash^n;r=5*(r=r<<13|r>>>19)+3864292196,this.hash=r}}},c.prototype.finish=function(){var t=this.hash^4*this.count;return t^=t>>>16,t*=2246822507,t^=t>>>13,t*=3266489909,t^=t>>>16},u.prototype.get=function(t,e){var n=this[t]||null;return null===n?null:n[e]||null},u.prototype.set=function(t,e,n){var r=this[t]||null;null===r&&(r={},this[t]=r),r[e]=n},e.Hash=c,e.Set=o,e.Map=a,e.BitSet=s,e.AltDict=l,e.DoubleDict=u,e.hashStuff=function(){var t=new c;return t.update.apply(arguments),t.finish()},e.escapeWhitespace=function(t,e){return t=(t=(t=t.replace("\t","\\t")).replace("\n","\\n")).replace("\r","\\r"),e&&(t=t.replace(" ","·")),t},e.arrayToString=n,e.titleCase=function(t){return t.replace(/\w\S*/g,function(t){return t.charAt(0).toUpperCase()+t.substr(1)})},e.equalArrays=function(t,e){if(!Array.isArray(t)||!Array.isArray(e))return!1;if(t==e)return!0;if(t.length!=e.length)return!1;for(var n=0;n"},set:function(t){this._text=t}}),r.prototype.toString=function(){var t=this.text;return t=null!==t?t.replace(/\n/g,"\\n").replace(/\r/g,"\\r").replace(/\t/g,"\\t"):"","[@"+this.tokenIndex+","+this.start+":"+this.stop+"='"+t+"',<"+this.type+">"+(this.channel>0?",channel="+this.channel:"")+","+this.line+":"+this.column+"]"},e.Token=n,e.CommonToken=r},function(t,e,n){var r=n(1).Token;function i(t,e){return this.start=t,this.stop=e,this}function o(){this.intervals=null,this.readOnly=!1}i.prototype.contains=function(t){return t>=this.start&&t=n.stop?(this.intervals.pop(t+1),this.reduce(t)):e.stop>=n.start&&(this.intervals[t]=new i(e.start,n.stop),this.intervals.pop(t+1))}},o.prototype.complement=function(t,e){var n=new o;n.addInterval(new i(t,e+1));for(var r=0;rr.start&&t.stop=r.stop?(this.intervals.splice(e,1),e-=1):t.start"):t.push("'"+String.fromCharCode(n.start)+"'"):t.push("'"+String.fromCharCode(n.start)+"'..'"+String.fromCharCode(n.stop-1)+"'")}return t.length>1?"{"+t.join(", ")+"}":t[0]},o.prototype.toIndexString=function(){for(var t=[],e=0;e"):t.push(n.start.toString()):t.push(n.start.toString()+".."+(n.stop-1).toString())}return t.length>1?"{"+t.join(", ")+"}":t[0]},o.prototype.toTokenString=function(t,e){for(var n=[],r=0;r1?"{"+n.join(", ")+"}":n[0]},o.prototype.elementName=function(t,e,n){return n===r.EOF?"":n===r.EPSILON?"":t[n]||e[n]},e.Interval=i,e.IntervalSet=o},function(t,e){function n(){return this.atn=null,this.stateNumber=n.INVALID_STATE_NUMBER,this.stateType=null,this.ruleIndex=0,this.epsilonOnlyTransitions=!1,this.transitions=[],this.nextTokenWithinRule=null,this}function r(){return n.call(this),this.stateType=n.BASIC,this}function i(){return n.call(this),this.decision=-1,this.nonGreedy=!1,this}function o(){return i.call(this),this.endState=null,this}function s(){return o.call(this),this.stateType=n.BLOCK_START,this}function a(){return n.call(this),this.stateType=n.BLOCK_END,this.startState=null,this}function l(){return n.call(this),this.stateType=n.RULE_STOP,this}function u(){return n.call(this),this.stateType=n.RULE_START,this.stopState=null,this.isPrecedenceRule=!1,this}function c(){return i.call(this),this.stateType=n.PLUS_LOOP_BACK,this}function h(){return o.call(this),this.stateType=n.PLUS_BLOCK_START,this.loopBackState=null,this}function p(){return o.call(this),this.stateType=n.STAR_BLOCK_START,this}function f(){return n.call(this),this.stateType=n.STAR_LOOP_BACK,this}function d(){return i.call(this),this.stateType=n.STAR_LOOP_ENTRY,this.loopBackState=null,this.isPrecedenceDecision=null,this}function y(){return n.call(this),this.stateType=n.LOOP_END,this.loopBackState=null,this}function g(){return i.call(this),this.stateType=n.TOKEN_START,this}n.INVALID_TYPE=0,n.BASIC=1,n.RULE_START=2,n.BLOCK_START=3,n.PLUS_BLOCK_START=4,n.STAR_BLOCK_START=5,n.TOKEN_START=6,n.RULE_STOP=7,n.BLOCK_END=8,n.STAR_LOOP_BACK=9,n.STAR_LOOP_ENTRY=10,n.PLUS_LOOP_BACK=11,n.LOOP_END=12,n.serializationNames=["INVALID","BASIC","RULE_START","BLOCK_START","PLUS_BLOCK_START","STAR_BLOCK_START","TOKEN_START","RULE_STOP","BLOCK_END","STAR_LOOP_BACK","STAR_LOOP_ENTRY","PLUS_LOOP_BACK","LOOP_END"],n.INVALID_STATE_NUMBER=-1,n.prototype.toString=function(){return this.stateNumber},n.prototype.equals=function(t){return t instanceof n&&this.stateNumber===t.stateNumber},n.prototype.isNonGreedyExitState=function(){return!1},n.prototype.addTransition=function(t,e){void 0===e&&(e=-1),0===this.transitions.length?this.epsilonOnlyTransitions=t.isEpsilon:this.epsilonOnlyTransitions!==t.isEpsilon&&(this.epsilonOnlyTransitions=!1),-1===e?this.transitions.push(t):this.transitions.splice(e,1,t)},r.prototype=Object.create(n.prototype),r.prototype.constructor=r,i.prototype=Object.create(n.prototype),i.prototype.constructor=i,o.prototype=Object.create(i.prototype),o.prototype.constructor=o,s.prototype=Object.create(o.prototype),s.prototype.constructor=s,a.prototype=Object.create(n.prototype),a.prototype.constructor=a,l.prototype=Object.create(n.prototype),l.prototype.constructor=l,u.prototype=Object.create(n.prototype),u.prototype.constructor=u,c.prototype=Object.create(i.prototype),c.prototype.constructor=c,h.prototype=Object.create(o.prototype),h.prototype.constructor=h,p.prototype=Object.create(o.prototype),p.prototype.constructor=p,f.prototype=Object.create(n.prototype),f.prototype.constructor=f,d.prototype=Object.create(i.prototype),d.prototype.constructor=d,y.prototype=Object.create(n.prototype),y.prototype.constructor=y,g.prototype=Object.create(i.prototype),g.prototype.constructor=g,e.ATNState=n,e.BasicState=r,e.DecisionState=i,e.BlockStartState=o,e.BlockEndState=a,e.LoopEndState=y,e.RuleStartState=u,e.RuleStopState=l,e.TokensStartState=g,e.PlusLoopbackState=c,e.StarLoopbackState=f,e.StarLoopEntryState=d,e.PlusBlockStartState=h,e.StarBlockStartState=p,e.BasicBlockStartState=s},function(t,e,n){var r=n(1).Token,i=n(2).Interval,o=new i(-1,-2);n(0);function s(){return this}function a(){return s.call(this),this}function l(){return a.call(this),this}function u(){return l.call(this),this}function c(){return l.call(this),this}function h(){return c.call(this),this}function p(){return this}function f(){return this}function d(t){return c.call(this),this.parentCtx=null,this.symbol=t,this}function y(t){return d.call(this,t),this}function g(){return this}a.prototype=Object.create(s.prototype),a.prototype.constructor=a,l.prototype=Object.create(a.prototype),l.prototype.constructor=l,u.prototype=Object.create(l.prototype),u.prototype.constructor=u,c.prototype=Object.create(l.prototype),c.prototype.constructor=c,h.prototype=Object.create(c.prototype),h.prototype.constructor=h,p.prototype.visit=function(t){return Array.isArray(t)?t.map(function(t){return t.accept(this)},this):t.accept(this)},p.prototype.visitChildren=function(t){return this.visit(t.children)},p.prototype.visitTerminal=function(t){},p.prototype.visitErrorNode=function(t){},f.prototype.visitTerminal=function(t){},f.prototype.visitErrorNode=function(t){},f.prototype.enterEveryRule=function(t){},f.prototype.exitEveryRule=function(t){},d.prototype=Object.create(c.prototype),d.prototype.constructor=d,d.prototype.getChild=function(t){return null},d.prototype.getSymbol=function(){return this.symbol},d.prototype.getParent=function(){return this.parentCtx},d.prototype.getPayload=function(){return this.symbol},d.prototype.getSourceInterval=function(){if(null===this.symbol)return o;var t=this.symbol.tokenIndex;return new i(t,t)},d.prototype.getChildCount=function(){return 0},d.prototype.accept=function(t){return t.visitTerminal(this)},d.prototype.getText=function(){return this.symbol.text},d.prototype.toString=function(){return this.symbol.type===r.EOF?"":this.symbol.text},y.prototype=Object.create(d.prototype),y.prototype.constructor=y,y.prototype.isErrorNode=function(){return!0},y.prototype.accept=function(t){return t.visitErrorNode(this)},g.prototype.walk=function(t,e){if(e instanceof h||void 0!==e.isErrorNode&&e.isErrorNode())t.visitErrorNode(e);else if(e instanceof c)t.visitTerminal(e);else{this.enterRule(t,e);for(var n=0;n=0&&this.startIndexe.returnState&&(f[0]=e.returnState,f[1]=t.returnState);var d=[p,p],y=new u(d,f);return null!==r&&r.set(t,e,y),y}var f=[t.returnState,e.returnState],d=[t.parentCtx,e.parentCtx];t.returnState>e.returnState&&(f[0]=e.returnState,f[1]=t.returnState,d=[e.parentCtx,t.parentCtx]);var g=new u(d,f);return null!==r&&r.set(t,e,g),g}(t,e,n,r);if(n){if(t instanceof l)return t;if(e instanceof l)return e}return t instanceof a&&(t=new u([t.getParent()],[t.returnState])),e instanceof a&&(e=new u([e.getParent()],[e.returnState])),function(t,e,n,r){if(null!==r){var i=r.get(t,e);if(null!==i)return i;if(null!==(i=r.get(e,t)))return i}var s=0,l=0,h=0,p=[],f=[];for(;s0&&(t+=", "),this.returnStates[e]!==o.EMPTY_RETURN_STATE?(t+=this.returnStates[e],null!==this.parents[e]?t=t+" "+this.parents[e]:t+="null"):t+="$";return t+"]"},e.merge=c,e.PredictionContext=o,e.PredictionContextCache=s,e.SingletonPredictionContext=a,e.predictionContextFromRuleContext=function t(e,n){if(void 0!==n&&null!==n||(n=r.EMPTY),null===n.parentCtx||n===r.EMPTY)return o.EMPTY;var i=t(e,n.parentCtx),s=e.states[n.invokingState].transitions[0];return a.create(i,s.followState.stateNumber)},e.getCachedPredictionContext=function t(e,n,r){if(e.isEmpty())return e;var i=r[e]||null;if(null!==i)return i;if(null!==(i=n.get(e)))return r[e]=i,i;for(var s=!1,l=[],c=0;c=this.states.length)throw"Invalid state number.";var n=this.states[t],r=this.nextTokens(n);if(!r.contains(s.EPSILON))return r;var o=new i;for(o.addSet(r),o.removeOne(s.EPSILON);null!==e&&e.invokingState>=0&&r.contains(s.EPSILON);){var a=this.states[e.invokingState].transitions[0];r=this.nextTokens(a.followState),o.addSet(r),o.removeOne(s.EPSILON),e=e.parentCtx}return r.contains(s.EPSILON)&&o.addOne(s.EOF),o},o.INVALID_ALT_NUMBER=0,e.ATN=o},function(t,e,n){var r=n(1).Token,i=(n(2).Interval,n(2).IntervalSet),o=n(10).Predicate,s=n(10).PrecedencePredicate;function a(t){if(void 0===t||null===t)throw"target cannot be null.";return this.target=t,this.isEpsilon=!1,this.label=null,this}function l(t,e){return a.call(this,t),this.label_=e,this.label=this.makeLabel(),this.serializationType=a.ATOM,this}function u(t,e,n,r){return a.call(this,t),this.ruleIndex=e,this.precedence=n,this.followState=r,this.serializationType=a.RULE,this.isEpsilon=!0,this}function c(t,e){return a.call(this,t),this.serializationType=a.EPSILON,this.isEpsilon=!0,this.outermostPrecedenceReturn=e,this}function h(t,e,n){return a.call(this,t),this.serializationType=a.RANGE,this.start=e,this.stop=n,this.label=this.makeLabel(),this}function p(t){return a.call(this,t),this}function f(t,e,n,r){return p.call(this,t),this.serializationType=a.PREDICATE,this.ruleIndex=e,this.predIndex=n,this.isCtxDependent=r,this.isEpsilon=!0,this}function d(t,e,n,r){return a.call(this,t),this.serializationType=a.ACTION,this.ruleIndex=e,this.actionIndex=void 0===n?-1:n,this.isCtxDependent=void 0!==r&&r,this.isEpsilon=!0,this}function y(t,e){return a.call(this,t),this.serializationType=a.SET,void 0!==e&&null!==e?this.label=e:(this.label=new i,this.label.addOne(r.INVALID_TYPE)),this}function g(t,e){return y.call(this,t,e),this.serializationType=a.NOT_SET,this}function v(t){return a.call(this,t),this.serializationType=a.WILDCARD,this}function x(t,e){return p.call(this,t),this.serializationType=a.PRECEDENCE,this.precedence=e,this.isEpsilon=!0,this}a.EPSILON=1,a.RANGE=2,a.RULE=3,a.PREDICATE=4,a.ATOM=5,a.ACTION=6,a.SET=7,a.NOT_SET=8,a.WILDCARD=9,a.PRECEDENCE=10,a.serializationNames=["INVALID","EPSILON","RANGE","RULE","PREDICATE","ATOM","ACTION","SET","NOT_SET","WILDCARD","PRECEDENCE"],a.serializationTypes={EpsilonTransition:a.EPSILON,RangeTransition:a.RANGE,RuleTransition:a.RULE,PredicateTransition:a.PREDICATE,AtomTransition:a.ATOM,ActionTransition:a.ACTION,SetTransition:a.SET,NotSetTransition:a.NOT_SET,WildcardTransition:a.WILDCARD,PrecedencePredicateTransition:a.PRECEDENCE},l.prototype=Object.create(a.prototype),l.prototype.constructor=l,l.prototype.makeLabel=function(){var t=new i;return t.addOne(this.label_),t},l.prototype.matches=function(t,e,n){return this.label_===t},l.prototype.toString=function(){return this.label_},u.prototype=Object.create(a.prototype),u.prototype.constructor=u,u.prototype.matches=function(t,e,n){return!1},c.prototype=Object.create(a.prototype),c.prototype.constructor=c,c.prototype.matches=function(t,e,n){return!1},c.prototype.toString=function(){return"epsilon"},h.prototype=Object.create(a.prototype),h.prototype.constructor=h,h.prototype.makeLabel=function(){var t=new i;return t.addRange(this.start,this.stop),t},h.prototype.matches=function(t,e,n){return t>=this.start&&t<=this.stop},h.prototype.toString=function(){return"'"+String.fromCharCode(this.start)+"'..'"+String.fromCharCode(this.stop)+"'"},p.prototype=Object.create(a.prototype),p.prototype.constructor=p,f.prototype=Object.create(p.prototype),f.prototype.constructor=f,f.prototype.matches=function(t,e,n){return!1},f.prototype.getPredicate=function(){return new o(this.ruleIndex,this.predIndex,this.isCtxDependent)},f.prototype.toString=function(){return"pred_"+this.ruleIndex+":"+this.predIndex},d.prototype=Object.create(a.prototype),d.prototype.constructor=d,d.prototype.matches=function(t,e,n){return!1},d.prototype.toString=function(){return"action_"+this.ruleIndex+":"+this.actionIndex},y.prototype=Object.create(a.prototype),y.prototype.constructor=y,y.prototype.matches=function(t,e,n){return this.label.contains(t)},y.prototype.toString=function(){return this.label.toString()},g.prototype=Object.create(y.prototype),g.prototype.constructor=g,g.prototype.matches=function(t,e,n){return t>=e&&t<=n&&!y.prototype.matches.call(this,t,e,n)},g.prototype.toString=function(){return"~"+y.prototype.toString.call(this)},v.prototype=Object.create(a.prototype),v.prototype.constructor=v,v.prototype.matches=function(t,e,n){return t>=e&&t<=n},v.prototype.toString=function(){return"."},x.prototype=Object.create(p.prototype),x.prototype.constructor=x,x.prototype.matches=function(t,e,n){return!1},x.prototype.getPredicate=function(){return new s(this.precedence)},x.prototype.toString=function(){return this.precedence+" >= _p"},e.Transition=a,e.AtomTransition=l,e.SetTransition=y,e.NotSetTransition=g,e.RuleTransition=u,e.ActionTransition=d,e.EpsilonTransition=c,e.RangeTransition=h,e.WildcardTransition=v,e.PredicateTransition=f,e.PrecedencePredicateTransition=x,e.AbstractPredicateTransition=p},function(t,e,n){var r=n(7).ATN,i=n(0),o=i.Hash,s=i.Set,a=n(10).SemanticContext,l=n(6).merge;function u(t){return t.hashCodeForConfigSet()}function c(t,e){return t===e||null!==t&&null!==e&&t.equalsForConfigSet(e)}function h(t){return this.configLookup=new s(u,c),this.fullCtx=void 0===t||t,this.readOnly=!1,this.configs=[],this.uniqueAlt=0,this.conflictingAlts=null,this.hasSemanticContext=!1,this.dipsIntoOuterContext=!1,this.cachedHashCode=-1,this}function p(){return h.call(this),this.configLookup=new s,this}h.prototype.add=function(t,e){if(void 0===e&&(e=null),this.readOnly)throw"This set is readonly";t.semanticContext!==a.NONE&&(this.hasSemanticContext=!0),t.reachesIntoOuterContext>0&&(this.dipsIntoOuterContext=!0);var n=this.configLookup.add(t);if(n===t)return this.cachedHashCode=-1,this.configs.push(t),!0;var r=!this.fullCtx,i=l(n.context,t.context,r,e);return n.reachesIntoOuterContext=Math.max(n.reachesIntoOuterContext,t.reachesIntoOuterContext),t.precedenceFilterSuppressed&&(n.precedenceFilterSuppressed=!0),n.context=i,!0},h.prototype.getStates=function(){for(var t=new s,e=0;e0){var s=null;i.map(function(t){(null===s||t.precedence0){var s=i.sort(function(t,e){return t.compareTo(e)}),l=s[s.length-1];n.add(l)}return this.opnds=n.values(),this}o.prototype.hashCode=function(){var t=new i;return this.updateHashCode(t),t.finish()},o.prototype.evaluate=function(t,e){},o.prototype.evalPrecedence=function(t,e){return this},o.andContext=function(t,e){if(null===t||t===o.NONE)return e;if(null===e||e===o.NONE)return t;var n=new l(t,e);return 1===n.opnds.length?n.opnds[0]:n},o.orContext=function(t,e){if(null===t)return e;if(null===e)return t;if(t===o.NONE||e===o.NONE)return o.NONE;var n=new u(t,e);return 1===n.opnds.length?n.opnds[0]:n},s.prototype=Object.create(o.prototype),s.prototype.constructor=s,o.NONE=new s,s.prototype.evaluate=function(t,e){var n=this.isCtxDependent?e:null;return t.sempred(n,this.ruleIndex,this.predIndex)},s.prototype.updateHashCode=function(t){t.update(this.ruleIndex,this.predIndex,this.isCtxDependent)},s.prototype.equals=function(t){return this===t||t instanceof s&&(this.ruleIndex===t.ruleIndex&&this.predIndex===t.predIndex&&this.isCtxDependent===t.isCtxDependent)},s.prototype.toString=function(){return"{"+this.ruleIndex+":"+this.predIndex+"}?"},a.prototype=Object.create(o.prototype),a.prototype.constructor=a,a.prototype.evaluate=function(t,e){return t.precpred(e,this.precedence)},a.prototype.evalPrecedence=function(t,e){return t.precpred(e,this.precedence)?o.NONE:null},a.prototype.compareTo=function(t){return this.precedence-t.precedence},a.prototype.updateHashCode=function(t){t.update(31)},a.prototype.equals=function(t){return this===t||t instanceof a&&this.precedence===t.precedence},a.prototype.toString=function(){return"{"+this.precedence+">=prec}?"},a.filterPrecedencePredicates=function(t){var e=[];return t.values().map(function(t){t instanceof a&&e.push(t)}),e},l.prototype=Object.create(o.prototype),l.prototype.constructor=l,l.prototype.equals=function(t){return this===t||t instanceof l&&this.opnds===t.opnds},l.prototype.updateHashCode=function(t){t.update(this.opnds,"AND")},l.prototype.evaluate=function(t,e){for(var n=0;n3?t.slice(3):t},u.prototype=Object.create(o.prototype),u.prototype.constructor=u,u.prototype.constructor=function(t){return this===t||t instanceof u&&this.opnds===t.opnds},u.prototype.updateHashCode=function(t){t.update(this.opnds,"OR")},u.prototype.evaluate=function(t,e){for(var n=0;n3?t.slice(3):t},e.SemanticContext=o,e.PrecedencePredicate=a,e.Predicate=s},function(t,e,n){var r=n(9).ATNConfigSet,i=n(0),o=i.Hash,s=i.Set;function a(t,e){return this.alt=e,this.pred=t,this}function l(t,e){return null===t&&(t=-1),null===e&&(e=new r),this.stateNumber=t,this.configs=e,this.edges=null,this.isAcceptState=!1,this.prediction=0,this.lexerActionExecutor=null,this.requiresFullContext=!1,this.predicates=null,this}a.prototype.toString=function(){return"("+this.pred+", "+this.alt+")"},l.prototype.getAltSet=function(){var t=new s;if(null!==this.configs)for(var e=0;e0?",up="+this.reachesIntoOuterContext:"")+")"},l.prototype=Object.create(a.prototype),l.prototype.constructor=l,l.prototype.updateHashCode=function(t){t.update(this.state.stateNumber,this.alt,this.context,this.semanticContext,this.passedThroughNonGreedyDecision,this.lexerActionExecutor)},l.prototype.equals=function(t){return this===t||t instanceof l&&this.passedThroughNonGreedyDecision==t.passedThroughNonGreedyDecision&&(this.lexerActionExecutor?this.lexerActionExecutor.equals(t.lexerActionExecutor):!t.lexerActionExecutor)&&a.prototype.equals.call(this,t)},l.prototype.hashCodeForConfigSet=l.prototype.hashCode,l.prototype.equalsForConfigSet=l.prototype.equals,l.prototype.checkNonGreedyDecision=function(t,e){return t.passedThroughNonGreedyDecision||e instanceof r&&e.nonGreedy},e.ATNConfig=a,e.LexerATNConfig=l},function(t,e,n){var r=n(4).RuleNode,i=n(4).INVALID_INTERVAL,o=n(7).INVALID_ALT_NUMBER;function s(t,e){return r.call(this),this.parentCtx=t||null,this.invokingState=e||-1,this}s.prototype=Object.create(r.prototype),s.prototype.constructor=s,s.prototype.depth=function(){for(var t=0,e=this;null!==e;)e=e.parentCtx,t+=1;return t},s.prototype.isEmpty=function(){return-1===this.invokingState},s.prototype.getSourceInterval=function(){return i},s.prototype.getRuleContext=function(){return this},s.prototype.getPayload=function(){return this},s.prototype.getText=function(){return 0===this.getChildCount()?"":this.children.map(function(t){return t.getText()}).join("")},s.prototype.getAltNumber=function(){return o},s.prototype.setAltNumber=function(t){},s.prototype.getChild=function(t){return null},s.prototype.getChildCount=function(){return 0},s.prototype.accept=function(t){return t.visitChildren(this)},e.RuleContext=s;var a=n(21).Trees;s.prototype.toStringTree=function(t,e){return a.toStringTree(this,t,e)},s.prototype.toString=function(t,e){t=t||null,e=e||null;for(var n=this,r="[";null!==n&&n!==e;){if(null===t)n.isEmpty()||(r+=n.invokingState);else{var i=n.ruleIndex;r+=i>=0&&i":"\n"===t?"\\n":"\t"===t?"\\t":"\r"===t?"\\r":t},l.prototype.getCharErrorDisplay=function(t){return"'"+this.getErrorDisplayForChar(t)+"'"},l.prototype.recover=function(t){this._input.LA(1)!==r.EOF&&(t instanceof a?this._interp.consume(this._input):this._input.consume())},e.Lexer=l},function(t,e){function n(){return this}function r(){return n.call(this),this}function i(t){if(n.call(this),null===t)throw"delegates";return this.delegates=t,this}n.prototype.syntaxError=function(t,e,n,r,i,o){},n.prototype.reportAmbiguity=function(t,e,n,r,i,o,s){},n.prototype.reportAttemptingFullContext=function(t,e,n,r,i,o){},n.prototype.reportContextSensitivity=function(t,e,n,r,i,o){},r.prototype=Object.create(n.prototype),r.prototype.constructor=r,r.INSTANCE=new r,r.prototype.syntaxError=function(t,e,n,r,i,o){console.error("line "+n+":"+r+" "+i)},i.prototype=Object.create(n.prototype),i.prototype.constructor=i,i.prototype.syntaxError=function(t,e,n,r,i,o){this.delegates.map(function(s){s.syntaxError(t,e,n,r,i,o)})},i.prototype.reportAmbiguity=function(t,e,n,r,i,o,s){this.delegates.map(function(a){a.reportAmbiguity(t,e,n,r,i,o,s)})},i.prototype.reportAttemptingFullContext=function(t,e,n,r,i,o){this.delegates.map(function(s){s.reportAttemptingFullContext(t,e,n,r,i,o)})},i.prototype.reportContextSensitivity=function(t,e,n,r,i,o){this.delegates.map(function(s){s.reportContextSensitivity(t,e,n,r,i,o)})},e.ErrorListener=n,e.ConsoleErrorListener=r,e.ProxyErrorListener=i},function(t,e){function n(t,e,n){return this.dfa=t,this.literalNames=e||[],this.symbolicNames=n||[],this}function r(t){return n.call(this,t,null),this}n.prototype.toString=function(){if(null===this.dfa.s0)return null;for(var t="",e=this.dfa.sortedStates(),n=0;n")).concat(this.getStateString(s))).concat("\n"))}}return 0===t.length?null:t},n.prototype.getEdgeLabel=function(t){return 0===t?"EOF":null!==this.literalNames||null!==this.symbolicNames?this.literalNames[t-1]||this.symbolicNames[t-1]:String.fromCharCode(t-1)},n.prototype.getStateString=function(t){var e=(t.isAcceptState?":":"")+"s"+t.stateNumber+(t.requiresFullContext?"^":"");return t.isAcceptState?null!==t.predicates?e+"=>"+t.predicates.toString():e+"=>"+t.prediction.toString():e},r.prototype=Object.create(n.prototype),r.prototype.constructor=r,r.prototype.getEdgeLabel=function(t){return"'"+String.fromCharCode(t)+"'"},e.DFASerializer=n,e.LexerDFASerializer=r},function(t,e,n){var r=n(14).RuleContext,i=n(4),o=i.INVALID_INTERVAL,s=i.TerminalNode,a=i.TerminalNodeImpl,l=i.ErrorNodeImpl,u=n(2).Interval;function c(t,e){t=t||null,e=e||null,r.call(this,t,e),this.ruleIndex=-1,this.children=null,this.start=null,this.stop=null,this.exception=null}function h(t,e,n){return c.call(t,e),this.ruleIndex=n,this}c.prototype=Object.create(r.prototype),c.prototype.constructor=c,c.prototype.copyFrom=function(t){this.parentCtx=t.parentCtx,this.invokingState=t.invokingState,this.children=null,this.start=t.start,this.stop=t.stop,t.children&&(this.children=[],t.children.map(function(t){t instanceof l&&(this.children.push(t),t.parentCtx=this)},this))},c.prototype.enterRule=function(t){},c.prototype.exitRule=function(t){},c.prototype.addChild=function(t){return null===this.children&&(this.children=[]),this.children.push(t),t},c.prototype.removeLastChild=function(){null!==this.children&&this.children.pop()},c.prototype.addTokenNode=function(t){var e=new a(t);return this.addChild(e),e.parentCtx=this,e},c.prototype.addErrorNode=function(t){var e=new l(t);return this.addChild(e),e.parentCtx=this,e},c.prototype.getChild=function(t,e){if(e=e||null,null===this.children||t<0||t>=this.children.length)return null;if(null===e)return this.children[t];for(var n=0;n=this.children.length)return null;for(var n=0;n=this._size)throw"cannot consume EOF";this._index+=1},i.prototype.LA=function(t){if(0===t)return 0;t<0&&(t+=1);var e=this._index+t-1;return e<0||e>=this._size?r.EOF:this.data[e]},i.prototype.LT=function(t){return this.LA(t)},i.prototype.mark=function(){return-1},i.prototype.release=function(t){},i.prototype.seek=function(t){t<=this._index?this._index=t:this._index=Math.min(t,this._size)},i.prototype.getText=function(t,e){if(e>=this._size&&(e=this._size-1),t>=this._size)return"";if(this.decodeToUnicodeCodePoints){for(var n="",r=t;r<=e;r++)n+=String.fromCodePoint(this.data[r]);return n}return this.strdata.slice(t,e+1)},i.prototype.toString=function(){return this.strdata},e.InputStream=i},function(t,e,n){var r=n(12);function i(){return r.tree.ParseTreeVisitor.call(this),this}i.prototype=Object.create(r.tree.ParseTreeVisitor.prototype),i.prototype.constructor=i,i.prototype.visitGrammarFile=function(t){return this.visitChildren(t)},i.prototype.visitGrammerDecl=function(t){return this.visitChildren(t)},i.prototype.visitStatExprSplit=function(t){return this.visitChildren(t)},i.prototype.visitStatList=function(t){return this.visitChildren(t)},i.prototype.visitStatValue=function(t){return this.visitChildren(t)},i.prototype.visitExprExpression=function(t){return this.visitChildren(t)},i.prototype.visitExprValue=function(t){return this.visitChildren(t)},i.prototype.visitArithmeticRuleCollection=function(t){return this.visitChildren(t)},i.prototype.visitParserAtomExpr=function(t){return this.visitChildren(t)},i.prototype.visitParserAtomParserId=function(t){return this.visitChildren(t)},i.prototype.visitParserAtomLexerId=function(t){return this.visitChildren(t)},i.prototype.visitParserAtomStr=function(t){return this.visitChildren(t)},i.prototype.visitLexerRuleCollection=function(t){return this.visitChildren(t)},i.prototype.visitMeaningfulSplit=function(t){return this.visitChildren(t)},i.prototype.visitLexerRuleStrings=function(t){return this.visitChildren(t)},i.prototype.visitLexerRuleList=function(t){return this.visitChildren(t)},i.prototype.visitLexerRuleComplex=function(t){return this.visitChildren(t)},i.prototype.visitStrings=function(t){return this.visitChildren(t)},i.prototype.visitLexerRuleExpr=function(t){return this.visitChildren(t)},e.BlocklyGrammerVisitor=i},function(t,e,n){var r=n(0),i=n(1).Token,o=(n(4).RuleNode,n(4).ErrorNode),s=n(4).TerminalNode,a=n(18).ParserRuleContext,l=n(14).RuleContext,u=n(7).INVALID_ALT_NUMBER;function c(){}c.toStringTree=function(t,e,n){e=e||null,null!==(n=n||null)&&(e=n.ruleNames);var i=c.getNodeText(t,e);i=r.escapeWhitespace(i,!1);var o=t.getChildCount();if(0===o)return i;var s="("+i+" ";o>0&&(i=c.toStringTree(t.getChild(0),e),s=s.concat(i));for(var a=1;a=n},W.prototype.deserialize=function(t){this.reset(t),this.checkVersion(),this.checkUUID();var e=this.readATN();this.readStates(e),this.readRules(e),this.readModes(e);var n=[];return this.readSets(e,n,this.readInt.bind(this)),this.isFeatureSupported(Y,this.uuid)&&this.readSets(e,n,this.readInt32.bind(this)),this.readEdges(e,n),this.readDecisions(e),this.readLexerActions(e),this.markPrecedenceDecisions(e),this.verifyATN(e),this.deserializationOptions.generateRuleBypassTransitions&&e.grammarType===o.PARSER&&(this.generateRuleBypassTransitions(e),this.verifyATN(e)),e},W.prototype.reset=function(t){var e=t.split("").map(function(t){var e=t.charCodeAt(0);return e>1?e-2:-1});e[0]=t.charCodeAt(0),this.data=e,this.pos=0},W.prototype.checkVersion=function(){var t=this.readInt();if(3!==t)throw"Could not deserialize ATN with version "+t+" (expected 3)."},W.prototype.checkUUID=function(){var t=this.readUUID();if(K.indexOf(t)<0)throw"59627784-3BE5-417A-B9EB-8131A7286089";this.uuid=t},W.prototype.readATN=function(){var t=this.readInt(),e=this.readInt();return new i(t,e)},W.prototype.readStates=function(t){for(var e,n,r,i=[],o=[],s=this.readInt(),l=0;l0;)i.addTransition(p.transitions[f-1]),p.transitions=p.transitions.slice(-1);t.ruleToStartState[e].addTransition(new I(i)),o.addTransition(new I(a));var d=new l;t.addState(d),d.addTransition(new C(o,t.ruleToTokenType[e])),i.addTransition(new I(d))},W.prototype.stateIsEndStateFor=function(t,e){if(t.ruleIndex!==e)return null;if(!(t instanceof x))return null;var n=t.transitions[t.transitions.length-1].target;return n instanceof p&&n.epsilonOnlyTransitions&&n.transitions[0].target instanceof d?t:null},W.prototype.markPrecedenceDecisions=function(t){for(var e=0;e=0):this.checkCondition(n.transitions.length<=1||n instanceof d)}},W.prototype.checkCondition=function(t,e){if(!t)throw void 0!==e&&null!==e||(e="IllegalState"),e},W.prototype.readInt=function(){return this.data[this.pos++]},W.prototype.readInt32=function(){return this.readInt()|this.readInt()<<16},W.prototype.readLong=function(){return 4294967295&this.readInt32()|this.readInt32()<<32};var X=function(){for(var t=[],e=0;e<256;e++)t[e]=(e+256).toString(16).substr(1).toUpperCase();return t}();W.prototype.readUUID=function(){for(var t=[],e=7;e>=0;e--){var n=this.readInt();t[2*e+1]=255&n,t[2*e]=n>>8&255}return X[t[0]]+X[t[1]]+X[t[2]]+X[t[3]]+"-"+X[t[4]]+X[t[5]]+"-"+X[t[6]]+X[t[7]]+"-"+X[t[8]]+X[t[9]]+"-"+X[t[10]]+X[t[11]]+X[t[12]]+X[t[13]]+X[t[14]]+X[t[15]]},W.prototype.edgeFactory=function(t,e,n,i,o,s,a,l){var u=t.states[i];switch(e){case E.EPSILON:return new I(u);case E.RANGE:return new R(u,0!==a?r.EOF:o,s);case E.RULE:return new k(t.states[o],s,a,u);case E.PREDICATE:return new O(u,o,s,0!==a);case E.PRECEDENCE:return new P(u,o);case E.ATOM:return new C(u,0!==a?r.EOF:o);case E.ACTION:return new L(u,o,s,0!==a);case E.SET:return new A(u,l[o]);case E.NOT_SET:return new b(u,l[o]);case E.WILDCARD:return new N(u);default:throw"The specified transition type: "+e+" is not valid."}},W.prototype.stateFactory=function(t,e){if(null===this.stateFactories){var n=[];n[a.INVALID_TYPE]=null,n[a.BASIC]=function(){return new l},n[a.RULE_START]=function(){return new f},n[a.BLOCK_START]=function(){return new T},n[a.PLUS_BLOCK_START]=function(){return new m},n[a.STAR_BLOCK_START]=function(){return new _},n[a.TOKEN_START]=function(){return new y},n[a.RULE_STOP]=function(){return new d},n[a.BLOCK_END]=function(){return new h},n[a.STAR_LOOP_BACK]=function(){return new v},n[a.STAR_LOOP_ENTRY]=function(){return new x},n[a.PLUS_LOOP_BACK]=function(){return new g},n[a.LOOP_END]=function(){return new p},this.stateFactories=n}if(t>this.stateFactories.length||null===this.stateFactories[t])throw"The specified state type "+t+" is not valid.";var r=this.stateFactories[t]();if(null!==r)return r.ruleIndex=e,r},W.prototype.lexerActionFactory=function(t,e,n){if(null===this.actionFactories){var r=[];r[j.CHANNEL]=function(t,e){return new B(t)},r[j.CUSTOM]=function(t,e){return new U(t,e)},r[j.MODE]=function(t,e){return new G(t)},r[j.MORE]=function(t,e){return V.INSTANCE},r[j.POP_MODE]=function(t,e){return q.INSTANCE},r[j.PUSH_MODE]=function(t,e){return new z(t)},r[j.SKIP]=function(t,e){return M.INSTANCE},r[j.TYPE]=function(t,e){return new H(t)},this.actionFactories=r}if(t>this.actionFactories.length||null===this.actionFactories[t])throw"The specified lexer action type "+t+" is not valid.";return this.actionFactories[t](e,n)},e.ATNDeserializer=W},function(t,e){function n(t){return void 0===t&&(t=null),this.readOnly=!1,this.verifyATN=null===t||t.verifyATN,this.generateRuleBypassTransitions=null!==t&&t.generateRuleBypassTransitions,this}n.defaultOptions=new n,n.defaultOptions.readOnly=!0,e.ATNDeserializationOptions=n},function(t,e){function n(){}function r(t){return this.actionType=t,this.isPositionDependent=!1,this}function i(){return r.call(this,n.SKIP),this}function o(t){return r.call(this,n.TYPE),this.type=t,this}function s(t){return r.call(this,n.PUSH_MODE),this.mode=t,this}function a(){return r.call(this,n.POP_MODE),this}function l(){return r.call(this,n.MORE),this}function u(t){return r.call(this,n.MODE),this.mode=t,this}function c(t,e){return r.call(this,n.CUSTOM),this.ruleIndex=t,this.actionIndex=e,this.isPositionDependent=!0,this}function h(t){return r.call(this,n.CHANNEL),this.channel=t,this}function p(t,e){return r.call(this,e.actionType),this.offset=t,this.action=e,this.isPositionDependent=!0,this}n.CHANNEL=0,n.CUSTOM=1,n.MODE=2,n.MORE=3,n.POP_MODE=4,n.PUSH_MODE=5,n.SKIP=6,n.TYPE=7,r.prototype.hashCode=function(){var t=new Hash;return this.updateHashCode(t),t.finish()},r.prototype.updateHashCode=function(t){t.update(this.actionType)},r.prototype.equals=function(t){return this===t},i.prototype=Object.create(r.prototype),i.prototype.constructor=i,i.INSTANCE=new i,i.prototype.execute=function(t){t.skip()},i.prototype.toString=function(){return"skip"},o.prototype=Object.create(r.prototype),o.prototype.constructor=o,o.prototype.execute=function(t){t.type=this.type},o.prototype.updateHashCode=function(t){t.update(this.actionType,this.type)},o.prototype.equals=function(t){return this===t||t instanceof o&&this.type===t.type},o.prototype.toString=function(){return"type("+this.type+")"},s.prototype=Object.create(r.prototype),s.prototype.constructor=s,s.prototype.execute=function(t){t.pushMode(this.mode)},s.prototype.updateHashCode=function(t){t.update(this.actionType,this.mode)},s.prototype.equals=function(t){return this===t||t instanceof s&&this.mode===t.mode},s.prototype.toString=function(){return"pushMode("+this.mode+")"},a.prototype=Object.create(r.prototype),a.prototype.constructor=a,a.INSTANCE=new a,a.prototype.execute=function(t){t.popMode()},a.prototype.toString=function(){return"popMode"},l.prototype=Object.create(r.prototype),l.prototype.constructor=l,l.INSTANCE=new l,l.prototype.execute=function(t){t.more()},l.prototype.toString=function(){return"more"},u.prototype=Object.create(r.prototype),u.prototype.constructor=u,u.prototype.execute=function(t){t.mode(this.mode)},u.prototype.updateHashCode=function(t){t.update(this.actionType,this.mode)},u.prototype.equals=function(t){return this===t||t instanceof u&&this.mode===t.mode},u.prototype.toString=function(){return"mode("+this.mode+")"},c.prototype=Object.create(r.prototype),c.prototype.constructor=c,c.prototype.execute=function(t){t.action(null,this.ruleIndex,this.actionIndex)},c.prototype.updateHashCode=function(t){t.update(this.actionType,this.ruleIndex,this.actionIndex)},c.prototype.equals=function(t){return this===t||t instanceof c&&(this.ruleIndex===t.ruleIndex&&this.actionIndex===t.actionIndex)},h.prototype=Object.create(r.prototype),h.prototype.constructor=h,h.prototype.execute=function(t){t._channel=this.channel},h.prototype.updateHashCode=function(t){t.update(this.actionType,this.channel)},h.prototype.equals=function(t){return this===t||t instanceof h&&this.channel===t.channel},h.prototype.toString=function(){return"channel("+this.channel+")"},p.prototype=Object.create(r.prototype),p.prototype.constructor=p,p.prototype.execute=function(t){this.action.execute(t)},p.prototype.updateHashCode=function(t){t.update(this.actionType,this.offset,this.action)},p.prototype.equals=function(t){return this===t||t instanceof p&&(this.offset===t.offset&&this.action===t.action)},e.LexerActionType=n,e.LexerSkipAction=i,e.LexerChannelAction=h,e.LexerCustomAction=c,e.LexerIndexedCustomAction=p,e.LexerMoreAction=l,e.LexerTypeAction=o,e.LexerPushModeAction=s,e.LexerPopModeAction=a,e.LexerModeAction=u},function(t,e,n){var r=n(1).Token,i=n(16).ConsoleErrorListener,o=n(16).ProxyErrorListener;function s(){return this._listeners=[i.INSTANCE],this._interp=null,this._stateNumber=-1,this}s.tokenTypeMapCache={},s.ruleIndexMapCache={},s.prototype.checkVersion=function(t){"4.7"!==t&&console.log("ANTLR runtime and generated code versions disagree: 4.7!="+t)},s.prototype.addErrorListener=function(t){this._listeners.push(t)},s.prototype.removeErrorListeners=function(){this._listeners=[]},s.prototype.getTokenTypeMap=function(){var t=this.getTokenNames();if(null===t)throw"The current recognizer does not provide a list of token names.";var e=this.tokenTypeMapCache[t];return void 0===e&&((e=t.reduce(function(t,e,n){t[e]=n})).EOF=r.EOF,this.tokenTypeMapCache[t]=e),e},s.prototype.getRuleIndexMap=function(){var t=this.ruleNames;if(null===t)throw"The current recognizer does not provide a list of rule names.";var e=this.ruleIndexMapCache[t];return void 0===e&&(e=t.reduce(function(t,e,n){t[e]=n}),this.ruleIndexMapCache[t]=e),e},s.prototype.getTokenType=function(t){var e=this.getTokenTypeMap()[t];return void 0!==e?e:r.INVALID_TYPE},s.prototype.getErrorHeader=function(t){return"line "+t.getOffendingToken().line+":"+t.getOffendingToken().column},s.prototype.getTokenErrorDisplay=function(t){if(null===t)return"";var e=t.text;return null===e&&(e=t.type===r.EOF?"":"<"+t.type+">"),"'"+(e=e.replace("\n","\\n").replace("\r","\\r").replace("\t","\\t"))+"'"},s.prototype.getErrorListenerDispatch=function(){return new o(this._listeners)},s.prototype.sempred=function(t,e,n){return!0},s.prototype.precpred=function(t,e){return!0},Object.defineProperty(s.prototype,"state",{get:function(){return this._stateNumber},set:function(t){this._stateNumber=t}}),e.Recognizer=s},function(t,e,n){var r=n(11).DFAState,i=n(9).ATNConfigSet,o=n(6).getCachedPredictionContext;function s(t,e){return this.atn=t,this.sharedContextCache=e,this}s.ERROR=new r(2147483647,new i),s.prototype.getCachedContext=function(t){if(null===this.sharedContextCache)return t;return o(t,this.sharedContextCache,{})},e.ATNSimulator=s},function(t,e,n){n(0).Set;var r=n(0).Map,i=n(0).BitSet,o=n(0).AltDict,s=n(7).ATN,a=n(3).RuleStopState,l=n(9).ATNConfigSet,u=n(13).ATNConfig,c=n(10).SemanticContext,h=(n(0).Hash,n(0).hashStuff);n(0).equalArrays;function p(){return this}p.SLL=0,p.LL=1,p.LL_EXACT_AMBIG_DETECTION=2,p.hasSLLConflictTerminatingPrediction=function(t,e){if(p.allConfigsInRuleStopStates(e))return!0;if(t===p.SLL&&e.hasSemanticContext){for(var n=new l,r=0;r1)return!0}return!1},p.allSubsetsEqual=function(t){for(var e=null,n=0;n=n)){var i,o=e.charCodeAt(r);return o>=55296&&o<=56319&&n>r+1&&(i=e.charCodeAt(r+1))>=56320&&i<=57343?1024*(o-55296)+i-56320+65536:o}};t?t(String.prototype,"codePointAt",{value:e,configurable:!0,writable:!0}):String.prototype.codePointAt=e}()},function(t,e){var n,r,i,o;String.fromCodePoint||(n=function(){try{var t={},e=Object.defineProperty,n=e(t,t,t)&&e}catch(t){}return n}(),r=String.fromCharCode,i=Math.floor,o=function(t){var e,n,o=[],s=-1,a=arguments.length;if(!a)return"";for(var l="";++s1114111||i(u)!=u)throw RangeError("Invalid code point: "+u);u<=65535?o.push(u):(e=55296+((u-=65536)>>10),n=u%1024+56320,o.push(e,n)),(s+1==a||o.length>16384)&&(l+=r.apply(null,o),o.length=0)}return l},n?n(String,"fromCodePoint",{value:o,configurable:!0,writable:!0}):String.fromCodePoint=o)},function(t,e,n){var r=n(1).Token,i=n(5),o=i.NoViableAltException,s=i.InputMismatchException,a=i.FailedPredicateException,l=i.ParseCancellationException,u=n(3).ATNState,c=n(2).Interval,h=n(2).IntervalSet;function p(){}function f(){return p.call(this),this.errorRecoveryMode=!1,this.lastErrorIndex=-1,this.lastErrorStates=null,this}function d(){return f.call(this),this}p.prototype.reset=function(t){},p.prototype.recoverInline=function(t){},p.prototype.recover=function(t,e){},p.prototype.sync=function(t){},p.prototype.inErrorRecoveryMode=function(t){},p.prototype.reportError=function(t){},f.prototype=Object.create(p.prototype),f.prototype.constructor=f,f.prototype.reset=function(t){this.endErrorCondition(t)},f.prototype.beginErrorCondition=function(t){this.errorRecoveryMode=!0},f.prototype.inErrorRecoveryMode=function(t){return this.errorRecoveryMode},f.prototype.endErrorCondition=function(t){this.errorRecoveryMode=!1,this.lastErrorStates=null,this.lastErrorIndex=-1},f.prototype.reportMatch=function(t){this.endErrorCondition(t)},f.prototype.reportError=function(t,e){this.inErrorRecoveryMode(t)||(this.beginErrorCondition(t),e instanceof o?this.reportNoViableAlternative(t,e):e instanceof s?this.reportInputMismatch(t,e):e instanceof a?this.reportFailedPredicate(t,e):(console.log("unknown recognition error type: "+e.constructor.name),console.log(e.stack),t.notifyErrorListeners(e.getOffendingToken(),e.getMessage(),e)))},f.prototype.recover=function(t,e){this.lastErrorIndex===t.getInputStream().index&&null!==this.lastErrorStates&&this.lastErrorStates.indexOf(t.state)>=0&&t.consume(),this.lastErrorIndex=t._input.index,null===this.lastErrorStates&&(this.lastErrorStates=[]),this.lastErrorStates.push(t.state);var n=this.getErrorRecoverySet(t);this.consumeUntil(t,n)},f.prototype.sync=function(t){if(!this.inErrorRecoveryMode(t)){var e=t._interp.atn.states[t.state],n=t.getTokenStream().LA(1),i=t.atn.nextTokens(e);if(!i.contains(r.EPSILON)&&!i.contains(n))switch(e.stateType){case u.BLOCK_START:case u.STAR_BLOCK_START:case u.PLUS_BLOCK_START:case u.STAR_LOOP_ENTRY:if(null!==this.singleTokenDeletion(t))return;throw new s(t);case u.PLUS_LOOP_BACK:case u.STAR_LOOP_BACK:this.reportUnwantedToken(t);var o=new h;o.addSet(t.getExpectedTokens());var a=o.addSet(this.getErrorRecoverySet(t));this.consumeUntil(t,a)}}},f.prototype.reportNoViableAlternative=function(t,e){var n,i=t.getTokenStream();n=null!==i?e.startToken.type===r.EOF?"":i.getText(new c(e.startToken,e.offendingToken)):"";var o="no viable alternative at input "+this.escapeWSAndQuote(n);t.notifyErrorListeners(o,e.offendingToken,e)},f.prototype.reportInputMismatch=function(t,e){var n="mismatched input "+this.getTokenErrorDisplay(e.offendingToken)+" expecting "+e.getExpectedTokens().toString(t.literalNames,t.symbolicNames);t.notifyErrorListeners(n,e.offendingToken,e)},f.prototype.reportFailedPredicate=function(t,e){var n="rule "+t.ruleNames[t._ctx.ruleIndex]+" "+e.message;t.notifyErrorListeners(n,e.offendingToken,e)},f.prototype.reportUnwantedToken=function(t){if(!this.inErrorRecoveryMode(t)){this.beginErrorCondition(t);var e=t.getCurrentToken(),n="extraneous input "+this.getTokenErrorDisplay(e)+" expecting "+this.getExpectedTokens(t).toString(t.literalNames,t.symbolicNames);t.notifyErrorListeners(n,e,null)}},f.prototype.reportMissingToken=function(t){if(!this.inErrorRecoveryMode(t)){this.beginErrorCondition(t);var e=t.getCurrentToken(),n="missing "+this.getExpectedTokens(t).toString(t.literalNames,t.symbolicNames)+" at "+this.getTokenErrorDisplay(e);t.notifyErrorListeners(n,e,null)}},f.prototype.recoverInline=function(t){var e=this.singleTokenDeletion(t);if(null!==e)return t.consume(),e;if(this.singleTokenInsertion(t))return this.getMissingSymbol(t);throw new s(t)},f.prototype.singleTokenInsertion=function(t){var e=t.getTokenStream().LA(1),n=t._interp.atn,r=n.states[t.state].transitions[0].target;return!!n.nextTokens(r,t._ctx).contains(e)&&(this.reportMissingToken(t),!0)},f.prototype.singleTokenDeletion=function(t){var e=t.getTokenStream().LA(2);if(this.getExpectedTokens(t).contains(e)){this.reportUnwantedToken(t),t.consume();var n=t.getCurrentToken();return this.reportMatch(t),n}return null},f.prototype.getMissingSymbol=function(t){var e,n=t.getCurrentToken(),i=this.getExpectedTokens(t).first();e=i===r.EOF?"":"";var o=n,s=t.getTokenStream().LT(-1);return o.type===r.EOF&&null!==s&&(o=s),t.getTokenFactory().create(o.source,i,e,r.DEFAULT_CHANNEL,-1,-1,o.line,o.column)},f.prototype.getExpectedTokens=function(t){return t.getExpectedTokens()},f.prototype.getTokenErrorDisplay=function(t){if(null===t)return"";var e=t.text;return null===e&&(e=t.type===r.EOF?"":"<"+t.type+">"),this.escapeWSAndQuote(e)},f.prototype.escapeWSAndQuote=function(t){return"'"+(t=(t=(t=t.replace(/\n/g,"\\n")).replace(/\r/g,"\\r")).replace(/\t/g,"\\t"))+"'"},f.prototype.getErrorRecoverySet=function(t){for(var e=t._interp.atn,n=t._ctx,i=new h;null!==n&&n.invokingState>=0;){var o=e.states[n.invokingState].transitions[0],s=e.nextTokens(o.followState);i.addSet(s),n=n.parentCtx}return i.removeOne(r.EPSILON),i},f.prototype.consumeUntil=function(t,e){for(var n=t.getTokenStream().LA(1);n!==r.EOF&&!e.contains(n);)t.consume(),n=t.getTokenStream().LA(1)},d.prototype=Object.create(f.prototype),d.prototype.constructor=d,d.prototype.recover=function(t,e){for(var n=t._ctx;null!==n;)n.exception=e,n=n.parentCtx;throw new l(e)},d.prototype.recoverInline=function(t){this.recover(t,new s(t))},d.prototype.sync=function(t){},e.BailErrorStrategy=d,e.DefaultErrorStrategy=f},function(t,e){},function(t,e,n){Converter=n(33).Converter},function(module,exports,__webpack_require__){antlr4=__webpack_require__(12);var BlocklyGrammerVisitor=__webpack_require__(20).BlocklyGrammerVisitor,BlocklyGrammerLexer=__webpack_require__(51).BlocklyGrammerLexer,BlocklyGrammerParser=__webpack_require__(52).BlocklyGrammerParser,Visitors=__webpack_require__(53),SymbolVisitor=Visitors.SymbolVisitor,EvalVisitor=Visitors.EvalVisitor,tpl=__webpack_require__(54);function Converter(){return this}Converter.prototype.constructor=Converter,Converter.prototype.init=function(){return this.toolboxGap=5,this.toolboxId="toolbox",this.blocklyDivId="blocklyDiv",this.workSpaceName="workspace",this.codeAreaId="codeArea",this},Converter.prototype.main=function(t,e,n){return this.init(),this.generBlocks(t,e),this.renderGrammerName(),this.generToolbox(),this.generMainFile(),this.writeMainFile(n),this},Converter.prototype.generBlocks=function(grammerFile,functions){functions||(functions=[]);var temp_consoleError=console.error;console.error=function(t){throw new Error(t)};var chars=new antlr4.InputStream(grammerFile),lexer=new BlocklyGrammerLexer(chars),tokens=new antlr4.CommonTokenStream(lexer),parser=new BlocklyGrammerParser(tokens);parser.buildParseTrees=!0;var tree=parser.grammarFile();console.error=temp_consoleError;var svisitor=(new SymbolVisitor).init();this.svisitor=svisitor,svisitor.visit(tree),console.log(svisitor),svisitor.checkSymbol();var evisitor=(new EvalVisitor).init(svisitor,grammerFile);return this.evisitor=evisitor,eval(this.evisitor.matchInject("Function_0")),functions[0]&&functions[0].call(this),evisitor.visit(tree),eval(this.evisitor.matchInject("Function_1")),functions[1]&&functions[1].call(this),evisitor.generBlocks(),console.log(evisitor),this.blocks=evisitor.blocks,eval(this.evisitor.matchInject("Function_2")),functions[2]&&functions[2].call(this),this},Converter.prototype.renderGrammerName=function(){this.grammerName=this.svisitor.grammerName,this.generLanguage=this.evisitor.generLanguage;var t=this.grammerName,e=this.generLanguage;return this.OmitedError=tpl.OmitedError(),this.Functions_pre=tpl.Functions_pre(t),this.Functions_xmlText=tpl.Functions_xmlText(t),this.Functions_blocksIniter=tpl.Functions_blocksIniter(t,e),this.mainFileTPL=tpl.mainFileTPL,this},Converter.prototype.generToolbox=function(){eval(this.grammerName+"Functions={};"),eval(this.Functions_xmlText),eval(this.blocks),eval("var blocksobj = "+this.grammerName+"Blocks;"),console.log(blocksobj);var text=[];for(var key in text.push('"),this.toolbox=this.textToPrettyText(text.join("")),this},Converter.prototype.generMainFile=function(){var t=[],e=this.grammerName;t.push(this.blocks),t.push("\n\n"),t.push(this.OmitedError),t.push("\n\n"),t.push(e+"Functions={}\n\n"),t.push(this.evisitor.matchInject("Functions")),t.push("\n\n"),t.push(this.Functions_pre),t.push("\n\n"),t.push(this.Functions_xmlText),t.push("\n\n"),t.push(this.Functions_blocksIniter),t.push("\n\n"),t.push(e+"Functions.blocksIniter();\n\n"),this.mainFile=this.mainFileTPL(e,this.generLanguage,this.blocklyDivId,this.codeAreaId,this.toolbox,this.workSpaceName,this.toolboxId,t.join(""))},Converter.prototype.writeMainFile=function(t){t||(t=this.grammerName+"index.html"),this.createAndDownloadFile(this.mainFile.join(""),t,"html")},Converter.prototype.block=function(t){var e=this.evisitor.expressionRules[t];return e||(e=this.evisitor.statementRules[t]),e&&1!==e.checklength?e.blockjs:null},Converter.prototype.textToPrettyText=function(t){for(var e=t.split("<"),n="",r=1;r"!=i.slice(-2)&&(n+=" ")}var o=e.join("\n");return(o=o.replace(/(<(\w+)\b[^>]*>[^\n]*)\n *<\/\2>/g,"$1")).replace(/^\n/,"")},Converter.prototype.createAndDownloadFile=function(t,e,n){var r=new Blob([t],{type:"text/"+n}),i=new MouseEvent("click",{view:window,bubbles:!0,cancelable:!1}),o=document.createElement("a");o.href=window.URL.createObjectURL(r),o.download=e,o.textContent="Download file!",o.dispatchEvent(i)},exports.Converter=Converter},function(t,e,n){e.ATN=n(7).ATN,e.ATNDeserializer=n(22).ATNDeserializer,e.LexerATNSimulator=n(37).LexerATNSimulator,e.ParserATNSimulator=n(40).ParserATNSimulator,e.PredictionMode=n(27).PredictionMode},function(t,e,n){var r=n(0).Set,i=n(0).BitSet,o=n(1).Token,s=n(13).ATNConfig,a=(n(2).Interval,n(2).IntervalSet),l=n(3).RuleStopState,u=n(8).RuleTransition,c=n(8).NotSetTransition,h=n(8).WildcardTransition,p=n(8).AbstractPredicateTransition,f=n(6),d=f.predictionContextFromRuleContext,y=f.PredictionContext,g=f.SingletonPredictionContext;function v(t){this.atn=t}v.HIT_PRED=o.INVALID_TYPE,v.prototype.getDecisionLookahead=function(t){if(null===t)return null;for(var e=t.transitions.length,n=[],o=0;ox.MAX_DFA_EDGE)return null;var n=t.edges[e-x.MIN_DFA_EDGE];return void 0===n&&(n=null),x.debug&&null!==n&&console.log("reuse state "+t.stateNumber+" edge to "+n.stateNumber),n},x.prototype.computeTargetState=function(t,e,n){var r=new l;return this.getReachableConfigSet(t,e.configs,r,n),0===r.items.length?(r.hasSemanticContext||this.addDFAEdge(e,n,s.ERROR),s.ERROR):this.addDFAEdge(e,n,null,r)},x.prototype.failOrAccept=function(t,e,n,i){if(null!==this.prevAccept.dfaState){var o=t.dfaState.lexerActionExecutor;return this.accept(e,o,this.startIndex,t.index,t.line,t.column),t.dfaState.prediction}if(i===r.EOF&&e.index===this.startIndex)return r.EOF;throw new y(this.recog,e,this.startIndex,n)},x.prototype.getReachableConfigSet=function(t,e,n,i){for(var s=o.INVALID_ALT_NUMBER,a=0;ax.MAX_DFA_EDGE?n:(x.debug&&console.log("EDGE "+t+" -> "+n+" upon "+e),null===t.edges&&(t.edges=[]),t.edges[e-x.MIN_DFA_EDGE]=n,n)},x.prototype.addDFAState=function(t){for(var e=new a(null,t),n=null,r=0;r0&&(o=this.getAltThatFinishedDecisionEntryRule(i))!==a.INVALID_ALT_NUMBER?o:a.INVALID_ALT_NUMBER},I.prototype.getAltThatFinishedDecisionEntryRule=function(t){for(var e=[],n=0;n0||r.state instanceof x&&r.context.hasEmptyPath())&&e.indexOf(r.alt)<0&&e.push(r.alt)}return 0===e.length?a.INVALID_ALT_NUMBER:Math.min.apply(null,e)},I.prototype.splitAccordingToSemanticValidity=function(t,e){for(var n=new c(t.fullCtx),r=new c(t.fullCtx),i=0;i50))throw"problem";if(t.state instanceof x){if(!t.context.isEmpty()){for(var a=0;a=0&&(p+=1);this.closureCheckingStopState(h,e,n,c,i,p,s)}}},I.prototype.canDropLoopEntryEdgeInLeftRecursiveRule=function(t){var e=t.state;if(e.stateType!=l.STAR_LOOP_ENTRY)return!1;if(e.stateType!=l.STAR_LOOP_ENTRY||!e.isPrecedenceDecision||t.context.isEmpty()||t.context.hasEmptyPath())return!1;for(var n=t.context.length,r=0;r=0?this.parser.ruleNames[t]:""},I.prototype.getEpsilonTarget=function(t,e,n,r,i,o){switch(e.serializationType){case S.RULE:return this.ruleTransition(t,e);case S.PRECEDENCE:return this.precedenceTransition(t,e,n,r,i);case S.PREDICATE:return this.predTransition(t,e,n,r,i);case S.ACTION:return this.actionTransition(t,e);case S.EPSILON:return new u({state:e.target},t);case S.ATOM:case S.RANGE:case S.SET:return o&&e.matches(h.EOF,0,1)?new u({state:e.target},t):null;default:return null}},I.prototype.actionTransition=function(t,e){if(this.debug){var n=-1==e.actionIndex?65535:e.actionIndex;console.log("ACTION edge "+e.ruleIndex+":"+n)}return new u({state:e.target},t)},I.prototype.precedenceTransition=function(t,e,n,i,o){this.debug&&(console.log("PRED (collectPredicates="+n+") "+e.precedence+">=_p, ctx dependent=true"),null!==this.parser&&console.log("context surrounding pred is "+r.arrayToString(this.parser.getRuleInvocationStack())));var s=null;if(n&&i)if(o){var a=this._input.index;this._input.seek(this._startIndex);var l=e.getPredicate().evaluate(this.parser,this._outerContext);this._input.seek(a),l&&(s=new u({state:e.target},t))}else{var c=v.andContext(t.semanticContext,e.getPredicate());s=new u({state:e.target,semanticContext:c},t)}else s=new u({state:e.target},t);return this.debug&&console.log("config from pred transition="+s),s},I.prototype.predTransition=function(t,e,n,i,o){this.debug&&(console.log("PRED (collectPredicates="+n+") "+e.ruleIndex+":"+e.predIndex+", ctx dependent="+e.isCtxDependent),null!==this.parser&&console.log("context surrounding pred is "+r.arrayToString(this.parser.getRuleInvocationStack())));var s=null;if(n&&(e.isCtxDependent&&i||!e.isCtxDependent))if(o){var a=this._input.index;this._input.seek(this._startIndex);var l=e.getPredicate().evaluate(this.parser,this._outerContext);this._input.seek(a),l&&(s=new u({state:e.target},t))}else{var c=v.andContext(t.semanticContext,e.getPredicate());s=new u({state:e.target,semanticContext:c},t)}else s=new u({state:e.target},t);return this.debug&&console.log("config from pred transition="+s),s},I.prototype.ruleTransition=function(t,e){this.debug&&console.log("CALL rule "+this.getRuleName(e.target.ruleIndex)+", ctx="+t.context);var n=e.followState,r=R.create(t.context,n.stateNumber);return new u({state:e.target,context:r},t)},I.prototype.getConflictingAlts=function(t){var e=y.getConflictingAltSubsets(t);return y.getAlts(e)},I.prototype.getConflictingAltsOrUniqueAlt=function(t){var e=null;return t.uniqueAlt!==a.INVALID_ALT_NUMBER?(e=new o).add(t.uniqueAlt):e=t.conflictingAlts,e},I.prototype.getTokenName=function(t){if(t===h.EOF)return"EOF";if(null!==this.parser&&null!==this.parser.literalNames){if(!(t>=this.parser.literalNames.length&&t>=this.parser.symbolicNames.length))return(this.parser.literalNames[t]||this.parser.symbolicNames[t])+"<"+t+">";console.log(t+" ttype out of range: "+this.parser.literalNames),console.log(""+this.parser.getInputStream().getTokens())}return""+t},I.prototype.getLookaheadName=function(t){return this.getTokenName(t.LA(1))},I.prototype.dumpDeadEndConfigs=function(t){console.log("dead end configs: ");for(var e=t.getDeadEndConfigs(),n=0;n0){var o=r.state.transitions[0];if(o instanceof AtomTransition)i="Atom "+this.getTokenName(o.label);else if(o instanceof E){i=(o instanceof C?"~":"")+"Set "+o.set}}console.error(r.toString(this.parser,!0)+":"+i)}},I.prototype.noViableAlt=function(t,e,n,r){return new k(this.parser,t,t.get(r),t.LT(1),n,e)},I.prototype.getUniqueAlt=function(t){for(var e=a.INVALID_ALT_NUMBER,n=0;n "+r+" upon "+this.getTokenName(n)),null===r)return null;if(r=this.addDFAState(t,r),null===e||n<-1||n>this.atn.maxTokenType)return r;if(null===e.edges&&(e.edges=[]),e.edges[n+1]=r,this.debug){var i=null===this.parser?null:this.parser.literalNames,o=null===this.parser?null:this.parser.symbolicNames;console.log("DFA=\n"+t.toString(i,o))}return r},I.prototype.addDFAState=function(t,e){if(e==d.ERROR)return e;var n=t.states.get(e);return null!==n?n:(e.stateNumber=t.states.length,e.configs.readOnly||(e.configs.optimizeConfigs(this),e.configs.setReadonly(!0)),t.states.add(e),this.debug&&console.log("adding new DFA state: "+e),e)},I.prototype.reportAttemptingFullContext=function(t,e,n,r,i){if(this.debug||this.retry_debug){var o=new _(r,i+1);console.log("reportAttemptingFullContext decision="+t.decision+":"+n+", input="+this.parser.getTokenStream().getText(o))}null!==this.parser&&this.parser.getErrorListenerDispatch().reportAttemptingFullContext(this.parser,t,r,i,e,n)},I.prototype.reportContextSensitivity=function(t,e,n,r,i){if(this.debug||this.retry_debug){var o=new _(r,i+1);console.log("reportContextSensitivity decision="+t.decision+":"+n+", input="+this.parser.getTokenStream().getText(o))}null!==this.parser&&this.parser.getErrorListenerDispatch().reportContextSensitivity(this.parser,t,r,i,e,n)},I.prototype.reportAmbiguity=function(t,e,n,r,i,o,s){if(this.debug||this.retry_debug){var a=new _(n,r+1);console.log("reportAmbiguity "+o+":"+s+", input="+this.parser.getTokenStream().getText(a))}null!==this.parser&&this.parser.getErrorListenerDispatch().reportAmbiguity(this.parser,t,n,r,i,o,s)},e.ParserATNSimulator=I},function(t,e,n){e.DFA=n(42).DFA,e.DFASerializer=n(17).DFASerializer,e.LexerDFASerializer=n(17).LexerDFASerializer,e.PredPrediction=n(11).PredPrediction},function(t,e,n){var r=n(0).Set,i=n(11).DFAState,o=n(3).StarLoopEntryState,s=n(9).ATNConfigSet,a=n(17).DFASerializer,l=n(17).LexerDFASerializer;function u(t,e){if(void 0===e&&(e=0),this.atnStartState=t,this.decision=e,this._states=new r,this.s0=null,this.precedenceDfa=!1,t instanceof o&&t.isPrecedenceDecision){this.precedenceDfa=!0;var n=new i(null,new s);n.edges=[],n.isAcceptState=!1,n.requiresFullContext=!1,this.s0=n}return this}u.prototype.getPrecedenceStartState=function(t){if(!this.precedenceDfa)throw"Only precedence DFAs may contain a precedence start state.";return t<0||t>=this.s0.edges.length?null:this.s0.edges[t]||null},u.prototype.setPrecedenceStartState=function(t,e){if(!this.precedenceDfa)throw"Only precedence DFAs may contain a precedence start state.";t<0||(this.s0.edges[t]=e)},u.prototype.setPrecedenceDfa=function(t){if(this.precedenceDfa!==t){if(this._states=new DFAStatesSet,t){var e=new i(null,new s);e.edges=[],e.isAcceptState=!1,e.requiresFullContext=!1,this.s0=e}else this.s0=null;this.precedenceDfa=t}},Object.defineProperty(u.prototype,"states",{get:function(){return this._states}}),u.prototype.sortedStates=function(){return this._states.values().sort(function(t,e){return t.stateNumber-e.stateNumber})},u.prototype.toString=function(t,e){return t=t||null,e=e||null,null===this.s0?"":new a(this,t,e).toString()},u.prototype.toLexerString=function(){return null===this.s0?"":new l(this).toString()},e.DFA=u},function(t,e,n){var r=n(4);e.Trees=n(21).Trees,e.RuleNode=r.RuleNode,e.ParseTreeListener=r.ParseTreeListener,e.ParseTreeVisitor=r.ParseTreeVisitor,e.ParseTreeWalker=r.ParseTreeWalker},function(t,e,n){e.RecognitionException=n(5).RecognitionException,e.NoViableAltException=n(5).NoViableAltException,e.LexerNoViableAltException=n(5).LexerNoViableAltException,e.InputMismatchException=n(5).InputMismatchException,e.FailedPredicateException=n(5).FailedPredicateException,e.DiagnosticErrorListener=n(45).DiagnosticErrorListener,e.BailErrorStrategy=n(30).BailErrorStrategy,e.ErrorListener=n(16).ErrorListener},function(t,e,n){var r=n(0).BitSet,i=n(16).ErrorListener,o=n(2).Interval;function s(t){return i.call(this),t=t||!0,this.exactOnly=t,this}s.prototype=Object.create(i.prototype),s.prototype.constructor=s,s.prototype.reportAmbiguity=function(t,e,n,r,i,s,a){if(!this.exactOnly||i){var l="reportAmbiguity d="+this.getDecisionDescription(t,e)+": ambigAlts="+this.getConflictingAlts(s,a)+", input='"+t.getTokenStream().getText(new o(n,r))+"'";t.notifyErrorListeners(l)}},s.prototype.reportAttemptingFullContext=function(t,e,n,r,i,s){var a="reportAttemptingFullContext d="+this.getDecisionDescription(t,e)+", input='"+t.getTokenStream().getText(new o(n,r))+"'";t.notifyErrorListeners(a)},s.prototype.reportContextSensitivity=function(t,e,n,r,i,s){var a="reportContextSensitivity d="+this.getDecisionDescription(t,e)+", input='"+t.getTokenStream().getText(new o(n,r))+"'";t.notifyErrorListeners(a)},s.prototype.getDecisionDescription=function(t,e){var n=e.decision,r=e.atnStartState.ruleIndex,i=t.ruleNames;if(r<0||r>=i.length)return""+n;var o=i[r]||null;return null===o||0===o.length?""+n:n+" ("+o+")"},s.prototype.getConflictingAlts=function(t,e){if(null!==t)return t;for(var n=new r,i=0;i=0&&(this.fetchedEOF?this.index0)||this.fetch(e)>=e},a.prototype.fetch=function(t){if(this.fetchedEOF)return 0;for(var e=0;e=this.tokens.length&&(e=this.tokens.length-1);for(var o=t;o=this.tokens.length?this.tokens[this.tokens.length-1]:this.tokens[e]},a.prototype.adjustSeekIndex=function(t){return t},a.prototype.lazyInit=function(){-1===this.index&&this.setup()},a.prototype.setup=function(){this.sync(0),this.index=this.adjustSeekIndex(0)},a.prototype.setTokenSource=function(t){this.tokenSource=t,this.tokens=[],this.index=-1,this.fetchedEOF=!1},a.prototype.nextTokenOnChannel=function(t,e){if(this.sync(t),t>=this.tokens.length)return-1;for(var n=this.tokens[t];n.channel!==this.channel;){if(n.type===r.EOF)return-1;t+=1,this.sync(t),n=this.tokens[t]}return t},a.prototype.previousTokenOnChannel=function(t,e){for(;t>=0&&this.tokens[t].channel!==e;)t-=1;return t},a.prototype.getHiddenTokensToRight=function(t,e){if(void 0===e&&(e=-1),this.lazyInit(),t<0||t>=this.tokens.length)throw t+" not in 0.."+this.tokens.length-1;var n=this.nextTokenOnChannel(t+1,i.DEFAULT_TOKEN_CHANNEL),r=t+1,o=-1===n?this.tokens.length-1:n;return this.filterForChannel(r,o,e)},a.prototype.getHiddenTokensToLeft=function(t,e){if(void 0===e&&(e=-1),this.lazyInit(),t<0||t>=this.tokens.length)throw t+" not in 0.."+this.tokens.length-1;var n=this.previousTokenOnChannel(t-1,i.DEFAULT_TOKEN_CHANNEL);if(n===t-1)return null;var r=n+1,o=t-1;return this.filterForChannel(r,o,e)},a.prototype.filterForChannel=function(t,e,n){for(var r=[],o=t;o=this.tokens.length&&(n=this.tokens.length-1);for(var i="",s=e;s=0&&this._parseListeners.splice(e,1),0===this._parseListeners.length&&(this._parseListeners=null)}},p.prototype.removeParseListeners=function(){this._parseListeners=null},p.prototype.triggerEnterRuleEvent=function(){if(null!==this._parseListeners){var t=this._ctx;this._parseListeners.map(function(e){e.enterEveryRule(t),t.enterRule(e)})}},p.prototype.triggerExitRuleEvent=function(){if(null!==this._parseListeners){var t=this._ctx;this._parseListeners.slice(0).reverse().map(function(e){t.exitRule(e),e.exitEveryRule(t)})}},p.prototype.getTokenFactory=function(){return this._input.tokenSource._factory},p.prototype.setTokenFactory=function(t){this._input.tokenSource._factory=t},p.prototype.getATNWithBypassAlts=function(){var t=this.getSerializedATN();if(null===t)throw"The current parser does not support an ATN with bypass alternatives.";var e=this.bypassAltsAtnCache[t];if(null===e){var n=new l;n.generateRuleBypassTransitions=!0,e=new a(n).deserialize(t),this.bypassAltsAtnCache[t]=e}return e};var f=n(15).Lexer;p.prototype.compileParseTreePattern=function(t,e,n){if(null===(n=n||null)&&null!==this.getTokenStream()){var r=this.getTokenStream().tokenSource;r instanceof f&&(n=r)}if(null===n)throw"Parser can't discover a lexer to use";return new ParseTreePatternMatcher(n,this).compile(t,e)},p.prototype.getInputStream=function(){return this.getTokenStream()},p.prototype.setInputStream=function(t){this.setTokenStream(t)},p.prototype.getTokenStream=function(){return this._input},p.prototype.setTokenStream=function(t){this._input=null,this.reset(),this._input=t},p.prototype.getCurrentToken=function(){return this._input.LT(1)},p.prototype.notifyErrorListeners=function(t,e,n){e=e||null,n=n||null,null===e&&(e=this.getCurrentToken()),this._syntaxErrors+=1;var r=e.line,i=e.column;this.getErrorListenerDispatch().syntaxError(this,e,r,i,t,n)},p.prototype.consume=function(){var t=this.getCurrentToken();t.type!==r.EOF&&this.getInputStream().consume();var e,n=null!==this._parseListeners&&this._parseListeners.length>0;(this.buildParseTrees||n)&&((e=this._errHandler.inErrorRecoveryMode(this)?this._ctx.addErrorNode(t):this._ctx.addTokenNode(t)).invokingState=this.state,n&&this._parseListeners.map(function(t){e instanceof c||void 0!==e.isErrorNode&&e.isErrorNode()?t.visitErrorNode(e):e instanceof u&&t.visitTerminal(e)}));return t},p.prototype.addContextToParseTree=function(){null!==this._ctx.parentCtx&&this._ctx.parentCtx.addChild(this._ctx)},p.prototype.enterRule=function(t,e,n){this.state=e,this._ctx=t,this._ctx.start=this._input.LT(1),this.buildParseTrees&&this.addContextToParseTree(),null!==this._parseListeners&&this.triggerEnterRuleEvent()},p.prototype.exitRule=function(){this._ctx.stop=this._input.LT(-1),null!==this._parseListeners&&this.triggerExitRuleEvent(),this.state=this._ctx.invokingState,this._ctx=this._ctx.parentCtx},p.prototype.enterOuterAlt=function(t,e){t.setAltNumber(e),this.buildParseTrees&&this._ctx!==t&&null!==this._ctx.parentCtx&&(this._ctx.parentCtx.removeLastChild(),this._ctx.parentCtx.addChild(t)),this._ctx=t},p.prototype.getPrecedence=function(){return 0===this._precedenceStack.length?-1:this._precedenceStack[this._precedenceStack.length-1]},p.prototype.enterRecursionRule=function(t,e,n,r){this.state=e,this._precedenceStack.push(r),this._ctx=t,this._ctx.start=this._input.LT(1),null!==this._parseListeners&&this.triggerEnterRuleEvent()},p.prototype.pushNewRecursionContext=function(t,e,n){var r=this._ctx;r.parentCtx=t,r.invokingState=e,r.stop=this._input.LT(-1),this._ctx=t,this._ctx.start=r.start,this.buildParseTrees&&this._ctx.addChild(r),null!==this._parseListeners&&this.triggerEnterRuleEvent()},p.prototype.unrollRecursionContexts=function(t){this._precedenceStack.pop(),this._ctx.stop=this._input.LT(-1);var e=this._ctx;if(null!==this._parseListeners)for(;this._ctx!==t;)this.triggerExitRuleEvent(),this._ctx=this._ctx.parentCtx;else this._ctx=t;e.parentCtx=t,this.buildParseTrees&&null!==t&&t.addChild(e)},p.prototype.getInvokingContext=function(t){for(var e=this._ctx;null!==e;){if(e.ruleIndex===t)return e;e=e.parentCtx}return null},p.prototype.precpred=function(t,e){return e>=this._precedenceStack[this._precedenceStack.length-1]},p.prototype.inContext=function(t){return!1},p.prototype.isExpectedToken=function(t){var e=this._interp.atn,n=this._ctx,i=e.states[this.state],o=e.nextTokens(i);if(o.contains(t))return!0;if(!o.contains(r.EPSILON))return!1;for(;null!==n&&n.invokingState>=0&&o.contains(r.EPSILON);){var s=e.states[n.invokingState].transitions[0];if((o=e.nextTokens(s.followState)).contains(t))return!0;n=n.parentCtx}return!(!o.contains(r.EPSILON)||t!==r.EOF)},p.prototype.getExpectedTokens=function(){return this._interp.atn.getExpectedTokens(this.state,this._ctx)},p.prototype.getExpectedTokensWithinCurrentRule=function(){var t=this._interp.atn,e=t.states[this.state];return t.nextTokens(e)},p.prototype.getRuleIndex=function(t){var e=this.getRuleIndexMap()[t];return null!==e?e:-1},p.prototype.getRuleInvocationStack=function(t){null===(t=t||null)&&(t=this._ctx);for(var e=[];null!==t;){var n=t.ruleIndex;n<0?e.push("n/a"):e.push(this.ruleNames[n]),t=t.parentCtx}return e},p.prototype.getDFAStrings=function(){return this._interp.decisionToDFA.toString()},p.prototype.dumpDFA=function(){for(var t=!1,e=0;e0&&(t&&console.log(),this.printer.println("Decision "+n.decision+":"),this.printer.print(n.toString(this.literalNames,this.symbolicNames)),t=!0)}},p.prototype.getSourceName=function(){return this._input.sourceName},p.prototype.setTrace=function(t){t?(null!==this._tracer&&this.removeParseListener(this._tracer),this._tracer=new h(this),this.addParseListener(this._tracer)):(this.removeParseListener(this._tracer),this._tracer=null)},e.Parser=p},function(t,e,n){var r=n(12),i=["悋Ꜫ脳맭䅼㯧瞆奤","ŝ\b\t\t","\t\t\t\t","\b\t\b\t\t\t\n\t\n\v\t\v","\f\t\f\r\t\r\t\t","\t\t\t\t","\t\t\t","\t\t\t\t","\t\t\t","\t\t \t ","","","","","","","","","","","","","","\b\b\t\t\n\n","\v\v\v\v\v\v","\v\v\v\v\v\v","\v\v\v\v\v\v","\v\v\v\v\v\v","\v\v\v\v\v\v","\v\v\v\v\v\v","\v\v\v\v\v\v","\v\f\f\r\r","","Ó\n\fÖ","\v","Ü\n\fß\v","ã\n\fæ\v","ê\n","ï\n\fò","\v","ù\n","þ\n\fā\v","Ĉ\n","","","ę\n","Ĝ\n","ġ\n\rĢ","","ī\n\fĮ\v","","","Ŀ\n\fł","\v","Ō\n\f","ŏ\v ","    ŗ\n \f  Ś\v  "," ÔĬŀ!","\t\v\r\b\t\n\v\f\r","!#%","')+-/13579",";=?__C\\","2;C\\aac|c|$$^^\n$$11^^dd","hhppttvv))^^\n))11^^ddhhppttvv2;CHch",'\v\v""\f\f==~~',"ũ","\t","\v\r","","","","","!","#%","35","79;","=?","AI","K\t„","\v†\rˆ","“•","—™","ÄÆ","ÈÊ","Ì!Ù","#à%é'ë",")õ+ú","-Ą/ĉ","1ď3đ","5ě7Ġ","9Ħ;Ĵ=Ň","?ŒABi","BCtCDcDEo","EFoFGcGHtH","IJ=J","KLuLMvMNc","NOvOPGPQzQR","rRStSTUTUr","UVnVWkWXv",'XY"YZ<Z["[\\',")\\]?]^?^_",'?_`"`auabv',"bcccdvdeg","efofggghphi",'vij"jk`kl"',"lm?mn?no?",'op"pqgqrzrs',"rstttuguvu","vwuwxkxyq",'yzpz{"{|x|}','"}~?~?',"€?€)‚",'"‚ƒ=ƒ\b',"„…<…\n","†‡~‡\f","ˆ‰g‰ŠzŠ","‹r‹ŒtŒ","gŽuŽ","uk‘q","‘’p’","“”A”","•–-–","—˜,˜","™šOš›g","›œcœp","žkžŸpŸ ","i ¡h¡¢","w¢£n£¤U","¤¥r¥¦n","¦§k§¨v¨",'©"©ª<ª«','"«¬)¬­',"?­®?®¯?",'¯°"°±o',"±²g²³c³","´p´µkµ¶","p¶·i·¸","h¸¹w¹ºn",'º»"»¼`','¼½"½¾?¾',"¿?¿À?ÀÁ",')ÁÂ"ÂÃ',"=ÃÄÅ","*ÅÆÇ","+ÇÈÉ","€ÉÊË","0ËÌÔ","]ÍÎ^ÎÓ^","ÏÐ^ÐÓ_","ÑÓ\nÒÍ","ÒÏÒÑ","ÓÖÔÕ","ÔÒÕ×","ÖÔר_","Ø ÙÝ\tÚ","Ü\tÛÚÜ","ßÝÛÝ",'ÞÞ"ß',"Ýàä\tá","ã\tâáã","æäâä","åå$æ","äçê+è","ê'éçé","èê&ë","ð$ìï)íï","\nîìîí","ïòðî","ðññó","òðóô","$ô(õø","^öù\t÷ù/","øöø÷","ù*úÿ)","ûþ-üþ\n\býû","ýüþā","ÿýÿĀ","ĀĂāÿ","Ăă)ă,","Ąć^ąĈ\t\t","ĆĈ/ćą","ćĆĈ.","ĉĊwĊċ1","ċČ1Čč1č","Ď1Ď0ďĐ","\t\nĐ2đĒ%","Ēē!ēĔ","Ĕĕ\bĕ4","ĖĘėę\f","ĘėĘę","ęĜĚĜ\f","ěĖěĚ","ĜĝĝĞ\b","Ğ6ğġ\t\vĠ","ğġĢĢ","ĠĢģģ","ĤĤĥ\bĥ","8Ħħ1ħĨ",",ĨĬĩī","\vĪĩīĮ","ĬĭĬĪ","ĭįĮĬ","įİ,İı","1ıIJIJij","\bij:Ĵĵ","hĵĶtĶķc","ķĸiĸĹo","ĹĺgĺĻpĻ","ļvļŀĽ","Ŀ\vľĽĿ","łŀŁŀ","ľŁŃł","ŀŃń=ń","ŅŅņ\bņ","<Ňň1ňʼn","1ʼnōŊŌ","\n\fŋŊŌŏ","ōŋōŎ","ŎŐŏō","Őő\bő>","Œœ/œŔ@","ŔŘŕŗ\n\r","ŖŕŗŚ","ŘŖŘř","řśŚŘ","śŜ\b Ŝ@","ÒÔÝäéîðøýÿćĘ","ěĢĬŀōŘ\b"].join(""),o=(new r.atn.ATNDeserializer).deserialize(i),s=o.decisionToState.map(function(t,e){return new r.dfa.DFA(t,e)});function a(t){return r.Lexer.call(this,t),this._interp=new r.atn.LexerATNSimulator(this,o,s,new r.PredictionContextCache),this}a.prototype=Object.create(r.Lexer.prototype),a.prototype.constructor=a,a.EOF=r.Token.EOF,a.T__0=1,a.T__1=2,a.T__2=3,a.T__3=4,a.T__4=5,a.T__5=6,a.T__6=7,a.T__7=8,a.T__8=9,a.T__9=10,a.T__10=11,a.T__11=12,a.T__12=13,a.T__13=14,a.Brackets=15,a.LexerIdentifier=16,a.ParserIdentifier=17,a.String=18,a.LabelForParserRule=19,a.Newline=20,a.WhiteSpace=21,a.BlockComment=22,a.FragmentComment=23,a.LineComment=24,a.ArrowComment=25,a.prototype.channelNames=["DEFAULT_TOKEN_CHANNEL","HIDDEN"],a.prototype.modeNames=["DEFAULT_MODE"],a.prototype.literalNames=[null,"'grammar'","';'","'statExprSplit : '=== statement ^ === expression v ===' ;'","':'","'|'","'expression'","'?'","'+'","'*'","'MeaningfulSplit : '=== meaningful ^ ===' ;'","'('","')'","'~'","'.'"],a.prototype.symbolicNames=[null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,"Brackets","LexerIdentifier","ParserIdentifier","String","LabelForParserRule","Newline","WhiteSpace","BlockComment","FragmentComment","LineComment","ArrowComment"],a.prototype.ruleNames=["T__0","T__1","T__2","T__3","T__4","T__5","T__6","T__7","T__8","T__9","T__10","T__11","T__12","T__13","Brackets","LexerIdentifier","ParserIdentifier","String","STRING_double","ESC_double","STRING_single","ESC_single","UNICODE","HEX","LabelForParserRule","Newline","WhiteSpace","BlockComment","FragmentComment","LineComment","ArrowComment"],a.prototype.grammarFileName="BlocklyGrammer.g4",e.BlocklyGrammerLexer=a},function(t,e,n){var r=n(12),i=n(20).BlocklyGrammerVisitor,o=["悋Ꜫ脳맭䅼㯧瞆奤","Õ\t\t","\t\t\t\t","\b\t\b\t\t\t\n\t\n\v\t\v\f\t\f","\r\t\r\n\f"," \v$\n","\f'\v","","","8\n\r9","@\n\fC\v","F\n","L\n","Q\nS\n\fV\v","\\","\n\f_\vb\n","f\n\f","i\v\b\b\b\bn\n\b\bp\n\b","\b\b\b\bu\n\b\bw\n\b\b\b\b","\b|\n\b\b~\n\b\b\b\b\bƒ\n\b","\b…\n\b\b‡\n\b\t\tŠ\n\t\f\t","\t\v\t\n\n\v\v\v","\v\v\v\v\v\v","\v\v›\n\v\r\v\vœ","\v\v\v\v\v\v","\v\v¦\n\v\f\f\f\f«","\n\f\f­\n\f\f¯\n\f\r\f\f°\r","\r\r\r\r\r\r\r\r\r","\r\r\r\r\r\rÂ\n\r\r\r","\r\r\r\r\r\r\r\r","\rÎ\n\r\rÐ\n\r\f\r\rÓ\v\r\r","%‹\b\n\f","\t\v","\n\vð,","0\bE","\na\fc†","‹Ž","¥®","Á","\b"," ","!"," !%",'"$\n#"$\'',"%&%#","&('%()","\t)*\n*+\t+",",--../","/01","12334","4756","687589","979::;",";F<==A",">@\b?>@","CA?AB","BDCADF","E2E<F\t","GH\bHK","IL\fJLKI","KJLTMP","NQ\fOQPN","POQS","RMSVTR","TUUWVT","WbXYY]","Z\\\b[Z","\\_][]^","^`_]`b","aGaX","b\vcg\bdf","\bedfige","ghh\r","igjo\bkm\t","ln\tmlmn","npokop","p‡qv","rt\tsu\tts","tuuwvr","vww‡x}","y{\tz|\t{z","{||~","}y}~~‡","„€‚\t","ƒ\t‚","‚ƒƒ…","„€„…","…‡†j","†q†x","†‡","ˆŠ\v‰ˆ","Š‹Œ","‹‰Œ","‹Ž\f","‘","‘’’“\f","“””¦","•––—","—š\f˜™","™›\fš˜","›œœš","œž","žŸŸ¦"," ¡¡¢","¢£\r£¤","¤¦¥","¥•¥ ","¦§¬","¨ª\t©«\t","ª©ª«","«­¬¨","¬­­¯","®§¯°","°®°±","±²³\b\r³","´\r´µ\rµ¶","¶Â·¸","¸Â\r\b¹Â","º»»¼","¼½½Â","¾Â¿Â","ÀÂÁ²","Á·Á¹","ÁºÁ¾","Á¿ÁÀ","ÂÑÃÄ\f","\vÄÅÅÐ","\r\fÆÇ\f\nÇÐ\r\v","ÈÉ\f\rÉÐ\tÊË","\f\fËÍ\tÌÎ\t","ÍÌÍÎ","ÎÐÏÃ","ÏÆÏÈ","ÏÊÐÓ","ÑÏÑÒ","ÒÓÑ"," %9AEKPT]agmotv{}‚„†‹œ¥","ª¬°ÁÍÏÑ"].join(""),s=(new r.atn.ATNDeserializer).deserialize(o),a=s.decisionToState.map(function(t,e){return new r.dfa.DFA(t,e)}),l=new r.PredictionContextCache,u=[null,"'grammar'","';'","'statExprSplit : '=== statement ^ === expression v ===' ;'","':'","'|'","'expression'","'?'","'+'","'*'","'MeaningfulSplit : '=== meaningful ^ ===' ;'","'('","')'","'~'","'.'"],c=[null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,"Brackets","LexerIdentifier","ParserIdentifier","String","LabelForParserRule","Newline","WhiteSpace","BlockComment","FragmentComment","LineComment","ArrowComment"],h=["grammarFile","grammerDecl","statExprSplit","statementRule","expressionRule","arithmeticRuleCollection","parserRuleAtom","lexerRuleCollection","meaningfulSplit","lexerRule","strings","lexerRuleExpr"];function p(t){return r.Parser.call(this,t),this._interp=new r.atn.ParserATNSimulator(this,s,a,l),this.ruleNames=h,this.literalNames=u,this.symbolicNames=c,this}function f(t,e,n){return void 0===e&&(e=null),void 0!==n&&null!==n||(n=-1),r.ParserRuleContext.call(this,e,n),this.parser=t,this.ruleIndex=p.RULE_grammarFile,this}function d(t,e,n){return void 0===e&&(e=null),void 0!==n&&null!==n||(n=-1),r.ParserRuleContext.call(this,e,n),this.parser=t,this.ruleIndex=p.RULE_grammerDecl,this}function y(t,e,n){return void 0===e&&(e=null),void 0!==n&&null!==n||(n=-1),r.ParserRuleContext.call(this,e,n),this.parser=t,this.ruleIndex=p.RULE_statExprSplit,this}function g(t,e,n){return void 0===e&&(e=null),void 0!==n&&null!==n||(n=-1),r.ParserRuleContext.call(this,e,n),this.parser=t,this.ruleIndex=p.RULE_statementRule,this}function v(t,e){return g.call(this,t),g.prototype.copyFrom.call(this,e),this}function x(t,e){return g.call(this,t),g.prototype.copyFrom.call(this,e),this}function m(t,e,n){return void 0===e&&(e=null),void 0!==n&&null!==n||(n=-1),r.ParserRuleContext.call(this,e,n),this.parser=t,this.ruleIndex=p.RULE_expressionRule,this}function _(t,e){return m.call(this,t),m.prototype.copyFrom.call(this,e),this}function T(t,e){return m.call(this,t),m.prototype.copyFrom.call(this,e),this}function S(t,e,n){return void 0===e&&(e=null),void 0!==n&&null!==n||(n=-1),r.ParserRuleContext.call(this,e,n),this.parser=t,this.ruleIndex=p.RULE_arithmeticRuleCollection,this}function E(t,e,n){return void 0===e&&(e=null),void 0!==n&&null!==n||(n=-1),r.ParserRuleContext.call(this,e,n),this.parser=t,this.ruleIndex=p.RULE_parserRuleAtom,this}function C(t,e){return E.call(this,t),E.prototype.copyFrom.call(this,e),this}function A(t,e){return E.call(this,t),E.prototype.copyFrom.call(this,e),this}function b(t,e){return E.call(this,t),E.prototype.copyFrom.call(this,e),this}function k(t,e){return E.call(this,t),E.prototype.copyFrom.call(this,e),this}function R(t,e,n){return void 0===e&&(e=null),void 0!==n&&null!==n||(n=-1),r.ParserRuleContext.call(this,e,n),this.parser=t,this.ruleIndex=p.RULE_lexerRuleCollection,this}function L(t,e,n){return void 0===e&&(e=null),void 0!==n&&null!==n||(n=-1),r.ParserRuleContext.call(this,e,n),this.parser=t,this.ruleIndex=p.RULE_meaningfulSplit,this}function I(t,e,n){return void 0===e&&(e=null),void 0!==n&&null!==n||(n=-1),r.ParserRuleContext.call(this,e,n),this.parser=t,this.ruleIndex=p.RULE_lexerRule,this}function N(t,e){return I.call(this,t),I.prototype.copyFrom.call(this,e),this}function O(t,e){return I.call(this,t),I.prototype.copyFrom.call(this,e),this}function P(t,e){return I.call(this,t),I.prototype.copyFrom.call(this,e),this}function w(t,e,n){return void 0===e&&(e=null),void 0!==n&&null!==n||(n=-1),r.ParserRuleContext.call(this,e,n),this.parser=t,this.ruleIndex=p.RULE_strings,this}function F(t,e,n){return void 0===e&&(e=null),void 0!==n&&null!==n||(n=-1),r.ParserRuleContext.call(this,e,n),this.parser=t,this.ruleIndex=p.RULE_lexerRuleExpr,this}p.prototype=Object.create(r.Parser.prototype),p.prototype.constructor=p,Object.defineProperty(p.prototype,"atn",{get:function(){return s}}),p.EOF=r.Token.EOF,p.T__0=1,p.T__1=2,p.T__2=3,p.T__3=4,p.T__4=5,p.T__5=6,p.T__6=7,p.T__7=8,p.T__8=9,p.T__9=10,p.T__10=11,p.T__11=12,p.T__12=13,p.T__13=14,p.Brackets=15,p.LexerIdentifier=16,p.ParserIdentifier=17,p.String=18,p.LabelForParserRule=19,p.Newline=20,p.WhiteSpace=21,p.BlockComment=22,p.FragmentComment=23,p.LineComment=24,p.ArrowComment=25,p.RULE_grammarFile=0,p.RULE_grammerDecl=1,p.RULE_statExprSplit=2,p.RULE_statementRule=3,p.RULE_expressionRule=4,p.RULE_arithmeticRuleCollection=5,p.RULE_parserRuleAtom=6,p.RULE_lexerRuleCollection=7,p.RULE_meaningfulSplit=8,p.RULE_lexerRule=9,p.RULE_strings=10,p.RULE_lexerRuleExpr=11,f.prototype=Object.create(r.ParserRuleContext.prototype),f.prototype.constructor=f,f.prototype.grammerDecl=function(){return this.getTypedRuleContext(d,0)},f.prototype.statExprSplit=function(){return this.getTypedRuleContext(y,0)},f.prototype.lexerRuleCollection=function(t){return void 0===t&&(t=null),null===t?this.getTypedRuleContexts(R):this.getTypedRuleContext(R,t)},f.prototype.meaningfulSplit=function(){return this.getTypedRuleContext(L,0)},f.prototype.statementRule=function(t){return void 0===t&&(t=null),null===t?this.getTypedRuleContexts(g):this.getTypedRuleContext(g,t)},f.prototype.expressionRule=function(t){return void 0===t&&(t=null),null===t?this.getTypedRuleContexts(m):this.getTypedRuleContext(m,t)},f.prototype.accept=function(t){return t instanceof i?t.visitGrammarFile(this):t.visitChildren(this)},p.GrammarFileContext=f,p.prototype.grammarFile=function(){var t=new f(this,this._ctx,this.state);this.enterRule(t,0,p.RULE_grammarFile);try{this.enterOuterAlt(t,1),this.state=24,this.grammerDecl(),this.state=28,this._errHandler.sync(this);for(var e=this._interp.adaptivePredict(this._input,0,this._ctx);1!=e&&e!=r.atn.ATN.INVALID_ALT_NUMBER;)2===e&&(this.state=25,this.statementRule()),this.state=30,this._errHandler.sync(this),e=this._interp.adaptivePredict(this._input,0,this._ctx);this.state=31,this.statExprSplit(),this.state=35,this._errHandler.sync(this);for(e=this._interp.adaptivePredict(this._input,1,this._ctx);1!=e&&e!=r.atn.ATN.INVALID_ALT_NUMBER;)2===e&&(this.state=32,this.expressionRule()),this.state=37,this._errHandler.sync(this),e=this._interp.adaptivePredict(this._input,1,this._ctx);this.state=38,this.lexerRuleCollection(),this.state=39,this.meaningfulSplit(),this.state=40,this.lexerRuleCollection()}catch(e){if(!(e instanceof r.error.RecognitionException))throw e;t.exception=e,this._errHandler.reportError(this,e),this._errHandler.recover(this,e)}finally{this.exitRule()}return t},d.prototype=Object.create(r.ParserRuleContext.prototype),d.prototype.constructor=d,d.prototype.LexerIdentifier=function(){return this.getToken(p.LexerIdentifier,0)},d.prototype.accept=function(t){return t instanceof i?t.visitGrammerDecl(this):t.visitChildren(this)},p.GrammerDeclContext=d,p.prototype.grammerDecl=function(){var t=new d(this,this._ctx,this.state);this.enterRule(t,2,p.RULE_grammerDecl);try{this.enterOuterAlt(t,1),this.state=42,this.match(p.T__0),this.state=43,this.match(p.LexerIdentifier),this.state=44,this.match(p.T__1)}catch(e){if(!(e instanceof r.error.RecognitionException))throw e;t.exception=e,this._errHandler.reportError(this,e),this._errHandler.recover(this,e)}finally{this.exitRule()}return t},y.prototype=Object.create(r.ParserRuleContext.prototype),y.prototype.constructor=y,y.prototype.accept=function(t){return t instanceof i?t.visitStatExprSplit(this):t.visitChildren(this)},p.StatExprSplitContext=y,p.prototype.statExprSplit=function(){var t=new y(this,this._ctx,this.state);this.enterRule(t,4,p.RULE_statExprSplit);try{this.enterOuterAlt(t,1),this.state=46,this.match(p.T__2)}catch(e){if(!(e instanceof r.error.RecognitionException))throw e;t.exception=e,this._errHandler.reportError(this,e),this._errHandler.recover(this,e)}finally{this.exitRule()}return t},g.prototype=Object.create(r.ParserRuleContext.prototype),g.prototype.constructor=g,g.prototype.copyFrom=function(t){r.ParserRuleContext.prototype.copyFrom.call(this,t)},v.prototype=Object.create(g.prototype),v.prototype.constructor=v,p.StatValueContext=v,v.prototype.ParserIdentifier=function(){return this.getToken(p.ParserIdentifier,0)},v.prototype.parserRuleAtom=function(t){return void 0===t&&(t=null),null===t?this.getTypedRuleContexts(E):this.getTypedRuleContext(E,t)},v.prototype.accept=function(t){return t instanceof i?t.visitStatValue(this):t.visitChildren(this)},x.prototype=Object.create(g.prototype),x.prototype.constructor=x,p.StatListContext=x,x.prototype.ParserIdentifier=function(t){return void 0===t&&(t=null),null===t?this.getTokens(p.ParserIdentifier):this.getToken(p.ParserIdentifier,t)},x.prototype.accept=function(t){return t instanceof i?t.visitStatList(this):t.visitChildren(this)},p.StatementRuleContext=g,p.prototype.statementRule=function(){var t=new g(this,this._ctx,this.state);this.enterRule(t,6,p.RULE_statementRule);var e=0;try{switch(this.state=67,this._errHandler.sync(this),this._interp.adaptivePredict(this._input,4,this._ctx)){case 1:t=new x(this,t),this.enterOuterAlt(t,1),this.state=48,this.match(p.ParserIdentifier),this.state=49,this.match(p.T__3),this.state=50,this.match(p.ParserIdentifier),this.state=53,this._errHandler.sync(this),e=this._input.LA(1);do{this.state=51,this.match(p.T__4),this.state=52,this.match(p.ParserIdentifier),this.state=55,this._errHandler.sync(this),e=this._input.LA(1)}while(e===p.T__4);this.state=57,this.match(p.T__1);break;case 2:for(t=new v(this,t),this.enterOuterAlt(t,2),this.state=58,this.match(p.ParserIdentifier),this.state=59,this.match(p.T__3),this.state=63,this._errHandler.sync(this),e=this._input.LA(1);0==(-32&e)&&0!=(1<1)for(var i,o=0;i=t[1][o];o++)e[i]&&this.error("语句 "+i+" 同时在两个语句集合 "+e[i]+" 和 "+t[0]+" 中出现了"),e[i]=t[0],n(this.statementRules,i).length>1&&this.error(t[0]+" 下的子规则 "+i+' 包含了"|"');var s;for(r=0;s=this.expressionRules[r];r++)s[1].length>1&&"expression"!==s[0]&&this.error("表达式 "+s[0]+' 包含了"|"')},SymbolVisitor.prototype.visitGrammarFile=function(t){return this.visit(t.grammerDecl()),this.visit(t.statementRule()),this.visit(t.expressionRule()),this.visit(t.lexerRuleCollection(0)),this},SymbolVisitor.prototype.visitGrammerDecl=function(t){this.grammerName=t.children[1].getText()},SymbolVisitor.prototype.visitStatList=function(t){for(var e,n=t.ParserIdentifier(),r=0;e=n[r];r++)n[r]=e.getText();var i=n.shift();this.statementRules.push([i,n])},SymbolVisitor.prototype.visitStatValue=function(t){var e=t.ParserIdentifier(0).getText();this.statementRules.push([e,[e]])},SymbolVisitor.prototype.visitExprExpression=function(t){var e=[];this.expression_arithmetic_num=t.arithmeticRuleCollection().length;for(var n=0;n1){this.notEntry[t[e]]=!0;for(var n,r=0;n=o.check[r];r++){var i=this.getRule("statement",n);i.blockjs.nextStatement=o.check,this.setRule("statement",n,i),this.notEntry[n]=!0}}for(e=0;o=this.statementRules[t[e]];e++)this.notEntry[t[e]]||(this.notEntry[t[e]]=!1,delete o.blockjs.previousStatement,delete o.blockjs.nextStatement,delete o.blockjs.inputsInline,o.blockjs.colour=this.entryColor);var o,s=[],a=[];for(e=0;o=this.statementRules[t[e]];e++)if(o.check.length>1)a.push([t[e],o]);else{s.push(o),o.type="statement";var l=[],u="",c=function(t){t>0&&(u+=Array(2*t+1).join(" ")),t<0&&(u=u.slice(0,2*t))},h="Blockly."+this.generLanguage+".";l.push(u+"function(block) {\n"),c(1);for(r=0;y=o.blockobj.args[r];r++){var p=this.varPrefix+o.blockobj.vars[r];if(y.id)"value"===y.blockType?(l.push(u+"var "+p+" = "+h+"valueToCode(block, '"),l.push(p+"', \n "+u+h+this.recieveOrder+")")):"statement"===y.blockType?(l.push(u+"var "+p+" = "+h+"statementToCode(block, '"),l.push(p+"')")):(l.push(u+"var "+p+" = block.getFieldValue('"),l.push(p+"')")),"field_checkbox"===y.data.type&&l.push(" === 'TRUE'"),l.push(";\n"),y.multi,{field_checkbox:!0,field_dropdown:!0,field_number:!0,field_colour:!0,field_angle:!0,field_image:!0}[y.data.type]||y.omitted||(l.push(u+"if ("+p+"==='') {\n"),c(1),l.push(u+"throw new OmitedError(block,'"+p+"','"),l.push(t[e]+"');\n"),c(-1),l.push(u+"}\n")),"field"===y.blockType&&(l.push(u+p+" = "+this.grammerName+"Functions.pre('"),l.push(y.id+"')("+p+");\n"))}o.blockobj.inject.generFunc?(o.blockobj.inject.override&&(c(-9999),(l=[]).push(u+"function(block) {\n"),c(1)),l.push(u+o.blockobj.inject.generFunc.split("\n").join("\n"+u)),l.push("\n")):(l.push(u+"var code = '1111111111;\\n';\n"),l.push(u+"return code;\n")),c(-1),l.push(u+"}"),o.generFunc=l.join("")}t=Object.keys(this.expressionRules);var f;for(e=0;f=this.expressionRules[t[e]];e++)if(f.check.length>1)a.push([t[e],f]);else{s.push(f),f.type="value";l=[],u="",c=function(t){t>0&&(u+=Array(2*t+1).join(" ")),t<0&&(u=u.slice(0,2*t))},h="Blockly."+this.generLanguage+".";l.push(u+"function(block) {\n"),c(1);for(r=0;y=f.blockobj.args[r];r++){p=this.varPrefix+f.blockobj.vars[r];if(y.id)"value"===y.blockType?(l.push(u+"var "+p+" = "+h+"valueToCode(block, '"),l.push(p+"', \n "+u+h+this.recieveOrder+")")):"statement"===y.blockType?(l.push(u+"var "+p+" = "+h+"statementToCode(block, '"),l.push(p+"')")):(l.push(u+"var "+p+" = block.getFieldValue('"),l.push(p+"')")),"field_checkbox"===y.data.type&&l.push(" === 'TRUE'"),l.push(";\n"),y.multi,{field_checkbox:!0,field_dropdown:!0,field_number:!0,field_colour:!0,field_angle:!0,field_image:!0}[y.data.type]||y.omitted||(l.push(u+"if ("+p+"==='') {\n"),c(1),l.push(u+"throw new OmitedError(block,'"+p+"','"),l.push(t[e]+"');\n"),c(-1),l.push(u+"}\n")),"field"===y.blockType&&(l.push(u+p+" = "+this.grammerName+"Functions.pre('"),l.push(y.id+"')("+p+");\n"))}f.blockobj.inject.generFunc?(f.blockobj.inject.override&&(c(-9999),(l=[]).push(u+"function(block) {\n"),c(1)),l.push(u+f.blockobj.inject.generFunc.split("\n").join("\n"+u)),l.push("\n")):(l.push(u+"var code = 0000000000;\n"),l.push(u+"return [code, "+h+this.sendOrder+"];\n")),c(-1),l.push(u+"}"),f.generFunc=l.join("")}var d;for(e=0;d=s[e];e++){d.args=[],d.argsType=[],d.fieldDefault=[];var y;for(r=0;y=d.blockobj.args[r];r++)y.id&&(d.args.push(d.blockobj.vars[r]),d.argsType.push(y.blockType),d.fieldDefault.push(d.blockobj.fieldDefault[r]));l=[],u="",c=function(t){t>0&&(u+=Array(2*t+1).join(" ")),t<0&&(u=u.slice(0,2*t))};var g=this.grammerName,v=d.check[0];l.push(u+"function (inputs,isShadow,comment) {\n"),c(1),l.push(u+"return "+g+"Functions.xmlText('"),l.push(v+"',inputs,isShadow,comment);\n"),c(-1),l.push(u+"}"),d.xmlText=l.join("")}this.temp_xml=s,this.temp_collection=a},EvalVisitor.prototype.generBlocks=function(){var t=[],e="",n=function(t){t>0&&(e+=Array(2*t+1).join(" ")),t<0&&(e=e.slice(0,2*t))};temp_xml=this.temp_xml,delete this.temp_xml,temp_collection=this.temp_collection,delete this.temp_collection,t.push(e+this.grammerName+"Blocks = {\n"),n(1);for(var r,i=0;r=temp_collection[i];i++)t.push(e+'"'+r[0]+'": '),t.push(JSON.stringify(r[1].check,null,2).split("\n").join("\n"+e)),t.push(",\n");function o(t,e,n){var r=e.blockjs,i=JSON.stringify(r).split("\n").join("\n"+n),o={};r=JSON.parse(i);for(var s,a=0;s=e.blockobj.args[a];a++)if(s.id){var l=t.getRule(s.blockType,s.id);l&&1!==l.check.length&&(r.args0[a].check="1_fry2_3_inrgv"+s.id,o['"1_fry2_3_inrgv'+s.id+'"']=t.grammerName+"Blocks."+s.id)}if(r.nextStatement)for(var u,c=0;u=temp_collection[c];c++)if(-1!==u[1].check.indexOf(r.type)){r.nextStatement="1_fry2_3_inrgv"+u[0],o['"1_fry2_3_inrgv'+u[0]+'"']=t.grammerName+"Blocks."+u[0];break}for(var h in i=JSON.stringify(r,null,2).split("\n").join("\n"+n),o)i=i.split(h).join(o[h]);return i}t.pop(),t.push("\n"),n(-1),t.push(e+"}\n"),t.push(e+this.grammerName+"Blocks = Object.assign("),t.push(this.grammerName+"Blocks,{\n"),n(1);var s;for(i=0;s=temp_xml[i];i++)t.push(e+'"'+s.check[0]+'": {\n'),n(1),t.push(e+'"type": "'+s.type+'",\n'),t.push(e+'"json": '),t.push(o(this,s,e)),t.push(",\n"),t.push(e+'"generFunc": '),t.push(s.generFunc.split("\n").join("\n"+e)),t.push(",\n"),t.push(e+'"args": '),t.push(JSON.stringify(s.args,null,2).split("\n").join("\n"+e)),t.push(",\n"),t.push(e+'"argsType": '),t.push(JSON.stringify(s.argsType,null,0)),t.push(",\n"),t.push(e+'"fieldDefault": '),t.push(JSON.stringify(s.fieldDefault,null,0)),t.push(",\n"),t.push(e+'"xmlText": '),t.push(s.xmlText.split("\n").join("\n"+e)),t.push("\n"),n(-1),t.push(e+"},\n");t.pop(),t.push(e+"}\n"),n(-1),t.push(e+"});\n"),this.blocks=t.join("")},EvalVisitor.prototype.SpeicalLexerRule=function(t){var e={};return"Bool"===t?(e={type:"field_checkbox",checked:!0},this.setRule("lexer",t,e),!0):"Int"===t?(e={type:"field_number",value:0,min:0,precision:1},this.setRule("lexer",t,e),!0):"Number"===t?(e={type:"field_number",value:0},this.setRule("lexer",t,e),!0):"Colour"===t?(e={type:"field_colour",colour:"#ffffff"},this.setRule("lexer",t,e),!0):"Angle"===t?(e={type:"field_angle",angle:90},this.setRule("lexer",t,e),!0):"BGNL"===t&&(e={type:"input_dummy"},this.setRule("lexer",t,e),!0)},EvalVisitor.prototype.visitGrammarFile=function(t){this.visit(t.lexerRuleCollection(0)),this.visit(t.statementRule()),this.expression_arithmetic_num=0,this.visit(t.expressionRule()),this.assemble()},EvalVisitor.prototype.visitStrings=function(t){for(var e,n=t.String(),r=0;e=n[r];r++)n[r]=this.escapeString(e.getText());return n.join(" ")},EvalVisitor.prototype.visitLexerRuleStrings=function(t){var e=t.LexerIdentifier(0).getText();if(!this.SpeicalLexerRule(e)){var n=this.visit(t.strings(0));this.setRule("lexer",e,n)}},EvalVisitor.prototype.visitLexerRuleList=function(ctx){var lexerId=ctx.LexerIdentifier(0).getText();if(!this.SpeicalLexerRule(lexerId))if("_List"===lexerId.slice(-5)||"_Img"===lexerId.slice(-4)){var strings=ctx.strings(),values=this.matchInject(lexerId);values=values?eval(values):[];for(var ii=0,value;value=strings[ii];ii++){var string_=this.visit(value);strings[ii]=[string_,null==values[ii]?string_:values[ii]]}if("_List"===lexerId.slice(-5))var lexervalue={type:"field_dropdown",options:strings};else var lexervalue={type:"field_image",src:strings[0][0],width:strings[1]&&strings[1][0]||0,height:strings[2]&&strings[2][0]||0,alt:"*"};this.setRule("lexer",lexerId,lexervalue)}else this.visitLexerRuleComplex(ctx)},EvalVisitor.prototype.visitLexerRuleComplex=function(t){var e=t.LexerIdentifier(0).getText();if(!this.SpeicalLexerRule(e)){var n={type:"field_input",text:e+"_default"};this.setRule("lexer",e,n)}},EvalVisitor.prototype.visitStatValue=function(t){this.status={name:t.ParserIdentifier(0).getText(),type:"statement",message:[],args:[]},this.visitChildren(t);var e=this.status;delete this.status,this.initAssemble(e)},BlocklyGrammerVisitor.prototype.visitArithmeticRuleCollection=function(t){this.status={name:"expression",type:"value",message:["%1"],args:[{id:"expression",blockType:"value",omitted:!1,data:{type:"input_value"}}]},this.visitChildren(t),this.status.name="expression_arithmetic_"+this.expression_arithmetic_num,this.expression_arithmetic_num++;var e=this.status;delete this.status,this.initAssemble(e)},BlocklyGrammerVisitor.prototype.visitExprValue=function(t){this.status={name:t.ParserIdentifier(0).getText(),type:"value",message:[],args:[]},this.visitChildren(t);var e=this.status;delete this.status,this.initAssemble(e)},EvalVisitor.prototype.visitParserAtomExpr=function(t){var e={id:"expression",blockType:"value",omitted:t.children.length>1,data:{type:"input_value"}};this.status.args.push(e),this.status.message.push("%"+this.status.args.length)},EvalVisitor.prototype.visitParserAtomParserId=function(t){var e=t.children[0].getText(),n=t.children.length>1&&t.children[1].getText()||"",r=this.getRule("value",e)?"value":"statement",i={id:e,blockType:r,omitted:"?"===n||"*"===n,multi:"+"===n||"*"===n,data:{type:"input_"+r}};"value"===r&&i.multi&&this.error(this.status.name+" 下出现了复数组合的表达式 "+e+n),this.status.args.push(i),this.status.message.push("%"+this.status.args.length)},EvalVisitor.prototype.visitParserAtomLexerId=function(t){var e=t.children[0].getText(),n=this.getRule("lexer",e);if(n){var r={id:e,blockType:"field",omitted:t.children.length>1,data:n};"BGNL"===e&&(r={data:n}),"string"!=typeof n?(this.status.args.push(r),this.status.message.push("%"+this.status.args.length)):this.status.message.push(n)}},EvalVisitor.prototype.visitParserAtomStr=function(t){var e=this.escapeString(t.String().getText());this.status.message.push(e)},exports.SymbolVisitor=SymbolVisitor,exports.EvalVisitor=EvalVisitor},function(t,e){e.OmitedError=function(){return"//生成代码中,当一个不允许省略的值或块省略时,会抛出这个错误\nfunction OmitedError(block, var_, rule, fileName, lineNumber) {\n var message = 'no omitted '+var_+' at '+rule;\n var instance = new Error(message, fileName, lineNumber);\n instance.block = block;\n instance.varName = var_;\n instance.blockName = rule;\n instance.name = 'OmitedError';\n Object.setPrototypeOf(instance, Object.getPrototypeOf(this));\n if (Error.captureStackTrace) {\n Error.captureStackTrace(instance, OmitedError);\n }\n return instance;\n}\n\nOmitedError.prototype = Object.create(Error.prototype);\nOmitedError.prototype.constructor = OmitedError;\n//处理此错误的omitedcheckUpdateFunction定义在下面"},e.Functions_pre=function(t){return`${t}Functions.Int_pre = function(intstr) {\n return parseInt(intstr);\n}\n\n${t}Functions.Number_pre = function(intstr) {\n return parseFloat(intstr);\n}\n\n//返回各LexerRule文本域的预处理函数,方便用来统一转义等等\n${t}Functions.pre = function(LexerId) {\n if (${t}Functions.hasOwnProperty(LexerId+'_pre')) {\n return ${t}Functions[LexerId+'_pre'];\n }\n return function(obj){return obj}\n}`},e.Functions_xmlText=function(t){return`//构造这个方法是为了能够不借助workspace,从语法树直接构造图块结构\n//inputs的第i个元素是第i个args的xmlText,null或undefined表示空\n//inputs的第rule.args.length个元素是其下一个语句的xmlText\n${t}Functions.xmlText = function (ruleName,inputs,isShadow,comment) {\n var rule = ${t}Blocks[ruleName];\n var blocktext = isShadow?'shadow':'block';\n var xmlText = [];\n xmlText.push('<'+blocktext+' type="'+ruleName+'">');\n if(!inputs)inputs=[];\n for (var ii=0,inputType;inputType=rule.argsType[ii];ii++) {\n var input = inputs[ii];\n var _input = '';\n var noinput = (input===null || input===undefined);\n if(noinput && inputType==='field') continue;\n if(noinput) input = '';\n if(inputType!=='field') {\n var subList = false;\n var subrulename = rule.args[ii];\n subrulename=subrulename.split('_').slice(0,-1).join('_');\n var subrule = ${t}Blocks[subrulename];\n if (subrule instanceof Array) {\n subrulename=subrule[subrule.length-1];\n subrule = ${t}Blocks[subrulename];\n subList = true;\n }\n _input = subrule.xmlText([],true);\n if(noinput && !subList && !isShadow) {\n //无输入的默认行为是: 如果语句块的备选方块只有一个,直接代入方块\n input = subrule.xmlText();\n }\n }\n xmlText.push('<'+inputType+' name="'+rule.args[ii]+'">');\n xmlText.push(_input+input);\n xmlText.push('');\n }\n if(comment){\n xmlText.push('/g,'] ] >'));\n xmlText.push(']]>');\n }\n var next = inputs[rule.args.length];\n if (next) {//next\n xmlText.push('');\n xmlText.push(next);\n xmlText.push('');\n }\n xmlText.push('');\n return xmlText.join('');\n}`},e.Functions_blocksIniter=function(t,e){return`//把各方块的信息注册到Blockly中\n${t}Functions.blocksIniter = function(){\n var blocksobj = ${t}Blocks;\n for(var key in blocksobj) {\n var value = blocksobj[key];\n if(value instanceof Array)continue;\n (function(key,value){\n Blockly.Blocks[key] = {\n init: function() {this.jsonInit(value.json);}\n }\n })(key,value);\n Blockly.${e}[key] = value.generFunc;\n }\n}`},e.mainFileTPL=function(t,e,n,r,i,o,s,a){return[`\n\n\n${t} --antlr-blockly`,'\n + + diff --git a/editor.html b/editor.html index c5dcf5b9..a03d70db 100644 --- a/editor.html +++ b/editor.html @@ -200,20 +200,6 @@ --> - @@ -221,14 +207,12 @@ - 开启中文名替换 + + 展开值块逻辑运算 @@ -240,6 +224,10 @@ +
@@ -343,7 +331,7 @@ 线 矩形 - tileset贴图 + tileset平铺 填充 @@ -386,7 +374,7 @@ - +
@@ -610,6 +598,8 @@ + + diff --git a/extensions/dynamicMapEditor.js b/extensions/dynamicMapEditor.js index 83690a51..eff1ec7c 100644 --- a/extensions/dynamicMapEditor.js +++ b/extensions/dynamicMapEditor.js @@ -8,7 +8,7 @@ function dynamicMapEditor() { // 所有显示的ID this.displayIds = [ 'none', 'yellowWall', 'blueWall', 'whiteWall', 'yellowDoor', 'blueDoor', 'redDoor', 'star', 'lava', 'lavaNet', - 'yellowKey', 'blueKey', 'redKey', 'redJewel', 'blueJewel', 'greenJewel', 'yellowJewel', + 'yellowKey', 'blueKey', 'redKey', 'redGem', 'blueGem', 'greenGem', 'yellowGem', 'redPotion', 'bluePotion', 'yellowPotion', 'greenPotion', 'pickaxe', 'bomb', 'centerFly', 'cls:autotile', 'cls:enemys', 'cls:enemy48' ]; diff --git a/libs/actions.js b/libs/actions.js index 0a9ed824..391ab9f0 100644 --- a/libs/actions.js +++ b/libs/actions.js @@ -1919,7 +1919,7 @@ actions.prototype._clickSwitchs = function (x, y) { var topIndex = this.HSIZE - parseInt((choices.length - 1) / 2) + (core.status.event.ui.offset || 0); var selection = y - topIndex; if (x < this.CHOICES_LEFT || x > this.CHOICES_RIGHT) { - if (selection != 2 && selection != 3 && selection != 4) return; + if (selection != 1 && selection != 2 && selection != 3 && selection != 4) return; } var width = choices[selection].width; var leftPos = (core.__PIXELS__ - width) / 2, rightPos = (core.__PIXELS__ + width) / 2; @@ -1928,32 +1928,32 @@ actions.prototype._clickSwitchs = function (x, y) { core.status.event.selection = selection; switch (selection) { case 0: - return this._clickSwitchs_bgm(); + return this._clickSwitchs_bgmSound(); case 1: - return this._clickSwitchs_sound(); - case 2: if (x == leftGrid || x == leftGrid + 1) return this._clickSwitchs_userVolume(-1); if (x == rightGrid || x == rightGrid + 1) return this._clickSwitchs_userVolume(1); return; - case 3: + case 2: if (x == leftGrid || x == leftGrid + 1) return this._clickSwitchs_moveSpeed(-10); if (x == rightGrid || x == rightGrid + 1) return this._clickSwitchs_moveSpeed(10); return; - case 4: + case 3: if (x == leftGrid || x == leftGrid + 1) return this._clickSwitchs_floorChangeTime(-100); if (x == rightGrid || x == rightGrid + 1) return this._clickSwitchs_floorChangeTime(100); return; + case 4: + if (x == leftGrid || x == leftGrid + 1) return this._clickSwitchs_setSize(-1); + if (x == rightGrid || x == rightGrid + 1) return this._clickSwitchs_setSize(1); + return; case 5: return this._clickSwitchs_displayEnemyDamage(); case 6: - return this._clickSwitchs_displayCritical(); + return this._clickSwitchs_displayCriticalExtra(); case 7: - return this._clickSwitchs_displayExtraDamage(); - case 8: return this._clickSwitchs_potionNoRouting(); - case 9: + case 8: return this._clickSwitchs_clickMove(); - case 10: + case 9: core.status.event.selection = 0; core.ui.drawSettings(); break; @@ -1961,13 +1961,23 @@ actions.prototype._clickSwitchs = function (x, y) { } } -actions.prototype._clickSwitchs_bgm = function () { - core.triggerBgm(); - core.ui.drawSwitchs(); -} - -actions.prototype._clickSwitchs_sound = function () { - core.musicStatus.soundStatus = !core.musicStatus.soundStatus; +actions.prototype._clickSwitchs_bgmSound = function () { + var bgm = core.musicStatus.bgmStatus; + var sound = core.musicStatus.soundStatus; + if (bgm && sound) { + sound = false; + } else if (bgm && !sound) { + bgm = false; + sound = true; + } else if (!bgm && sound) { + sound = false; + } else { + bgm = true; + sound = true; + } + if (bgm != core.musicStatus.bgmStatus) + core.triggerBgm(); + core.musicStatus.soundStatus = sound; core.setLocalStorage('soundStatus', core.musicStatus.soundStatus); core.ui.drawSwitchs(); } @@ -1995,6 +2005,17 @@ actions.prototype._clickSwitchs_floorChangeTime = function (delta) { core.ui.drawSwitchs(); } +actions.prototype._clickSwitchs_setSize = function (delta) { + var index = core.domStyle.availableScale.indexOf(core.domStyle.scale); + if (index < 0) return; + index += delta; + if (index < 0 || index >= core.domStyle.availableScale.length); + core.domStyle.scale = core.domStyle.availableScale[index]; + core.setLocalStorage('scale', core.domStyle.scale); + core.resize(); + core.ui.drawSwitchs(); +} + actions.prototype._clickSwitchs_displayEnemyDamage = function () { core.flags.displayEnemyDamage = !core.flags.displayEnemyDamage; core.updateDamage(); @@ -2002,16 +2023,26 @@ actions.prototype._clickSwitchs_displayEnemyDamage = function () { core.ui.drawSwitchs(); } -actions.prototype._clickSwitchs_displayCritical = function () { - core.flags.displayCritical = !core.flags.displayCritical; +actions.prototype._clickSwitchs_displayCriticalExtra = function () { + var critical = core.flags.displayCritical; + var extra = core.flags.displayExtraDamage; + if (critical && extra) { + extra = false; + } else if (critical && !extra) { + critical = false; + extra = true; + } else if (!critical && extra) { + critical = false; + extra = false; + } else { + critical = true; + extra = true; + } + + core.flags.displayCritical = critical; + core.flags.displayExtraDamage = extra; core.updateDamage(); core.setLocalStorage('critical', core.flags.displayCritical); - core.ui.drawSwitchs(); -} - -actions.prototype._clickSwitchs_displayExtraDamage = function () { - core.flags.displayExtraDamage = !core.flags.displayExtraDamage; - core.updateDamage(); core.setLocalStorage('extraDamage', core.flags.displayExtraDamage); core.ui.drawSwitchs(); } @@ -2037,15 +2068,17 @@ actions.prototype._keyUpSwitchs = function (keycode) { } if (keycode == 37) { switch (core.status.event.selection) { - case 2: return this._clickSwitchs_userVolume(-1); - case 3: return this._clickSwitchs_moveSpeed(-10); - case 4: this._clickSwitchs_floorChangeTime(-100); + case 1: return this._clickSwitchs_userVolume(-1); + case 2: return this._clickSwitchs_moveSpeed(-10); + case 3: return this._clickSwitchs_floorChangeTime(-100); + case 4: return this._clickSwitchs_setSize(-1); } } else if (keycode == 39) { switch (core.status.event.selection) { - case 2: return this._clickSwitchs_userVolume(1); - case 3: return this._clickSwitchs_moveSpeed(10); - case 4: this._clickSwitchs_floorChangeTime(100); + case 1: return this._clickSwitchs_userVolume(1); + case 2: return this._clickSwitchs_moveSpeed(10); + case 3: return this._clickSwitchs_floorChangeTime(100); + case 4: return this._clickSwitchs_setSize(1); } } this._selectChoices(core.status.event.ui.choices.length, keycode, this._clickSwitchs); diff --git a/libs/control.js b/libs/control.js index 40527187..3de2103f 100644 --- a/libs/control.js +++ b/libs/control.js @@ -146,6 +146,11 @@ control.prototype._animationFrame_globalAnimate = function (timestamp) { core.status.autotileAnimateObjs.blocks.forEach(function (block) { core.maps._drawAutotileAnimate(block, core.status.globalAnimateStatus); }); + + // Global hero animate + if ((core.status.hero || {}).animate && core.status.heroMoving == 0) { + core.drawHero('stop', null, core.status.globalAnimateStatus); + } } // Box animate core.drawBoxAnimate(); @@ -260,7 +265,7 @@ control.prototype._animationFrame_weather_fog = function () { var w = core.__PIXELS__, h = core.__PIXELS__; core.setAlpha('weather', 0.5); core.animateFrame.weather.nodes.forEach(function (p) { - ctx.drawImage(core.animateFrame.weather.fog, p.x - ox, p.y - oy, w, h); + core.drawImage(ctx, core.animateFrame.weather.fog, p.x - ox, p.y - oy, w, h); p.x += p.xs; p.y += p.ys; if (p.x > core.bigmap.width*32 - w/2) { @@ -768,7 +773,7 @@ control.prototype.tryMoveDirectly = function (destX, destY) { } ////// 绘制勇士 ////// -control.prototype.drawHero = function (status, offset) { +control.prototype.drawHero = function (status, offset, frame) { if (!core.isPlaying() || !core.status.floorId || core.status.gameOver) return; var x = core.getHeroLoc('x'), y = core.getHeroLoc('y'), direction = core.getHeroLoc('direction'); status = status || 'stop'; @@ -783,17 +788,65 @@ control.prototype.drawHero = function (status, offset) { core.status.heroCenter.py = 32 * y + offsetY + 32 - core.material.icons.hero.height / 2; if (!core.hasFlag('hideHero')) { - this._drawHero_getDrawObjs(direction, x, y, status, offset).forEach(function (block) { - core.drawImage('hero', block.img, block.heroIcon[block.status]*block.width, - block.heroIcon.loc * block.height, block.width, block.height, - block.posx+(32-block.width)/2, block.posy+32-block.height, block.width, block.height); - }); + this._drawHero_draw(direction, x, y, status, offset, frame); } + this._drawHero_updateViewport(); +} + +control.prototype._drawHero_updateViewport = function () { core.control.updateViewport(); core.setGameCanvasTranslate('hero', 0, 0); } +control.prototype._drawHero_draw = function (direction, x, y, status, offset, frame) { + this._drawHero_getDrawObjs(direction, x, y, status, offset).forEach(function (block) { + core.drawImage('hero', block.img, (block.heroIcon[block.status] + (frame || 0))%4*block.width, + block.heroIcon.loc * block.height, block.width, block.height, + block.posx+(32-block.width)/2, block.posy+32-block.height, block.width, block.height); + }); +} + +control.prototype.triggerHero = function (type, time, callback) { + if (type == null) { + type = core.hasFlag('hideHero') ? 'show' : 'hide'; + } + if ((core.hasFlag('hideHero') && type != 'show') || (!core.hasFlag('hideHero') && type != 'hide')) { + if (callback) callback(); + return; + } + if (type == 'show') core.removeFlag('hideHero'); + else core.setFlag('hideHero', true); + + time = time || 0; + if (time == 0) { + core.drawHero(); + if (callback) callback(); + return; + } + time /= Math.max(core.status.replay.speed, 1) + this._triggerHero_animate(type, 10 / time, callback); +} + +control.prototype._triggerHero_animate = function (type, delta, callback) { + var opacity = type != 'show' ? 1 : 0; + var animate = setInterval(function () { + opacity += type != 'show' ? -delta : delta; + core.clearMap('hero'); + core.setAlpha('hero', opacity); + core.control._drawHero_draw(core.getHeroLoc('direction'), core.getHeroLoc('x'), core.getHeroLoc('y'), 'stop', 0); + core.setAlpha('hero', 1); + if (opacity >= 1 || opacity <= 0) { + delete core.animateFrame.asyncId[animate]; + clearInterval(animate); + core.drawHero(); + if (callback) callback(); + } + }, 10); + + core.animateFrame.asyncId[animate] = true; +} + control.prototype._drawHero_getDrawObjs = function (direction, x, y, status, offset) { var heroIconArr = core.material.icons.hero, drawObjs = [], index = 0; drawObjs.push({ @@ -984,7 +1037,7 @@ control.prototype.checkBlock = function () { core.updateStatusBar(); } } - this._checkBlock_snipe(core.status.checkBlock.snipe[loc]); + this._checkBlock_repulse(core.status.checkBlock.repulse[loc]); this._checkBlock_ambush(core.status.checkBlock.ambush[loc]); } @@ -998,10 +1051,10 @@ control.prototype._checkBlock_disableQuickShop = function () { } ////// 阻击 ////// -control.prototype._checkBlock_snipe = function (snipe) { - if (!snipe || snipe.length == 0) return; +control.prototype._checkBlock_repulse = function (repulse) { + if (!repulse || repulse.length == 0) return; var actions = []; - snipe.forEach(function (t) { + repulse.forEach(function (t) { actions.push({"type": "move", "loc": [t[0],t[1]], "steps": [t[3]], "time": 250, "keep": true, "async": true}); }); actions.push({"type": "waitAsync"}); @@ -1047,6 +1100,7 @@ control.prototype.updateDamage = function (floorId, ctx) { control.prototype._updateDamage_damage = function (floorId, ctx) { core.setTextAlign(ctx, 'left'); + core.extractBlocks(floorId); core.status.maps[floorId].blocks.forEach(function (block) { var x = block.x, y = block.y; if (!block.disable && block.event.cls.indexOf('enemy') == 0 && block.event.displayDamage !== false) { @@ -1526,10 +1580,12 @@ control.prototype._replayAction_getNext = function (action) { control.prototype._replayAction_moveDirectly = function (action) { if (action.indexOf("move:")!=0) return false; // 忽略连续的瞬移事件 - while (core.status.replay.toReplay.length>0 && - core.status.replay.toReplay[0].indexOf('move:')==0) { - core.status.route.push(action); - action = core.status.replay.toReplay.shift(); + if (!core.hasFlag('poison')) { + while (core.status.replay.toReplay.length>0 && + core.status.replay.toReplay[0].indexOf('move:')==0) { + core.status.route.push(action); + action = core.status.replay.toReplay.shift(); + } } var pos=action.substring(5).split(":"); @@ -2008,12 +2064,17 @@ control.prototype.getRealStatusOrDefault = function (status, name) { ////// 设置某个属性的增幅值 ////// control.prototype.setBuff = function (name, value) { + // 仅保留三位有效buff值 + value = parseFloat(value.toFixed(3)); this.setFlag('__'+name+'_buff__', value); } ////// 加减某个属性的增幅值 ////// control.prototype.addBuff = function (name, value) { - this.setFlag('__'+name+'_buff__', this.getBuff(name) + value); + var buff = this.getBuff(name) + value; + // 仅保留三位有效buff值 + buff = parseFloat(buff.toFixed(3)); + this.setFlag('__'+name+'_buff__', buff); } ////// 获得某个属性的增幅值 ////// @@ -2467,72 +2528,14 @@ control.prototype.updateHeroIcon = function (name) { var ratio = Math.min(w / h, 1), width = 32 * ratio, left = 16 - width/2; var canvas = document.createElement("canvas"); - var context = canvas.getContext("2d"); + var ctx = canvas.getContext("2d"); canvas.width = 32; canvas.height = 32; - context.drawImage(image, 0, 0, w, h, left, 0, width, 32); + core.drawImage(ctx, image, 0, 0, w, h, left, 0, width, 32); core.statusBar.image.name.src = canvas.toDataURL("image/png"); } -control.prototype.updateGlobalAttribute = function (name) { - if (name == null) name = Object.keys(core.status.globalAttribute); - if (name instanceof Array) { - name.forEach(function (t) { - core.control.updateGlobalAttribute(t); - }); - return; - } - var attribute = core.status.globalAttribute || core.initStatus.globalAttribute; - if (attribute == null) return; - switch (name) { - case 'statusLeftBackground': - if (!core.domStyle.isVertical) { - core.dom.statusBar.style.background = attribute[name]; - } - break; - case 'statusTopBackground': - if (core.domStyle.isVertical) { - core.dom.statusBar.style.background = attribute[name]; - } - break; - case 'toolsBackground': - if (core.domStyle.isVertical) { - core.dom.toolBar.style.background = attribute[name]; - } - break; - case 'borderColor': - { - var border = '3px ' + attribute[name] + ' solid'; - core.dom.statusBar.style.borderTop = border; - core.dom.statusBar.style.borderLeft = border; - core.dom.statusBar.style.borderRight = core.domStyle.isVertical?border:''; - core.dom.statusBar.style.borderBottom = core.domStyle.isVertical?'':border; - core.dom.gameDraw.style.border = border; - core.dom.toolBar.style.borderLeft = border; - core.dom.toolBar.style.borderRight = core.domStyle.isVertical?border:''; - core.dom.toolBar.style.borderBottom = core.domStyle.isVertical?border:''; - break; - } - case 'statusBarColor': - { - var texts = core.dom.statusTexts; - for (var i=0;i= CANVAS_WIDTH + BAR_WIDTH || (clientWidth > clientHeight && clientHeight < CANVAS_WIDTH)) { + if (clientWidth - 3 * BORDER >= CANVAS_WIDTH + BAR_WIDTH || (clientWidth > clientHeight && clientHeight - 2 * BORDER < CANVAS_WIDTH)) { // 横屏 core.domStyle.isVertical = false; - core.domStyle.scale = Math.min(1, clientHeight / CANVAS_WIDTH); + + core.domStyle.availableScale = []; + [1, 1.25, 1.5, 1.75, 2].forEach(function (v) { + if (clientWidth - 3 * BORDER >= v*(CANVAS_WIDTH + BAR_WIDTH) && clientHeight - 2 * BORDER >= v * CANVAS_WIDTH) { + core.domStyle.availableScale.push(v); // 64x64 + } + }); + if (core.domStyle.availableScale.indexOf(core.domStyle.scale) < 0) { + core.domStyle.scale = Math.min(1, (clientHeight - 2 * BORDER) / CANVAS_WIDTH); + } } else { // 竖屏 core.domStyle.isVertical = true; - core.domStyle.scale = Math.min(1, clientWidth / CANVAS_WIDTH); + core.domStyle.scale = Math.min(1, (clientWidth - 2 * BORDER) / CANVAS_WIDTH); + core.domStyle.availableScale = []; } var statusDisplayArr = this._shouldDisplayStatus(), count = statusDisplayArr.length; @@ -2664,15 +2678,16 @@ control.prototype.resize = function() { clientWidth: clientWidth, clientHeight: clientHeight, CANVAS_WIDTH: CANVAS_WIDTH, + BORDER: BORDER, BAR_WIDTH: BAR_WIDTH, - outerSize: CANVAS_WIDTH * core.domStyle.scale, + outerSize: CANVAS_WIDTH * core.domStyle.scale + 2 * BORDER, globalAttribute: globalAttribute, - border: '3px ' + globalAttribute.borderColor + ' solid', + border: '3px ' + core.arrayToRGBA(globalAttribute.borderColor) + ' solid', statusDisplayArr: statusDisplayArr, count: count, col: col, - statusBarHeightInVertical: core.domStyle.isVertical ? (32 * col + 6) * core.domStyle.scale + 6 : 0, - toolbarHeightInVertical: core.domStyle.isVertical ? 44 * core.domStyle.scale + 6 : 0, + statusBarHeightInVertical: core.domStyle.isVertical ? (32 * col + 6) * core.domStyle.scale + 2 * BORDER : 0, + toolbarHeightInVertical: core.domStyle.isVertical ? 44 * core.domStyle.scale + 2 * BORDER : 0, is15x15: core.__SIZE__ == 15 }; @@ -2689,7 +2704,7 @@ control.prototype._resize_gameGroup = function (obj) { totalHeight = obj.outerSize + obj.statusBarHeightInVertical + obj.toolbarHeightInVertical } else { - totalWidth = (obj.CANVAS_WIDTH + obj.BAR_WIDTH) * core.domStyle.scale; + totalWidth = obj.outerSize + obj.BAR_WIDTH * core.domStyle.scale + obj.BORDER; totalHeight = obj.outerSize; } gameGroup.style.width = totalWidth + "px"; @@ -2698,10 +2713,9 @@ control.prototype._resize_gameGroup = function (obj) { gameGroup.style.top = (obj.clientHeight - totalHeight) / 2 + "px"; // floorMsgGroup var floorMsgGroup = core.dom.floorMsgGroup; - floorMsgGroup.style.width = obj.outerSize - 6 + "px"; - floorMsgGroup.style.height = totalHeight - 6 + "px"; - floorMsgGroup.style.background = obj.globalAttribute.floorChangingBackground; - floorMsgGroup.style.color = obj.globalAttribute.floorChangingTextColor; + floorMsgGroup.style = obj.globalAttribute.floorChangingStyle; + floorMsgGroup.style.width = obj.outerSize - 2 * obj.BORDER + "px"; + floorMsgGroup.style.height = totalHeight - 2 * obj.BORDER + "px"; // musicBtn if (core.domStyle.isVertical || core.domStyle.scale < 1) { core.dom.musicBtn.style.right = core.dom.musicBtn.style.bottom = "3px"; @@ -2713,7 +2727,7 @@ control.prototype._resize_gameGroup = function (obj) { } control.prototype._resize_canvas = function (obj) { - var innerSize = (obj.outerSize - 6) + "px"; + var innerSize = (obj.CANVAS_WIDTH * core.domStyle.scale) + "px"; for (var i = 0; i < core.dom.gameCanvas.length; ++i) core.dom.gameCanvas[i].style.width = core.dom.gameCanvas[i].style.height = innerSize; core.dom.gif.style.width = core.dom.gif.style.height = innerSize; @@ -2738,8 +2752,6 @@ control.prototype._resize_canvas = function (obj) { // resize next main.dom.next.style.width = main.dom.next.style.height = 5 * core.domStyle.scale + "px"; main.dom.next.style.borderBottomWidth = main.dom.next.style.borderRightWidth = 4 * core.domStyle.scale + "px"; - - } control.prototype._resize_statusBar = function (obj) { @@ -2752,7 +2764,7 @@ control.prototype._resize_statusBar = function (obj) { statusBar.style.fontSize = 16 * core.domStyle.scale + "px"; } else { - statusBar.style.width = obj.BAR_WIDTH * core.domStyle.scale + "px"; + statusBar.style.width = (obj.BAR_WIDTH * core.domStyle.scale + obj.BORDER) + "px"; statusBar.style.height = obj.outerSize + "px"; statusBar.style.background = obj.globalAttribute.statusLeftBackground; // --- 计算文字大小 @@ -2764,22 +2776,22 @@ control.prototype._resize_statusBar = function (obj) { statusBar.style.borderBottom = core.domStyle.isVertical ? '' : obj.border; // 自绘状态栏 if (core.domStyle.isVertical) { - core.dom.statusCanvas.style.width = obj.outerSize - 6 + "px"; - core.dom.statusCanvas.width = core.__PIXELS__; + core.dom.statusCanvas.style.width = obj.CANVAS_WIDTH + "px"; + core.dom.statusCanvas.width = obj.CANVAS_WIDTH; core.dom.statusCanvas.style.height = obj.statusBarHeightInVertical - 3 + "px"; core.dom.statusCanvas.height = obj.col * 32 + 9; } else { - core.dom.statusCanvas.style.width = obj.BAR_WIDTH * core.domStyle.scale - 3 + "px"; - core.dom.statusCanvas.width = obj.BAR_WIDTH - 3; - core.dom.statusCanvas.style.height = obj.outerSize - 6 + "px"; - core.dom.statusCanvas.height = core.__PIXELS__; + core.dom.statusCanvas.style.width = obj.BAR_WIDTH * core.domStyle.scale + "px"; + core.dom.statusCanvas.width = obj.BAR_WIDTH; + core.dom.statusCanvas.style.height = obj.outerSize - 2 * obj.BORDER + "px"; + core.dom.statusCanvas.height = obj.CANVAS_WIDTH; } core.dom.statusCanvas.style.display = core.flags.statusCanvas ? "block" : "none"; } control.prototype._resize_status = function (obj) { - var statusHeight = (core.domStyle.isVertical ? 1 : (core.__HALF_SIZE__ + 3) / obj.count) * 32 * core.domStyle.scale * 0.8; + var statusHeight = (core.domStyle.isVertical ? 1 : (core.__HALF_SIZE__ + obj.BORDER) / obj.count) * 32 * core.domStyle.scale * 0.8; // status for (var i = 0; i < core.dom.status.length; ++i) { var id = core.dom.status[i].id, style = core.dom.status[i].style; @@ -2787,7 +2799,7 @@ control.prototype._resize_status = function (obj) { style.display = core.flags.statusCanvas || obj.statusDisplayArr.indexOf(id) < 0 ? 'none': 'block'; style.margin = 3 * core.domStyle.scale + "px"; style.height = statusHeight + "px"; - style.maxWidth = obj.BAR_WIDTH * core.domStyle.scale * (core.domStyle.isVertical ? 0.95 : 1) + "px"; + style.maxWidth = obj.BAR_WIDTH * core.domStyle.scale * (core.domStyle.isVertical ? 0.95 : 1) + obj.BORDER + "px"; if (obj.is15x15 && !core.domStyle.isVertical) style.marginLeft = 11 * core.domStyle.scale + "px"; } @@ -2819,7 +2831,7 @@ control.prototype._resize_toolBar = function (obj) { toolBar.style.background = obj.globalAttribute.toolsBackground; } else { - toolBar.style.width = obj.BAR_WIDTH * core.domStyle.scale + "px"; + toolBar.style.width = obj.BAR_WIDTH * core.domStyle.scale + obj.BORDER + "px"; toolBar.style.top = 0.718 * obj.outerSize + "px"; toolBar.style.height = 0.281 * obj.outerSize + "px"; toolBar.style.background = 'transparent'; @@ -2844,7 +2856,6 @@ control.prototype._resize_tools = function (obj) { style.marginTop = 6 * core.domStyle.scale + "px" } core.dom.hard.style.lineHeight = toolsHeight + "px"; - core.dom.hard.style.color = obj.globalAttribute.hardLabelColor; if (core.domStyle.isVertical) { core.dom.hard.style.width = obj.outerSize - 9 * toolsMarginLeft - 8.5 * toolsHeight - 12 + "px"; } diff --git a/libs/core.js b/libs/core.js index d853edbc..0da652b7 100644 --- a/libs/core.js +++ b/libs/core.js @@ -84,6 +84,7 @@ function core() { // 样式 this.domStyle = { scale: 1.0, + availableScale: [], isVertical: false, showStatusBar: true, toolbarBtn: false, @@ -190,15 +191,13 @@ function core() { }, "globalAttribute": { 'equipName': main.equipName || [], - "statusLeftBackground": main.statusLeftBackground || "url(project/materials/ground.png) repeat", - "statusTopBackground": main.statusTopBackground || "url(project/materials/ground.png) repeat", - "toolsBackground": main.toolsBackground || "url(project/materials/ground.png) repeat", - "borderColor": main.borderColor || "white", - "statusBarColor": main.statusBarColor || "white", - "hardLabelColor": main.hardLabelColor || "red", - "floorChangingBackground": main.floorChangingBackground || "black", - "floorChangingTextColor": main.floorChangingTextColor || "white", - "font": main.font || "Verdana" + "statusLeftBackground": main.styles.statusLeftBackground || "url(project/materials/ground.png) repeat", + "statusTopBackground": main.styles.statusTopBackground || "url(project/materials/ground.png) repeat", + "toolsBackground": main.styles.toolsBackground || "url(project/materials/ground.png) repeat", + "borderColor": main.styles.borderColor || [204,204,204,1], + "statusBarColor": main.styles.statusBarColor || [255,255,255,1], + "floorChangingStyle": main.styles.floorChangingStyle || "background-color: black; color: white", + "font": main.styles.font || "Verdana" }, 'curtainColor': null, 'openingDoor': null, @@ -292,6 +291,12 @@ core.prototype._init_sys_flags = function () { // 行走速度 core.values.moveSpeed = core.getLocalStorage('moveSpeed', 100); core.values.floorChangeTime = core.getLocalStorage('floorChangeTime', 500); + if (main.mode != 'editor') { + core.domStyle.scale = core.getLocalStorage('scale', 1); + if (core.domStyle.scale != 1) { + core.resize(); + } + } } core.prototype._init_platform = function () { diff --git a/libs/enemys.js b/libs/enemys.js index b4478955..b530e738 100644 --- a/libs/enemys.js +++ b/libs/enemys.js @@ -299,6 +299,7 @@ enemys.prototype._getDamage = function (enemy, hero, x, y, floorId) { enemys.prototype.getCurrentEnemys = function (floorId) { floorId = floorId || core.status.floorId; var enemys = [], used = {}; + core.extractBlocks(floorId); var mapBlocks = core.status.maps[floorId].blocks; for (var b = 0; b < mapBlocks.length; b++) { if (!mapBlocks[b].disable && mapBlocks[b].event.cls.indexOf('enemy') == 0) { @@ -364,6 +365,7 @@ enemys.prototype.hasEnemyLeft = function (enemyId, floorId) { else if (enemyId) enemyMap[enemyId] = true; else enemyMap = null; for (var i = 0; i < floorId.length; i++) { + core.extractBlocks(floorId[i]); var mapBlocks = core.status.maps[floorId[i]].blocks; for (var b = 0; b < mapBlocks.length; b++) { if (!mapBlocks[b].disable && mapBlocks[b].event.cls.indexOf('enemy') === 0) { diff --git a/libs/events.js b/libs/events.js index b7601032..44b2054f 100644 --- a/libs/events.js +++ b/libs/events.js @@ -61,6 +61,7 @@ events.prototype._startGame_start = function (hard, seed, route, callback) { core.dom.musicBtn.style.display = 'block'; core.push(todo, core.firstData.startCanvas); } + core.push(todo, {"type": "function", "function": "function() { core.events._startGame_setHard(); }"}) core.push(todo, core.firstData.startText); this.insertAction(todo, null, null, function () { core.events._startGame_afterStart(nowLoc, callback); @@ -69,6 +70,22 @@ events.prototype._startGame_start = function (hard, seed, route, callback) { if (route != null) core.startReplay(route); } +events.prototype._startGame_setHard = function () { + // 根据难度设置flag:hard + // 这一段应当在startCanvas之后,startText之前做 + var hardValue = 0; + var hardColor = 'red'; + main.levelChoose.forEach(function (one) { + if (one.name == core.status.hard) { + hardValue = one.hard; + hardColor = core.arrayToRGBA(one.color || [255,0,0,1]); + core.insertAction(one.action); + } + }); + core.setFlag('hard', 0); + core.setFlag('__hardColor__', hardColor); +} + events.prototype._startGame_afterStart = function (nowLoc, callback) { core.ui.closePanel(); this._startGame_statusBar(); @@ -441,7 +458,7 @@ events.prototype._openDoor_check = function (id, x, y, needKey) { } // 是否存在门或暗墙 - if (core.material.icons.animates[id] == null) { + if (core.material.icons.animates[id] == null && core.material.icons.npc48[id] == null) { return clearAndReturn(); } @@ -452,13 +469,14 @@ events.prototype._openDoor_check = function (id, x, y, needKey) { return clearAndReturn(); doorInfo = doorInfo.doorInfo; // Check all keys - var keyInfo = doorInfo[0]; + var keyInfo = doorInfo.keys || {}; if (needKey) { - if (keyInfo == null) { - core.drawTip("无法开启此门"); - return clearAndReturn(); - } for (var keyName in keyInfo) { + // --- 如果是一个不存在的道具,则直接认为无法开启 + if (!core.material.items[keyName]) { + core.drawTip("无法开启此门"); + return clearAndReturn(); + } var keyValue = keyInfo[keyName]; if (core.itemCount(keyName) < keyValue) { core.drawTip("你没有" + ((core.material.items[keyName] || {}).name || "钥匙"), null, true); @@ -470,22 +488,28 @@ events.prototype._openDoor_check = function (id, x, y, needKey) { core.removeItem(keyName, keyInfo[keyName]); } } - core.playSound(doorInfo[1] || 'door.mp3'); + core.playSound(doorInfo.openSound); return true; } events.prototype._openDoor_animate = function (id, x, y, callback) { - var door = core.material.icons.animates[id]; - var speed = 40; + var blockInfo = core.getBlockInfo(id); + var image = blockInfo.image, posY = blockInfo.posY, height = blockInfo.height; + + var speed = (core.getBlockById(id).event.doorInfo.time || 160) / 4; var locked = core.status.lockControl; core.lockControl(); core.status.replay.animate = true; core.removeBlock(x, y); - core.drawImage('event', core.material.images.animates, 0, 32 * door, 32, 32, 32 * x, 32 * y, 32, 32); + core.drawImage('event', image, 0, posY * height + height - 32, 32, 32, x * 32, y * 32, 32, 32); + if (height > 32) + core.drawImage('event2', image, 0, posY * height, 32, height - 32, x * 32, y * 32 + 32 - height, 32, height - 32); var state = 0; var animate = window.setInterval(function () { core.clearMap('event', 32 * x, 32 * y, 32, 32); + if (height > 32) + core.clearMap('event2', x * 32, y * 32 + 32 - height, 32, height - 32) state++; if (state == 4) { clearInterval(animate); @@ -496,7 +520,9 @@ events.prototype._openDoor_animate = function (id, x, y, callback) { if (callback) callback(); return; } - core.drawImage('event', core.material.images.animates, 32 * state, 32 * door, 32, 32, 32 * x, 32 * y, 32, 32); + core.drawImage('event', image, 32 * state, posY * height + height - 32, 32, 32, x * 32, y * 32, 32, 32); + if (height > 32) + core.drawImage('event2', image, 32 * state, posY * height, 32, height - 32, x * 32, y * 32 + 32 - height, 32, height - 32); }, core.status.replay.speed == 24 ? 1 : speed / Math.max(core.status.replay.speed, 1)); core.animateFrame.asyncId[animate] = true; } @@ -661,6 +687,7 @@ events.prototype._changeFloor_getHeroLoc = function (floorId, stair, heroLoc) { heroLoc.y = core.status.maps[floorId][stair][1]; } else { + core.extractBlocks(floorId); var blocks = core.status.maps[floorId].blocks; for (var i in blocks) { if (!blocks[i].disable && blocks[i].event.id === stair) { @@ -903,6 +930,8 @@ events.prototype.doAction = function (keepUI) { } events.prototype._doAction_finishEvents = function () { + if (core.status.gameOver) return true; + // 事件处理完毕 if (core.status.event.data.list.length == 0) { // 检测并执行延迟自动事件 @@ -960,7 +989,7 @@ events.prototype.insertCommonEvent = function (name, x, y, callback, addToLast) if (callback) callback(); return; } - this.insertAction(commonEvent, x, y, callback, addToLast); + this.insertAction({"type": "dowhile", "condition": "false", "data": commonEvent}, x, y, callback, addToLast); } ////// 获得一个公共事件 ////// @@ -1281,10 +1310,16 @@ events.prototype._action_hide = function (data, x, y, prefix) { events.prototype._action_setBlock = function (data, x, y, prefix) { data.loc = this.__action_getLoc2D(data.loc, x, y, prefix); - data.loc.forEach(function (t) { - core.setBlock(data.number, t[0], t[1], data.floorId); - }); - core.doAction(); + data.time = data.time || 0; + data.floorId = data.floorId || core.status.floorId; + if (data.time > 0 && data.floorId == core.status.floorId) { + this.__action_doAsyncFunc(data.async, core.animateSetBlocks, data.number, data.loc, data.floorId, data.time); + } else { + data.loc.forEach(function (loc) { + core.setBlock(data.number, loc[0], loc[1], data.floorId); + }); + core.doAction(); + } } events.prototype._action_turnBlock = function (data, x, y, prefix) { @@ -1424,7 +1459,7 @@ events.prototype._action_changePos = function (data, x, y, prefix) { events.prototype._action_showImage = function (data, x, y, prefix) { if (core.isReplaying()) data.time = 0; this.__action_doAsyncFunc(data.async || data.time == 0, core.showImage, - data.code, data.image, data.sloc, data.loc, data.opacity, data.time); + data.code, data.image + (data.reverse || ''), data.sloc, data.loc, data.opacity, data.time); } events.prototype._precompile_showImage = function (data) { @@ -1980,15 +2015,25 @@ events.prototype._action_hideStatusBar = function (data, x, y, prefix) { } events.prototype._action_showHero = function (data, x, y, prefix) { - core.removeFlag('hideHero'); - core.drawHero(); - core.doAction(); + data.time = data.time || 0; + if (data.time > 0) { + this.__action_doAsyncFunc(data.async, core.triggerHero, 'show', data.time); + } else { + core.removeFlag('hideHero'); + core.drawHero(); + core.doAction(); + } } events.prototype._action_hideHero = function (data, x, y, prefix) { - core.setFlag('hideHero', true); - core.drawHero(); - core.doAction(); + data.time = data.time || 0; + if (data.time > 0) { + this.__action_doAsyncFunc(data.async, core.triggerHero, 'hide', data.time); + } else { + core.setFlag('hideHero', true); + core.drawHero(); + core.doAction(); + } } events.prototype._action_vibrate = function (data, x, y, prefix) { @@ -2026,7 +2071,7 @@ events.prototype._action_wait = function (data, x, y, prefix) { } else if (data.timeout) { core.status.event.interval = setTimeout(function() { core.status.route.push("input:none"); - core.removeFlag("type"); + core.setFlag("type", -1); core.doAction(); }, data.timeout); } @@ -2535,7 +2580,7 @@ events.prototype.setEnemy = function (id, name, value, prefix) { ////// 设置楼层属性 ////// events.prototype.setFloorInfo = function (name, value, floorId, prefix) { floorId = floorId || core.status.floorId; - core.status.maps[floorId][name] = core.calValue(value, prefix); + core.status.maps[floorId][name] = value; core.updateStatusBar(); } @@ -2548,10 +2593,14 @@ events.prototype.setGlobalAttribute = function (name, value) { // --- 检查 [] if (value.charAt(0) == '[' && value.charAt(value.length - 1) == ']') value = eval(value); + // --- 检查颜色 + if (/^[0-9 ]+,[0-9 ]+,[0-9 ]+(,[0-9. ]+)?$/.test(value)) { + value = 'rgba(' + value + ')'; + } } core.status.globalAttribute[name] = value; - core.updateGlobalAttribute(name); core.setFlag('globalAttribute', core.status.globalAttribute); + core.resize(); } ////// 设置全局开关 ////// @@ -2574,7 +2623,8 @@ events.prototype.setGlobalFlag = function (name, value) { events.prototype.closeDoor = function (x, y, id, callback) { id = id || ""; - if (core.material.icons.animates[id] == null || core.getBlock(x, y) != null) { + if ((core.material.icons.animates[id] == null && core.material.icons.npc48[id] == null) + || core.getBlock(x, y) != null) { if (callback) callback(); return; } @@ -2585,27 +2635,36 @@ events.prototype.closeDoor = function (x, y, id, callback) { } // 关门动画 - core.playSound(doorInfo[2] || 'door.mp3'); - var door = core.material.icons.animates[id]; - var speed = 40, state = 0; + core.playSound(doorInfo.closeDoor); + var blockInfo = core.getBlockInfo(id); + var image = blockInfo.image, posY = blockInfo.posY, height = blockInfo.height; + + var speed = (doorInfo.time || 160) / 4, state = 0; var animate = window.setInterval(function () { state++; if (state == 4) { clearInterval(animate); delete core.animateFrame.asyncId[animate]; - core.setBlock(core.getNumberById(id), x, y); + core.setBlock(id, x, y); if (callback) callback(); return; } core.clearMap('event', 32 * x, 32 * y, 32, 32); - core.drawImage('event', core.material.images.animates, 32 * (4-state), 32 * door, 32, 32, 32 * x, 32 * y, 32, 32); + core.drawImage('event', image, 32 * (4-state), posY * height + height - 32, 32, 32, x * 32, y * 32, 32, 32); + if (height > 32) + core.drawImage('event2', image, 32 * (4-state), posY * height, 32, height - 32, x * 32, y * 32 + 32 - height, 32, height - 32); }, core.status.replay.speed == 24 ? 1 : speed / Math.max(core.status.replay.speed, 1)); core.animateFrame.asyncId[animate] = true; } ////// 显示图片 ////// events.prototype.showImage = function (code, image, sloc, loc, opacityVal, time, callback) { + var imageName = null; if (typeof image == 'string') { + imageName = image; + if (image.endsWith(':x') || image.endsWith(':y') || image.endsWith(':o')) { + image = image.substring(0, image.length - 2); + } image = core.getMappedName(image); image = core.material.images.images[image]; } @@ -2627,7 +2686,7 @@ events.prototype.showImage = function (code, image, sloc, loc, opacityVal, time, time = time || 0; var name = "image" + zIndex; var ctx = core.createCanvas(name, x, y, w, h, zIndex); - ctx.drawImage(image, sx, sy, sw, sh, 0, 0, w, h); + core.drawImage(ctx, imageName == null ? image : imageName, sx, sy, sw, sh, 0, 0, w, h); if (time == 0) { core.setOpacity(name, opacityVal); if (callback) callback(); diff --git a/libs/icons.js b/libs/icons.js index a21780f3..375cf9e8 100644 --- a/libs/icons.js +++ b/libs/icons.js @@ -36,16 +36,13 @@ icons.prototype.getAllIconIds = function () { return this.allIconIds; } -icons.prototype._getAnimateFrames = function (cls, useOriginValue) { +icons.prototype._getAnimateFrames = function (cls) { if (cls == 'enemys' || cls == 'npcs') { return 2; } - if (cls == 'animates' || cls == 'enemy48') { + if (cls == 'animates' || cls == 'enemy48' || cls == 'npc48') { return 4; } - if (cls == 'npc48') { - return useOriginValue ? 4 : 1; - } return 1; } @@ -53,6 +50,7 @@ icons.prototype._getAnimateFrames = function (cls, useOriginValue) { icons.prototype.getTilesetOffset = function (id) { if (typeof id == 'string') { + id = core.getIdOfThis(id); // Tileset的ID必须是 X+数字 的形式 if (!/^X\d+$/.test(id)) return null; id = parseInt(id.substring(1)); @@ -74,4 +72,4 @@ icons.prototype.getTilesetOffset = function (id) { startOffset += this.tilesetStartOffset; } return null; -} \ No newline at end of file +} diff --git a/libs/items.js b/libs/items.js index 41c9d61c..3a22cac6 100644 --- a/libs/items.js +++ b/libs/items.js @@ -31,7 +31,6 @@ items.prototype.getItemEffect = function (itemId, itemNum) { var itemCls = core.material.items[itemId].cls; // 消耗品 if (itemCls === 'items') { - var ratio = parseInt(core.status.thisMap.item_ratio) || 1; var curr_hp = core.status.hero.hp; if (itemId in this.itemEffect) { try { @@ -64,10 +63,9 @@ items.prototype.getItemEffectTip = function (itemId) { var itemCls = core.material.items[itemId].cls; // 消耗品 if (itemCls === 'items') { - var ratio = parseInt(core.status.thisMap.item_ratio) || 1; if (itemId in this.itemEffectTip) { try { - return eval(this.itemEffectTip[itemId]) || ""; + return core.replaceText(this.itemEffectTip[itemId]) || ""; } catch (e) { main.log(e); return ""; @@ -95,7 +93,6 @@ items.prototype.useItem = function (itemId, noRoute, callback) { items.prototype._useItemEffect = function (itemId) { if (itemId in this.useItemEffect) { try { - var ratio = parseInt(core.status.thisMap.item_ratio) || 1; eval(this.useItemEffect[itemId]); } catch (e) { @@ -292,53 +289,41 @@ items.prototype.unloadEquip = function (equipType, callback) { } items.prototype.compareEquipment = function (compareEquipId, beComparedEquipId) { - var result = {}; + var result = {"value": {}, "percentage": {}}; var first = core.material.items[compareEquipId], second = core.material.items[beComparedEquipId]; - for (var name in core.status.hero) { - if (typeof core.status.hero[name] == 'number') { - var ans = 0; - if (first) ans += (first.equip || {})[name] || 0; - if (second) ans -= (second.equip || {})[name] || 0; - if (ans != 0) result[name] = ans; + for (var one in result) { + for (var name in core.status.hero) { + if (typeof core.status.hero[name] == 'number') { + var ans = 0; + if (first) ans += ((first.equip || {})[one] || {})[name] || 0; + if (second) ans -= ((second.equip || {})[one] || {})[name] || 0; + if (ans != 0) result[one][name] = ans; + } } } return result; } ////// 实际换装的效果 ////// -items.prototype._loadEquipEffect = function (equipId, unloadEquipId, isPercentage) { +items.prototype._loadEquipEffect = function (equipId, unloadEquipId) { // 比较能力值 var result = core.compareEquipment(equipId, unloadEquipId); - if (isPercentage) { - for (var name in result) - core.addBuff(name, result[name] / 100); - } - else { - for (var name in result) - core.status.hero[name] += result[name]; - } + for (var name in result.percentage) + core.addBuff(name, result.percentage[name] / 100); + + for (var name in result.value) + core.status.hero[name] += result.value[name]; } items.prototype._realLoadEquip = function (type, loadId, unloadId, callback) { var loadEquip = core.material.items[loadId] || {}, unloadEquip = core.material.items[unloadId] || {}; - loadEquip.equip = loadEquip.equip || {}; - unloadEquip.equip = unloadEquip.equip || {} - - var loadPercentage = loadEquip.equip.percentage, unloadPercentage = unloadEquip.equip.percentage; - - if (loadId && unloadId && (loadPercentage || false) != (unloadPercentage || false)) { - this.unloadEquip(type); - this.loadEquip(loadId); - if (callback) callback(); - return; - } // --- 音效 this._realLoadEquip_playSound(); // --- 实际换装 - this._loadEquipEffect(loadId, unloadId, loadPercentage == null ? unloadPercentage : loadPercentage); + this._loadEquipEffect(loadId, unloadId); // --- 加减 if (loadId) core.removeItem(loadId); diff --git a/libs/maps.js b/libs/maps.js index ae76cecb..ede1ce9c 100644 --- a/libs/maps.js +++ b/libs/maps.js @@ -22,6 +22,17 @@ maps.prototype._setFloorSize = function (floorId) { core.floors[floorId].height = core.floors[floorId].height || core.__SIZE__; } +maps.prototype._resetFloorImages = function () { + for (var floorId in core.status.maps) { + (core.status.maps[floorId].images || []).forEach(function (one) { + var flag = "__floorImg__" + floorId + "_" + one.x + "_" + one.y; + if (core.getFlag(flag) == null) { + if (one.disabled) core.setFlag(flag, true); + } + }) + } +} + // ------ 加载地图与地图的存档读档(压缩与解压缩) ------ // ////// 加载某个楼层(从剧本或存档中) ////// @@ -42,12 +53,27 @@ maps.prototype.loadFloor = function (floorId, map) { if (notCopy.indexOf(name) == -1 && map[name] != null) content[name] = core.clone(map[name]); } - map = this.decompressMap(map.map, floorId); - // 事件处理 - content['blocks'] = this._mapIntoBlocks(map, floor, floorId); + content.map = map.map; + if (main.mode == 'editor') { + this.extractBlocks(content); + } return content; } +/// 根据需求解析出blocks +maps.prototype.extractBlocks = function (map) { + map = map || core.status.floorId; + if (typeof map == 'string') map = (core.status.maps||{})[map]; + if (!map) return; + if (map.blocks) return; + if (map.deleted) { + map.blocks = []; + return; + } + var floorId = map.floorId; + map.blocks = this._mapIntoBlocks(this.decompressMap(map.map, floorId), core.floors[floorId], floorId); +} + maps.prototype._mapIntoBlocks = function (map, floor, floorId) { var blocks = []; var mw = core.floors[floorId].width; @@ -64,6 +90,7 @@ maps.prototype._mapIntoBlocks = function (map, floor, floorId) { ////// 从ID获得数字 ////// maps.prototype.getNumberById = function (id) { + id = this.getIdOfThis(id); core.status.id2number = core.status.id2number || {}; if (core.status.id2number[id] != null) return core.status.id2number[id]; return core.status.id2number[id] = this._getNumberById(id); @@ -94,6 +121,13 @@ maps.prototype.getBlockById = function (id) { return this.getBlockByNumber(this.getNumberById(id)); } +maps.prototype.getIdOfThis = function (id) { + if (id != 'this') return id; + if (core.status.event.id != 'action') return id; + if (!core.status.event.data || core.status.event.data.x == null || core.status.event.data.y == null) return id; + return core.getBlockId(core.status.event.data.x, core.status.event.data.y) || id; +} + ////// 数字和ID的对应关系 ////// maps.prototype.initBlock = function (x, y, id, addInfo, eventFloor) { var disable = null; @@ -137,7 +171,7 @@ maps.prototype._addInfo = function (block) { block.event.trigger = 'getItem'; } if (block.event.animate == null) { - block.event.animate = core.icons._getAnimateFrames(block.event.cls, false); + block.event.animate = core.icons._getAnimateFrames(block.event.cls); } block.event.height = 32; if (block.event.cls == 'enemy48' || block.event.cls == 'npc48') @@ -266,17 +300,16 @@ maps.prototype.saveMap = function (floorId) { return map; } // 砍层状态:直接返回 - if (main.mode == 'play' && (flags.__removed__ || []).indexOf(floorId) >= 0) { - return { canFlyTo: false, cannotViewMap: true }; + if ((flags.__removed__ || []).indexOf(floorId) >= 0) { + return { deleted: true, canFlyTo: false, cannotViewMap: true }; } - var map = maps[floorId], floor = core.floors[floorId]; - var blocks = this._getMapArrayFromBlocks(map.blocks, floor.width, floor.height, true); - if (main.mode == 'editor') return blocks; - - var thisFloor = this._compressFloorData(map, floor); - var mapArr = this.compressMap(blocks, floorId); - if (mapArr != null) thisFloor.map = mapArr; + var map = maps[floorId]; + var thisFloor = this._compressFloorData(map, core.floors[floorId]); + if (map.blocks) { + var mapArr = this.compressMap(map.blocks, map.width, map.height, floorId); + if (mapArr != null) thisFloor.map = mapArr; + } return thisFloor; } @@ -305,23 +338,6 @@ maps.prototype.loadMap = function (data, floorId) { return this.loadFloor(floorId, data[floorId]); } -////// 删除地图,不计入存档 ////// -maps.prototype.removeMaps = function (fromId, toId) { - if (!core.isPlaying()) return; - toId = toId || fromId; - var fromIndex = core.floorIds.indexOf(fromId), - toIndex = core.floorIds.indexOf(toId); - if (toIndex < 0) toIndex = core.floorIds.length - 1; - flags.__removed__ = flags.__removed__ || []; - for (var i = fromIndex; i <= toIndex; ++i) { - var floorId = core.floorIds[i]; - delete flags.__visited__[floorId]; - flags.__removed__.push(floorId); - core.status.maps[floorId].canFlyTo = false; - core.status.maps[floorId].cannotViewMap = true; - } -} - ////// 更改地图画布的尺寸 maps.prototype.resizeMap = function (floorId) { floorId = floorId || core.status.floorId; @@ -345,18 +361,12 @@ maps.prototype.resizeMap = function (floorId) { ////// 将当前地图重新变成二维数组形式 ////// maps.prototype.getMapArray = function (floorId, showDisable) { floorId = floorId || core.status.floorId; - return this._getMapArrayFromBlocks(core.status.maps[floorId].blocks, - core.floors[floorId].width, core.floors[floorId].height, showDisable); + var map = core.status.maps[floorId]; + if (!map.blocks) return map.map; + return this._getMapArrayFromBlocks(map.blocks, map.width, map.height, showDisable); } maps.prototype._getMapArrayFromBlocks = function (blockArray, width, height, showDisable) { - if (typeof blockArray == 'string') { - var floorId = blockArray; - blockArray = core.status.maps[floorId].blocks; - width = core.floors[floorId].width; - height = core.floors[floorId].height; - } - var blocks = []; var allzero = []; for (var y = 0; y < width; y++) allzero.push(0); @@ -380,6 +390,7 @@ maps.prototype._getMapArrayFromBlocks = function (blockArray, width, height, sho maps.prototype.getMapBlocksObj = function (floorId, showDisable) { floorId = floorId || core.status.floorId; var obj = {}; + core.extractBlocks(floorId); core.status.maps[floorId].blocks.forEach(function (block) { if (!block.disable || showDisable) obj[block.x + "," + block.y] = block; @@ -564,8 +575,6 @@ maps.prototype._canMoveDirectly_checkGlobal = function () { if (core.status.thisMap.cannotMoveDirectly) return false; // flag:cannotMoveDirectly为true:不能 if (core.hasFlag('cannotMoveDirectly')) return false; - // 中毒状态:不能 - if (core.hasFlag('poison')) return false; return true; } @@ -688,7 +697,7 @@ maps.prototype._automaticRoute_deepAdd = function (x, y) { // 绕过路障 if (id.endsWith("Net")) deepAdd += 100; // 绕过血瓶和绿宝石 - if (core.hasFlag('__potionNoRouting__') && (id.endsWith("Potion") || id == 'greenJewel')) deepAdd += 100; + if (core.hasFlag('__potionNoRouting__') && (id.endsWith("Potion") || id == 'greenGem')) deepAdd += 100; // 绕过传送点 // if (block.block.event.trigger == 'changeFloor') deepAdd+=10; } @@ -771,6 +780,7 @@ maps.prototype.drawMap = function (floorId, callback) { core.clearMap('all'); this.generateGroundPattern(floorId); core.status.floorId = floorId; + core.extractBlocks(floorId); core.status.thisMap = core.status.maps[floorId]; this._drawMap_drawAll(); @@ -828,7 +838,7 @@ maps.prototype._drawBg_drawBackground = function (floorId, ctx) { if (groundInfo != null) { for (var i = 0; i < width; i++) { for (var j = 0; j < height; j++) { - ctx.drawImage(groundInfo.image, 32 * groundInfo.posX, groundInfo.height * groundInfo.posY, 32, 32, i * 32, j * 32, 32, 32); + core.drawImage(ctx, groundInfo.image, 32 * groundInfo.posX, groundInfo.height * groundInfo.posY, 32, 32, i * 32, j * 32, 32, 32); } } } @@ -837,6 +847,7 @@ maps.prototype._drawBg_drawBackground = function (floorId, ctx) { ////// 绘制事件层 ////// maps.prototype.drawEvents = function (floorId, blocks, ctx) { floorId = floorId || core.status.floorId; + core.extractBlocks(floorId); if (!blocks) blocks = core.status.maps[floorId].blocks; var arr = this._getMapArrayFromBlocks(blocks, core.floors[floorId].width, core.floors[floorId].height); var onMap = ctx == null; @@ -909,36 +920,25 @@ maps.prototype._drawFloorImages = function (floorId, ctx, name, images, currStat floorId = floorId || core.status.floorId; if (!images) images = this._getFloorImages(floorId); var redraw = currStatus != null; - images.forEach(function (t) { - if (typeof t == 'string') t = [0, 0, t]; - var dx = parseInt(t[0]), dy = parseInt(t[1]), imageName = t[2], frame = core.clamp(parseInt(t[4]), 1, 8); - imageName = core.getMappedName(imageName); - var image = core.material.images.images[imageName]; + images.forEach(function (one) { + var image = core.material.images.images[core.getMappedName(one.name)]; + var frame = one.frame || 1; + if (!image) return; + var flag = "__floorImg__" + floorId + "_" + one.x + "_" + one.y; + if (core.hasFlag(flag)) return; if (redraw && frame == 1) return; // 不重绘 - if (core.isset(dx) && core.isset(dy) && image && - !core.hasFlag("__floorImg__" + floorId + "_" + dx + "_" + dy)) { - var width = parseInt(image.width / frame), offsetX = (currStatus || 0) % frame * width; - if (/.*\.gif/i.test(imageName) && main.mode == 'play') { - if (redraw) return; // 忽略gif - this._drawFloorImages_gif(image, dx, dy); - return; - } - core.maps._drawFloorImage(ctx, name, t[3], image, offsetX, width, dx, dy, redraw); + if (/.*\.gif/i.test(one.name)) { + if (redraw) return; + this._drawFloorImages_gif(image, one.x, one.y); + return; } - }); + this._drawFloorImage(ctx, name, one, image, currStatus); + }, this); } maps.prototype._getFloorImages = function (floorId) { - floorId = floorId || core.status.floorId; - var images = []; - if ((core.status.maps || core.floors)[floorId].images) { - images = (core.status.maps || core.floors)[floorId].images; - if (typeof images == 'string') { - images = [[0, 0, images]]; - } - } - return images; + return ((core.status.maps || core.floors)[floorId || core.status.floorId] || {}).images || []; } maps.prototype._drawFloorImages_gif = function (image, dx, dy) { @@ -954,30 +954,26 @@ maps.prototype._drawFloorImages_gif = function (image, dx, dy) { return; } -maps.prototype._drawFloorImage = function (ctx, name, type, image, offsetX, width, dx, dy, redraw) { +maps.prototype._drawFloorImage = function (ctx, name, one, image, currStatus) { var height = image.height; - var _draw = function () { - if (redraw) core.clearMap(ctx, dx, dy, width, height); - core.drawImage(ctx, image, offsetX, 0, width, height, dx, dy, width, height); - } - if (!type) { - if (name != 'bg') return; - return _draw(); - } - if (type == 1) { - if (name != 'fg') return; - return _draw(); - } - if (type == 2) { + var imageName = one.name + (one.reverse||''); + var width = parseInt((one.w == null ? image.width : one.w) / (one.frame || 1)); + var height = one.h == null ? image.height : one.h; + var sx = (one.sx || 0) + (currStatus || 0) % (one.frame || 1) * width; + var sy = one.sy || 0; + + if (one.canvas != 'auto' && one.canvas != name) return; + if (one.canvas != 'auto') { + if (currStatus != null) core.clearMap(ctx, one.x, one.y, width, height); + core.drawImage(ctx, imageName, sx, sy, width, height, one.x, one.y, width, height); + } else { if (name == 'bg') { - if (redraw) core.clearMap(ctx, dx, dy + height - 32, width, 32); - core.drawImage('bg', image, offsetX, height - 32, width, 32, dx, dy + height - 32, width, 32); + if (currStatus != null) core.clearMap(ctx, one.x, one.y + height - 32, width, 32); + core.drawImage(ctx, imageName, sx, sy + height - 32, width, 32, one.x, one.y+height - 32, width, 32); + } else if (name == 'fg') { + if (currStatus != null) core.clearMap(ctx, one.x, one.y, width, height - 32); + core.drawImage(ctx, imageName, sx, sy, width, height - 32, one.x, one.y, width, height - 32); } - else if (name == 'fg') { - if (redraw) core.clearMap(ctx, dx, dy, width, height - 32); - core.drawImage('fg', image, offsetX, 0, width, height - 32, dx, dy, width, height - 32); - } - return; } } @@ -1048,7 +1044,7 @@ maps.prototype._drawAutotile_render = function(canvas, x, y, size, autotile, sta ]; var data = indexData[index]; if(index>=16){ // 拐角直接绘制 - canvas.drawImage(autotile, data[0][0], data[0][1], data[0][2], data[0][3], data[0][4], data[0][5], size/2, size/2); + core.drawImage(canvas, autotile, data[0][0], data[0][1], data[0][2], data[0][3], data[0][4], data[0][5], size/2, size/2); }else{ // 非拐角要根据是否已经绘制进行切分后绘制 this._drawAutotile_renderCut(canvas, autotile, x, y, size, data, done); } @@ -1089,7 +1085,7 @@ maps.prototype._drawAutotile_renderCut = function(canvas, autotile, x, y, size, } for(var i = 0; i<4; i++){ var dt = drawData[i];if(!dt)continue; - canvas.drawImage(autotile, dt[0], dt[1], 16, 16, x + (i % 2) * size / 2, y + parseInt(i / 2) * size / 2, size/2, size/2); + core.drawImage(canvas, autotile, dt[0], dt[1], 16, 16, x + (i % 2) * size / 2, y + parseInt(i / 2) * size / 2, size/2, size/2); }; } @@ -1099,7 +1095,7 @@ maps.prototype._drawAutotile_drawBlockByIndex = function (ctx, dx, dy, autotileI var sx = 16 * ((index - 1) % 6), sy = 16 * (~~((index - 1) / 6)); status = status || 0; status %= parseInt(autotileImg.width / 96); - ctx.drawImage(autotileImg, sx + 96 * status, sy, 16, 16, dx, dy, size / 2, size / 2); + core.drawImage(ctx, autotileImg, sx + 96 * status, sy, 16, 16, dx, dy, size / 2, size / 2); } maps.prototype._drawAutotile_getAutotileAroundId = function (currId, x, y, mapArr) { @@ -1170,16 +1166,16 @@ maps.prototype._makeAutotileEdges = function () { var n = core.maps.getNumberById(t); core.material.autotileEdges[n] = [n]; - ctx.clearRect(0, 0, 32, 32); - ctx.drawImage(core.material.images.autotile[t], 0, 0, 32, 32, 0, 0, 32, 32); + core.clearMap(ctx, 0, 0, 32, 32); + core.drawImage(ctx, core.material.images.autotile[t], 0, 0, 32, 32, 0, 0, 32, 32); var data = canvas.toDataURL("image/png"); autotileIds.forEach(function (t2) { if (t == t2) return; var n2 = core.maps.getNumberById(t2); - ctx.clearRect(0, 0, 32, 32); - ctx.drawImage(core.material.images.autotile[t2], 32, 0, 32, 32, 0, 0, 32, 32); + core.clearMap(ctx, 0, 0, 32, 32); + core.drawImage(ctx, core.material.images.autotile[t2], 32, 0, 32, 32, 0, 0, 32, 32); if (data == canvas.toDataURL("image/png")) { core.material.autotileEdges[n].push(n2); } @@ -1204,6 +1200,7 @@ maps.prototype.drawThumbnail = function (floorId, blocks, options, toDraw) { } maps.prototype._drawThumbnail_drawTempCanvas = function (floorId, blocks, options) { + core.extractBlocks(floorId); blocks = blocks || core.status.maps[floorId].blocks; options = options || {} @@ -1238,11 +1235,11 @@ maps.prototype._drawThumbnail_realDrawTempCanvas = function (floorId, blocks, op this.drawEvents(floorId, blocks, tempCanvas); // 缩略图:勇士 if (options.heroLoc) { - options.heroIcon = options.heroIcon || core.status.hero.image; + options.heroIcon = options.heroIcon || core.status.hero.image || 'hero.png'; options.heroIcon = core.getMappedName(options.heroIcon); var icon = core.material.icons.hero[options.heroLoc.direction]; var height = core.material.images.images[options.heroIcon].height / 4; - tempCanvas.drawImage(core.material.images.images[options.heroIcon], icon.stop * 32, icon.loc * height, 32, height, + core.drawImage(tempCanvas, core.material.images.images[options.heroIcon], icon.stop * 32, icon.loc * height, 32, height, 32 * options.heroLoc.x, 32 * options.heroLoc.y + 32 - height, 32, height); } // 缩略图:前景 @@ -1272,21 +1269,21 @@ maps.prototype._drawThumbnail_drawToTarget = function (floorId, toDraw) { var side = (size - realWidth) / 2; core.fillRect(ctx, x, y, side, realHeight, '#000000'); core.fillRect(ctx, x + size - side, y, side, realHeight); - ctx.drawImage(tempCanvas.canvas, 0, 0, tempWidth, tempHeight, x + side, y, realWidth, realHeight); + core.drawImage(ctx, tempCanvas.canvas, 0, 0, tempWidth, tempHeight, x + side, y, realWidth, realHeight); } else { var realWidth = size, realHeight = realWidth * tempHeight / tempWidth; var side = (size - realHeight) / 2; core.fillRect(ctx, x, y, realWidth, side, '#000000'); core.fillRect(ctx, x, y + size - side, realWidth, side); - ctx.drawImage(tempCanvas.canvas, 0, 0, tempWidth, tempHeight, x, y + side, realWidth, realHeight); + core.drawImage(ctx, tempCanvas.canvas, 0, 0, tempWidth, tempHeight, x, y + side, realWidth, realHeight); } } else { // 只绘制可见窗口 var offsetX = core.clamp(centerX - core.__HALF_SIZE__, 0, width - core.__SIZE__), offsetY = core.clamp(centerY - core.__HALF_SIZE__, 0, height - core.__SIZE__); - ctx.drawImage(tempCanvas.canvas, offsetX * 32, offsetY * 32, core.__PIXELS__, core.__PIXELS__, x, y, size, size); + core.drawImage(ctx, tempCanvas.canvas, offsetX * 32, offsetY * 32, core.__PIXELS__, core.__PIXELS__, x, y, size, size); } } @@ -1340,6 +1337,7 @@ maps.prototype.enemyExists = function (x, y, id, floorId) { maps.prototype.getBlock = function (x, y, floorId, showDisable) { floorId = floorId || core.status.floorId; if (!floorId) return null; + core.extractBlocks(floorId); var blocks = core.status.maps[floorId].blocks; for (var n = 0; n < blocks.length; n++) { if (blocks[n].x == x && blocks[n].y == y) { @@ -1417,6 +1415,7 @@ maps.prototype.searchBlock = function (id, floorId, showDisable) { }); return result; } + core.extractBlocks(floorId); for (var i = 0; i < core.status.maps[floorId].blocks.length; ++i) { var block = core.status.maps[floorId].blocks[i]; if ((showDisable || !block.disable) && (core.matchWildcard(id, block.event.id) || core.matchRegex(id, block.event.id))) { @@ -1472,7 +1471,7 @@ maps.prototype.hideBlock = function (x, y, floorId) { maps.prototype.hideBlockByIndex = function (index, floorId) { floorId = floorId || core.status.floorId; if (!floorId) return; - + core.extractBlocks(floorId); var blocks = core.status.maps[floorId].blocks, block = blocks[index]; block.disable = true; } @@ -1512,7 +1511,7 @@ maps.prototype.removeBlock = function (x, y, floorId) { maps.prototype.removeBlockByIndex = function (index, floorId) { floorId = floorId || core.status.floorId; if (!floorId) return; - + core.extractBlocks(floorId); var blocks = core.status.maps[floorId].blocks, block = blocks[index]; blocks.splice(index, 1); } @@ -1638,6 +1637,103 @@ maps.prototype.setBlock = function (number, x, y, floorId) { } } +maps.prototype.animateSetBlock = function (number, x, y, floorId, time, callback) { + floorId = floorId || core.status.floorId; + time = time || 0; + if (floorId != core.status.floorId || time == 0) { + // 不在当前楼层,直接忽略 + this.setBlock(number, x, y, floorId); + if (callback) callback(); + return; + } + 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]); + + // 如果原本是启用的 + if (originBlock != null && !originBlock.block.disable) { + return this._animateSetBlock_originEnabled(block, number, x, y, floorId, time, callback); + } + + // 如果原本不存在 + if (originBlock == null) { + return this._animateSetBlock_originNotExists(block, number, x, y, floorId, time, callback); + } + + // 如果原本存在且禁用;应当直接设置,没有动画 + if (originBlock != null && originBlock.block.disable) { + return this._animateSetBlock_originDisabled(number, x, y, floorId, callback); + } + if (callback) callback(); +} + +maps.prototype._animateSetBlock_originEnabled = function (block, number, x, y, floorId, time, callback) { + // 情况1:设置到0 + if (block.id == 0) { + // 如果该点红点没有事件 - 直接删除 + if (!block.event.trigger) { + return this.animateBlock([x, y], 'remove', time, callback); + } else { + // 如果该点红点有事件;则设置到0,但是需启用 + return this.animateBlock([x, y], 'hide', time, function () { + core.setBlock(0, x, y, floorId); + core.showBlock(x, y, floorId); + if (callback) callback(); + }); + } + } + // 情况2:设置到非0 + else { + return this.animateBlock([x, y], 'hide', time / 2, function () { + core.setBlock(number, x, y, floorId); + core.animateBlock([x, y], 'show', time / 2, callback); + }) + } +} + +maps.prototype._animateSetBlock_originNotExists = function (block, number, x, y, floorId, time, callback) { + // 情况1:设置到0;没有动画效果 + if (block.id == 0) { + core.setBlock(number, x, y, floorId); + if (callback) callback(); + } + else { + // 情况2:设置到非0,有淡入动画 + core.setBlock(number, x, y, floorId); + core.hideBlock(x, y, floorId); + core.animateBlock([x, y], 'show', time, callback); + return; + } +} + +maps.prototype._animateSetBlock_originDisabled = function (number, x, y, floorId, callback) { + core.setBlock(number, x, y, floorId); + if (callback) callback(); +} + +maps.prototype.animateSetBlocks = function (number, locs, floorId, time, callback) { + if (!(locs instanceof Array)) { + if (callback) callback(); + return; + } + if (typeof locs[0] == 'number' && typeof locs[1] == 'number') + locs = [locs]; + + var count = locs.length; + var _afterSet = function () { + count--; + if (count == 0) { + if (callback) callback(); + } + } + locs.forEach(function (loc) { + core.animateSetBlock(number, loc[0], loc[1], floorId, time, _afterSet); + }); +} + ////// 事件转向 ////// maps.prototype.turnBlock = function (direction, x, y, floorId) { var id = core.getBlockId(x, y, floorId, true); @@ -1668,6 +1764,7 @@ maps.prototype.replaceBlock = function (fromNumber, toNumber, floorId) { return; } var toBlock = this.getBlockByNumber(toNumber, true); + core.extractBlocks(floorId); core.status.maps[floorId].blocks.forEach(function (block) { if (block.id == fromNumber) { block.id = toNumber; @@ -1817,7 +1914,7 @@ maps.prototype.moveBlock = function (x, y, steps, time, keep, callback) { } maps.prototype._moveBlock_doMove = function (blockInfo, canvases, moveInfo, callback) { - var animateTotal = core.icons._getAnimateFrames(blockInfo.cls, true), animateTime = 0; + var animateTotal = core.icons._getAnimateFrames(blockInfo.cls), animateTime = 0; var animate = window.setInterval(function () { if (blockInfo.cls != 'tileset') { animateTime += moveInfo.per_time; diff --git a/libs/thirdparty/LICENSE.md b/libs/thirdparty/LICENSE.md index 667f1d31..2d1241cf 100644 --- a/libs/thirdparty/LICENSE.md +++ b/libs/thirdparty/LICENSE.md @@ -228,35 +228,6 @@ localforage WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. - - -mid -============ - -Copyright (c) 2010, Matt Westcott & Ben Firshman -All rights reserved. - -Redistribution and use in source and binary forms, with or without -modification, are permitted provided that the following conditions are met: - - * Redistributions of source code must retain the above copyright notice, this - list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above copyright notice, - this list of conditions and the following disclaimer in the documentation - and/or other materials provided with the distribution. - * The names of its contributors may not be used to endorse or promote products - derived from this software without specific prior written permission. - -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND -ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED -WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR -ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES -(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; -LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON -ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. zip ============ diff --git a/libs/thirdparty/mid.js b/libs/thirdparty/mid.js deleted file mode 100644 index 45af166d..00000000 --- a/libs/thirdparty/mid.js +++ /dev/null @@ -1,701 +0,0 @@ -var sampleRate = 44100; /* hard-coded in Flash player */ - -function AudioPlayer(context, generator, loop) { - - // Uses Webkit Web Audio API if available - sampleRate = context.sampleRate; - - var channelCount = 2; - var bufferSize = 4096*4; // Higher for less gitches, lower for less latency - - var node = context.createScriptProcessor(bufferSize, 0, channelCount); - - node.onaudioprocess = function(e) { process(e) }; - - function process(e) { - if (generator.finished) { - if (loop) { - generator.reset(); - generator.finished = false; - } - else { - node.disconnect(); - return; - } - } - - var dataLeft = e.outputBuffer.getChannelData(0); - var dataRight = e.outputBuffer.getChannelData(1); - - var generate = generator.generate(bufferSize); - - for (var i = 0; i < bufferSize; ++i) { - dataLeft[i] = generate[i*2]; - dataRight[i] = generate[i*2+1]; - } - } - - // start - // node.connect(context.destination); - - return { - 'play': function () { - node.connect(context.destination); - }, - 'pause': function() { - node.disconnect(); - } - } -} -/* -class to parse the .mid file format -(depends on stream.js) -*/ -function MidiFile(data) { - function readChunk(stream) { - var id = stream.read(4); - var length = stream.readInt32(); - return { - 'id': id, - 'length': length, - 'data': stream.read(length) - }; - } - - var lastEventTypeByte; - - function readEvent(stream) { - var event = {}; - event.deltaTime = stream.readVarInt(); - var eventTypeByte = stream.readInt8(); - if ((eventTypeByte & 0xf0) == 0xf0) { - /* system / meta event */ - if (eventTypeByte == 0xff) { - /* meta event */ - event.type = 'meta'; - var subtypeByte = stream.readInt8(); - var length = stream.readVarInt(); - switch(subtypeByte) { - case 0x00: - event.subtype = 'sequenceNumber'; - if (length != 2) throw "Expected length for sequenceNumber event is 2, got " + length; - event.number = stream.readInt16(); - return event; - case 0x01: - event.subtype = 'text'; - event.text = stream.read(length); - return event; - case 0x02: - event.subtype = 'copyrightNotice'; - event.text = stream.read(length); - return event; - case 0x03: - event.subtype = 'trackName'; - event.text = stream.read(length); - return event; - case 0x04: - event.subtype = 'instrumentName'; - event.text = stream.read(length); - return event; - case 0x05: - event.subtype = 'lyrics'; - event.text = stream.read(length); - return event; - case 0x06: - event.subtype = 'marker'; - event.text = stream.read(length); - return event; - case 0x07: - event.subtype = 'cuePoint'; - event.text = stream.read(length); - return event; - case 0x20: - event.subtype = 'midiChannelPrefix'; - if (length != 1) throw "Expected length for midiChannelPrefix event is 1, got " + length; - event.channel = stream.readInt8(); - return event; - case 0x2f: - event.subtype = 'endOfTrack'; - if (length != 0) throw "Expected length for endOfTrack event is 0, got " + length; - return event; - case 0x51: - event.subtype = 'setTempo'; - if (length != 3) throw "Expected length for setTempo event is 3, got " + length; - event.microsecondsPerBeat = ( - (stream.readInt8() << 16) - + (stream.readInt8() << 8) - + stream.readInt8() - ) - return event; - case 0x54: - event.subtype = 'smpteOffset'; - if (length != 5) throw "Expected length for smpteOffset event is 5, got " + length; - var hourByte = stream.readInt8(); - event.frameRate = { - 0x00: 24, 0x20: 25, 0x40: 29, 0x60: 30 - }[hourByte & 0x60]; - event.hour = hourByte & 0x1f; - event.min = stream.readInt8(); - event.sec = stream.readInt8(); - event.frame = stream.readInt8(); - event.subframe = stream.readInt8(); - return event; - case 0x58: - event.subtype = 'timeSignature'; - if (length != 4) throw "Expected length for timeSignature event is 4, got " + length; - event.numerator = stream.readInt8(); - event.denominator = Math.pow(2, stream.readInt8()); - event.metronome = stream.readInt8(); - event.thirtyseconds = stream.readInt8(); - return event; - case 0x59: - event.subtype = 'keySignature'; - if (length != 2) throw "Expected length for keySignature event is 2, got " + length; - event.key = stream.readInt8(true); - event.scale = stream.readInt8(); - return event; - case 0x7f: - event.subtype = 'sequencerSpecific'; - event.data = stream.read(length); - return event; - default: - // console.log("Unrecognised meta event subtype: " + subtypeByte); - event.subtype = 'unknown' - event.data = stream.read(length); - return event; - } - event.data = stream.read(length); - return event; - } else if (eventTypeByte == 0xf0) { - event.type = 'sysEx'; - var length = stream.readVarInt(); - event.data = stream.read(length); - return event; - } else if (eventTypeByte == 0xf7) { - event.type = 'dividedSysEx'; - var length = stream.readVarInt(); - event.data = stream.read(length); - return event; - } else { - throw "Unrecognised MIDI event type byte: " + eventTypeByte; - } - } else { - /* channel event */ - var param1; - if ((eventTypeByte & 0x80) == 0) { - /* running status - reuse lastEventTypeByte as the event type. - eventTypeByte is actually the first parameter - */ - param1 = eventTypeByte; - eventTypeByte = lastEventTypeByte; - } else { - param1 = stream.readInt8(); - lastEventTypeByte = eventTypeByte; - } - var eventType = eventTypeByte >> 4; - event.channel = eventTypeByte & 0x0f; - event.type = 'channel'; - switch (eventType) { - case 0x08: - event.subtype = 'noteOff'; - event.noteNumber = param1; - event.velocity = stream.readInt8(); - return event; - case 0x09: - event.noteNumber = param1; - event.velocity = stream.readInt8(); - if (event.velocity == 0) { - event.subtype = 'noteOff'; - } else { - event.subtype = 'noteOn'; - } - return event; - case 0x0a: - event.subtype = 'noteAftertouch'; - event.noteNumber = param1; - event.amount = stream.readInt8(); - return event; - case 0x0b: - event.subtype = 'controller'; - event.controllerType = param1; - event.value = stream.readInt8(); - return event; - case 0x0c: - event.subtype = 'programChange'; - event.programNumber = param1; - return event; - case 0x0d: - event.subtype = 'channelAftertouch'; - event.amount = param1; - return event; - case 0x0e: - event.subtype = 'pitchBend'; - event.value = param1 + (stream.readInt8() << 7); - return event; - default: - throw "Unrecognised MIDI event type: " + eventType - } - } - } - - stream = Stream(data); - var headerChunk = readChunk(stream); - if (headerChunk.id != 'MThd' || headerChunk.length != 6) { - throw "Bad .mid file - header not found"; - } - var headerStream = Stream(headerChunk.data); - var formatType = headerStream.readInt16(); - var trackCount = headerStream.readInt16(); - var timeDivision = headerStream.readInt16(); - - if (timeDivision & 0x8000) { - throw "Expressing time division in SMTPE frames is not supported yet" - } else { - ticksPerBeat = timeDivision; - } - - var header = { - 'formatType': formatType, - 'trackCount': trackCount, - 'ticksPerBeat': ticksPerBeat - } - var tracks = []; - for (var i = 0; i < header.trackCount; i++) { - tracks[i] = []; - var trackChunk = readChunk(stream); - if (trackChunk.id != 'MTrk') { - throw "Unexpected chunk - expected MTrk, got "+ trackChunk.id; - } - var trackStream = Stream(trackChunk.data); - while (!trackStream.eof()) { - var event = readEvent(trackStream); - tracks[i].push(event); - //console.log(event); - } - } - - return { - 'header': header, - 'tracks': tracks - } -} -function Replayer(midiFile, synth) { - var trackStates = []; - var beatsPerMinute = 120; - var ticksPerBeat = midiFile.header.ticksPerBeat; - var channelCount = 16; - var channels = []; - var nextEventInfo; - var samplesToNextEvent; - - function Channel() { - - var generatorsByNote = {}; - var currentProgram = PianoProgram; - - function noteOn(note, velocity) { - if (generatorsByNote[note] && !generatorsByNote[note].released) { - /* playing same note before releasing the last one. BOO */ - generatorsByNote[note].noteOff(); /* TODO: check whether we ought to be passing a velocity in */ - } - generator = currentProgram.createNote(note, velocity); - synth.addGenerator(generator); - generatorsByNote[note] = generator; - } - function noteOff(note, velocity) { - if (generatorsByNote[note] && !generatorsByNote[note].released) { - generatorsByNote[note].noteOff(velocity); - } - } - function setProgram(programNumber) { - currentProgram = PROGRAMS[programNumber] || PianoProgram; - } - - return { - 'noteOn': noteOn, - 'noteOff': noteOff, - 'setProgram': setProgram - } - } - - function getNextEvent() { - var ticksToNextEvent = null; - var nextEventTrack = null; - var nextEventIndex = null; - - for (var i = 0; i < trackStates.length; i++) { - if ( - trackStates[i].ticksToNextEvent != null - && (ticksToNextEvent == null || trackStates[i].ticksToNextEvent < ticksToNextEvent) - ) { - ticksToNextEvent = trackStates[i].ticksToNextEvent; - nextEventTrack = i; - nextEventIndex = trackStates[i].nextEventIndex; - } - } - if (nextEventTrack != null) { - /* consume event from that track */ - var nextEvent = midiFile.tracks[nextEventTrack][nextEventIndex]; - if (midiFile.tracks[nextEventTrack][nextEventIndex + 1]) { - trackStates[nextEventTrack].ticksToNextEvent += midiFile.tracks[nextEventTrack][nextEventIndex + 1].deltaTime; - } else { - trackStates[nextEventTrack].ticksToNextEvent = null; - } - trackStates[nextEventTrack].nextEventIndex += 1; - /* advance timings on all tracks by ticksToNextEvent */ - for (var i = 0; i < trackStates.length; i++) { - if (trackStates[i].ticksToNextEvent != null) { - trackStates[i].ticksToNextEvent -= ticksToNextEvent - } - } - nextEventInfo = { - 'ticksToEvent': ticksToNextEvent, - 'event': nextEvent, - 'track': nextEventTrack - } - var beatsToNextEvent = ticksToNextEvent / ticksPerBeat; - var secondsToNextEvent = beatsToNextEvent / (beatsPerMinute / 60); - samplesToNextEvent += secondsToNextEvent * synth.sampleRate; - } else { - nextEventInfo = null; - samplesToNextEvent = null; - self.finished = true; - } - } - - function generate(samples) { - var data = new Array(samples*2); - var samplesRemaining = samples; - var dataOffset = 0; - - while (true) { - if (samplesToNextEvent != null && samplesToNextEvent <= samplesRemaining) { - /* generate samplesToNextEvent samples, process event and repeat */ - var samplesToGenerate = Math.ceil(samplesToNextEvent); - if (samplesToGenerate > 0) { - synth.generateIntoBuffer(samplesToGenerate, data, dataOffset); - dataOffset += samplesToGenerate * 2; - samplesRemaining -= samplesToGenerate; - samplesToNextEvent -= samplesToGenerate; - } - - handleEvent(); - getNextEvent(); - } else { - /* generate samples to end of buffer */ - if (samplesRemaining > 0) { - synth.generateIntoBuffer(samplesRemaining, data, dataOffset); - samplesToNextEvent -= samplesRemaining; - } - break; - } - } - return data; - } - - function handleEvent() { - var event = nextEventInfo.event; - switch (event.type) { - case 'meta': - switch (event.subtype) { - case 'setTempo': - beatsPerMinute = 60000000 / event.microsecondsPerBeat - } - break; - case 'channel': - switch (event.subtype) { - case 'noteOn': - channels[event.channel].noteOn(event.noteNumber, event.velocity); - break; - case 'noteOff': - channels[event.channel].noteOff(event.noteNumber, event.velocity); - break; - case 'programChange': - //console.log('program change to ' + event.programNumber); - channels[event.channel].setProgram(event.programNumber); - break; - } - break; - } - } - - function reset() { - for (var i = 0; i < midiFile.tracks.length; i++) { - trackStates[i] = { - 'nextEventIndex': 0, - 'ticksToNextEvent': ( - midiFile.tracks[i].length ? - midiFile.tracks[i][0].deltaTime : - null - ) - }; - } - for (var i = 0; i < channelCount; i++) { - channels[i] = Channel(); - } - samplesToNextEvent = 0; - getNextEvent(); - } - - reset(); - - var self = { - 'reset': reset, - 'generate': generate, - 'finished': false - } - return self; -} -/* Wrapper for accessing strings through sequential reads */ -function Stream(str) { - var position = 0; - - function read(length) { - var result = str.substr(position, length); - position += length; - return result; - } - - /* read a big-endian 32-bit integer */ - function readInt32() { - var result = ( - (str.charCodeAt(position) << 24) - + (str.charCodeAt(position + 1) << 16) - + (str.charCodeAt(position + 2) << 8) - + str.charCodeAt(position + 3)); - position += 4; - return result; - } - - /* read a big-endian 16-bit integer */ - function readInt16() { - var result = ( - (str.charCodeAt(position) << 8) - + str.charCodeAt(position + 1)); - position += 2; - return result; - } - - /* read an 8-bit integer */ - function readInt8(signed) { - var result = str.charCodeAt(position); - if (signed && result > 127) result -= 256; - position += 1; - return result; - } - - function eof() { - return position >= str.length; - } - - /* read a MIDI-style variable-length integer - (big-endian value in groups of 7 bits, - with top bit set to signify that another byte follows) - */ - function readVarInt() { - var result = 0; - while (true) { - var b = readInt8(); - if (b & 0x80) { - result += (b & 0x7f); - result <<= 7; - } else { - /* b is the last byte */ - return result + b; - } - } - } - - return { - 'eof': eof, - 'read': read, - 'readInt32': readInt32, - 'readInt16': readInt16, - 'readInt8': readInt8, - 'readVarInt': readVarInt - } -} -function SineGenerator(freq) { - var self = {'alive': true}; - var period = sampleRate / freq; - var t = 0; - - self.generate = function(buf, offset, count) { - for (; count; count--) { - var phase = t / period; - var result = Math.sin(phase * 2 * Math.PI); - buf[offset++] += result; - buf[offset++] += result; - t++; - } - } - - return self; -} - -function SquareGenerator(freq, phase) { - var self = {'alive': true}; - var period = sampleRate / freq; - var t = 0; - - self.generate = function(buf, offset, count) { - for (; count; count--) { - var result = ( (t / period) % 1 > phase ? 1 : -1); - buf[offset++] += result; - buf[offset++] += result; - t++; - } - } - - return self; -} - -function ADSRGenerator(child, attackAmplitude, sustainAmplitude, attackTimeS, decayTimeS, releaseTimeS) { - var self = {'alive': true} - var attackTime = sampleRate * attackTimeS; - var decayTime = sampleRate * (attackTimeS + decayTimeS); - var decayRate = (attackAmplitude - sustainAmplitude) / (decayTime - attackTime); - var releaseTime = null; /* not known yet */ - var endTime = null; /* not known yet */ - var releaseRate = sustainAmplitude / (sampleRate * releaseTimeS); - var t = 0; - - self.noteOff = function() { - if (self.released) return; - releaseTime = t; - self.released = true; - endTime = releaseTime + sampleRate * releaseTimeS; - } - - self.generate = function(buf, offset, count) { - if (!self.alive) return; - var input = new Array(count * 2); - for (var i = 0; i < count*2; i++) { - input[i] = 0; - } - child.generate(input, 0, count); - - childOffset = 0; - while(count) { - if (releaseTime != null) { - if (t < endTime) { - /* release */ - while(count && t < endTime) { - var ampl = sustainAmplitude - releaseRate * (t - releaseTime); - buf[offset++] += input[childOffset++] * ampl; - buf[offset++] += input[childOffset++] * ampl; - t++; - count--; - } - } else { - /* dead */ - self.alive = false; - return; - } - } else if (t < attackTime) { - /* attack */ - while(count && t < attackTime) { - var ampl = attackAmplitude * t / attackTime; - buf[offset++] += input[childOffset++] * ampl; - buf[offset++] += input[childOffset++] * ampl; - t++; - count--; - } - } else if (t < decayTime) { - /* decay */ - while(count && t < decayTime) { - var ampl = attackAmplitude - decayRate * (t - attackTime); - buf[offset++] += input[childOffset++] * ampl; - buf[offset++] += input[childOffset++] * ampl; - t++; - count--; - } - } else { - /* sustain */ - while(count) { - buf[offset++] += input[childOffset++] * sustainAmplitude; - buf[offset++] += input[childOffset++] * sustainAmplitude; - t++; - count--; - } - } - } - } - - return self; -} - -function midiToFrequency(note) { - return 440 * Math.pow(2, (note-69)/12); -} - -PianoProgram = { - 'attackAmplitude': 0.2, - 'sustainAmplitude': 0.1, - 'attackTime': 0.02, - 'decayTime': 0.3, - 'releaseTime': 0.02, - 'createNote': function(note, velocity) { - var frequency = midiToFrequency(note); - return ADSRGenerator( - SineGenerator(frequency), - this.attackAmplitude * (velocity / 128), this.sustainAmplitude * (velocity / 128), - this.attackTime, this.decayTime, this.releaseTime - ); - } -} - -StringProgram = { - 'createNote': function(note, velocity) { - var frequency = midiToFrequency(note); - return ADSRGenerator( - SineGenerator(frequency), - 0.5 * (velocity / 128), 0.2 * (velocity / 128), - 0.4, 0.8, 0.4 - ); - } -} - -PROGRAMS = { - 41: StringProgram, - 42: StringProgram, - 43: StringProgram, - 44: StringProgram, - 45: StringProgram, - 46: StringProgram, - 47: StringProgram, - 49: StringProgram, - 50: StringProgram -}; - -function Synth(sampleRate) { - - var generators = []; - - function addGenerator(generator) { - generators.push(generator); - } - - function generate(samples) { - var data = new Array(samples*2); - generateIntoBuffer(samples, data, 0); - return data; - } - - function generateIntoBuffer(samplesToGenerate, buffer, offset) { - for (var i = offset; i < offset + samplesToGenerate * 2; i++) { - buffer[i] = 0; - } - for (var i = generators.length - 1; i >= 0; i--) { - generators[i].generate(buffer, offset, samplesToGenerate); - if (!generators[i].alive) generators.splice(i, 1); - } - } - - return { - 'sampleRate': sampleRate, - 'addGenerator': addGenerator, - 'generate': generate, - 'generateIntoBuffer': generateIntoBuffer - } -} diff --git a/libs/thirdparty/mid.min.js b/libs/thirdparty/mid.min.js deleted file mode 100644 index 62466cc1..00000000 --- a/libs/thirdparty/mid.min.js +++ /dev/null @@ -1 +0,0 @@ -var sampleRate=44100;function AudioPlayer(b,f,a){sampleRate=b.sampleRate;var c=2;var g=4096*4;var d=b.createScriptProcessor(g,0,c);d.onaudioprocess=function(h){e(h)};function e(m){if(f.finished){if(a){f.reset();f.finished=false}else{d.disconnect();return}}var l=m.outputBuffer.getChannelData(0);var k=m.outputBuffer.getChannelData(1);var h=f.generate(g);for(var j=0;j>4;u.channel=t&15;u.type="channel";switch(i){case 8:u.subtype="noteOff";u.noteNumber=v;u.velocity=w.readInt8();return u;case 9:u.noteNumber=v;u.velocity=w.readInt8();if(u.velocity==0){u.subtype="noteOff"}else{u.subtype="noteOn"}return u;case 10:u.subtype="noteAftertouch";u.noteNumber=v;u.amount=w.readInt8();return u;case 11:u.subtype="controller";u.controllerType=v;u.value=w.readInt8();return u;case 12:u.subtype="programChange";u.programNumber=v;return u;case 13:u.subtype="channelAftertouch";u.amount=v;return u;case 14:u.subtype="pitchBend";u.value=v+(w.readInt8()<<7);return u;default:throw"Unrecognised MIDI event type: "+i}}}stream=Stream(g);var k=a(stream);if(k.id!="MThd"||k.length!=6){throw"Bad .mid file - header not found"}var f=Stream(k.data);var d=f.readInt16();var h=f.readInt16();var p=f.readInt16();if(p&32768){throw"Expressing time division in SMTPE frames is not supported yet"}else{ticksPerBeat=p}var j={"formatType":d,"trackCount":h,"ticksPerBeat":ticksPerBeat};var m=[];for(var e=0;e0){c.generateIntoBuffer(r,t,p);p+=r*2;s-=r;e-=r}i();g()}else{if(s>0){c.generateIntoBuffer(s,t,p);e-=s}break}}return t}function i(){var p=m.event;switch(p.type){case"meta":switch(p.subtype){case"setTempo":o=60000000/p.microsecondsPerBeat}break;case"channel":switch(p.subtype){case"noteOn":d[p.channel].noteOn(p.noteNumber,p.velocity);break;case"noteOff":d[p.channel].noteOff(p.noteNumber,p.velocity);break;case"programChange":d[p.channel].setProgram(p.programNumber);break}break}}function f(){for(var p=0;p127){i-=256}b+=1;return i}function c(){return b>=g.length}function d(){var j=0;while(true){var i=h();if(i&128){j+=(i&127);j<<=7}else{return j+i}}}return{"eof":c,"read":e,"readInt32":f,"readInt16":a,"readInt8":h,"readVarInt":d}}function SineGenerator(c){var a={"alive":true};var d=sampleRate/c;var b=0;a.generate=function(g,i,h){for(;h;h--){var f=b/d;var e=Math.sin(f*2*Math.PI);g[i++]+=e;g[i++]+=e;b++}};return a}function SquareGenerator(d,a){var b={"alive":true};var e=sampleRate/d;var c=0;b.generate=function(g,i,h){for(;h;h--){var f=((c/e)%1>a?1:-1);g[i++]+=f;g[i++]+=f;c++}};return b}function ADSRGenerator(c,i,k,h,l,j){var n={"alive":true};var f=sampleRate*h;var g=sampleRate*(h+l);var b=(i-k)/(g-f);var a=null;var e=null;var d=k/(sampleRate*j);var m=0;n.noteOff=function(){if(n.released){return}a=m;n.released=true;e=a+sampleRate*j};n.generate=function(p,t,s){if(!n.alive){return}var o=new Array(s*2);for(var r=0;r=0;g--){c[g].generate(f,j,h);if(!c[g].alive){c.splice(g,1)}}}return{"sampleRate":b,"addGenerator":e,"generate":a,"generateIntoBuffer":d}}; \ No newline at end of file diff --git a/libs/ui.js b/libs/ui.js index 204796d0..c7182d51 100644 --- a/libs/ui.js +++ b/libs/ui.js @@ -108,9 +108,9 @@ ui.prototype.fillBoldText = function (name, text, x, y, style, strokeStyle, font if (!ctx) return; if (font) ctx.font = font; if (!style) style = ctx.fillStyle; - if (style instanceof Array) style = core.arrayToRGBA(style); + style = core.arrayToRGBA(style); if (!strokeStyle) strokeStyle = '#000000'; - if (strokeStyle instanceof Array) strokeStyle = core.arrayToRGBA(strokeStyle); + strokeStyle = core.arrayToRGBA(strokeStyle); ctx.fillStyle = strokeStyle; ctx.fillText(text, x-1, y-1); ctx.fillText(text, x-1, y+1); @@ -392,15 +392,13 @@ ui.prototype.setOpacity = function (name, opacity) { ////// 设置某个canvas的绘制属性(如颜色等) ////// ui.prototype.setFillStyle = function (name, style) { var ctx = this.getContextByName(name); - if (style instanceof Array) style = core.arrayToRGBA(style); - if (ctx) ctx.fillStyle = style; + if (ctx) ctx.fillStyle = core.arrayToRGBA(style); } ////// 设置某个canvas边框属性 ////// ui.prototype.setStrokeStyle = function (name, style) { var ctx = this.getContextByName(name); - if (style instanceof Array) style = core.arrayToRGBA(style); - if (ctx) ctx.strokeStyle = style; + if (ctx) ctx.strokeStyle = core.arrayToRGBA(style); } ////// 设置某个canvas的对齐 ////// @@ -507,32 +505,61 @@ ui.prototype.splitLines = function (name, text, maxWidth, font) { ////// 绘制一张图片 ////// ui.prototype.drawImage = function (name, image, x, y, w, h, x1, y1, w1, h1) { + // 检测文件名以 :x, :y, :o 结尾,表示左右翻转,上下翻转和中心翻转 var ctx = this.getContextByName(name); if (!ctx) return; + var reverse = null; if (typeof image == 'string') { + if (image.endsWith(':x') || image.endsWith(':y') || image.endsWith(':o')) { + reverse = image.charAt(image.length - 1); + image = image.substring(0, image.length - 2); + } image = core.getMappedName(image); image = core.material.images.images[image]; - if (!image) return; + if (!image || !(image instanceof Image)) return; } + var scale = { + 'x': [-1, 1], + 'y': [1, -1], + 'o': [-1, -1] + }; + // 只能接受2, 4, 8个参数 if (x != null && y != null) { - if (w != null && h != null) { - if (x1 != null && y1 != null && w1 != null && h1 != null) { + if (w == null || h == null) { + // 两个参数变成四个参数 + w = image.width; + h = image.height; + } + if (x1 != null && y1 != null && w1 != null && h1 != null) { + if (reverse == null) { ctx.drawImage(image, x, y, w, h, x1, y1, w1, h1); - return; + } else { + ctx.save(); + ctx.translate(x1 + w1 / 2, y1 + h1 / 2); + ctx.scale(scale[reverse][0], scale[reverse][1]); + ctx.drawImage(image, x, y, w, h, -w1 / 2, -h1 / 2, w1, h1); + ctx.restore(); } - ctx.drawImage(image, x, y, w, h); return; } - ctx.drawImage(image, x, y); + if (reverse == null) { + ctx.drawImage(image, x, y, w, h); + } else { + ctx.save(); + ctx.translate(x + w / 2, y + h / 2); + ctx.scale(scale[reverse][0], scale[reverse][1]); + ctx.drawImage(image, -w / 2, -h / 2, w, h); + ctx.restore(); + } return; } } ui.prototype._uievent_drawImage = function (data) { this._createUIEvent(); - this.drawImage('uievent', data.image, core.calValue(data.x), core.calValue(data.y), core.calValue(data.w), core.calValue(data.h), + this.drawImage('uievent', data.image + (data.reverse || ''), core.calValue(data.x), core.calValue(data.y), core.calValue(data.w), core.calValue(data.h), core.calValue(data.x1), core.calValue(data.y1), core.calValue(data.w1), core.calValue(data.h1)); } @@ -547,7 +574,7 @@ ui.prototype.drawIcon = function (name, id, x, y, w, h, frame) { info = {image: core.statusBar.icons[id], posX: 0, posY: 0, height: 32}; else return; } - ctx.drawImage(info.image, 32 * (info.posX + frame), info.height * info.posY, 32, info.height, x, y, w || 32, h || info.height); + core.drawImage(ctx, info.image, 32 * (info.posX + frame), info.height * info.posY, 32, info.height, x, y, w || 32, h || info.height); } ui.prototype._uievent_drawIcon = function (data) { @@ -567,7 +594,7 @@ ui.prototype.closePanel = function () { if (core.status.hero && core.status.hero.flags) { // 清除全部临时变量 Object.keys(core.status.hero.flags).forEach(function (name) { - if (name.startsWith("@temp@")) { + if (name.startsWith("@temp@") || /^arg\d+$/.test(name)) { delete core.status.hero.flags[name]; } }); @@ -723,7 +750,7 @@ ui.prototype._getPosition = function (content) { py = core.status.event.data.y; } content = content.replace("\b", "\\b") - .replace(/\\b\[(up|center|down|hero|null)(,(hero|null|\d+,\d+|\d+))?]/g, function (s0, s1, s2, s3) { + .replace(/\\b\[(up|center|down|hero|this)(,(hero|null|\d+,\d+|\d+))?]/g, function (s0, s1, s2, s3) { pos = s1; if (s3 == 'hero' || s1=='hero' && !s3) { px = core.status.hero.loc.x; @@ -747,7 +774,7 @@ ui.prototype._getPosition = function (content) { noPeak = core.getBlockId(px, py) == null; } } - if(pos=='hero' || pos=='null'){ + if(pos=='hero' || pos=='this'){ pos = py==null?'center':(py>=core.__HALF_SIZE__? 'up':'down'); } return ""; @@ -792,64 +819,53 @@ ui.prototype._clearUIEventSelector = function (codes) { ui.prototype._drawSelector = function (ctx, background, w, h, left, top) { left = left || 0; top = top || 0; - ctx = this.getContextByName(ctx); - if (!ctx) return; - if (typeof background == 'string') - background = core.material.images.images[background]; - if (!(background instanceof Image)) return; // back - ctx.drawImage(background, 130, 66, 28, 28, left+2, top+2, w-4, h-4); + core.drawImage(ctx, background, 130, 66, 28, 28, left+2, top+2, w-4, h-4); // corner - ctx.drawImage(background, 128, 64, 2, 2, left, top, 2, 2); - ctx.drawImage(background, 158, 64, 2, 2, left+w-2, top, 2, 2); - ctx.drawImage(background, 128, 94, 2, 2, left, top+h-2, 2, 2); - ctx.drawImage(background, 158, 94, 2, 2, left+w-2, top+h-2, 2, 2); + core.drawImage(ctx, background, 128, 64, 2, 2, left, top, 2, 2); + core.drawImage(ctx, background, 158, 64, 2, 2, left+w-2, top, 2, 2); + core.drawImage(ctx, background, 128, 94, 2, 2, left, top+h-2, 2, 2); + core.drawImage(ctx, background, 158, 94, 2, 2, left+w-2, top+h-2, 2, 2); // border - ctx.drawImage(background, 130, 64, 28, 2, left+2, top, w-4, 2); - ctx.drawImage(background, 130, 94, 28, 2, left+2, top+h-2, w-4, 2); - ctx.drawImage(background, 128, 66, 2, 28, left, top+2, 2,h-4); - ctx.drawImage(background, 158, 66, 2, 28, left+w-2, top+2, 2,h-4); + core.drawImage(ctx, background, 130, 64, 28, 2, left+2, top, w-4, 2); + core.drawImage(ctx, background, 130, 94, 28, 2, left+2, top+h-2, w-4, 2); + core.drawImage(ctx, background, 128, 66, 2, 28, left, top+2, 2,h-4); + core.drawImage(ctx, background, 158, 66, 2, 28, left+w-2, top+2, 2,h-4); } ////// 绘制 WindowSkin ui.prototype.drawWindowSkin = function(background, ctx, x, y, w, h, direction, px, py) { background = background || core.status.textAttribute.background; - if (typeof background == 'string') { - background = core.getMappedName(background); - background = core.material.images.images[background]; - } // 仿RM窗口皮肤 ↓ - var dstImage = core.getContextByName(ctx); - if (!dstImage) return; // 绘制背景 - dstImage.drawImage(background, 0, 0, 128, 128, x+2, y+2, w-4, h-4); + core.drawImage(ctx, background, 0, 0, 128, 128, x+2, y+2, w-4, h-4); // 绘制边框 // 上方 - dstImage.drawImage(background, 128, 0, 16, 16, x, y, 16, 16); + core.drawImage(ctx, background, 128, 0, 16, 16, x, y, 16, 16); for (var dx = 0; dx < w - 64; dx += 32) { - dstImage.drawImage(background, 144, 0, 32, 16,x+dx+16, y, 32, 16); - dstImage.drawImage(background, 144,48, 32, 16,x+dx+16, y+h-16, 32, 16); + 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); } - dstImage.drawImage(background, 144, 0,w-dx-32, 16,x+dx+16, y,w-dx-32, 16); - dstImage.drawImage(background, 144,48,w-dx-32, 16,x+dx+16, y+h-16,w-dx-32, 16); - dstImage.drawImage(background, 176, 0, 16, 16, x+w-16, y, 16, 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) { - dstImage.drawImage(background, 128,16, 16, 32, x,y+dy+16, 16, 32); - dstImage.drawImage(background, 176,16, 16, 32, x+w-16,y+dy+16, 16, 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); } - dstImage.drawImage(background, 128,16, 16,h-dy-32, x,y+dy+16, 16,h-dy-32); - dstImage.drawImage(background, 176,16, 16,h-dy-32, x+w-16,y+dy+16, 16,h-dy-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); // 下方 - dstImage.drawImage(background, 128,48, 16, 16, x, y+h-16, 16, 16); - dstImage.drawImage(background, 176,48, 16, 16, x+w-16, y+h-16, 16, 16); + 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'){ - dstImage.drawImage(background,128,96,32,32,px,y+h-3,32,32); + core.drawImage(ctx, background,128,96,32,32,px,y+h-3,32,32); }else if(direction == 'down') { - dstImage.drawImage(background,160,96,32,32,px,y-29,32,32); + core.drawImage(ctx, background,160,96,32,32,px,y-29,32,32); } } // 仿RM窗口皮肤 ↑ @@ -903,7 +919,7 @@ ui.prototype._drawBackground_drawWindowSkin = function (background, left, top, r ui.prototype._drawBackground_drawColor = function (background, left, top, right, bottom, position, px, py, xoffset, yoffset) { var alpha = background[3]; core.setAlpha('ui', alpha); - core.setStrokeStyle('ui', core.status.globalAttribute.borderColor); + core.setStrokeStyle('ui', core.arrayToRGBA(core.status.globalAttribute.borderColor)); core.setFillStyle('ui', core.arrayToRGB(background)); core.setLineWidth('ui', 2); // 绘制 @@ -956,6 +972,7 @@ ui.prototype._getDrawableIconInfo = function (id) { if (id && id.indexOf('flag:') === 0) { id = core.getFlag(id.substring(5), id); } + id = core.getIdOfThis(id); var image = null, icon = null; ["terrains","animates","items","npcs","enemys"].forEach(function (v) { if (core.material.icons[v][id] != null) { @@ -991,8 +1008,7 @@ ui.prototype.drawTextContent = function (ctx, content, config) { config.left = config.left || 0; config.right = config.left + (config.maxWidth == null ? (ctx != null ? ctx.canvas.width : core.__PIXELS__) : config.maxWidth) config.top = config.top || 0; - config.color = config.color || textAttribute.text; - if (config.color instanceof Array) config.color = core.arrayToRGBA(config.color); + config.color = core.arrayToRGBA(config.color || textAttribute.text); if (config.bold == null) config.bold = textAttribute.bold; config.italic = false; config.align = config.align || textAttribute.align || "left"; @@ -1045,7 +1061,7 @@ ui.prototype._drawTextContent_draw = function (ctx, tempCtx, content, config) { if (config.index >= config.blocks.length) return false; var block = config.blocks[config.index++]; if (block != null) { - ctx.drawImage(tempCtx.canvas, block.left, block.top, block.width, block.height, + core.drawImage(ctx, tempCtx.canvas, block.left, block.top, block.width, block.height, config.left + block.left + block.marginLeft, config.top + block.top + block.marginTop, block.width, block.height); } @@ -1283,18 +1299,14 @@ ui.prototype.drawTextBox = function(content, showAll) { ui.prototype._drawTextBox_drawImages = function (content) { return content.replace(/(\f|\\f)\[(.*?)]/g, function (text, sympol, str) { var ss = str.split(","); - if (ss.length!=3 && ss.length!=5 && ss.length!=9) return ""; - ss[0] = core.getMappedName(ss[0]); - var img = core.material.images.images[ss[0]]; - if (!img) return ""; // 绘制 if (ss.length==3) - core.drawImage('ui', img, parseFloat(ss[1]), parseFloat(ss[2])); + core.drawImage('ui', ss[0], parseFloat(ss[1]), parseFloat(ss[2])); else if (ss.length==5) - core.drawImage('ui', img, 0, 0, img.width, img.height, parseFloat(ss[1]), parseFloat(ss[2]), parseFloat(ss[3]), parseFloat(ss[4])); + core.drawImage('ui', ss[0], parseFloat(ss[1]), parseFloat(ss[2]), parseFloat(ss[3]), parseFloat(ss[4])); else if (ss.length==9 || ss.length==10) { if (ss.length==10) core.setAlpha('ui', parseFloat(ss[9])); - core.drawImage('ui', img, parseFloat(ss[1]), parseFloat(ss[2]), parseFloat(ss[3]), parseFloat(ss[4]), parseFloat(ss[5]), parseFloat(ss[6]), parseFloat(ss[7]), parseFloat(ss[8])); + core.drawImage('ui', ss[0], parseFloat(ss[1]), parseFloat(ss[2]), parseFloat(ss[3]), parseFloat(ss[4]), parseFloat(ss[5]), parseFloat(ss[6]), parseFloat(ss[7]), parseFloat(ss[8])); core.setAlpha('ui', 1); } return ""; @@ -1386,10 +1398,20 @@ ui.prototype._drawTextBox_drawTitleAndIcon = function (titleInfo, hPos, vPos, al core.status.boxAnimateObjs = []; // --- 勇士 if (titleInfo.image == core.material.images.hero) { - core.clearMap('ui', hPos.left + 15, image_top, 32, titleInfo.height); - core.fillRect('ui', hPos.left + 15, image_top, 32, titleInfo.height, core.material.groundPattern); - core.drawImage('ui', titleInfo.image, 0, 0, core.material.icons.hero.width || 32, core.material.icons.hero.height, - hPos.left + 15, image_top, 32, titleInfo.height); + 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 + }) + } else { + core.clearMap('ui', hPos.left + 15, image_top, 32, titleInfo.height); + core.fillRect('ui', hPos.left + 15, image_top, 32, titleInfo.height, core.material.groundPattern); + core.drawImage('ui', titleInfo.image, 0, 0, core.material.icons.hero.width || 32, core.material.icons.hero.height, + hPos.left + 15, image_top, 32, titleInfo.height); + } } else { core.status.boxAnimateObjs.push({ @@ -1560,8 +1582,7 @@ ui.prototype._drawChoices_drawChoices = function (choices, isWindowSkin, hPos, v core.setTextAlign('ui', 'center'); core.setFont('ui', this._buildFont(17, true)); for (var i = 0; i < choices.length; i++) { - var color = choices[i].color || core.status.textAttribute.text; - if (color instanceof Array) color = core.arrayToRGBA(color); + var color = core.arrayToRGBA(choices[i].color || core.status.textAttribute.text); core.setFillStyle('ui', color); var offset = this.HPIXEL; if (choices[i].icon) { @@ -1655,16 +1676,15 @@ ui.prototype.drawWaiting = function(text) { ui.prototype.drawSwitchs = function() { core.status.event.id = 'switchs'; var choices = [ - "背景音乐: "+(core.musicStatus.bgmStatus ? "[ON]" : "[OFF]"), - "背景音效: "+(core.musicStatus.soundStatus ? "[ON]" : "[OFF]"), + "音乐/音效: "+(core.musicStatus.bgmStatus ? "[ON]" : "[OFF]") + " "+(core.musicStatus.soundStatus ? "[ON]" : "[OFF]"), //显示为 0~10 十挡 " < 音量:" + Math.round(Math.sqrt(100 * core.musicStatus.userVolume)) + " > ", //数值越大耗时越长 " < 步时:" + core.values.moveSpeed + " > ", " < 转场:" + core.values.floorChangeTime + " > ", + " < 放缩:" + Math.max(core.domStyle.scale, 1) + "x > ", "怪物显伤: "+(core.flags.displayEnemyDamage ? "[ON]" : "[OFF]"), - "临界显伤: "+(core.flags.displayCritical ? "[ON]" : "[OFF]"), - "领域显伤: "+(core.flags.displayExtraDamage ? "[ON]" : "[OFF]"), + "临界/领域: "+(core.flags.displayCritical ? "[ON]" : "[OFF]")+" "+(core.flags.displayExtraDamage ? "[ON]" : "[OFF]"), "血瓶绕路: "+(core.hasFlag('__potionNoRouting__') ? "[ON]":"[OFF]"), "单击瞬移: "+(!core.hasFlag("__noClickMove__") ? "[ON]":"[OFF]"), "返回主菜单" @@ -1970,7 +1990,7 @@ ui.prototype.drawBookDetail = function (index) { core.fillRect('data', left, top, width, height, '#000000'); core.setAlpha('data', 1); core.strokeRect('data', left - 1, top - 1, width + 1, height + 1, - core.status.globalAttribute.borderColor, 2); + core.arrayToRGBA(core.status.globalAttribute.borderColor), 2); this._drawBookDetail_drawContent(enemy, content, {top: top, content_left: content_left, bottom: bottom, validWidth: validWidth}); } @@ -2460,23 +2480,17 @@ ui.prototype._drawEquipbox_description = function (info, max_height) { } ui.prototype._drawEquipbox_getStatusChanged = function (info, equip, equipType, y) { - var compare, differentMode = null; - if (info.index < this.LAST) compare = core.compareEquipment(null, info.selectId); - else { - if (equipType<0) differentMode = '<当前没有该装备的空位,请先卸下装备>'; - else { - var last = core.material.items[info.equipEquipment[equipType]]||{}; - if (last.equip && (last.equip.percentage || false) != (equip.equip.percentage || false)) - differentMode = '<数值和比例模式之间的切换不显示属性变化>'; - else - compare = core.compareEquipment(info.selectId, info.equipEquipment[equipType]); - } + if (info.index < this.LAST) { + // 光标在装备栏上:查询卸下装备属性 + return core.compareEquipment(null, info.selectId); } - if (differentMode != null) { - core.fillText('ui', differentMode, 10, y, '#CCCCCC', this._buildFont(14, false)); - return; + if (equipType < 0) { + // 没有空位 + core.fillText('ui', '<当前没有该装备的空位,请先卸下装备>', 10, y, '#CCCCCC', this._buildFont(14, false)); + return null; } - return compare; + // 光标在装备上:查询装上后的属性变化 + return core.compareEquipment(info.selectId, info.equipEquipment[equipType]); } ui.prototype._drawEquipbox_drawStatusChanged = function (info, y, equip, equipType) { @@ -2486,19 +2500,19 @@ ui.prototype._drawEquipbox_drawStatusChanged = function (info, y, equip, equipTy // --- 变化值... core.setFont('ui', this._buildFont(14, true)); - for (var name in compare) { + for (var name in core.status.hero) { + if (typeof core.status.hero[name] != 'number') continue; + var nowValue = core.getRealStatus(name); + // 查询新值 + var newValue = (core.getStatus(name) + (compare.value[name] || 0)) + * (core.getBuff(name) + (compare.percentage[name] || 0) / 100); + if (nowValue == newValue) continue; var text = this._drawEquipbox_getStatusName(name); this._drawEquipbox_drawStatusChanged_draw(text + " ", '#CCCCCC', obj); - var nowValue = core.getStatus(name) * core.getBuff(name), newValue = (core.getStatus(name) + compare[name]) * core.getBuff(name); - if (equip.equip.percentage) { - var nowBuff = core.getBuff(name), newBuff = nowBuff + compare[name] / 100; - nowValue = Math.floor(nowBuff * core.getStatus(name)); - newValue = Math.floor(newBuff * core.getStatus(name)); - } nowValue = core.formatBigNumber(nowValue); newValue = core.formatBigNumber(newValue); this._drawEquipbox_drawStatusChanged_draw(nowValue+"->", '#CCCCCC', obj); - this._drawEquipbox_drawStatusChanged_draw(newValue, compare[name]>0?'#00FF00':'#FF0000', obj); + this._drawEquipbox_drawStatusChanged_draw(newValue, newValue>nowValue?'#00FF00':'#FF0000', obj); obj.drawOffset += 8; } } @@ -2629,14 +2643,16 @@ ui.prototype._drawSLPanel_drawRecord = function(title, data, x, y, size, cho, hi core.fillText('ui', title, x, y, highLight?'#FFD700':'#FFFFFF', this._buildFont(17, true)); core.strokeRect('ui', x-size/2, y+15, size, size, cho?strokeColor:'#FFFFFF', cho?6:2); if (data && data.floorId) { - core.drawThumbnail(data.floorId, core.maps.loadMap(data.maps, data.floorId).blocks, { + var map = core.maps.loadMap(data.maps, data.floorId); + core.extractBlocks(map); + core.drawThumbnail(data.floorId, map.blocks, { heroLoc: data.hero.loc, heroIcon: data.hero.image, flags: data.hero.flags }, { ctx: 'ui', x: x-size/2, y: y+15, size: size, centerX: data.hero.loc.x, centerY: data.hero.loc.y }); if (core.isPlaying() && core.getFlag("hard") != data.hero.flags.hard) { core.fillRect('ui', x-size/2, y+15, size, size, [0, 0, 0, 0.4], 2); - core.fillText('ui', data.hard, x, parseInt(y+22+size/2), core.dom.hard.style.color, this._buildFont(30,true)); + core.fillText('ui', data.hard, x, parseInt(y+22+size/2), data.hero.flags.__hardColor__ || 'red', this._buildFont(30,true)); } var v = core.formatBigNumber(data.hero.hp,true)+"/"+core.formatBigNumber(data.hero.atk,true)+"/"+core.formatBigNumber(data.hero.def,true); var v2 = "/"+core.formatBigNumber(data.hero.mdef,true); @@ -2799,6 +2815,7 @@ ui.prototype._drawStatistics_add = function (floorId, obj, x1, x2, value) { } ui.prototype._drawStatistics_floorId = function (floorId, obj) { + core.extractBlocks(floorId); var floor = core.status.maps[floorId], blocks = floor.blocks; // 隐藏层不给看 if (floor.cannotViewMap && floorId!=core.status.floorId) return; @@ -2829,7 +2846,6 @@ ui.prototype._drawStatistics_items = function (floorId, floor, id, obj) { if (obj.cls[id]=='items' && id!='superPotion') { var temp = core.clone(core.status.hero); core.setFlag("__statistics__", true); - var ratio = floor.item_ratio||1; try { eval(core.items.itemEffect[id]); } catch (e) {} hp = core.status.hero.hp - temp.hp; diff --git a/libs/utils.js b/libs/utils.js index 1698c02e..cc8ac172 100644 --- a/libs/utils.js +++ b/libs/utils.js @@ -352,13 +352,13 @@ utils.prototype.splitImage = function (image, width, height) { width = width || 32; height = height || width; var canvas = document.createElement("canvas"); - var context = canvas.getContext("2d"); + var ctx = canvas.getContext("2d"); var ans = []; for (var j = 0; j < image.height; j += height) { for (var i = 0; i < image.width; i += width) { var w = Math.min(width, image.width - i), h = Math.min(height, image.height - j); canvas.width = w; canvas.height = h; - context.drawImage(image, i, j, w, h, 0, 0, w, h); + core.drawImage(ctx, image, i, j, w, h, 0, 0, w, h); var img = new Image(); img.src = canvas.toDataURL("image/png"); ans.push(img); @@ -401,6 +401,7 @@ utils.prototype.formatSize = function (size) { utils.prototype.formatBigNumber = function (x, onMap) { x = Math.floor(parseFloat(x)); if (!core.isset(x)) return '???'; + if (x > 1e24 || x < -1e24) return x; var c = x < 0 ? "-" : ""; x = Math.abs(x); @@ -436,12 +437,14 @@ utils.prototype.formatBigNumber = function (x, onMap) { ////// 数组转RGB ////// utils.prototype.arrayToRGB = function (color) { + if (!(color instanceof Array)) return color; var nowR = this.clamp(parseInt(color[0]), 0, 255), nowG = this.clamp(parseInt(color[1]), 0, 255), nowB = this.clamp(parseInt(color[2]), 0, 255); return "#" + ((1 << 24) + (nowR << 16) + (nowG << 8) + nowB).toString(16).slice(1); } utils.prototype.arrayToRGBA = function (color) { + if (!(color instanceof Array)) return color; if (color[3] == null) color[3] = 1; var nowR = this.clamp(parseInt(color[0]), 0, 255), nowG = this.clamp(parseInt(color[1]), 0, 255), nowB = this.clamp(parseInt(color[2]), 0, 255), nowA = this.clamp(parseFloat(color[3]), 0, 1); @@ -1125,51 +1128,6 @@ utils.prototype.same = function (a, b) { return false; } -utils.prototype._export = function (floorIds) { - if (!floorIds) floorIds = [core.status.floorId]; - else if (floorIds == 'all') floorIds = core.clone(core.floorIds); - else if (typeof floorIds == 'string') floorIds = [floorIds]; - - var monsterMap = {}; - - // map - var content = floorIds.length + "\n" + core.__SIZE__ + " " + core.__SIZE__ + "\n\n"; - floorIds.forEach(function (floorId) { - var arr = core.maps._getMapArrayFromBlocks(core.status.maps[floorId].blocks, core.__SIZE__, core.__SIZE__); - content += arr.map(function (x) { - // check monster - x.forEach(function (t) { - var block = core.maps.getBlockByNumber(t); - if (block.event.cls.indexOf("enemy") == 0) { - monsterMap[t] = block.event.id; - } - }) - return x.join("\t"); - }).join("\n") + "\n\n"; - }) - - // values - content += ["redJewel", "blueJewel", "greenJewel", "redPotion", "bluePotion", - "yellowPotion", "greenPotion", "sword1", "shield1"].map(function (x) { - return core.values[x] || 0; - }).join(" ") + "\n\n"; - - // monster - content += Object.keys(monsterMap).length + "\n"; - for (var t in monsterMap) { - var id = monsterMap[t], monster = core.material.enemys[id]; - content += t + " " + monster.hp + " " + monster.atk + " " + - monster.def + " " + monster.money + " " + monster.special + "\n"; - } - content += "\n0 0 0 0 0 0\n\n"; - content += core.status.hero.hp + " " + core.status.hero.atk + " " - + core.status.hero.def + " " + core.status.hero.mdef + " " + core.status.hero.money + " " - + core.itemCount('yellowKey') + " " + core.itemCount("blueKey") + " " + core.itemCount("redKey") + " 0 " - + core.status.hero.loc.x + " " + core.status.hero.loc.y + "\n"; - - console.log(content); -} - utils.prototype.unzip = function (blobOrUrl, success, error, convertToText, onprogress) { var _error = function (msg) { main.log(msg); diff --git a/main.js b/main.js index 71421aca..7f502e20 100644 --- a/main.js +++ b/main.js @@ -200,18 +200,19 @@ main.prototype.init = function (mode, callback) { var mainData = data_a1e2fb4a_e986_4524_b0da_9b7ba7c0874d.main; for(var ii in mainData)main[ii]=mainData[ii]; - main.dom.startBackground.src = main.startBackground; - main.dom.startLogo.style=main.startLogoStyle; - main.dom.startButtonGroup.style = main.startButtonsStyle; - main.levelChoose.forEach(function(value){ + main.dom.startBackground.src = main.styles.startBackground; + main.dom.startLogo.style=main.styles.startLogoStyle; + main.dom.startButtonGroup.style = main.styles.startButtonsStyle; + main.levelChoose = main.levelChoose || []; + main.levelChoose.forEach(function (value) { var span = document.createElement('span'); span.setAttribute('class','startButton'); - span.innerText=value[0]; + span.innerText=value.title || ''; (function(span,str_){ span.onclick = function () { core.events.startGame(str_); } - })(span,value[1]); + })(span,value.name||''); main.dom.levelChooseButtons.appendChild(span); }); main.createOnChoiceAnimation(); @@ -724,10 +725,9 @@ main.dom.playGame.onclick = function () { main.dom.startButtons.style.display='none'; main.core.control.checkBgm(); - if (main.core.isset(main.core.flags.startDirectly) && main.core.flags.startDirectly) { + if (main.levelChoose.length == 0) { core.events.startGame(""); - } - else { + } else { main.dom.levelChooseButtons.style.display='block'; main.selectedButton = null; main.selectButton(0); diff --git a/project/data.js b/project/data.js index 4f33fa23..40c16e7d 100644 --- a/project/data.js +++ b/project/data.js @@ -41,41 +41,48 @@ var data_a1e2fb4a_e986_4524_b0da_9b7ba7c0874d = "背景图.jpg": "bg.jpg", "背景音乐.mp3": "bgm.mp3" }, - "startBackground": "project/images/bg.jpg", - "startLogoStyle": "color: black", "levelChoose": [ - [ - "简单", - "Easy" - ], - [ - "普通", - "Normal" - ], - [ - "困难", - "Hard" - ], - [ - "噩梦", - "Hell" - ] + { + "title": "简单", + "name": "Easy", + "hard": 1, + "action": [ + { + "type": "comment", + "text": "在这里写该难度需执行的事件" + } + ] + }, + { + "title": "普通", + "name": "Normal", + "hard": 2, + "color": [ + 0, + 255, + 0, + 1 + ], + "action": [] + } ], "equipName": [ "武器", "盾牌" ], "startBgm": null, - "statusLeftBackground": "url(project/materials/ground.png) repeat", - "statusTopBackground": "url(project/materials/ground.png) repeat", - "toolsBackground": "url(project/materials/ground.png) repeat", - "borderColor": "#CCCCCC", - "statusBarColor": "white", - "hardLabelColor": "red", - "floorChangingBackground": "black", - "floorChangingTextColor": "white", - "font": "Verdana", - "startButtonsStyle": "background-color: #32369F; opacity: 0.85; color: #FFFFFF; border: #FFFFFF 2px solid; caret-color: #FFD700;" + "styles": { + "startBackground": "project/images/bg.jpg", + "startLogoStyle": "color: black", + "startButtonsStyle": "background-color: #32369F; opacity: 0.85; color: #FFFFFF; border: #FFFFFF 2px solid; caret-color: #FFD700;", + "statusLeftBackground": "url(project/materials/ground.png) repeat", + "statusTopBackground": "url(project/materials/ground.png) repeat", + "toolsBackground": "url(project/materials/ground.png) repeat", + "borderColor": [204,204,204,1], + "statusBarColor": [255,255,255,1], + "floorChangingStyle": "background-color: black; color: white", + "font": "Verdana" + } }, "firstData": { "title": "魔塔样板", @@ -84,6 +91,7 @@ var data_a1e2fb4a_e986_4524_b0da_9b7ba7c0874d = "floorId": "sample0", "hero": { "image": "hero.png", + "animate": false, "name": "阳光", "lv": 1, "hpmax": 9999, @@ -158,7 +166,7 @@ var data_a1e2fb4a_e986_4524_b0da_9b7ba7c0874d = }, { "type": "if", - "condition": "core.flags.startDirectly", + "condition": "main.levelChoose.length == 0", "true": [ { "type": "comment", @@ -172,7 +180,7 @@ var data_a1e2fb4a_e986_4524_b0da_9b7ba7c0874d = }, { "type": "function", - "function": "function(){\nvar choices = [];\nmain.levelChoose.forEach(function (one) {\n\tchoices.push({\n\t\t\"text\": one[0],\n\t\t\"action\": [\n\t\t\t{ \"type\": \"function\", \"function\": \"function() { core.status.hard = '\" + one[1] + \"'; }\" }\n\t\t]\n\t});\n})\ncore.insertAction({ \"type\": \"choices\", \"choices\": choices });\n}" + "function": "function(){\nvar choices = [];\nmain.levelChoose.forEach(function (one) {\n\tchoices.push({\n\t\t\"text\": one.title || '',\n\t\t\"action\": [\n\t\t\t{ \"type\": \"function\", \"function\": \"function() { core.status.hard = '\" + (one.name || '') + \"'; }\" }\n\t\t]\n\t});\n})\ncore.insertAction({ \"type\": \"choices\", \"choices\": choices });\n}" } ] }, @@ -219,7 +227,7 @@ var data_a1e2fb4a_e986_4524_b0da_9b7ba7c0874d = }, { "type": "if", - "condition": "!core.isReplaying()", + "condition": "(!core.isReplaying())", "true": [ { "type": "function", @@ -239,60 +247,6 @@ var data_a1e2fb4a_e986_4524_b0da_9b7ba7c0874d = } ], "startText": [ - { - "type": "comment", - "text": "根据难度分歧设置并给其他初始值" - }, - { - "type": "switch", - "condition": "core.status.hard", - "caseList": [ - { - "case": "'Easy'", - "action": [ - { - "type": "setValue", - "name": "flag:hard", - "value": "1" - }, - { - "type": "comment", - "text": "可以在这里修改初始道具或属性,比如赠送黄钥匙等" - } - ] - }, - { - "case": "'Normal'", - "action": [ - { - "type": "setValue", - "name": "flag:hard", - "value": "2" - } - ] - }, - { - "case": "'Hard'", - "action": [ - { - "type": "setValue", - "name": "flag:hard", - "value": "3" - } - ] - }, - { - "case": "'Hell'", - "action": [ - { - "type": "setValue", - "name": "flag:hard", - "value": "4" - } - ] - } - ] - }, { "type": "comment", "text": "初始剧情" @@ -303,7 +257,7 @@ var data_a1e2fb4a_e986_4524_b0da_9b7ba7c0874d = "shops": [ { "id": "shop1", - "text": "\t[贪婪之神,blueShop]勇敢的武士啊, 给我${20+2*flag:shop1}金币就可以:", + "text": "\t[贪婪之神,moneyShop]勇敢的武士啊, 给我${20+2*flag:shop1}金币就可以:", "textInList": "1F金币商店", "mustEnable": false, "disablePreview": false, @@ -368,7 +322,7 @@ var data_a1e2fb4a_e986_4524_b0da_9b7ba7c0874d = }, { "id": "shop2", - "text": "\t[贪婪之神,pinkShop]勇敢的武士啊, 给我一定经验就可以:", + "text": "\t[贪婪之神,expShop]勇敢的武士啊, 给我一定经验就可以:", "textInList": "1F经验商店", "mustEnable": false, "disablePreview": true, @@ -465,9 +419,9 @@ var data_a1e2fb4a_e986_4524_b0da_9b7ba7c0874d = "lavaDamage": 100, "poisonDamage": 10, "weakValue": 20, - "redJewel": 3, - "blueJewel": 3, - "greenJewel": 5, + "redGem": 3, + "blueGem": 3, + "greenGem": 5, "redPotion": 100, "bluePotion": 250, "yellowPotion": 500, @@ -499,7 +453,6 @@ var data_a1e2fb4a_e986_4524_b0da_9b7ba7c0874d = "betweenAttackMax": false, "useLoop": false, "startUsingCanvas": false, - "startDirectly": false, "statusCanvas": false, "displayEnemyDamage": true, "displayCritical": true, diff --git a/project/enemys.js b/project/enemys.js index f5e49f15..cf035ecf 100644 --- a/project/enemys.js +++ b/project/enemys.js @@ -1,88 +1,84 @@ var enemys_fcae963b_31c9_42b4_b48c_bb48d09f3f80 = { - "greenSlime": {"name":"绿头怪","hp":100,"atk":120,"def":0,"money":1,"experience":1,"point":0,"special":[1,5,7,8]}, - "redSlime": {"name":"红头怪","hp":0,"atk":0,"def":0,"money":0,"experience":0,"point":0,"special":[16,18],"value":10}, - "blackSlime": {"name":"青头怪","hp":0,"atk":0,"def":0,"money":0,"experience":0,"point":0,"special":0}, - "slimelord": {"name":"怪王","hp":100,"atk":120,"def":0,"money":10,"experience":0,"point":0,"special":[1,9]}, - "bat": {"name":"小蝙蝠","hp":100,"atk":120,"def":0,"money":2,"experience":0,"point":0,"special":1}, - "bigBat": {"name":"大蝙蝠","hp":0,"atk":0,"def":0,"money":0,"experience":0,"point":0,"special":0}, - "redBat": {"name":"红蝙蝠","hp":100,"atk":120,"def":0,"money":5,"experience":0,"point":0,"special":4}, - "vampire": {"name":"冥灵魔王","hp":0,"atk":0,"def":0,"money":0,"experience":0,"point":0,"special":0}, - "skeleton": {"name":"骷髅人","hp":0,"atk":0,"def":0,"money":0,"experience":0,"point":0,"special":0}, - "skeletonCaptain": {"name":"骷髅队长","hp":0,"atk":0,"def":0,"money":0,"experience":0,"point":0,"special":0}, - "zombie": {"name":"兽人","hp":0,"atk":0,"def":0,"money":0,"experience":0,"point":0,"special":0}, - "zombieKnight": {"name":"兽人武士","hp":0,"atk":0,"def":0,"money":0,"experience":0,"point":0,"special":0}, - "rock": {"name":"石头人","hp":100,"atk":120,"def":0,"money":4,"experience":0,"point":0,"special":3}, - "bluePriest": {"name":"初级法师","hp":100,"atk":120,"def":0,"money":3,"experience":0,"point":1,"special":2}, - "redPriest": {"name":"高级法师","hp":0,"atk":0,"def":0,"money":0,"experience":0,"point":0,"special":0}, - "brownWizard": {"name":"初级巫师","hp":100,"atk":120,"def":0,"money":16,"experience":0,"point":0,"special":15,"value":100,"range":2}, - "redWizard": {"name":"高级巫师","hp":1000,"atk":1200,"def":0,"money":160,"experience":0,"point":0,"special":15,"value":200,"zoneSquare":true}, - "swordsman": {"name":"双手剑士","hp":100,"atk":120,"def":0,"money":6,"experience":0,"point":0,"special":[5,23]}, - "soldier": {"name":"冥战士","hp":0,"atk":0,"def":0,"money":0,"experience":0,"point":0,"special":0}, - "yellowKnight": {"name":"金骑士","hp":0,"atk":0,"def":0,"money":0,"experience":0,"point":0,"special":0}, - "redKnight": {"name":"红骑士","hp":0,"atk":0,"def":0,"money":0,"experience":0,"point":0,"special":0}, - "darkKnight": {"name":"黑骑士","hp":0,"atk":0,"def":0,"money":0,"experience":0,"point":0,"special":0}, - "blueKnight": {"name":"蓝骑士","hp":100,"atk":120,"def":0,"money":9,"experience":0,"point":0,"special":8}, - "goldSlime": {"name":"黄头怪","hp":0,"atk":0,"def":0,"money":0,"experience":0,"point":0,"special":0}, - "poisonSkeleton": {"name":"紫骷髅","hp":0,"atk":0,"def":0,"money":0,"experience":0,"point":0,"special":0}, - "poisonBat": {"name":"紫蝙蝠","hp":100,"atk":120,"def":0,"money":14,"experience":0,"point":0,"special":13}, - "skeletonPriest": {"name":"骷髅法师","hp":100,"atk":100,"def":0,"money":0,"experience":0,"point":0,"special":18,"value":20}, - "skeletonKing": {"name":"骷髅王","hp":0,"atk":0,"def":0,"money":0,"experience":0,"point":0,"special":0}, - "evilHero": {"name":"迷失勇者","hp":0,"atk":0,"def":0,"money":0,"experience":0,"point":0,"special":0}, - "demonPriest": {"name":"魔神法师","hp":0,"atk":0,"def":0,"money":0,"experience":0,"point":0,"special":0}, - "goldHornSlime": {"name":"金角怪","hp":0,"atk":0,"def":0,"money":0,"experience":0,"point":0,"special":0}, - "silverSlime": {"name":"银头怪","hp":100,"atk":120,"def":0,"money":15,"experience":0,"point":0,"special":14}, - "whiteHornSlime": {"name":"尖角怪","hp":0,"atk":0,"def":0,"money":0,"experience":0,"point":0,"special":0}, - "redSwordsman": {"name":"剑王","hp":100,"atk":120,"def":0,"money":7,"experience":0,"point":0,"special":6,"n":8}, - "poisonZombie": {"name":"绿兽人","hp":100,"atk":120,"def":0,"money":13,"experience":0,"point":0,"special":12}, - "octopus": {"name":"血影","hp":0,"atk":0,"def":0,"money":0,"experience":0,"point":0,"special":0}, - "greenKnight": {"name":"强盾骑士","hp":0,"atk":0,"def":0,"money":0,"experience":0,"point":0,"special":0}, - "angel": {"name":"天使","hp":0,"atk":0,"def":0,"money":0,"experience":0,"point":0,"special":0}, - "elemental": {"name":"元素生物","hp":0,"atk":0,"def":0,"money":0,"experience":0,"point":0,"special":0}, - "steelGuard": {"name":"铁守卫","hp":0,"atk":0,"def":0,"money":0,"experience":0,"point":0,"special":18,"value":20}, - "evilBat": {"name":"邪恶蝙蝠","hp":1000,"atk":1,"def":0,"money":0,"experience":0,"point":0,"special":[2,3]}, - "frozenSkeleton": {"name":"冻死骨","hp":0,"atk":0,"def":0,"money":0,"experience":0,"point":0,"special":0}, - "silverSlimelord": {"name":"银怪王","hp":0,"atk":0,"def":0,"money":0,"experience":0,"point":0,"special":0}, - "goldSlimelord": {"name":"金怪王","hp":0,"atk":0,"def":0,"money":0,"experience":0,"point":0,"special":0}, - "skeletonWarrior": {"name":"骷髅士兵","hp":0,"atk":0,"def":0,"money":0,"experience":0,"point":0,"special":0}, - "ghostWarrior": {"name":"冥队长","hp":100,"atk":120,"def":0,"money":8,"experience":0,"point":0,"special":7}, - "whiteSlimeman": {"name":"水银战士","hp":0,"atk":0,"def":0,"money":0,"experience":0,"point":0,"special":0}, - "slimeman": {"name":"影子战士","hp":100,"atk":0,"def":0,"money":11,"experience":0,"point":0,"special":[10,21],"atkValue":2,"defValue":3}, - "yellowGT": {"name":"初级卫兵","hp":100,"atk":120,"def":0,"money":10,"experience":0,"point":0,"special":0}, - "blueGT": {"name":"中级卫兵","hp":0,"atk":0,"def":0,"money":0,"experience":0,"point":0,"special":0}, - "redGT": {"name":"高级卫兵","hp":0,"atk":0,"def":0,"money":0,"experience":0,"point":0,"special":0}, - "blackMS": {"name":"黑衣魔王","hp":1000,"atk":500,"def":0,"money":1000,"experience":1000,"point":0,"special":0,"notBomb":true}, - "yellowMS": {"name":"黄衣魔王","hp":0,"atk":0,"def":0,"money":0,"experience":0,"point":0,"special":0}, - "greenMS": {"name":"青衣武士","hp":0,"atk":0,"def":0,"money":0,"experience":0,"point":0,"special":0}, - "magicMaster": {"name":"黑暗大法师","hp":100,"atk":120,"def":0,"money":12,"experience":0,"point":0,"special":11,"value":0.3333333333333333,"add":true,"notBomb":true}, - "blueMS": {"name":"白衣武士","hp":100,"atk":120,"def":0,"money":17,"experience":0,"point":0,"special":16}, - "redMS": {"name":"红衣魔王","hp":0,"atk":0,"def":0,"money":0,"experience":0,"point":0,"special":0}, - "devilWarrior": {"name":"魔神武士","hp":0,"atk":0,"def":0,"money":0,"experience":0,"point":0,"special":0}, - "fairyEnemy": {"name":"仙子","hp":0,"atk":0,"def":0,"money":0,"experience":0,"point":0,"special":0}, - "dragon": {"name":"魔龙","hp":0,"atk":0,"def":0,"money":0,"experience":0,"point":0,"special":0}, - "skeletonKnight": {"name":"骷髅武士","hp":0,"atk":0,"def":0,"money":0,"experience":0,"point":0,"special":0}, - "skeletonPresbyter": {"name":"骷髅巫师","hp":0,"atk":0,"def":0,"money":0,"experience":0,"point":0,"special":0}, - "ironRock": {"name":"铁面人","hp":0,"atk":0,"def":0,"money":0,"experience":0,"point":0,"special":0}, - "grayRock": {"name":"灰色石头人","hp":0,"atk":0,"def":0,"money":0,"experience":0,"point":0,"special":0}, - "yellowPriest": {"name":"中级法师","hp":0,"atk":0,"def":0,"money":0,"experience":0,"point":0,"special":0}, - "evilPrincess": {"name":"痛苦魔女","hp":0,"atk":0,"def":0,"money":0,"experience":0,"point":0,"special":0}, - "blademaster": {"name":"剑圣","hp":0,"atk":0,"def":0,"money":0,"experience":0,"point":0,"special":0}, - "evilFairy": {"name":"黑暗仙子","hp":0,"atk":0,"def":0,"money":0,"experience":0,"point":0,"special":0}, - "blueRock": {"name":"鬼邪石","hp":0,"atk":0,"def":0,"money":0,"experience":0,"point":0,"special":0}, - "skeletonLite": {"name":"骷髅精英","hp":0,"atk":0,"def":0,"money":0,"experience":0,"point":0,"special":0}, - "blueSkeleton": {"name":"蓝骷髅","hp":0,"atk":0,"def":0,"money":0,"experience":0,"point":0,"special":0}, - "bowman": {"name":"弓兵","hp":0,"atk":0,"def":0,"money":0,"experience":0,"point":0,"special":0}, - "liteBowman": {"name":"精锐弓兵","hp":0,"atk":0,"def":0,"money":0,"experience":0,"point":0,"special":0}, - "crismonZombie": {"name":"红兽人","hp":0,"atk":0,"def":0,"money":0,"experience":0,"point":0,"special":0}, - "watcherSlime": {"name":"邪眼怪","hp":0,"atk":0,"def":0,"money":0,"experience":0,"point":0,"special":0}, - "mutantSlimeman": {"name":"变异战士","hp":0,"atk":0,"def":0,"money":0,"experience":0,"point":0,"special":0}, - "devilKnight": {"name":"恶灵骑士","hp":0,"atk":0,"def":0,"money":0,"experience":0,"point":0,"special":0}, - "grayPriest": {"name":"混沌法师","hp":0,"atk":0,"def":0,"money":0,"experience":0,"point":0,"special":0}, - "greenGT": {"name":"卫兵队长","hp":0,"atk":0,"def":0,"money":0,"experience":0,"point":0,"special":0}, - "ghostSoldier": {"name":"冥队长","hp":0,"atk":0,"def":0,"money":0,"experience":0,"point":0,"special":0}, - "goldBat": {"name":"金蝙蝠","hp":0,"atk":0,"def":0,"money":0,"experience":0,"point":0,"special":0}, - "pinkSoldier": {"name":"红战士","hp":0,"atk":0,"def":0,"money":0,"experience":0,"point":0,"special":0}, - "pinkGhostSoldier": {"name":"红队长","hp":0,"atk":0,"def":0,"money":0,"experience":0,"point":0,"special":0}, - "greenSoldier": {"name":"青战士","hp":0,"atk":0,"def":0,"money":0,"experience":0,"point":0,"special":0}, - "greenGhostSoldier": {"name":"青队长","hp":0,"atk":0,"def":0,"money":0,"experience":0,"point":0,"special":0} + "greenSlime": {"name":"绿头怪","hp":100,"atk":120,"def":0,"money":1,"exp":1,"point":0,"special":[1,5,7,8]}, + "redSlime": {"name":"红头怪","hp":0,"atk":0,"def":0,"money":0,"exp":0,"point":0,"special":[16,18],"value":10}, + "blackSlime": {"name":"青头怪","hp":0,"atk":0,"def":0,"money":0,"exp":0,"point":0,"special":0}, + "slimelord": {"name":"怪王","hp":100,"atk":120,"def":0,"money":10,"exp":0,"point":0,"special":[1,9]}, + "bat": {"name":"小蝙蝠","hp":100,"atk":120,"def":0,"money":2,"exp":0,"point":0,"special":1}, + "bigBat": {"name":"大蝙蝠","hp":0,"atk":0,"def":0,"money":0,"exp":0,"point":0,"special":0}, + "redBat": {"name":"红蝙蝠","hp":100,"atk":120,"def":0,"money":5,"exp":0,"point":0,"special":4}, + "vampire": {"name":"冥灵魔王","hp":0,"atk":0,"def":0,"money":0,"exp":0,"point":0,"special":0}, + "skeleton": {"name":"骷髅人","hp":0,"atk":0,"def":0,"money":0,"exp":0,"point":0,"special":0}, + "skeletonCaptain": {"name":"骷髅队长","hp":0,"atk":0,"def":0,"money":0,"exp":0,"point":0,"special":0}, + "zombie": {"name":"兽人","hp":0,"atk":0,"def":0,"money":0,"exp":0,"point":0,"special":0}, + "zombieKnight": {"name":"兽人武士","hp":0,"atk":0,"def":0,"money":0,"exp":0,"point":0,"special":0}, + "rock": {"name":"石头人","hp":100,"atk":120,"def":0,"money":4,"exp":0,"point":0,"special":3}, + "bluePriest": {"name":"初级法师","hp":100,"atk":120,"def":0,"money":3,"exp":0,"point":1,"special":2}, + "redPriest": {"name":"高级法师","hp":0,"atk":0,"def":0,"money":0,"exp":0,"point":0,"special":0}, + "brownWizard": {"name":"初级巫师","hp":100,"atk":120,"def":0,"money":16,"exp":0,"point":0,"special":15,"value":100,"range":2}, + "redWizard": {"name":"高级巫师","hp":1000,"atk":1200,"def":0,"money":160,"exp":0,"point":0,"special":15,"value":200,"zoneSquare":true}, + "swordsman": {"name":"双手剑士","hp":100,"atk":120,"def":0,"money":6,"exp":0,"point":0,"special":[5,23]}, + "soldier": {"name":"冥战士","hp":0,"atk":0,"def":0,"money":0,"exp":0,"point":0,"special":0}, + "yellowKnight": {"name":"金骑士","hp":0,"atk":0,"def":0,"money":0,"exp":0,"point":0,"special":0}, + "redKnight": {"name":"红骑士","hp":0,"atk":0,"def":0,"money":0,"exp":0,"point":0,"special":0}, + "darkKnight": {"name":"黑骑士","hp":0,"atk":0,"def":0,"money":0,"exp":0,"point":0,"special":0}, + "blueKnight": {"name":"蓝骑士","hp":100,"atk":120,"def":0,"money":9,"exp":0,"point":0,"special":8}, + "goldSlime": {"name":"黄头怪","hp":0,"atk":0,"def":0,"money":0,"exp":0,"point":0,"special":0}, + "poisonSkeleton": {"name":"紫骷髅","hp":0,"atk":0,"def":0,"money":0,"exp":0,"point":0,"special":0}, + "poisonBat": {"name":"紫蝙蝠","hp":100,"atk":120,"def":0,"money":14,"exp":0,"point":0,"special":13}, + "skeletonPriest": {"name":"骷髅法师","hp":100,"atk":100,"def":0,"money":0,"exp":0,"point":0,"special":18,"value":20}, + "skeletonKing": {"name":"骷髅王","hp":0,"atk":0,"def":0,"money":0,"exp":0,"point":0,"special":0}, + "evilHero": {"name":"迷失勇者","hp":0,"atk":0,"def":0,"money":0,"exp":0,"point":0,"special":0}, + "demonPriest": {"name":"魔神法师","hp":0,"atk":0,"def":0,"money":0,"exp":0,"point":0,"special":0}, + "goldHornSlime": {"name":"金角怪","hp":0,"atk":0,"def":0,"money":0,"exp":0,"point":0,"special":0}, + "silverSlime": {"name":"银头怪","hp":100,"atk":120,"def":0,"money":15,"exp":0,"point":0,"special":14}, + "whiteHornSlime": {"name":"尖角怪","hp":0,"atk":0,"def":0,"money":0,"exp":0,"point":0,"special":0}, + "redSwordsman": {"name":"剑王","hp":100,"atk":120,"def":0,"money":7,"exp":0,"point":0,"special":6,"n":8}, + "poisonZombie": {"name":"绿兽人","hp":100,"atk":120,"def":0,"money":13,"exp":0,"point":0,"special":12}, + "octopus": {"name":"血影","hp":0,"atk":0,"def":0,"money":0,"exp":0,"point":0,"special":0}, + "princessEnemy": {"name":"假公主","hp":0,"atk":0,"def":0,"money":0,"exp":0,"point":0,"special":0}, + "angel": {"name":"天使","hp":0,"atk":0,"def":0,"money":0,"exp":0,"point":0,"special":0}, + "elemental": {"name":"元素生物","hp":0,"atk":0,"def":0,"money":0,"exp":0,"point":0,"special":0}, + "steelGuard": {"name":"铁守卫","hp":0,"atk":0,"def":0,"money":0,"exp":0,"point":0,"special":18,"value":20}, + "evilBat": {"name":"邪恶蝙蝠","hp":1000,"atk":1,"def":0,"money":0,"exp":0,"point":0,"special":[2,3]}, + "frozenSkeleton": {"name":"冻死骨","hp":0,"atk":0,"def":0,"money":0,"exp":0,"point":0,"special":0}, + "silverSlimelord": {"name":"银怪王","hp":0,"atk":0,"def":0,"money":0,"exp":0,"point":0,"special":0}, + "goldSlimelord": {"name":"金怪王","hp":0,"atk":0,"def":0,"money":0,"exp":0,"point":0,"special":0}, + "skeletonWarrior": {"name":"骷髅士兵","hp":0,"atk":0,"def":0,"money":0,"exp":0,"point":0,"special":0}, + "ghostWarrior": {"name":"冥队长","hp":100,"atk":120,"def":0,"money":8,"exp":0,"point":0,"special":7}, + "whiteSlimeman": {"name":"水银战士","hp":0,"atk":0,"def":0,"money":0,"exp":0,"point":0,"special":0}, + "slimeman": {"name":"影子战士","hp":100,"atk":0,"def":0,"money":11,"exp":0,"point":0,"special":[10,21],"atkValue":2,"defValue":3}, + "yellowGT": {"name":"初级卫兵","hp":100,"atk":120,"def":0,"money":10,"exp":0,"point":0,"special":0}, + "blueGT": {"name":"中级卫兵","hp":0,"atk":0,"def":0,"money":0,"exp":0,"point":0,"special":0}, + "redGT": {"name":"高级卫兵","hp":0,"atk":0,"def":0,"money":0,"exp":0,"point":0,"special":0}, + "blackMS": {"name":"黑衣魔王","hp":1000,"atk":500,"def":0,"money":1000,"exp":1000,"point":0,"special":0,"notBomb":true}, + "yellowMS": {"name":"黄衣魔王","hp":0,"atk":0,"def":0,"money":0,"exp":0,"point":0,"special":0}, + "greenMS": {"name":"青衣武士","hp":0,"atk":0,"def":0,"money":0,"exp":0,"point":0,"special":0}, + "magicMaster": {"name":"黑暗大法师","hp":100,"atk":120,"def":0,"money":12,"exp":0,"point":0,"special":11,"value":0.3333333333333333,"add":true,"notBomb":true}, + "blueMS": {"name":"白衣武士","hp":100,"atk":120,"def":0,"money":17,"exp":0,"point":0,"special":16}, + "redMS": {"name":"红衣魔王","hp":0,"atk":0,"def":0,"money":0,"exp":0,"point":0,"special":0}, + "devilWarrior": {"name":"魔神武士","hp":0,"atk":0,"def":0,"money":0,"exp":0,"point":0,"special":0}, + "fairyEnemy": {"name":"仙子","hp":0,"atk":0,"def":0,"money":0,"exp":0,"point":0,"special":0}, + "dragon": {"name":"魔龙","hp":0,"atk":0,"def":0,"money":0,"exp":0,"point":0,"special":0}, + "skeletonKnight": {"name":"骷髅武士","hp":0,"atk":0,"def":0,"money":0,"exp":0,"point":0,"special":0}, + "skeletonPresbyter": {"name":"骷髅巫师","hp":0,"atk":0,"def":0,"money":0,"exp":0,"point":0,"special":0}, + "ironRock": {"name":"铁面人","hp":0,"atk":0,"def":0,"money":0,"exp":0,"point":0,"special":0}, + "grayRock": {"name":"灰色石头人","hp":0,"atk":0,"def":0,"money":0,"exp":0,"point":0,"special":0}, + "yellowPriest": {"name":"中级法师","hp":0,"atk":0,"def":0,"money":0,"exp":0,"point":0,"special":0}, + "evilPrincess": {"name":"痛苦魔女","hp":0,"atk":0,"def":0,"money":0,"exp":0,"point":0,"special":0}, + "blademaster": {"name":"剑圣","hp":0,"atk":0,"def":0,"money":0,"exp":0,"point":0,"special":0}, + "evilFairy": {"name":"黑暗仙子","hp":0,"atk":0,"def":0,"money":0,"exp":0,"point":0,"special":0}, + "blueRock": {"name":"鬼邪石","hp":0,"atk":0,"def":0,"money":0,"exp":0,"point":0,"special":0}, + "skeletonLite": {"name":"骷髅精英","hp":0,"atk":0,"def":0,"money":0,"exp":0,"point":0,"special":0}, + "greenKnight": {"name":"强盾骑士","hp":0,"atk":0,"def":0,"money":0,"exp":0,"point":0,"special":0}, + "bowman": {"name":"弓兵","hp":0,"atk":0,"def":0,"money":0,"exp":0,"point":0,"special":0}, + "liteBowman": {"name":"精锐弓兵","hp":0,"atk":0,"def":0,"money":0,"exp":0,"point":0,"special":0}, + "crismonZombie": {"name":"红兽人","hp":0,"atk":0,"def":0,"money":0,"exp":0,"point":0,"special":0}, + "watcherSlime": {"name":"邪眼怪","hp":0,"atk":0,"def":0,"money":0,"exp":0,"point":0,"special":0}, + "mutantSlimeman": {"name":"变异战士","hp":0,"atk":0,"def":0,"money":0,"exp":0,"point":0,"special":0}, + "devilKnight": {"name":"恶灵骑士","hp":0,"atk":0,"def":0,"money":0,"exp":0,"point":0,"special":0}, + "grayPriest": {"name":"混沌法师","hp":0,"atk":0,"def":0,"money":0,"exp":0,"point":0,"special":0}, + "greenGT": {"name":"卫兵队长","hp":0,"atk":0,"def":0,"money":0,"exp":0,"point":0,"special":0}, + "ghostSoldier": {"name":"冥队长","hp":0,"atk":0,"def":0,"money":0,"exp":0,"point":0,"special":0}, + "frostBat": {"name":"寒蝙蝠","hp":0,"atk":0,"def":0,"money":0,"exp":0,"point":0,"special":0} } \ No newline at end of file diff --git a/project/events.js b/project/events.js index af347cde..8847951f 100644 --- a/project/events.js +++ b/project/events.js @@ -175,7 +175,7 @@ var events_c12a15a8_c380_4b28_8144_256cba95f760 = "data": [ { "type": "choices", - "text": "\t[商人,woman]你有多余的钥匙想要出售吗?", + "text": "\t[商人,trader]你有多余的钥匙想要出售吗?", "choices": [ { "text": "黄钥匙(10金币)", @@ -204,7 +204,7 @@ var events_c12a15a8_c380_4b28_8144_256cba95f760 = } ], "false": [ - "\t[商人,woman]你没有黄钥匙!" + "\t[商人,trader]你没有黄钥匙!" ] } ] @@ -236,7 +236,7 @@ var events_c12a15a8_c380_4b28_8144_256cba95f760 = } ], "false": [ - "\t[商人,woman]你没有蓝钥匙!" + "\t[商人,trader]你没有蓝钥匙!" ] } ] diff --git a/project/floors/MT0.js b/project/floors/MT0.js index 8e98ca33..74b56253 100644 --- a/project/floors/MT0.js +++ b/project/floors/MT0.js @@ -8,7 +8,7 @@ main.floors.MT0= "cannotViewMap": false, "defaultGround": "ground", "images": [], - "item_ratio": 1, + "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], diff --git a/project/floors/sample0.js b/project/floors/sample0.js index 4af03e43..cc88bc8d 100644 --- a/project/floors/sample0.js +++ b/project/floors/sample0.js @@ -8,7 +8,7 @@ main.floors.sample0= "defaultGround": "ground", "images": [], "bgm": "bgm.mp3", - "item_ratio": 1, + "ratio": 1, "map": [ [ 0, 0,220, 0, 0, 20, 87, 3, 65, 64, 44, 43, 42], [ 0,246, 0,246, 0, 20, 0, 3, 58, 59, 60, 61, 41], @@ -46,8 +46,8 @@ main.floors.sample0= } ], "10,11": [ - "\t[老人,woman]这些是门,需要对应的钥匙打开。\n机关门必须使用特殊的开法。", - "\t[老人,woman]开门后可触发 afterOpenDoor 事件。\n\n有关事件的各种信息在下一层会有更为详细的说明。", + "\t[老人,trader]这些是门,需要对应的钥匙打开。\n机关门必须使用特殊的开法。", + "\t[老人,trader]开门后可触发 afterOpenDoor 事件。\n\n有关事件的各种信息在下一层会有更为详细的说明。", { "type": "hide", "time": 500 @@ -63,24 +63,24 @@ main.floors.sample0= } ], "2,8": [ - "\t[老人,magician]这些都是各种各样的怪物,所有怪物的数据都在enemys.js中设置。", - "\t[老人,magician]这批怪物分别为:普通、先攻、魔攻、坚固、2连击、3连击、4连击、破甲、反击、净化。", - "\t[老人,magician]打败怪物后可触发 afterBattle 事件。\n\n有关事件的各种信息在下一层会有更为详细的说明。", + "\t[老人,wizard]这些都是各种各样的怪物,所有怪物的数据都在enemys.js中设置。", + "\t[老人,wizard]这批怪物分别为:普通、先攻、魔攻、坚固、2连击、3连击、4连击、破甲、反击、净化。", + "\t[老人,wizard]打败怪物后可触发 afterBattle 事件。\n\n有关事件的各种信息在下一层会有更为详细的说明。", { "type": "hide", "time": 500 } ], "2,5": [ - "\t[老人,magician]模仿、吸血、中毒、衰弱、诅咒。\n\n请注意吸血怪需要设置value为吸血数值,可参见样板中黑暗大法师的写法。", + "\t[老人,wizard]模仿、吸血、中毒、衰弱、诅咒。\n\n请注意吸血怪需要设置value为吸血数值,可参见样板中黑暗大法师的写法。", { "type": "hide", "time": 500 } ], "2,3": [ - "\t[老人,magician]领域、夹击。\n请注意领域怪需要设置value为伤害数值,可参见样板中初级巫师的写法。", - "\t[老人,magician]夹击和领域同时发生时先计算领域,再夹击。\n自动寻路同样会尽量绕过你设置的这些点。", + "\t[老人,wizard]领域、夹击。\n请注意领域怪需要设置value为伤害数值,可参见样板中初级巫师的写法。", + "\t[老人,wizard]夹击和领域同时发生时先计算领域,再夹击。\n自动寻路同样会尽量绕过你设置的这些点。", { "type": "hide", "time": 500 diff --git a/project/floors/sample1.js b/project/floors/sample1.js index 9c769745..ea62368b 100644 --- a/project/floors/sample1.js +++ b/project/floors/sample1.js @@ -7,18 +7,20 @@ main.floors.sample1= "canUseQuickShop": true, "defaultGround": "grass", "images": [ - [ - 0, - 0, - "bg.jpg", - 0 - ] + { + "name": "bg.jpg", + "canvas": "bg", + "x": 0, + "y": 0, + "w": 416, + "h": 416 + } ], "weather": [ "snow", 6 ], - "item_ratio": 1, + "ratio": 1, "map": [ [ 7,131, 8,152, 9,130, 10,152,166,165,132,165,166], [ 0, 0, 0, 0, 0, 0, 0,152,165,164, 0,162,165], @@ -263,13 +265,13 @@ main.floors.sample1= } ], "10,4": [ - "\t[blackKing]你终于还是来了。", + "\t[blackMS]你终于还是来了。", "\t[hero]放开我们的公主!", - "\t[blackKing]如果我不愿意呢?", + "\t[blackMS]如果我不愿意呢?", "\t[hero]无需多说,拔剑吧!", { "type": "battle", - "id": "blackKing" + "id": "blackMS" }, { "type": "hide", @@ -285,7 +287,7 @@ main.floors.sample1= 7 ] }, - "\t[blackKing]没想到你已经变得这么强大了... 算你厉害。\n公主就交给你了,请好好对她。", + "\t[blackMS]没想到你已经变得这么强大了... 算你厉害。\n公主就交给你了,请好好对她。", { "type": "hide" } @@ -419,23 +421,23 @@ main.floors.sample1= { "case": "0", "action": [ - "\t[老人,woman]这是个很复杂的例子,它将教会你如何使用if 语句进行条件判断,以及 choices 提供选项来供用户进行选择。", - "\t[老人,woman]第一次访问我将显示这段文字;从第二次开始将会向你出售钥匙。\n钥匙价格将随着访问次数递增。\n当合计出售了七把钥匙后,将送你一把大黄门钥匙,并消失不再出现。", - "\t[老人,woman]这部分的逻辑比较长,请细心看样板的写法,是很容易看懂并理解的。" + "\t[老人,trader]这是个很复杂的例子,它将教会你如何使用if 语句进行条件判断,以及 choices 提供选项来供用户进行选择。", + "\t[老人,trader]第一次访问我将显示这段文字;从第二次开始将会向你出售钥匙。\n钥匙价格将随着访问次数递增。\n当合计出售了七把钥匙后,将送你一把大黄门钥匙,并消失不再出现。", + "\t[老人,trader]这部分的逻辑比较长,请细心看样板的写法,是很容易看懂并理解的。" ] }, { "case": "8", "action": [ - "\t[老人,woman]你购买的钥匙已经够多了,再继续卖给你的话我会有危险的。", - "\t[老人,woman]看在你贡献给我这么多钱的份上,送你一把大黄门钥匙吧,希望你能好好用它。", + "\t[老人,trader]你购买的钥匙已经够多了,再继续卖给你的话我会有危险的。", + "\t[老人,trader]看在你贡献给我这么多钱的份上,送你一把大黄门钥匙吧,希望你能好好用它。", { "type": "setValue", "name": "item:bigKey", "operator": "+=", "value": "1" }, - "\t[老人,woman]我先走了,拜拜~", + "\t[老人,trader]我先走了,拜拜~", { "type": "hide", "time": 500 @@ -450,7 +452,7 @@ main.floors.sample1= "action": [ { "type": "choices", - "text": "\t[老人,woman]少年,你需要钥匙吗?\n我这里有大把的!", + "text": "\t[老人,trader]少年,你需要钥匙吗?\n我这里有大把的!", "choices": [ { "text": "黄钥匙(${9+flag:woman_times}金币)", @@ -473,7 +475,7 @@ main.floors.sample1= } ], "false": [ - "\t[老人,woman]你的金钱不足!" + "\t[老人,trader]你的金钱不足!" ] } ] @@ -502,7 +504,7 @@ main.floors.sample1= } ], "false": [ - "\t[老人,woman]你的金钱不足!" + "\t[老人,trader]你的金钱不足!" ] } ] @@ -528,7 +530,7 @@ main.floors.sample1= } ], "false": [ - "\t[老人,woman]你的金钱不足!", + "\t[老人,trader]你的金钱不足!", { "type": "continue" } @@ -560,8 +562,8 @@ main.floors.sample1= } ], "12,11": [ - "\t[老人,womanMagician]使用 {\"type\":\"function\"} 可以写自定义的JS脚本。\n本塔支持的所有主要API会在doc文档内给出。", - "\t[老人,womanMagician]例如这个例子:即将弹出一个输入窗口,然后会将你的输入结果直接加到你的攻击力上。", + "\t[老人,recluse]使用 {\"type\":\"function\"} 可以写自定义的JS脚本。\n本塔支持的所有主要API会在doc文档内给出。", + "\t[老人,recluse]例如这个例子:即将弹出一个输入窗口,然后会将你的输入结果直接加到你的攻击力上。", { "type": "input", "text": "请输入你要加攻击力的数值:" @@ -584,7 +586,7 @@ main.floors.sample1= ], "false": [] }, - "\t[老人,womanMagician]具体可参见样板中本事件的写法。" + "\t[老人,recluse]具体可参见样板中本事件的写法。" ] }, "changeFloor": { diff --git a/project/floors/sample2.js b/project/floors/sample2.js index a118ee6d..bd142331 100644 --- a/project/floors/sample2.js +++ b/project/floors/sample2.js @@ -8,7 +8,7 @@ main.floors.sample2= "cannotViewMap": false, "defaultGround": "ground", "images": [], - "item_ratio": 1, + "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], diff --git a/project/floors/sample3.js b/project/floors/sample3.js index a3b996b0..0ae64ca8 100644 --- a/project/floors/sample3.js +++ b/project/floors/sample3.js @@ -18,7 +18,7 @@ main.floors.sample3= 10 ], "bgm": "bgm.mp3", - "item_ratio": 1, + "ratio": 1, "map": [ [ 5, 5, 5, 5, 5, 5, 87, 5, 5, 5, 5, 5, 5], [ 5, 4, 4, 4, 4, 1, 0, 1, 4, 4, 4, 4, 5], @@ -871,7 +871,7 @@ main.floors.sample3= "\t[hero]好温暖……", { "type": "setValue", - "name": "item:yellowJewel", + "name": "item:yellowGem", "value": "1" }, { diff --git a/project/functions.js b/project/functions.js index 145d6ead..8cd0e3be 100644 --- a/project/functions.js +++ b/project/functions.js @@ -26,6 +26,7 @@ var functions_d6ad677b_427a_4623_b50f_a445a3b0ef8a = // 初始化地图 core.status.floorId = floorId; core.status.maps = maps; + core.maps._resetFloorImages(); // 初始化怪物和道具 core.material.enemys = core.enemys.getEnemys(); core.material.items = core.items.getItems(); @@ -40,7 +41,6 @@ var functions_d6ad677b_427a_4623_b50f_a445a3b0ef8a = core._init_sys_flags(); // 初始化界面,状态栏等 core.resize(); - core.updateGlobalAttribute(); // 状态栏是否显示 if (core.hasFlag('hideStatusBar')) core.hideStatusBar(core.hasFlag('showToolbox')); @@ -115,6 +115,7 @@ var functions_d6ad677b_427a_4623_b50f_a445a3b0ef8a = core.status.hero.loc = heroLoc; // 检查重生怪并重置 if (!fromLoad) { + core.extractBlocks(floorId); core.status.maps[floorId].blocks.forEach(function (block) { if (block.disable && core.enemys.hasSpecial(block.event.id, 23)) { block.disable = false; @@ -358,7 +359,9 @@ var functions_d6ad677b_427a_4623_b50f_a445a3b0ef8a = } // 如果该点存在事件 -- V2.5.4 以后阻击怪也可以有战后事件了 - core.push(todo, core.floors[core.status.floorId].afterBattle[x + "," + y]); + if (core.status.floorId != null) { + core.push(todo, core.floors[core.status.floorId].afterBattle[x + "," + y]); + } // 在这里增加其他的自定义事件需求 /* @@ -385,6 +388,7 @@ var functions_d6ad677b_427a_4623_b50f_a445a3b0ef8a = var todo = []; // 检查该点的获得开门后事件。 + if (core.status.floorId == null) return; var event = core.floors[core.status.floorId].afterOpenDoor[x + "," + y]; if (event) core.unshift(todo, event); @@ -403,6 +407,7 @@ var functions_d6ad677b_427a_4623_b50f_a445a3b0ef8a = var todo = []; // 检查该点的获得道具后事件。 + if (core.status.floorId == null) return; var event = core.floors[core.status.floorId].afterGetItem[x + "," + y]; if (event && (event instanceof Array || !isGentleClick || !event.disableOnGentleClick)) { core.unshift(todo, event); @@ -432,7 +437,7 @@ var functions_d6ad677b_427a_4623_b50f_a445a3b0ef8a = return [ [1, "先攻", "怪物首先攻击"], [2, "魔攻", "怪物无视勇士的防御"], - [3, "坚固", "勇士每回合最多只能对怪物造成1点伤害"], + [3, "坚固", "怪物防御不小于勇士攻击-1"], [4, "2连击", "怪物每回合攻击2次"], [5, "3连击", "怪物每回合攻击3次"], [6, function (enemy) { return (enemy.n || '') + "连击"; }, function (enemy) { return "怪物每回合攻击" + (enemy.n || 4) + "次"; }], @@ -516,6 +521,7 @@ var functions_d6ad677b_427a_4623_b50f_a445a3b0ef8a = var cache = core.status.checkBlock.cache[index]; if (!cache) { // 没有该点的缓存,则遍历每个图块 + core.extractBlocks(floorId); core.status.maps[floorId].blocks.forEach(function (block) { if (!block.disable) { // 获得该图块的ID @@ -833,7 +839,7 @@ var functions_d6ad677b_427a_4623_b50f_a445a3b0ef8a = break; case 52: // 快捷键4:破冰/冰冻/地震/上下楼器/... 其他道具依次判断 { - var list = ["icePickaxe", "snow", "earthquake", "upFly", "downFly", "jumpShoes", "lifeWand", "poisonWine", "weakWine", "curseWine", "superWine"]; + var list = ["icePickaxe", "freezeBadge", "earthquake", "upFly", "downFly", "jumpShoes", "lifeWand", "poisonWine", "weakWine", "curseWine", "superWine"]; for (var i = 0; i < list.length; i++) { var itemId = list[i]; if (core.canUseItem(itemId)) { @@ -934,7 +940,7 @@ var functions_d6ad677b_427a_4623_b50f_a445a3b0ef8a = var toAttribute = core.getFlag('globalAttribute', core.status.globalAttribute); if (!core.same(toAttribute, core.status.globalAttribute)) { core.status.globalAttribute = toAttribute; - core.updateGlobalAttribute(); + core.resize(); } // 重置音量 core.events.setVolume(core.getFlag("__volume__", 1), 0); @@ -1032,6 +1038,7 @@ var functions_d6ad677b_427a_4623_b50f_a445a3b0ef8a = // 难度 core.statusBar.hard.innerText = core.status.hard; + core.statusBar.hard.style.color = core.getFlag('__hardColor__', 'red'); // 自定义状态栏绘制 core.drawStatusBar(); @@ -1051,7 +1058,7 @@ var functions_d6ad677b_427a_4623_b50f_a445a3b0ef8a = var damage = {}, // 每个点的伤害值 type = {}, // 每个点的伤害类型 - snipe = {}, // 每个点的阻击怪信息 + repulse = {}, // 每个点的阻击怪信息 ambush = {}; // 每个点的捕捉信息 // 计算血网和领域、阻击、激光的伤害,计算捕捉信息 @@ -1065,7 +1072,7 @@ var functions_d6ad677b_427a_4623_b50f_a445a3b0ef8a = type[loc] = type[loc] || {}; // 血网 - if (id == 'lavaNet' && !core.hasItem('shoes')) { + if (id == 'lavaNet' && !core.hasItem('amulet')) { damage[loc] = (damage[loc] || 0) + core.values.lavaDamage; type[loc]["血网伤害"] = true; } @@ -1096,8 +1103,8 @@ var functions_d6ad677b_427a_4623_b50f_a445a3b0ef8a = } // 阻击 - // 如果要防止阻击伤害,可以直接简单的将 flag:no_snipe 设为true - if (enemy && core.hasSpecial(enemy.special, 18) && !core.hasFlag('no_snipe')) { + // 如果要防止阻击伤害,可以直接简单的将 flag:no_repulse 设为true + if (enemy && core.hasSpecial(enemy.special, 18) && !core.hasFlag('no_repulse')) { for (var dir in core.utils.scan) { var nx = x + core.utils.scan[dir].x, ny = y + core.utils.scan[dir].y, @@ -1112,7 +1119,7 @@ var functions_d6ad677b_427a_4623_b50f_a445a3b0ef8a = var rnx = x + core.utils.scan[rdir].x, rny = y + core.utils.scan[rdir].y; if (rnx >= 0 && rnx < width && rny >= 0 && rny < height && core.getBlock(rnx, rny, floorId) == null) { - snipe[currloc] = (snipe[currloc] || []).concat([ + repulse[currloc] = (repulse[currloc] || []).concat([ [x, y, id, rdir] ]); } @@ -1207,7 +1214,7 @@ var functions_d6ad677b_427a_4623_b50f_a445a3b0ef8a = core.status.checkBlock = { damage: damage, type: type, - snipe: snipe, + repulse: repulse, ambush: ambush, cache: {} // clear cache }; @@ -1281,6 +1288,14 @@ var functions_d6ad677b_427a_4623_b50f_a445a3b0ef8a = // 判定能否瞬移到该点 if (ignoreSteps == null) ignoreSteps = core.canMoveDirectly(x, y); if (ignoreSteps >= 0) { + // 中毒也允许瞬移 + if (core.hasFlag('poison')) { + var damage = ignoreSteps * core.values.poisonDamage; + if (damage >= core.status.hero.hp) return false; + core.status.hero.statistics.poisonDamage += damage; + core.status.hero.hp -= damage; + } + core.clearMap('hero'); // 获得勇士最后的朝向 var lastDirection = core.status.route[core.status.route.length - 1]; @@ -1295,6 +1310,9 @@ var functions_d6ad677b_427a_4623_b50f_a445a3b0ef8a = // 统计信息 core.status.hero.statistics.moveDirectly++; core.status.hero.statistics.ignoreSteps += ignoreSteps; + if (core.hasFlag('poison')) { + core.updateStatusBar(); + } return true; } return false; @@ -1355,7 +1373,7 @@ var functions_d6ad677b_427a_4623_b50f_a445a3b0ef8a = // 绘制下一个数据 var name = toDraw[index]; // 图片大小25x25 - ctx.drawImage(core.statusBar.icons[name], leftOffset, topOffset, 25, 25); + core.drawImage(ctx, core.statusBar.icons[name], leftOffset, topOffset, 25, 25); // 文字内容 var text = (core.statusBar[name] || {}).innerText || " "; // 斜体判定:如果不是纯数字和字母,斜体会非常难看,需要取消 @@ -1391,9 +1409,9 @@ var functions_d6ad677b_427a_4623_b50f_a445a3b0ef8a = return [ 'yellowDoor', 'blueDoor', 'redDoor', 'greenDoor', 'steelDoor', 'yellowKey', 'blueKey', 'redKey', 'greenKey', 'steelKey', - 'redJewel', 'blueJewel', 'greenJewel', 'yellowJewel', + 'redGem', 'blueGem', 'greenGem', 'yellowGem', 'redPotion', 'bluePotion', 'greenPotion', 'yellowPotion', 'superPotion', - 'pickaxe', 'bomb', 'centerFly', 'icePickaxe', 'snow', + 'pickaxe', 'bomb', 'centerFly', 'icePickaxe', 'freezeBadge', 'earthquake', 'upFly', 'downFly', 'jumpShoes', 'lifeWand', 'poisonWine', 'weakWine', 'curseWine', 'superWine', 'sword1', 'sword2', 'sword3', 'sword4', 'sword5', diff --git a/project/icons.js b/project/icons.js index f821a482..c8988970 100644 --- a/project/icons.js +++ b/project/icons.js @@ -97,23 +97,26 @@ var icons_4665ee12_3a1f_44a4_bea3_0fccba634dc1 = "steelDoor2": 27, "steelDoor3": 28, "iceDoor": 29, - "iceDoor2": 30 + "iceDoor2": 30, + "magentaWall": 31 }, "npcs": { "man": 0, - "woman": 1, + "trader": 1, "thief": 2, "fairy": 3, - "magician": 4, - "womanMagician": 5, - "oldMan": 6, - "child": 7, - "wood": 8, - "pinkShop": 9, - "blueShop": 10, + "wizard": 4, + "recluse": 5, + "king": 6, + "youngMan": 7, + "sign": 8, + "expShop": 9, + "moneyShop": 10, "princess": 11, - "man2": 28, - "woman2": 29, + "greenMan": 28, + "blueTrader": 29, + "redMSNpc": 30, + "blackTrader": 31, "octopusLeftTop": 12, "octopusTop": 13, "octopusRightTop": 14, @@ -173,7 +176,7 @@ var icons_4665ee12_3a1f_44a4_bea3_0fccba634dc1 = "redSwordsman": 53, "poisonZombie": 55, "octopus": 57, - "greenKnight": 59, + "princessEnemy": 59, "skeletonWarrior": 9, "frozenSkeleton": 69, "silverSlimelord": 60, @@ -202,20 +205,16 @@ var icons_4665ee12_3a1f_44a4_bea3_0fccba634dc1 = "evilFairy": 51, "blueRock": 63, "skeletonLite": 64, - "blueSkeleton": 65, + "greenKnight": 65, "bowman": 66, "liteBowman": 67, "crismonZombie": 68, "watcherSlime": 70, "mutantSlimeman": 71, - "goldBat": 72, + "frostBat": 72, "devilKnight": 73, "grayPriest": 74, "greenGT": 75, - "pinkGhostSoldier": 77, - "greenSoldier": 78, - "greenGhostSoldier": 79, - "pinkSoldier": 76, "ghostSoldier": 11, "evilHero": 40 }, @@ -232,10 +231,10 @@ var icons_4665ee12_3a1f_44a4_bea3_0fccba634dc1 = "greenKey": 3, "steelKey": 4, "bigKey": 6, - "redJewel": 16, - "blueJewel": 17, - "greenJewel": 18, - "yellowJewel": 19, + "redGem": 16, + "blueGem": 17, + "greenGem": 18, + "yellowGem": 19, "redPotion": 20, "bluePotion": 21, "greenPotion": 22, @@ -262,7 +261,7 @@ var icons_4665ee12_3a1f_44a4_bea3_0fccba634dc1 = "upFly": 15, "downFly": 14, "coin": 11, - "snow": 41, + "freezeBadge": 41, "cross": 40, "superPotion": 29, "earthquake": 8, @@ -270,9 +269,9 @@ var icons_4665ee12_3a1f_44a4_bea3_0fccba634dc1 = "weakWine": 25, "curseWine": 27, "superWine": 28, - "knife": 42, - "moneyPocket": 46, - "shoes": 47, + "dagger": 42, + "silverCoin": 46, + "amulet": 47, "hammer": 48, "jumpShoes": 49, "skill1": 30, diff --git a/project/items.js b/project/items.js index 0a68a3f0..3e245d26 100644 --- a/project/items.js +++ b/project/items.js @@ -19,22 +19,22 @@ var items_296f5d02_12fd_4166_a7c1_b5e830c9ee3a = "text": "可以打开一扇红门", "hideInToolbox": true }, - "redJewel": { + "redGem": { "cls": "items", "name": "红宝石", - "text": "',攻击+${core.values.redJewel}'" + "text": "攻击+${core.values.redGem}" }, - "blueJewel": { + "blueGem": { "cls": "items", "name": "蓝宝石", - "text": "',防御+${core.values.blueJewel}'" + "text": ",防御+${core.values.blueGem}" }, - "greenJewel": { + "greenGem": { "cls": "items", "name": "绿宝石", - "text": "',护盾+${core.values.greenJewel}'" + "text": ",护盾+${core.values.greenGem}" }, - "yellowJewel": { + "yellowGem": { "cls": "items", "name": "黄宝石", "text": "可以进行加点" @@ -42,22 +42,22 @@ var items_296f5d02_12fd_4166_a7c1_b5e830c9ee3a = "redPotion": { "cls": "items", "name": "红血瓶", - "text": "',生命+${core.values.redPotion}'" + "text": ",生命+${core.values.redPotion}" }, "bluePotion": { "cls": "items", "name": "蓝血瓶", - "text": "',生命+${core.values.bluePotion}'" + "text": ",生命+${core.values.bluePotion}" }, "yellowPotion": { "cls": "items", "name": "黄血瓶", - "text": "',生命+${core.values.yellowPotion'}" + "text": ",生命+${core.values.yellowPotion}" }, "greenPotion": { "cls": "items", "name": "绿血瓶", - "text": "',生命+${core.values.greenPotion}'" + "text": ",生命+${core.values.greenPotion}" }, "sword0": { "cls": "items", @@ -65,8 +65,10 @@ var items_296f5d02_12fd_4166_a7c1_b5e830c9ee3a = "text": "一把已经生锈的剑", "equip": { "type": 0, - "atk": 0, - "animate": "sword" + "animate": "sword", + "value": { + "atk": 0 + } } }, "sword1": { @@ -75,8 +77,10 @@ var items_296f5d02_12fd_4166_a7c1_b5e830c9ee3a = "text": "一把很普通的铁剑", "equip": { "type": 0, - "atk": 10, - "animate": "sword" + "animate": "sword", + "value": { + "atk": 10 + } } }, "sword2": { @@ -85,8 +89,10 @@ var items_296f5d02_12fd_4166_a7c1_b5e830c9ee3a = "text": "一把很普通的银剑", "equip": { "type": 0, - "atk": 20, - "animate": "sword" + "animate": "sword", + "value": { + "atk": 20 + } } }, "sword3": { @@ -95,8 +101,10 @@ var items_296f5d02_12fd_4166_a7c1_b5e830c9ee3a = "text": "一把很普通的骑士剑", "equip": { "type": 0, - "atk": 40, - "animate": "sword" + "animate": "sword", + "value": { + "atk": 40 + } } }, "sword4": { @@ -105,8 +113,10 @@ var items_296f5d02_12fd_4166_a7c1_b5e830c9ee3a = "text": "一把很普通的圣剑", "equip": { "type": 0, - "atk": 80, - "animate": "sword" + "animate": "sword", + "value": { + "atk": 80 + } } }, "sword5": { @@ -115,8 +125,10 @@ var items_296f5d02_12fd_4166_a7c1_b5e830c9ee3a = "text": "一把很普通的神圣剑", "equip": { "type": 0, - "atk": 100, - "animate": "sword" + "animate": "sword", + "value": { + "atk": 160 + } } }, "shield0": { @@ -125,7 +137,9 @@ var items_296f5d02_12fd_4166_a7c1_b5e830c9ee3a = "text": "一个很破旧的铁盾", "equip": { "type": 1, - "def": 0 + "value": { + "def": 0 + } } }, "shield1": { @@ -134,7 +148,9 @@ var items_296f5d02_12fd_4166_a7c1_b5e830c9ee3a = "text": "一个很普通的铁盾", "equip": { "type": 1, - "def": 10 + "value": { + "def": 10 + } } }, "shield2": { @@ -143,7 +159,9 @@ var items_296f5d02_12fd_4166_a7c1_b5e830c9ee3a = "text": "一个很普通的银盾", "equip": { "type": 1, - "def": 20 + "value": { + "def": 20 + } } }, "shield3": { @@ -152,7 +170,9 @@ var items_296f5d02_12fd_4166_a7c1_b5e830c9ee3a = "text": "一个很普通的骑士盾", "equip": { "type": 1, - "def": 40 + "value": { + "def": 40 + } } }, "shield4": { @@ -161,7 +181,9 @@ var items_296f5d02_12fd_4166_a7c1_b5e830c9ee3a = "text": "一个很普通的圣盾", "equip": { "type": 1, - "def": 80 + "value": { + "def": 80 + } } }, "shield5": { @@ -170,17 +192,19 @@ var items_296f5d02_12fd_4166_a7c1_b5e830c9ee3a = "text": "一个很普通的神圣盾", "equip": { "type": 1, - "def": 100, - "mdef": 100 + "value": { + "def": 100, + "mdef": 100 + } } }, "superPotion": { "cls": "items", "name": "圣水" }, - "moneyPocket": { + "silverCoin": { "cls": "items", - "name": "金钱袋" + "name": "银币" }, "book": { "cls": "constants", @@ -200,7 +224,7 @@ var items_296f5d02_12fd_4166_a7c1_b5e830c9ee3a = "name": "幸运金币", "text": "持有时打败怪物可得双倍金币" }, - "snow": { + "freezeBadge": { "cls": "constants", "name": "冰冻徽章", "text": "可以将面前的熔岩变成平地" @@ -210,14 +234,14 @@ var items_296f5d02_12fd_4166_a7c1_b5e830c9ee3a = "name": "十字架", "text": "持有后无视怪物的无敌属性" }, - "knife": { + "dagger": { "cls": "constants", "name": "屠龙匕首", "text": "该道具尚未被定义" }, - "shoes": { + "amulet": { "cls": "constants", - "name": "绿鞋", + "name": "护符", "text": "持有时无视负面地形" }, "bigKey": { @@ -317,14 +341,14 @@ var items_296f5d02_12fd_4166_a7c1_b5e830c9ee3a = } }, "itemEffect": { - "redJewel": "core.status.hero.atk += core.values.redJewel * ratio", - "blueJewel": "core.status.hero.def += core.values.blueJewel * ratio", - "greenJewel": "core.status.hero.mdef += core.values.greenJewel * ratio", - "yellowJewel": "core.status.hero.hp+=1000;core.status.hero.atk+=6;core.status.hero.def+=6;core.status.hero.mdef+=10;", - "redPotion": "core.status.hero.hp += core.values.redPotion * ratio", - "bluePotion": "core.status.hero.hp += core.values.bluePotion * ratio", - "yellowPotion": "core.status.hero.hp += core.values.yellowPotion * ratio", - "greenPotion": "core.status.hero.hp += core.values.greenPotion * ratio", + "redGem": "core.status.hero.atk += core.values.redGem * core.status.thisMap.ratio", + "blueGem": "core.status.hero.def += core.values.blueGem * core.status.thisMap.ratio", + "greenGem": "core.status.hero.mdef += core.values.greenGem * core.status.thisMap.ratio", + "yellowGem": "core.status.hero.hp+=1000;core.status.hero.atk+=6;core.status.hero.def+=6;core.status.hero.mdef+=10;", + "redPotion": "core.status.hero.hp += core.values.redPotion * core.status.thisMap.ratio", + "bluePotion": "core.status.hero.hp += core.values.bluePotion * core.status.thisMap.ratio", + "yellowPotion": "core.status.hero.hp += core.values.yellowPotion * core.status.thisMap.ratio", + "greenPotion": "core.status.hero.hp += core.values.greenPotion * core.status.thisMap.ratio", "sword0": "core.status.hero.atk += 0", "sword1": "core.status.hero.atk += 10", "sword2": "core.status.hero.atk += 20", @@ -339,32 +363,32 @@ var items_296f5d02_12fd_4166_a7c1_b5e830c9ee3a = "shield5": "core.status.hero.def += 100;core.status.hero.mdef += 100", "bigKey": "core.status.hero.items.keys.yellowKey++;core.status.hero.items.keys.blueKey++;core.status.hero.items.keys.redKey++;", "superPotion": "core.status.hero.hp *= 2", - "moneyPocket": "core.status.hero.money += 500" + "silverCoin": "core.status.hero.money += 500" }, "itemEffectTip": { - "redJewel": "',攻击+'+core.values.redJewel * ratio", - "blueJewel": "',防御+'+core.values.blueJewel * ratio", - "greenJewel": "',护盾+'+core.values.greenJewel * ratio", - "yellowJewel": "',全属性提升'", - "redPotion": "',生命+'+core.values.redPotion * ratio", - "bluePotion": "',生命+'+core.values.bluePotion * ratio", - "yellowPotion": "',生命+'+core.values.yellowPotion * ratio", - "greenPotion": "',生命+'+core.values.greenPotion * ratio", - "sword0": "',攻击+0'", - "sword1": "',攻击+10'", - "sword2": "',攻击+20'", - "sword3": "',攻击+40'", - "sword4": "',攻击+80'", - "sword5": "',攻击+100'", - "shield0": "',防御+0'", - "shield1": "',防御+10'", - "shield2": "',防御+20'", - "shield3": "',防御+40'", - "shield4": "',防御+80'", - "shield5": "',防御+100,护盾+100'", - "bigKey": "',全钥匙+1'", - "superPotion": "',生命值翻倍'", - "moneyPocket": "',金币+500'" + "redGem": ",攻击+${core.values.redGem * core.status.thisMap.ratio}", + "blueGem": ",防御+${core.values.blueGem * core.status.thisMap.ratio}", + "greenGem": ",护盾+${core.values.greenGem * core.status.thisMap.ratio}", + "yellowGem": ",全属性提升", + "redPotion": ",生命+${core.values.redPotion * core.status.thisMap.ratio}", + "bluePotion": ",生命+${core.values.bluePotion * core.status.thisMap.ratio}", + "yellowPotion": ",生命+${core.values.yellowPotion * core.status.thisMap.ratio}", + "greenPotion": ",生命+${core.values.greenPotion * core.status.thisMap.ratio}", + "sword0": ",攻击+0", + "sword1": ",攻击+10", + "sword2": ",攻击+20", + "sword3": ",攻击+40", + "sword4": ",攻击+80", + "sword5": ",攻击+100", + "shield0": ",防御+0", + "shield1": ",防御+10", + "shield2": ",防御+20", + "shield3": ",防御+40", + "shield4": ",防御+80", + "shield5": ",防御+100,护盾+100", + "bigKey": ",全钥匙+1", + "superPotion": ",生命值翻倍", + "silverCoin": ",金币+500" }, "useItemEffect": { "book": "core.ui.drawBook(0);", @@ -372,7 +396,7 @@ var items_296f5d02_12fd_4166_a7c1_b5e830c9ee3a = "earthquake": "(function () {\n\tvar indexes = [];\n\tfor (var index in core.status.thisMap.blocks) {\n\t\tvar block = core.status.thisMap.blocks[index];\n\t\tif (!block.disable && block.event.canBreak) {\n\t\t\tindexes.push(index);\n\t\t}\n\t}\n\tcore.removeBlockByIndexes(indexes);\n\tcore.drawMap(core.status.floorId, function () {\n\t\tcore.drawTip(core.material.items[itemId].name + '使用成功');\n\t});\n})();", "pickaxe": "(function () {\n\tvar canBreak = function (x, y) {\n\t\tvar block = core.getBlock(x, y);\n\t\tif (block == null || block.block.disable) return false;\n\t\treturn block.block.event.canBreak;\n\t};\n\n\tvar success = false;\n\tvar pickaxeFourDirections = false; // 是否四方向破;如果是将其改成true\n\tif (pickaxeFourDirections) {\n\t\t// 四方向破\n\t\tfor (var direction in core.utils.scan) {\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 (canBreak(nx, ny)) {\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\t// 仅破当前\n\t\tif (canBreak(core.nextX(), core.nextY())) {\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('pickaxe.mp3');\n\t\tcore.drawTip(core.material.items[itemId].name + '使用成功');\n\t} else {\n\t\t// 无法使用\n\t\tcore.drawTip(\"当前无法使用\" + core.material.items[itemId].name);\n\t\tcore.addItem(itemId, 1);\n\t\treturn;\n\t}\n})();", "icePickaxe": "(function () {\n\tcore.removeBlock(core.nextX(), core.nextY());\n\tcore.drawTip(core.material.items[itemId].name + '使用成功');\n})();", - "snow": "(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) {\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.drawTip(core.material.items[itemId].name + '使用成功');\n\t} else {\n\t\tcore.drawTip(\"当前无法使用\" + core.material.items[itemId].name);\n\t\tcore.addItem(itemId, 1);\n\t\treturn;\n\t}\n})();", + "freezeBadge": "(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) {\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.drawTip(core.material.items[itemId].name + '使用成功');\n\t} else {\n\t\tcore.drawTip(\"当前无法使用\" + core.material.items[itemId].name);\n\t\tcore.addItem(itemId, 1);\n\t\treturn;\n\t}\n})();", "bigKey": "(function () {\n\tvar actions = core.searchBlock(\"yellowDoor\").map(function (block) {\n\t\treturn { \"type\": \"openDoor\", \"loc\": [block.x, block.y], \"async\": true };\n\t});\n\tactions.push({ \"type\": \"waitAsync\" });\n\tactions.push({ \"type\": \"tip\", \"text\": core.material.items[itemId].name + \"使用成功\" });\n\tcore.insertAction(actions);\n})();", "bomb": "(function () {\n\tvar canBomb = function (x, y) {\n\t\tvar block = core.getBlock(x, y);\n\t\tif (block == null || block.block.disable || block.block.event.cls.indexOf('enemy') != 0) return false;\n\t\tvar enemy = core.material.enemys[block.block.event.id];\n\t\treturn enemy && !enemy.notBomb;\n\t};\n\n\tvar bombList = []; // 炸掉的怪物坐标列表\n\tvar bombFourDirections = false; // 是否四方向可炸;如果是将其改成true。\n\tif (bombFourDirections) {\n\t\t// 四方向炸\n\t\tfor (var direction in core.utils.scan) {\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 (canBomb(nx, ny)) {\n\t\t\t\tbombList.push([nx, ny]);\n\t\t\t\tcore.removeBlock(nx, ny);\n\t\t\t}\n\t\t}\n\t} else {\n\t\t// 仅炸当前\n\t\tif (canBomb(core.nextX(), core.nextY())) {\n\t\t\tbombList.push([core.nextX(), core.nextY()]);\n\t\t\tcore.removeBlock(core.nextX(), core.nextY());\n\t\t}\n\t}\n\n\tif (bombList.length > 0) {\n\t\tcore.playSound('bomb.mp3');\n\t\tcore.drawTip(core.material.items[itemId].name + '使用成功');\n\t} else {\n\t\tcore.drawTip('当前无法使用' + core.material.items[itemId].name);\n\t\tcore.addItem(itemId, 1);\n\t\treturn;\n\t}\n\n\t// 炸弹后事件\n\t// 这是一个使用炸弹也能开门的例子\n\t/*\n\tif (core.status.floorId=='xxx' && core.terrainExists(x0,y0,'specialDoor') // 某个楼层,该机关门存在\n\t\t&& !core.enemyExists(x1,y1) && !core.enemyExists(x2,y2)) // 且守门的怪物都不存在\n\t{\n\t\tcore.insertAction([ // 插入事件\n\t\t\t{\"type\": \"openDoor\", \"loc\": [x0,y0]} // 开门\n\t\t])\n\t}\n\t*/\n})();", "centerFly": "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 + '使用成功');", @@ -388,10 +412,10 @@ var items_296f5d02_12fd_4166_a7c1_b5e830c9ee3a = "bluePotion": "core.status.hero.hp += core.values.bluePotion", "greenPotion": "core.status.hero.hp += core.values.greenPotion", "yellowPotion": "core.status.hero.hp += core.values.yellowPotion", - "redJewel": "core.status.hero.atk += core.values.redJewel", - "blueJewel": "core.status.hero.def += core.values.blueJewel", - "greenJewel": "core.status.hero.mdef += core.values.greenJewel", - "yellowJewel": null, + "redGem": "core.status.hero.atk += core.values.redGem", + "blueGem": "core.status.hero.def += core.values.blueGem", + "greenGem": "core.status.hero.mdef += core.values.greenGem", + "yellowGem": null, "skill1": "// 二倍斩的flag:skill为1\nif (core.getFlag('skill', 0)==0) { // 判断当前是否已经开了技能\n\tif (core.getStatus('mana')>=5) { // 这里要写当前能否开技能的条件判断,比如魔力值至少要多少\n\t\tcore.setFlag('skill', 1); // 开技能1\n\t\tcore.setFlag('skillName', '二倍斩'); // 设置技能名\n\t}\n\telse {\n\t\tcore.drawTip(\"魔力不足,无法开启技能\");\n\t}\n}\nelse { // 关闭技能\n\tcore.setFlag('skill', 0); // 关闭技能状态\n\tcore.setFlag('skillName', '无');\n}" }, "canUseItemEffect": { @@ -404,7 +428,7 @@ var items_296f5d02_12fd_4166_a7c1_b5e830c9ee3a = "centerFly": "(function () {\n\tvar toX = core.bigmap.width - 1 - core.getHeroLoc('x'),\n\t\ttoY = core.bigmap.height - 1 - core.getHeroLoc('y');\n\tvar id = core.getBlockId(toX, toY);\n\treturn id == null;\n})();", "upFly": "(function () {\n\tvar floorId = core.status.floorId,\n\t\tindex = core.floorIds.indexOf(floorId);\n\tif (index < core.floorIds.length - 1) {\n\t\tvar toId = core.floorIds[index + 1],\n\t\t\ttoX = core.getHeroLoc('x'),\n\t\t\ttoY = core.getHeroLoc('y');\n\t\tvar mw = core.floors[toId].width,\n\t\t\tmh = core.floors[toId].height;\n\t\tif (toX >= 0 && toX < mw && toY >= 0 && toY < mh && core.getBlock(toX, toY, toId) == null) {\n\t\t\treturn true;\n\t\t}\n\t}\n\treturn false;\n})();", "downFly": "(function () {\n\tvar floorId = core.status.floorId,\n\t\tindex = core.floorIds.indexOf(floorId);\n\tif (index > 0) {\n\t\tvar toId = core.floorIds[index - 1],\n\t\t\ttoX = core.getHeroLoc('x'),\n\t\t\ttoY = core.getHeroLoc('y');\n\t\tvar mw = core.floors[toId].width,\n\t\t\tmh = core.floors[toId].height;\n\t\tif (toX >= 0 && toX < mw && toY >= 0 && toY < mh && core.getBlock(toX, toY, toId) == null) {\n\t\t\treturn true;\n\t\t}\n\t}\n\treturn false;\n})();", - "snow": "true", + "freezeBadge": "true", "bigKey": "(function () {\n\treturn core.searchBlock('yellowDoor').length > 0;\n})();", "poisonWine": "core.hasFlag('poison');", "weakWine": "core.hasFlag('weak');", @@ -416,15 +440,15 @@ var items_296f5d02_12fd_4166_a7c1_b5e830c9ee3a = "bluePotion": "true", "greenPotion": "true", "yellowPotion": "true", - "redJewel": "true", - "blueJewel": "true", - "greenJewel": "true", - "yellowJewel": "true", + "redGem": "true", + "blueGem": "true", + "greenGem": "true", + "yellowGem": "true", "skill1": "true" }, "equipCondition": {}, "useItemEvent": { - "yellowJewel": [ + "yellowGem": [ { "type": "choices", "choices": [ diff --git a/project/maps.js b/project/maps.js index c09ef345..ee368f22 100644 --- a/project/maps.js +++ b/project/maps.js @@ -1,8 +1,8 @@ var maps_90f36752_8815_4be8_b32b_d7fad1d0542e = { - "1": {"cls":"animates","id":"yellowWall","canBreak":true,"animate":1,"doorInfo":[null,"door.mp3","door.mp3"]}, - "2": {"cls":"animates","id":"whiteWall","canBreak":true,"animate":1,"doorInfo":[null,"door.mp3","door.mp3"]}, - "3": {"cls":"animates","id":"blueWall","canBreak":true,"animate":1,"doorInfo":[null,"door.mp3","door.mp3"]}, + "1": {"cls":"animates","id":"yellowWall","canBreak":true,"animate":1,"doorInfo":{"time":160,"openSound":"door.mp3","closeSound":"door.mp3","keys":{}}}, + "2": {"cls":"animates","id":"whiteWall","canBreak":true,"animate":1,"doorInfo":{"time":160,"openSound":"door.mp3","closeSound":"door.mp3","keys":{}}}, + "3": {"cls":"animates","id":"blueWall","canBreak":true,"animate":1,"doorInfo":{"time":160,"openSound":"door.mp3","closeSound":"door.mp3","keys":{}}}, "4": {"cls":"animates","id":"star","name":"星空"}, "5": {"cls":"animates","id":"lava","name":"岩浆"}, "6": {"cls":"terrains","id":"ice"}, @@ -11,9 +11,9 @@ var maps_90f36752_8815_4be8_b32b_d7fad1d0542e = "9": {"cls":"terrains","id":"pinkShopLeft"}, "10": {"cls":"terrains","id":"pinkShopRight"}, "11": {"cls":"animates","id":"lavaNet","canPass":true,"trigger":"null","script":"(function () {\n\t// 血网的伤害效果移动到 checkBlock 中处理\n\n\t// 如果要做一次性血网,可直接注释掉下面这句话:\n\t// core.removeBlock(core.getHeroLoc('x'), core.getHeroLoc('y'));\n})();","name":"血网"}, - "12": {"cls":"animates","id":"poisonNet","canPass":true,"trigger":"null","script":"(function () {\n\t// 直接插入公共事件进行毒处理\n\tif (!core.hasItem('shoes')) {\n\t\tcore.insertAction({ \"type\": \"insert\", \"name\": \"毒衰咒处理\", \"args\": [0] });\n\t}\n\n\t// 如果要做一次性毒网,可直接注释掉下面这句话:\n\t// core.removeBlock(core.getHeroLoc('x'), core.getHeroLoc('y'));\n})()","name":"毒网"}, - "13": {"cls":"animates","id":"weakNet","canPass":true,"trigger":"null","script":"(function () {\n\t// 直接插入公共事件进行衰处理\n\tif (!core.hasItem('shoes')) {\n\t\tcore.insertAction({ \"type\": \"insert\", \"name\": \"毒衰咒处理\", \"args\": [1] });\n\t}\n\n\t// 如果要做一次性衰网,可直接注释掉下面这句话:\n\t// core.removeBlock(core.getHeroLoc('x'), core.getHeroLoc('y'));\n})()","name":"衰网"}, - "14": {"cls":"animates","id":"curseNet","canPass":true,"trigger":"null","script":"(function () {\n\t// 直接插入公共事件进行咒处理\n\tif (!core.hasItem('shoes')) {\n\t\tcore.insertAction({ \"type\": \"insert\", \"name\": \"毒衰咒处理\", \"args\": [2] });\n\t}\n\n\t// 如果要做一次性咒网,可直接注释掉下面这句话:\n\t// core.removeBlock(core.getHeroLoc('x'), core.getHeroLoc('y'));\n})()","name":"咒网"}, + "12": {"cls":"animates","id":"poisonNet","canPass":true,"trigger":"null","script":"(function () {\n\t// 直接插入公共事件进行毒处理\n\tif (!core.hasItem('amulet')) {\n\t\tcore.insertAction({ \"type\": \"insert\", \"name\": \"毒衰咒处理\", \"args\": [0] });\n\t}\n\n\t// 如果要做一次性毒网,可直接注释掉下面这句话:\n\t// core.removeBlock(core.getHeroLoc('x'), core.getHeroLoc('y'));\n})()","name":"毒网"}, + "13": {"cls":"animates","id":"weakNet","canPass":true,"trigger":"null","script":"(function () {\n\t// 直接插入公共事件进行衰处理\n\tif (!core.hasItem('amulet')) {\n\t\tcore.insertAction({ \"type\": \"insert\", \"name\": \"毒衰咒处理\", \"args\": [1] });\n\t}\n\n\t// 如果要做一次性衰网,可直接注释掉下面这句话:\n\t// core.removeBlock(core.getHeroLoc('x'), core.getHeroLoc('y'));\n})()","name":"衰网"}, + "14": {"cls":"animates","id":"curseNet","canPass":true,"trigger":"null","script":"(function () {\n\t// 直接插入公共事件进行咒处理\n\tif (!core.hasItem('amulet')) {\n\t\tcore.insertAction({ \"type\": \"insert\", \"name\": \"毒衰咒处理\", \"args\": [2] });\n\t}\n\n\t// 如果要做一次性咒网,可直接注释掉下面这句话:\n\t// core.removeBlock(core.getHeroLoc('x'), core.getHeroLoc('y'));\n})()","name":"咒网"}, "15": {"cls":"animates","id":"blueWater"}, "16": {"cls":"animates","id":"water"}, "20": {"cls":"autotile","id":"autotile"}, @@ -23,10 +23,10 @@ var maps_90f36752_8815_4be8_b32b_d7fad1d0542e = "24": {"cls":"items","id":"greenKey"}, "25": {"cls":"items","id":"steelKey"}, "26": {"cls":"items","id":"bigKey"}, - "27": {"cls":"items","id":"redJewel"}, - "28": {"cls":"items","id":"blueJewel"}, - "29": {"cls":"items","id":"greenJewel"}, - "30": {"cls":"items","id":"yellowJewel"}, + "27": {"cls":"items","id":"redGem"}, + "28": {"cls":"items","id":"blueGem"}, + "29": {"cls":"items","id":"greenGem"}, + "30": {"cls":"items","id":"yellowGem"}, "31": {"cls":"items","id":"redPotion"}, "32": {"cls":"items","id":"bluePotion"}, "33": {"cls":"items","id":"greenPotion"}, @@ -50,7 +50,7 @@ var maps_90f36752_8815_4be8_b32b_d7fad1d0542e = "51": {"cls":"items","id":"upFly"}, "52": {"cls":"items","id":"downFly"}, "53": {"cls":"items","id":"coin"}, - "54": {"cls":"items","id":"snow"}, + "54": {"cls":"items","id":"freezeBadge"}, "55": {"cls":"items","id":"cross"}, "56": {"cls":"items","id":"superPotion"}, "57": {"cls":"items","id":"earthquake"}, @@ -58,9 +58,9 @@ var maps_90f36752_8815_4be8_b32b_d7fad1d0542e = "59": {"cls":"items","id":"weakWine"}, "60": {"cls":"items","id":"curseWine"}, "61": {"cls":"items","id":"superWine"}, - "62": {"cls":"items","id":"knife"}, - "63": {"cls":"items","id":"moneyPocket"}, - "64": {"cls":"items","id":"shoes"}, + "62": {"cls":"items","id":"dagger"}, + "63": {"cls":"items","id":"silverCoin"}, + "64": {"cls":"items","id":"amulet"}, "65": {"cls":"items","id":"hammer"}, "68": {"cls":"items","id":"lifeWand"}, "69": {"cls":"items","id":"jumpShoes"}, @@ -68,12 +68,12 @@ var maps_90f36752_8815_4be8_b32b_d7fad1d0542e = "71": {"cls":"items","id":"shield0"}, "72": {"cls":"items","id":"skill1"}, "73": {"cls":"items","id":"wand"}, - "81": {"cls":"animates","id":"yellowDoor","trigger":"openDoor","animate":1,"doorInfo":[{"yellowKey":1},"door.mp3","door.mp3"],"name":"黄门"}, - "82": {"cls":"animates","id":"blueDoor","trigger":"openDoor","animate":1,"doorInfo":[{"blueKey":1},"door.mp3","door.mp3"],"name":"蓝门"}, - "83": {"cls":"animates","id":"redDoor","trigger":"openDoor","animate":1,"doorInfo":[{"redKey":1},"door.mp3","door.mp3"],"name":"红门"}, - "84": {"cls":"animates","id":"greenDoor","trigger":"openDoor","animate":1,"doorInfo":[{"greenKey":1},"door.mp3","door.mp3"],"name":"绿门"}, - "85": {"cls":"animates","id":"specialDoor","trigger":"openDoor","animate":1,"doorInfo":[null,"door.mp3","door.mp3"],"name":"机关门"}, - "86": {"cls":"animates","id":"steelDoor","trigger":"openDoor","animate":1,"doorInfo":[{"steelKey":1},"door.mp3","door.mp3"],"name":"铁门"}, + "81": {"cls":"animates","id":"yellowDoor","trigger":"openDoor","animate":1,"doorInfo":{"time":160,"openSound":"door.mp3","closeSound":"door.mp3","keys":{"yellowKey":1}},"name":"黄门"}, + "82": {"cls":"animates","id":"blueDoor","trigger":"openDoor","animate":1,"doorInfo":{"time":160,"openSound":"door.mp3","closeSound":"door.mp3","keys":{"blueKey":1}},"name":"蓝门"}, + "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":"铁门"}, "87": {"cls":"terrains","id":"upFloor","canPass":true}, "88": {"cls":"terrains","id":"downFloor","canPass":true}, "89": {"cls":"animates","id":"portal","canPass":true}, @@ -86,26 +86,31 @@ var maps_90f36752_8815_4be8_b32b_d7fad1d0542e = "102": {"cls":"animates","id":"crystalBottom"}, "103": {"cls":"animates","id":"fire"}, "104": {"cls":"animates","id":"switch"}, - "105": {"cls":"animates","id":"steelDoor2","doorInfo":[{},"door.mp3","door.mp3"],"animate":1,"trigger":"openDoor"}, - "106": {"cls":"animates","id":"steelDoor3","doorInfo":[{},"door.mp3","door.mp3"],"animate":1,"trigger":"openDoor"}, - "107": {"cls":"animates","id":"iceDoor","doorInfo":[{},"door.mp3","door.mp3"],"animate":1,"trigger":"openDoor"}, - "108": {"cls":"animates","id":"iceDoor2","doorInfo":[{},"door.mp3","door.mp3"],"animate":1,"trigger":"openDoor"}, + "105": {"cls":"animates","id":"steelDoor2","doorInfo":{"time":160,"openSound":"door.mp3","closeSound":"door.mp3","keys":{}},"animate":1,"trigger":"openDoor"}, + "106": {"cls":"animates","id":"steelDoor3","doorInfo":{"time":160,"openSound":"door.mp3","closeSound":"door.mp3","keys":{}},"animate":1,"trigger":"openDoor"}, + "107": {"cls":"animates","id":"iceDoor","doorInfo":{"time":160,"openSound":"door.mp3","closeSound":"door.mp3","keys":{}},"animate":1,"trigger":"openDoor"}, + "108": {"cls":"animates","id":"iceDoor2","doorInfo":{"time":160,"openSound":"door.mp3","closeSound":"door.mp3","keys":{}},"animate":1,"trigger":"openDoor"}, + "109": {"cls":"animates","id":"magentaWall","canBreak":true,"animate":1,"doorInfo":{"time":160,"openSound":"door.mp3","closeSound":"door.mp3","keys":{}}}, "121": {"cls":"npcs","id":"man"}, - "122": {"cls":"npcs","id":"woman"}, + "122": {"cls":"npcs","id":"trader"}, "123": {"cls":"npcs","id":"thief"}, "124": {"cls":"npcs","id":"fairy"}, - "125": {"cls":"npcs","id":"magician"}, - "126": {"cls":"npcs","id":"womanMagician"}, - "127": {"cls":"npcs","id":"oldMan"}, - "128": {"cls":"npcs","id":"child"}, - "129": {"cls":"npcs","id":"wood"}, - "130": {"cls":"npcs","id":"pinkShop"}, - "131": {"cls":"npcs","id":"blueShop"}, + "125": {"cls":"npcs","id":"wizard"}, + "126": {"cls":"npcs","id":"recluse"}, + "127": {"cls":"npcs","id":"king"}, + "128": {"cls":"npcs","id":"youngMan"}, + "129": {"cls":"npcs","id":"sign"}, + "130": {"cls":"npcs","id":"expShop"}, + "131": {"cls":"npcs","id":"moneyShop"}, "132": {"cls":"npcs","id":"princess"}, - "133": {"cls":"npc48","id":"npc0","faceIds":{"down":"npc0","left":"npc1","right":"npc2","up":"npc3"}}, - "134": {"cls":"npc48","id":"npc1","faceIds":{"down":"npc0","left":"npc1","right":"npc2","up":"npc3"}}, - "135": {"cls":"npc48","id":"npc2","faceIds":{"down":"npc0","left":"npc1","right":"npc2","up":"npc3"}}, - "136": {"cls":"npc48","id":"npc3","faceIds":{"down":"npc0","left":"npc1","right":"npc2","up":"npc3"}}, + "133": {"cls":"npc48","id":"npc0","faceIds":{"down":"npc0","left":"npc1","right":"npc2","up":"npc3"},"animate":1}, + "134": {"cls":"npc48","id":"npc1","faceIds":{"down":"npc0","left":"npc1","right":"npc2","up":"npc3"},"animate":1}, + "135": {"cls":"npc48","id":"npc2","faceIds":{"down":"npc0","left":"npc1","right":"npc2","up":"npc3"},"animate":1}, + "136": {"cls":"npc48","id":"npc3","faceIds":{"down":"npc0","left":"npc1","right":"npc2","up":"npc3"},"animate":1}, + "137": {"cls":"npcs","id":"greenMan"}, + "138": {"cls":"npcs","id":"blueTrader"}, + "139": {"cls":"npcs","id":"redMSNpc"}, + "140": {"cls":"npcs","id":"blackTrader"}, "151": {"cls":"autotile","id":"autotile1"}, "152": {"cls":"autotile","id":"autotile2"}, "153": {"cls":"autotile","id":"autotile3"}, @@ -135,8 +140,6 @@ var maps_90f36752_8815_4be8_b32b_d7fad1d0542e = "194": {"cls":"npcs","id":"dragonRight"}, "195": {"cls":"npcs","id":"dragonLeftBottom"}, "196": {"cls":"npcs","id":"dragonRightBottom"}, - "197": {"cls":"npcs","id":"man2"}, - "198": {"cls":"npcs","id":"woman2"}, "201": {"cls":"enemys","id":"greenSlime"}, "202": {"cls":"enemys","id":"redSlime"}, "203": {"cls":"enemys","id":"blackSlime"}, @@ -196,7 +199,7 @@ var maps_90f36752_8815_4be8_b32b_d7fad1d0542e = "257": {"cls":"enemys","id":"dragon"}, "258": {"cls":"enemys","id":"octopus"}, "259": {"cls":"enemys","id":"fairyEnemy"}, - "260": {"cls":"enemys","id":"greenKnight"}, + "260": {"cls":"enemys","id":"princessEnemy"}, "261": {"cls":"enemy48","id":"angel"}, "262": {"cls":"enemy48","id":"elemental"}, "263": {"cls":"enemy48","id":"steelGuard"}, @@ -206,21 +209,17 @@ var maps_90f36752_8815_4be8_b32b_d7fad1d0542e = "267": {"cls":"enemys","id":"grayRock"}, "268": {"cls":"enemys","id":"blueRock"}, "269": {"cls":"enemys","id":"skeletonLite"}, - "270": {"cls":"enemys","id":"blueSkeleton"}, + "270": {"cls":"enemys","id":"greenKnight"}, "271": {"cls":"enemys","id":"bowman"}, "272": {"cls":"enemys","id":"liteBowman"}, "273": {"cls":"enemys","id":"crismonZombie"}, "274": {"cls":"enemys","id":"frozenSkeleton"}, "275": {"cls":"enemys","id":"watcherSlime"}, "276": {"cls":"enemys","id":"mutantSlimeman"}, - "277": {"cls":"enemys","id":"goldBat"}, + "277": {"cls":"enemys","id":"frostBat"}, "278": {"cls":"enemys","id":"devilKnight"}, "279": {"cls":"enemys","id":"grayPriest"}, "280": {"cls":"enemys","id":"greenGT"}, - "281": {"cls":"enemys","id":"pinkSoldier"}, - "282": {"cls":"enemys","id":"pinkGhostSoldier"}, - "283": {"cls":"enemys","id":"greenSoldier"}, - "284": {"cls":"enemys","id":"greenGhostSoldier"}, "300": {"cls":"terrains","id":"ground"}, "301": {"cls":"terrains","id":"grass"}, "302": {"cls":"terrains","id":"grass2"}, diff --git a/project/materials/animates.png b/project/materials/animates.png index 774a7990..01305fd6 100644 Binary files a/project/materials/animates.png and b/project/materials/animates.png differ diff --git a/project/materials/enemys.png b/project/materials/enemys.png index 673612bb..10979fa3 100644 Binary files a/project/materials/enemys.png and b/project/materials/enemys.png differ diff --git a/project/materials/ground.png b/project/materials/ground.png index 84055d7f..4aa29d2a 100644 Binary files a/project/materials/ground.png and b/project/materials/ground.png differ diff --git a/project/materials/icons.png b/project/materials/icons.png index 5164f041..7ce946ec 100644 Binary files a/project/materials/icons.png and b/project/materials/icons.png differ diff --git a/project/materials/icons_old.png b/project/materials/icons_old.png new file mode 100644 index 00000000..311b6392 Binary files /dev/null and b/project/materials/icons_old.png differ diff --git a/project/materials/items.png b/project/materials/items.png index ffedc560..6d6054f0 100644 Binary files a/project/materials/items.png and b/project/materials/items.png differ diff --git a/project/materials/keyboard.png b/project/materials/keyboard.png index 46500bcb..0a89fc52 100644 Binary files a/project/materials/keyboard.png and b/project/materials/keyboard.png differ diff --git a/project/materials/npcs.png b/project/materials/npcs.png index 9f02067a..9647d7d9 100644 Binary files a/project/materials/npcs.png and b/project/materials/npcs.png differ diff --git a/project/plugins.js b/project/plugins.js index b8a4776e..eed88ab3 100644 --- a/project/plugins.js +++ b/project/plugins.js @@ -220,6 +220,49 @@ var plugins_bb40132b_638b_4a9f_b028_d3fe47acc8d1 = return null; } +}, + "removeMap": function () { + // 高层塔砍层插件,删除后不会存入存档,不可浏览地图也不可飞到。 + // 推荐用法: + // 对于超高层或分区域塔,当在1区时将2区以后的地图删除;1区结束时恢复2区,进二区时删除1区地图,以此类推 + // 这样可以大幅减少存档空间,以及加快存读档速度 + + // 删除楼层 + // core.removeMaps("MT1", "MT300") 删除MT1~MT300之间的全部层 + // core.removeMaps("MT10") 只删除MT10层 + this.removeMaps = function (fromId, toId) { + toId = toId || fromId; + var fromIndex = core.floorIds.indexOf(fromId), + toIndex = core.floorIds.indexOf(toId); + if (toIndex < 0) toIndex = core.floorIds.length - 1; + flags.__removed__ = flags.__removed__ || []; + for (var i = fromIndex; i <= toIndex; ++i) { + var floorId = core.floorIds[i]; + delete flags.__visited__[floorId]; + flags.__removed__.push(floorId); + core.status.maps[floorId].deleted = true; + core.status.maps[floorId].canFlyTo = false; + core.status.maps[floorId].cannotViewMap = true; + } + } + + // 恢复楼层 + // core.resumeMaps("MT1", "MT300") 恢复MT1~MT300之间的全部层 + // core.resumeMaps("MT10") 只恢复MT10层 + this.resumeMaps = function (fromId, toId) { + toId = toId || fromId; + var fromIndex = core.floorIds.indexOf(fromId), + toIndex = core.floorIds.indexOf(toId); + if (toIndex < 0) toIndex = core.floorIds.length - 1; + flags.__removed__ = flags.__removed__ || []; + for (var i = fromIndex; i <= toIndex; ++i) { + var floorId = core.floorIds[i]; + flags.__removed__ = flags.__removed__.filter(function (f) { return f != floorId; }); + if (core.status.maps[floorId].deleted) { + core.status.maps[floorId] = core.loadFloor(floorId); + } + } + } }, "itemShop": function () { // 道具商店相关的插件 @@ -618,41 +661,6 @@ var plugins_bb40132b_638b_4a9f_b028_d3fe47acc8d1 = }; }; - // 其实只注释了最后一行,只能这样了 - control.drawHero = function (status, offset) { - if (!core.isPlaying() || !core.status.floorId || core.status.gameOver) return; - var x = core.getHeroLoc('x'), - y = core.getHeroLoc('y'), - direction = core.getHeroLoc('direction'); - status = status || 'stop'; - offset = offset || 0; - var way = core.utils.scan[direction]; - var dx = way.x, - dy = way.y, - offsetX = dx * offset, - offsetY = dy * offset; - core.bigmap.offsetX = core.clamp((x - core.__HALF_SIZE__) * 32 + offsetX, 0, 32 * core.bigmap.width - core.__PIXELS__); - core.bigmap.offsetY = core.clamp((y - core.__HALF_SIZE__) * 32 + offsetY, 0, 32 * core.bigmap.height - core.__PIXELS__); - core.clearAutomaticRouteNode(x + dx, y + dy); - core.clearMap('hero'); - - if (!core.hasFlag('hideHero')) { - this._drawHero_getDrawObjs(direction, x, y, status, offset).forEach(function (block) { - core.drawImage('hero', block.img, block.heroIcon[block.status] * block.width, - block.heroIcon.loc * block.height, block.width, block.height, - block.posx + (32 - block.width) / 2, block.posy + 32 - block.height, block.width, block.height); - }); - } - - core.control.updateViewport(); - //core.setGameCanvasTranslate('hero', 0, 0); - }; - - // 复写转发 - core.drawHero = function (status, offset) { - return core.control.drawHero(status, offset); - }; - // 创建摄像机对象 this.camera = new this.Camera(); @@ -661,13 +669,17 @@ var plugins_bb40132b_638b_4a9f_b028_d3fe47acc8d1 = this.camera.update(); }; + core.control._drawHero_updateViewport = function () { + core.control.updateViewport(); + } + // 代理原本的镜头事件 - control.updateViewport = function () { + core.control.updateViewport = function () { core.plugin.camera.requestCameraUpdate(); }; // 更变楼层的行为追加,重置镜头 - events.prototype.changingFloor = function (floorId, heroLoc) { + core.events.changingFloor = function (floorId, heroLoc) { this.eventdata.changingFloor(floorId, heroLoc); core.plugin.camera.resetCamera(); }; diff --git a/runtime.d.ts b/runtime.d.ts index d07c908b..f6cb996f 100644 --- a/runtime.d.ts +++ b/runtime.d.ts @@ -42,7 +42,7 @@ type Animate = { type Floor = { title: string, - item_ratio: number + ratio: number } type ResolvedMap = { @@ -221,9 +221,7 @@ type gameStatus = { toolsBackground: string borderColor: string statusBarColor: string - hardLabelColor: string - floorChangingBackground: string - floorChangingTextColor: string + floorChangingStyle: string font: string } curtainColor: null @@ -652,9 +650,9 @@ declare class events { /** * 设置一项楼层属性并刷新状态栏 - * @example core.setFloorInfo('item_ratio', 2, 'MT0'); // 把主塔0层的血瓶和宝石变为双倍效果 - * @param name 'title','name','canFlyTo','canUseQuickShop','cannotViewMap','cannotMoveDirectly','upFloor','downFloor','defaultGround','images','color','weather','bgm','item_ratio','underGround'之一 - * @param values 属性的新值,可选。对'title'、'name'、'defaultGround'和'bgm'需要是字符串,对'underGround'和四个'canXxx'需要是布尔值,对两个'xxxFloor'需要是一行两列的自然数数组,对'item_ratio'需要是数字 + * @example core.setFloorInfo('ratio', 2, 'MT0'); // 把主塔0层的血瓶和宝石变为双倍效果 + * @param name 'title','name','canFlyTo','canUseQuickShop','cannotViewMap','cannotMoveDirectly','upFloor','downFloor','defaultGround','images','color','weather','bgm','ratio','underGround'之一 + * @param values 属性的新值,可选。对'title'、'name'、'defaultGround'和'bgm'需要是字符串,对'underGround'和四个'canXxx'需要是布尔值,对两个'xxxFloor'需要是一行两列的自然数数组,对'ratio'需要是数字 * @param floorId 楼层id,不填视为当前层 * @param prefix 独立开关前缀,一般不需要,下同 */ @@ -1542,7 +1540,7 @@ declare class utils { /** * 读取一个全局存储,适用于global:xxx,支持录像。 - * @example if (core.getGlobal('一周目已通关', false) === true) core.getItem('knife'); // 二周目游戏进行到此处时会获得一把屠龙匕首 + * @example if (core.getGlobal('一周目已通关', false) === true) core.getItem('dagger'); // 二周目游戏进行到此处时会获得一把屠龙匕首 * @param key 全局变量名称,支持中文 * @param defaultValue 可选,当此全局变量不存在或值为null、undefined时,用此值代替 * @returns 全局变量的值 diff --git a/styles.css b/styles.css index d981dfdf..0a12763a 100644 --- a/styles.css +++ b/styles.css @@ -74,7 +74,7 @@ color: #fff; font-size: 0.6rem; position: absolute; - top: 8%; + top: 10%; left: 5%; z-index: 15; } @@ -295,27 +295,22 @@ p#name { #bg { z-index: 10; - image-rendering: pixelated; } #event { z-index: 30; - image-rendering: pixelated; } #hero { z-index: 40; - image-rendering: pixelated; } #event2 { z-index: 50; - image-rendering: pixelated; } #fg { z-index: 60; - image-rendering: pixelated; } #damage { diff --git a/v2.x-final更新.txt b/v2.x-final更新.txt index cc988fc5..5f0b5cc9 100644 --- a/v2.x-final更新.txt +++ b/v2.x-final更新.txt @@ -8,7 +8,7 @@ (已完成!) 7. 建议把core.playBgm(bgm, startTime)的startTime参数在事件中也提供出来,以用于一些演出(比如适当的剧情处直接从高潮开始)。同理可以让“暂停背景音乐”记录下当前播放到了第几秒,并在“恢复背景音乐”中自动从这个秒数恢复。作者还可以手动配合音量渐变效果 (已完成!) 8. 系统设置菜单中“音量”和“步时”的点击区并不是根据文本长度自动适配的,这导致作者修改文本(包括但不限于翻译)后玩家难以找到准确的点击区,建议优化 (已完成!) 9. 建议给“显示选择项”、“显示确认框”、“等待用户操作”这三个事件添加一个“若多少毫秒内不响应则触发的分支”,用来实现一些如新新2的QTE,录像中可以记录“choice: timeout”、“confirm: timeout”和“wait: timeout”来表示触发了超时分支 -10. 建议给“转变图块”事件增加一个淡入时间参数,用于原本是空地或空气墙的情况,目前这种效果必须借助存在安全隐患的红点 +(已完成!) 10. 建议给“转变图块”事件增加一个淡入时间参数,用于原本是空地或空气墙的情况,目前这种效果必须借助存在安全隐患的红点 (已完成!) 11. 建议修复勇士后退时跟随者的鬼畜行为,并推出一套能够对跟随者位置和朝向进行读写的API甚至事件,且允许这些信息被计入存档,以实现一些演出效果甚至游戏要素,如新新2用公主占位防冰块 (已完成!) 12. “设置怪物属性”事件的下拉框目前只支持一部分,另一部分只能通过手敲json再解析来得到,希望提供完整支持 (已完成!) 13. 建议给core.moveAction(callback)提供对应的事件,用于在事件中让勇士像事件外一样移动,从而正常触发跑毒和阻激夹域捕等 @@ -28,7 +28,7 @@ (已完成!) 清除最近使用图块 (已完成!) cannotIn / cannotOut使用选项框 (已完成!) noPass->canPass改成选择框 -初始化&读档优化:不一次读取全部楼层并创建 +(已完成!) 初始化&读档优化:不一次读取全部楼层并创建 (已完成!) 绿钥匙进状态栏 (已完成!) 图块ID不可全数字 (已完成!) 怪物详细信息富文本化 @@ -44,23 +44,34 @@ (已完成!) 重构全局商店! (已完成!) 读档时色调数据丢失 (已完成!) 圆角边框 -像素高分辨率问题 +(不处理) 像素高分辨率问题 (已完成!) 道具效果优化,删除部分道具相关的开关 (已完成!) 素材列表选择 (已完成!) 油漆桶,动态更改地图大小 -地图拉框选择复制剪切删除 +(已完成!) 地图拉框选择复制剪切删除 +(已完成!) 额外素材区拖动选择一个区域 (已完成!) 素材替换 -大屏幕下放大游戏界面 +(已完成!) 大屏幕下放大游戏界面 (已完成!) 最近使用/最常使用的图块 (已完成!) loader并行加载 合并items.js (已完成!) 增加fonts目录,全塔属性增加fonts引用 (已完成!) 右边框输入完后解析按钮高亮 -32x48的门 +(已完成!) 32x48的门 +(已完成!) 难度分歧的图块(颜色,含SL界面) +(已完成!) 装备同时加属性和比例 +(已完成!) removeMap和resumeMap +(已完成!) 右键图块选择复制/粘贴事件 +(已完成!) showImage, drawImage,立绘等加上对称选项 +(已完成!) 更多的图块blockly化 +(已完成!) 勇士帧动画 +(不处理;现在静止状态可以有帧动画了,所以不考虑行走过程动画) 行走动画 +(已完成!) 合并main中一些设置内容 +(已完成!) \t[this], 勇士朝下,flag:arg清理,瞬移扣血 ------------- -(不处理) 0. 部分文案的修改,如“地图编辑器”(启动服务.exe中)、“enemys”、“snipe” +(不处理) 0. 部分文案的修改,如“地图编辑器”(启动服务.exe中)、“enemys”、“repulse” (造塔工具相关都给鹿神) 1. 便捷PS工具希望加入自定义单位宽高功能,希望把“白底转透明”增强为“纯色底转透明”(弹窗由作者输入RGB或RGBA值)。 (已修复) 2. 请求修复(如果还没修复)新建单张空白地图无法自定义宽高的bug (文档相关给秋橙) 3. 希望给M键“追加素材”功能写个更详细的说明,在线文档中没有所以离线文档中也没写成 @@ -90,7 +101,7 @@ (已完成!) 27. 勇士后退时跟随者很鬼畜,建议优化(每步聚集算是一种简陋的办法) (不处理) 28. 勇士的移动帧只有2,建议改为允许作者指定 (不处理) 29. 建议加一对“勇士开始抖动”和“勇士停止抖动”事件指令,来让勇士像图块一样原地抖动(即全局动画)。目前这个效果还只能通过隐藏勇士(或切换透明行走图)并转变图块/图层块来实现且只能用于事件处理中QAQ -30. 建议加一个“视角锁定”事件指令,从而允许用事件改变勇士位置、朝向或行走图时不会使视角重置到以其为中心,用于一些演出效果 +(不处理) 30. 建议加一个“视角锁定”事件指令,从而允许用事件改变勇士位置、朝向或行走图时不会使视角重置到以其为中心,用于一些演出效果 (已完成!) 31. 楼层切换事件(绿点)一旦使用blockly编辑就会无视全塔属性的切换时间,只能手动在表格中删除时间(数据相关“楼层切换”事件指令也有这个问题,有群友还希望这个默认时间能像步时和音量一样由玩家设定来节约拆塔时间)。使用blockly编辑也无法做出“ignore:true”的效果(用来覆盖全塔属性的禁止穿透),建议优化 (已完成!) 32. (关于CC的来回回档优化版)据其称,清空存档后会出现bug,此外他使用了W键导致二倍斩失效了(js的switch语句遇到duplicate cases居然不报错吗...) (已完成!) 33. (疑似已被CC修复)楼传平面塔模式在记录离开位置时会错误地把读档也算作离开 @@ -114,7 +125,7 @@ (已修复!) 49. 系统设置菜单中音量和步时的点击区并不是根据文本长度自动适配的,这导致作者修改文本(包括但不限于翻译)后玩家难以找到准确的点击区,建议优化 (不处理) 50. 建议给录像播放时的N键提供一个对应的移动端操作,以方便移动端作者 (已完成!) 51. 希望给“显示选择项”、“显示确认框”、“等待用户操作”这三个事件添加一个“若多少毫秒内不响应则触发的分支”,用来实现一些QTE,录像中可以记录“choice: timeout”、“confirm: timeout”和“wait: timeout”来表示触发了超时分支 -52. 希望给“转变图块”加一个淡入时间参数(显隐和转变图层块也希望加个淡入淡出时间参数,图层块也希望提供移动和跳跃事件),专门用于原本是空地或空气墙的情况。目前要实现这样的效果必须使用红点,然而红点有着“推箱子、阻击、捕捉、重生、炸锤和afterXxx事件”的系列问题,且会导致core.removeBlock()(隐藏事件)退化为core.hideBlock() +(已完成!) 52. 希望给“转变图块”加一个淡入时间参数(显隐和转变图层块也希望加个淡入淡出时间参数,图层块也希望提供移动和跳跃事件),专门用于原本是空地或空气墙的情况。目前要实现这样的效果必须使用红点,然而红点有着“推箱子、阻击、捕捉、重生、炸锤和afterXxx事件”的系列问题,且会导致core.removeBlock()(隐藏事件)退化为core.hideBlock() (不处理) 53. 希望“移动事件”的移速和淡出速度拆开成两个参数,目前这样捆绑在一起不太自由 (已完成) 54. 建议把图块属性的noPass改为勾选框而不是下拉框,因为null一定表示不可通行(道具根本没有noPass) (不处理,可以转变图块) 55. “移动事件”和“跳跃事件”会导致本来勾选了不显伤的怪物突然有了显伤,非常难看,建议优化 @@ -132,7 +143,7 @@ (不处理) 67. “画面震动”事件希望不要光左右晃,至少做成QQ窗口抖动的效果吧w (不处理) 68. “自动存档”事件希望加一个“读此档后打断当前事件”的勾选项,否则这种自动存档用于强制战斗之前就没什么意义了,读了档还是会强制战斗。录像兼容性方面,不知道如果这种自动存档只用于事件开头是不是就不会有问题 (已修复!) 69. “等待用户操作”虽然提供了场合块但还不支持将多个按键的场合合并(比如空格、回车和C键一般会被作者予以合并,执行内容如果只是大致相同也值得合并,在块内再行分歧),希望支持一下 -70. “显隐勇士”事件指令希望加个淡入淡出时间参数 +(已完成!) 70. “显隐勇士”事件指令希望加个淡入淡出时间参数 (不处理,请用等待事件) 1. 希望给core.drawTip()和core.playSound()出个同步版本,目前只有异步版本,后者如果要模拟同步就得绑在一个透明动画上 (已完成!) 72. “绘制描边文本”事件希望加一个“描边颜色”参数,目前只能描黑边 (已完成!) 73. 画弧既然有现成的API,那建议也作为UI绘制事件提供。甚至希望提供画椭圆功能(长短轴水平或铅直的那种)参数为中心坐标和长短轴长度 diff --git a/v266-v2.7接档说明.txt b/v266-v2.7接档说明.txt index baac3b03..e75cf70a 100644 --- a/v266-v2.7接档说明.txt +++ b/v266-v2.7接档说明.txt @@ -41,7 +41,7 @@ V2.6.6 -> V2.7 接档说明: 5. 使用VSCode分别打开接档后的V2.7和纯净的V2.7的【project/items.js】,并执行以下操作: - 将三色钥匙的cls从"keys"改成"tools",并新增 "hideInToolbox": true - 如下道具的【useItemEffect】和【canUseItemEffect】有所改变,请直接从纯净的V2.7覆盖到你要接档的V2.7: - - earthquake, pickaxe, icePickaxe, snow, bigKey, bomb, upFly, downFly + - earthquake, pickaxe, icePickaxe, freezeBadge, bigKey, bomb, upFly, downFly - 如果确认你的塔不会使用该道具,可忽略 - 黄宝石和生命魔杖增加了【useItemEvent】;如需使用请进行复制 @@ -49,7 +49,7 @@ V2.6.6 -> V2.7 接档说明: - 找到【terrains】中的三色墙和六色门,删除对应的这几行 - yellowWall, blueWall, whiteWall, yellowDoor, blueDoor, redDoor, greenDoor, specialDoor, steelDoor - (在V2.7中,terrains不再保留门的引用,门效果仅由animates决定) - - 将【terrains】中的 blueShop-left, blueShop-right, pinkShop-left, pinkShop-right 分别重命名为 + - 将【terrains】中的 moneyShop-left, moneyShop-right, expShop-left, expShop-right 分别重命名为 blueShopLeft, blueShopRight, pinkShopLeft, pinkShopRight 7. 使用VSCode分别打开接档后的V2.7和纯净的V2.7的【project/maps.js】,并执行以下操作: @@ -87,5 +87,8 @@ V2.6.6 -> V2.7 接档说明: - 「重启当前事件」已经被删除并且无法在游戏中使用。请替换成等价的循环处理或者插入事件 - 在V2.7中,所有的experience全部改名exp;请检查所有对经验值进行操作的地方 +其他: +Jewel改名Gem +道具效果提示文字replaceText