1){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(''+inputType+'>');\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(''+blocktext+'>');\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