diff --git a/_server/MotaAction.g4 b/_server/MotaAction.g4 index cbb5b2bf..ca76409d 100644 --- a/_server/MotaAction.g4 +++ b/_server/MotaAction.g4 @@ -322,6 +322,43 @@ 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; +*/; + + //为了避免关键字冲突,全部加了_s //动作 action @@ -2808,8 +2845,8 @@ Floor_Meta_List /*Floor_Meta_List ['title','name','canFlyTo', 'canUseQuickShop', 'cannotViewMap', 'cannotMoveDirectly', 'defaultGround', 'images', 'item_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', 'floorChangingBackground', 'floorChangingTextColor', 'equipName']*/; Global_Value_List : '血网伤害'|'中毒伤害'|'衰弱效果'|'红宝石效果'|'蓝宝石效果'|'绿宝石效果'|'红血瓶效果'|'蓝血瓶效果'|'黄血瓶效果'|'绿血瓶效果'|'破甲比例'|'反击比例'|'净化比例'|'仇恨增加值'|'动画时间' diff --git a/_server/MotaActionParse.js b/_server/MotaActionParse.js index 72108439..5654bd52 100644 --- a/_server/MotaActionParse.js +++ b/_server/MotaActionParse.js @@ -49,6 +49,15 @@ ActionParser.prototype.parse = function (obj,type) { } return MotaActionBlocks['level_m'].xmlText([text_choices]); + case 'levelChoose': + if(!obj) obj=[]; + var text_choices = null; + for(var ii=obj.length-1,choice;choice=obj[ii];ii--) { + text_choices=MotaActionBlocks['levelChooseChoice'].xmlText([ + choice.title, choice.name, choice.hard||0, choice.color, 'rgba('+choice.color+')', this.parseList(choice.action), text_choices]); + } + return MotaActionBlocks['levelChoose_m'].xmlText([text_choices]); + case 'shop': var buildsub = function(obj,parser,next){ var text_choices = null; diff --git a/_server/editor_blockly.js b/_server/editor_blockly.js index cba4dcaf..4a7cfd49 100644 --- a/_server/editor_blockly.js +++ b/_server/editor_blockly.js @@ -70,6 +70,11 @@ editor_blockly = function () { MotaActionBlocks['level_m'].xmlText(), MotaActionBlocks['commonEvent_m'].xmlText(), MotaActionBlocks['item_m'].xmlText(), + MotaActionFunctions.actionParser.parse([ + {"title":"简单", "name": "Easy", "hard": 1, "action": [ + {"type": "comment", "text": "在这里写该难度需执行的事件"} + ]} + ], 'levelChoose'), ], '显示文字':[ MotaActionBlocks['text_0_s'].xmlText(), diff --git a/_server/table/data.comment.js b/_server/table/data.comment.js index e99b0fd1..7b168af0 100644 --- a/_server/table/data.comment.js +++ b/_server/table/data.comment.js @@ -132,10 +132,10 @@ var data_comment_c456ea59_6018_45ef_8bcc_211a24c627dc = { }, "levelChoose": { "_leaf": true, - "_type": "textarea", - "_range": "thiseval instanceof Array && thiseval.length>=1 && thiseval[0] instanceof Array && thiseval[0].length==2", + "_type": "event", + "_event": "levelChoose", "_docs": "难度分歧", - "_data": "难度选择:每个数组的第一个是其在标题界面显示的难度,第二个是在游戏内部传输的字符串,会显示在状态栏,修改此处后需要在project/functions中作相应更改。\n如果需直接开始游戏将下面的startDirectly开关打开即可。" + "_data": "难度分歧定义和对应的事件;此处留空数组表示将直接开始游戏" }, "equipName": { "_leaf": true, @@ -188,13 +188,6 @@ var data_comment_c456ea59_6018_45ef_8bcc_211a24c627dc = { "_docs": "状态栏文字色", "_data": "状态栏的文字颜色,默认是白色" }, - "hardLabelColor": { - "_leaf": true, - "_type": "textarea", - "_string": true, - "_docs": "难度标签色", - "_data": "难度显示的颜色,默认是红色" - }, "floorChangingBackground": { "_leaf": true, "_type": "textarea", @@ -647,12 +640,6 @@ var data_comment_c456ea59_6018_45ef_8bcc_211a24c627dc = { "_docs": "标题事件化", "_data": "是否开始菜单canvas化;如果此项为true,则将使用canvas来绘制开始菜单" }, - "startDirectly": { - "_leaf": true, - "_type": "checkbox", - "_docs": "不选择难度", - "_data": "点击“开始游戏”后是否立刻开始游戏而不显示难度选择界面" - }, "statusCanvas": { "_leaf": true, "_type": "checkbox", diff --git a/editor-mobile.html b/editor-mobile.html index 37949d9b..df00077d 100644 --- a/editor-mobile.html +++ b/editor-mobile.html @@ -217,6 +217,7 @@ + diff --git a/editor.html b/editor.html index 17ff7d97..6f552c7c 100644 --- a/editor.html +++ b/editor.html @@ -213,6 +213,7 @@ + diff --git a/libs/control.js b/libs/control.js index 502d2f32..226165ac 100644 --- a/libs/control.js +++ b/libs/control.js @@ -2521,9 +2521,6 @@ control.prototype.updateGlobalAttribute = function (name) { texts[i].style.color = attribute[name]; break; } - case 'hardLabelColor': - core.dom.hard.style.color = attribute[name]; - break; case 'floorChangingBackground': core.dom.floorMsgGroup.style.background = attribute[name]; break; @@ -2844,7 +2841,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..dc5ee70d 100644 --- a/libs/core.js +++ b/libs/core.js @@ -195,7 +195,6 @@ function core() { "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" diff --git a/libs/events.js b/libs/events.js index 9add168b..694adc68 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(); diff --git a/libs/maps.js b/libs/maps.js index 438d30f8..69491d9e 100644 --- a/libs/maps.js +++ b/libs/maps.js @@ -1238,7 +1238,7 @@ 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; diff --git a/libs/ui.js b/libs/ui.js index 204796d0..690f9984 100644 --- a/libs/ui.js +++ b/libs/ui.js @@ -2636,7 +2636,7 @@ ui.prototype._drawSLPanel_drawRecord = function(title, data, x, y, size, cho, hi }); 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); diff --git a/main.js b/main.js index 71421aca..3f51a8c7 100644 --- a/main.js +++ b/main.js @@ -203,15 +203,16 @@ main.prototype.init = function (mode, callback) { main.dom.startBackground.src = main.startBackground; main.dom.startLogo.style=main.startLogoStyle; main.dom.startButtonGroup.style = main.startButtonsStyle; - main.levelChoose.forEach(function(value){ + 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 9e84f565..49707788 100644 --- a/project/data.js +++ b/project/data.js @@ -44,22 +44,29 @@ var data_a1e2fb4a_e986_4524_b0da_9b7ba7c0874d = "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": [ "武器", @@ -71,7 +78,6 @@ var data_a1e2fb4a_e986_4524_b0da_9b7ba7c0874d = "toolsBackground": "url(project/materials/ground.png) repeat", "borderColor": "#CCCCCC", "statusBarColor": "white", - "hardLabelColor": "red", "floorChangingBackground": "black", "floorChangingTextColor": "white", "font": "Verdana", @@ -158,7 +164,7 @@ var data_a1e2fb4a_e986_4524_b0da_9b7ba7c0874d = }, { "type": "if", - "condition": "core.flags.startDirectly", + "condition": "main.levelChoose.length == 0", "true": [ { "type": "comment", @@ -172,7 +178,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 +225,7 @@ var data_a1e2fb4a_e986_4524_b0da_9b7ba7c0874d = }, { "type": "if", - "condition": "!core.isReplaying()", + "condition": "(!core.isReplaying())", "true": [ { "type": "function", @@ -239,60 +245,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": "初始剧情" @@ -499,7 +451,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/functions.js b/project/functions.js index da5802df..cfa557c9 100644 --- a/project/functions.js +++ b/project/functions.js @@ -1032,6 +1032,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(); diff --git a/project/materials/animates.png b/project/materials/animates.png index e3b74ee9..01305fd6 100644 Binary files a/project/materials/animates.png and b/project/materials/animates.png differ diff --git a/runtime.d.ts b/runtime.d.ts index 013a574b..ee8de756 100644 --- a/runtime.d.ts +++ b/runtime.d.ts @@ -221,7 +221,6 @@ type gameStatus = { toolsBackground: string borderColor: string statusBarColor: string - hardLabelColor: string floorChangingBackground: string floorChangingTextColor: string font: string diff --git a/v2.x-final更新.txt b/v2.x-final更新.txt index 540ae267..acd4a0bc 100644 --- a/v2.x-final更新.txt +++ b/v2.x-final更新.txt @@ -56,8 +56,8 @@ 合并items.js (已完成!) 增加fonts目录,全塔属性增加fonts引用 (已完成!) 右边框输入完后解析按钮高亮 -32x48的门 -难度分歧的图块(颜色,含SL界面) +(已完成!) 32x48的门 +(已完成!) 难度分歧的图块(颜色,含SL界面) 装备同时加属性和比例 -------------