diff --git a/_server/blockly/MotaAction.g4 b/_server/blockly/MotaAction.g4
index 033ed685..e3bdd92d 100644
--- a/_server/blockly/MotaAction.g4
+++ b/_server/blockly/MotaAction.g4
@@ -165,6 +165,7 @@ action
| revisit_s
| exit_s
| setBlock_s
+ | setHero_s
| update_s
| sleep_s
| battle_s
@@ -415,6 +416,19 @@ var code = '{"type": "setBlock", "number":'+Int_0+floorstr+IdString_0+'},\n';
return code;
*/
+setHero_s
+ : '更改角色行走图' EvalString Newline
+ ;
+
+/* setHero_s
+tooltip : setHero:更改角色行走图
+helpUrl : https://ckcz123.github.io/mota-js/#/event?id=setHero-%e6%9b%b4%e6%94%b9%e8%a7%92%e8%89%b2%e8%a1%8c%e8%b5%b0%e5%9b%be
+colour : this.dataColor
+default : ["hero.png"]
+var code = '{"type": "setHero", "name": "'+EvalString_0+'"},\n';
+return code;
+*/
+
update_s
: '更新状态栏和地图显伤' Newline
;
@@ -1262,6 +1276,10 @@ ActionParser.prototype.parseAction = function() {
this.next = MotaActionBlocks['setBlock_s'].xmlText([
data.number||0,data.loc[0]||'',data.loc[1]||'',data.floorId||'',this.next]);
break;
+ case "setHero": // 改变勇士
+ this.next = MotaActionBlocks['setHero_s'].xmlText([
+ data.name,this.next]);
+ break;
case "move": // 移动事件
data.loc=data.loc||[];
this.next = MotaActionBlocks['move_s'].xmlText([
diff --git a/_server/editor_blockly.js b/_server/editor_blockly.js
index 0baf0f45..abfdf2e9 100644
--- a/_server/editor_blockly.js
+++ b/_server/editor_blockly.js
@@ -90,6 +90,7 @@ editor_blockly = function () {
MotaActionBlocks['battle_s'].xmlText(),
MotaActionBlocks['openDoor_s'].xmlText(),
MotaActionBlocks['setBlock_s'].xmlText(),
+ MotaActionBlocks['setHero_s'].xmlText(),
'',
MotaActionBlocks['if_s'].xmlText(),
MotaActionBlocks['revisit_s'].xmlText(),
diff --git a/libs/control.js b/libs/control.js
index f3a057b9..0ecaec87 100644
--- a/libs/control.js
+++ b/libs/control.js
@@ -357,7 +357,7 @@ control.prototype.setAutomaticRoute = function (destX, destY, stepPostfix) {
core.clearMap('hero', 0, 0, 416, 416);
core.setHeroLoc('x', destX);
core.setHeroLoc('y', destY);
- core.drawHero(core.getHeroLoc('direction'), core.getHeroLoc('x'), core.getHeroLoc('y'), 'stop');
+ core.drawHero();
core.status.route.push("move:"+destX+":"+destY);
}
}
@@ -594,9 +594,7 @@ control.prototype.setHeroMoveInterval = function (direction, x, y, callback) {
core.setHeroLoc('y', y+scan[direction].y);
core.moveOneStep();
core.clearMap('hero', 0, 0, 416, 416);
- core.drawHero(direction, core.getHeroLoc('x'), core.getHeroLoc('y'), 'stop');
- //if (core.status.heroStop)
- // core.drawHero(direction, core.getHeroLoc('x'), core.getHeroLoc('y'), 'stop');
+ core.drawHero(direction);
clearInterval(core.interval.heroMoveInterval);
core.status.heroMoving = 0;
if (core.isset(callback)) callback();
@@ -624,7 +622,7 @@ control.prototype.moveAction = function (callback) {
core.status.automaticRoute.moveStepBeforeStop = [];
if (canMove) // 非箭头:触发
core.trigger(x + scan[direction].x, y + scan[direction].y);
- core.drawHero(direction, x, y, 'stop');
+ core.drawHero(direction, x, y);
if (core.status.automaticRoute.moveStepBeforeStop.length==0) {
core.clearContinueAutomaticRoute();
@@ -652,7 +650,7 @@ control.prototype.moveAction = function (callback) {
}
}
else if (core.status.heroStop) {
- core.drawHero(core.getHeroLoc('direction'), core.getHeroLoc('x'), core.getHeroLoc('y'), 'stop');
+ core.drawHero();
}
if (core.status.event.id!='ski')
core.status.route.push(direction);
@@ -669,7 +667,7 @@ control.prototype.turnHero = function() {
else if (core.status.hero.loc.direction == 'right') core.status.hero.loc.direction = 'down';
else if (core.status.hero.loc.direction == 'down') core.status.hero.loc.direction = 'left';
else if (core.status.hero.loc.direction == 'left') core.status.hero.loc.direction = 'up';
- core.drawHero(core.status.hero.loc.direction, core.status.hero.loc.x, core.status.hero.loc.y, 'stop', 0, 0);
+ core.drawHero();
core.canvas.ui.clearRect(0, 0, 416, 416);
core.status.route.push("turn");
}
@@ -742,7 +740,7 @@ control.prototype.eventMoveHero = function(steps, time, callback) {
var x=core.getHeroLoc('x'), y=core.getHeroLoc('y');
if (moveSteps.length==0) {
clearInterval(animate);
- core.drawHero(core.getHeroLoc('direction'), x, y, 'stop');
+ core.drawHero(null, x, y);
core.status.replay.animate=false;
if (core.isset(callback)) callback();
}
@@ -792,7 +790,7 @@ control.prototype.waitHeroToStop = function(callback) {
core.status.automaticRoute.moveDirectly = false;
setTimeout(function(){
core.status.replay.animate=false;
- core.drawHero(core.getHeroLoc('direction'), core.getHeroLoc('x'), core.getHeroLoc('y'), 'stop');
+ core.drawHero();
callback();
}, 30);
}
@@ -808,10 +806,13 @@ control.prototype.drawHero = function (direction, x, y, status, offsetX, offsetY
offsetX = offsetX || 0;
offsetY = offsetY || 0;
var dx=offsetX==0?0:offsetX/Math.abs(offsetX), dy=offsetY==0?0:offsetY/Math.abs(offsetY);
+ if (!core.isset(x)) x = core.getHeroLoc('x');
+ if (!core.isset(y)) y = core.getHeroLoc('y');
core.clearAutomaticRouteNode(x+dx, y+dy);
- var heroIcon = core.material.icons.hero[direction];
x = x * 32;
y = y * 32;
+ status = status || 'stop';
+ var heroIcon = core.material.icons.hero[direction || core.getHeroLoc('direction')];
core.canvas.hero.clearRect(x - 32, y - 32, 96, 96);
var height=core.material.icons.hero.height;
core.canvas.hero.drawImage(core.material.images.hero, heroIcon[status] * 32, heroIcon.loc * height, 32, height, x + offsetX, y + offsetY + 32-height, 32, height);
@@ -869,7 +870,7 @@ control.prototype.updateCheckBlock = function() {
for (var n=0;n12 || ny<0 || ny>12) continue;
var id=core.status.checkBlock.map[13*nx+ny];
if (core.isset(id)) {
- var enemy = core.enemys.getEnemys(id);
+ var enemy = core.material.enemys[id];
if (core.isset(enemy) && core.enemys.hasSpecial(enemy.special, 18)) {
snipe.push({'direction': direction, 'x': nx, 'y': ny});
}
@@ -1615,7 +1616,7 @@ control.prototype.replay = function () {
core.clearMap('hero', 0, 0, 416, 416);
core.setHeroLoc('x', x);
core.setHeroLoc('y', y);
- core.drawHero(core.getHeroLoc('direction'), core.getHeroLoc('x'), core.getHeroLoc('y'), 'stop');
+ core.drawHero();
core.status.route.push("move:"+x+":"+y);
core.replay();
return;
@@ -1969,6 +1970,13 @@ control.prototype.loadData = function (data, callback) {
}
}
+ // load icons
+ var icon = core.getFlag("heroIcon", "hero.png");
+ if (core.isset(core.material.images.images[icon])) {
+ core.material.images.hero.src = core.material.images.images[icon].src;
+ core.material.icons.hero.height = core.material.images.hero.height/4;
+ }
+
core.events.afterLoadData(data);
core.changeFloor(data.floorId, null, data.hero.loc, 0, function() {
diff --git a/libs/events.js b/libs/events.js
index 77f37f19..3ac53e3f 100644
--- a/libs/events.js
+++ b/libs/events.js
@@ -366,7 +366,7 @@ events.prototype.doAction = function() {
}
if (floorId==core.status.floorId) {
core.drawMap(floorId);
- core.drawHero(core.getHeroLoc('direction'), core.getHeroLoc('x'), core.getHeroLoc('y'), 'stop');
+ core.drawHero();
core.updateStatusBar();
}
}
@@ -419,7 +419,7 @@ events.prototype.doAction = function() {
core.setHeroLoc('y', data.loc[1]);
}
if (core.isset(data.direction)) core.setHeroLoc('direction', data.direction);
- core.drawHero(core.getHeroLoc('direction'), core.getHeroLoc('x'), core.getHeroLoc('y'), 'stop');
+ core.drawHero();
this.doAction();
break;
case "showImage": // 显示图片
@@ -569,6 +569,15 @@ events.prototype.doAction = function() {
this.doAction();
}
break;
+ case "setHero":
+ if (core.isset(core.material.images.images[data.name]) && core.material.images.images[data.name].width==128) {
+ core.setFlag("heroIcon", data.name);
+ core.material.images.hero.src = core.material.images.images[data.name].src;
+ core.material.icons.hero.height = core.material.images.hero.height/4;
+ core.drawHero();
+ }
+ this.doAction();
+ break;
case "input":
{
var value;
@@ -972,7 +981,7 @@ events.prototype.changeFloor = function (floorId, stair, heroLoc, time, callback
core.setHeroLoc('direction', heroLoc.direction);
core.setHeroLoc('x', heroLoc.x);
core.setHeroLoc('y', heroLoc.y);
- core.drawHero(core.getHeroLoc('direction'), core.getHeroLoc('x'), core.getHeroLoc('y'), 'stop');
+ core.drawHero();
core.updateStatusBar();
var changed = function () {
diff --git a/libs/maps.js b/libs/maps.js
index 4b99a178..008f8676 100644
--- a/libs/maps.js
+++ b/libs/maps.js
@@ -893,7 +893,7 @@ maps.prototype.resetMap = function() {
var floorId = core.status.floorId;
core.status.maps[floorId] = this.loadFloor(floorId);
this.drawMap(floorId, function() {
- core.drawHero(core.getHeroLoc('direction'), core.getHeroLoc('x'), core.getHeroLoc('y'), 'stop');
+ core.drawHero();
core.updateStatusBar();
})
}
\ No newline at end of file
diff --git a/libs/ui.js b/libs/ui.js
index 89802697..4da0595c 100644
--- a/libs/ui.js
+++ b/libs/ui.js
@@ -1585,7 +1585,7 @@ ui.prototype.drawSLPanel = function(index) {
core.fillText('ui', i==0?"自动存档":name+id, (2*i+1)*u, 35, '#FFFFFF', "bold 17px Verdana");
core.strokeRect('ui', (2*i+1)*u-size/2, 50, size, size, i==offset?strokeColor:'#FFFFFF', i==offset?6:2);
if (core.isset(data) && core.isset(data.floorId)) {
- this.drawThumbnail(data.floorId, 'ui', core.maps.load(data.maps, data.floorId).blocks, (2*i+1)*u-size/2, 50, size, data.hero.loc);
+ this.drawThumbnail(data.floorId, 'ui', core.maps.load(data.maps, data.floorId).blocks, (2*i+1)*u-size/2, 50, size, data.hero.loc, data.hero.flags.heroIcon||"hero.png");
core.fillText('ui', core.formatDate(new Date(data.time)), (2*i+1)*u, 65+size, '#FFFFFF', '10px Verdana');
}
else {
@@ -1597,7 +1597,7 @@ ui.prototype.drawSLPanel = function(index) {
core.fillText('ui', name+id, (2*i-5)*u, 230, '#FFFFFF', "bold 17px Verdana");
core.strokeRect('ui', (2*i-5)*u-size/2, 245, size, size, i==offset?strokeColor:'#FFFFFF', i==offset?6:2);
if (core.isset(data) && core.isset(data.floorId)) {
- this.drawThumbnail(data.floorId, 'ui', core.maps.load(data.maps, data.floorId).blocks, (2*i-5)*u-size/2, 245, size, data.hero.loc);
+ this.drawThumbnail(data.floorId, 'ui', core.maps.load(data.maps, data.floorId).blocks, (2*i-5)*u-size/2, 245, size, data.hero.loc, data.hero.flags.heroIcon||"hero.png");
core.fillText('ui', core.formatDate(new Date(data.time)), (2*i-5)*u, 260+size, '#FFFFFF', '10px Verdana');
}
else {
@@ -1615,7 +1615,7 @@ ui.prototype.drawSLPanel = function(index) {
}
////// 绘制一个缩略图 //////
-ui.prototype.drawThumbnail = function(floorId, canvas, blocks, x, y, size, heroLoc) {
+ui.prototype.drawThumbnail = function(floorId, canvas, blocks, x, y, size, heroLoc, heroIcon) {
core.clearMap(canvas, x, y, size, size);
var groundId = core.floors[floorId].defaultGround || "ground";
var blockIcon = core.material.icons.terrains[groundId];
@@ -1664,10 +1664,12 @@ ui.prototype.drawThumbnail = function(floorId, canvas, blocks, x, y, size, heroL
}
if (core.isset(heroLoc)) {
- var heroIcon = core.material.icons.hero[heroLoc.direction];
- var height = core.material.icons.hero.height;
+ if (!core.isset(core.material.images.images[heroIcon]))
+ heroIcon = "hero.png";
+ var icon = core.material.icons.hero[heroLoc.direction];
+ var height = core.material.images.images[heroIcon].height/4;
var realHeight = persize*height/32;
- core.canvas[canvas].drawImage(core.material.images.hero, heroIcon.stop * 32, heroIcon.loc * height, 32, height, x+persize*heroLoc.x, y+persize*heroLoc.y+persize-realHeight, persize, realHeight);
+ core.canvas[canvas].drawImage(core.material.images.images[heroIcon], icon.stop * 32, icon.loc * height, 32, height, x+persize*heroLoc.x, y+persize*heroLoc.y+persize-realHeight, persize, realHeight);
}
images.forEach(function (t) {
diff --git a/project/data.js b/project/data.js
index 1d14035d..e49f7fbc 100644
--- a/project/data.js
+++ b/project/data.js
@@ -5,7 +5,7 @@ data_a1e2fb4a_e986_4524_b0da_9b7ba7c0874d =
"sample0", "sample1", "sample2", "MT0"
],
"images" : [
- "bg.jpg"
+ "bg.jpg", "hero0.png"
],
"animates" : [
"hand", "sword", "zone",
diff --git a/project/images/hero0.png b/project/images/hero0.png
new file mode 100644
index 00000000..d3f439e2
Binary files /dev/null and b/project/images/hero0.png differ
diff --git a/project/items.js b/project/items.js
index 6f7d33d1..3a7660ce 100644
--- a/project/items.js
+++ b/project/items.js
@@ -117,14 +117,14 @@ items_296f5d02_12fd_4166_a7c1_b5e830c9ee3a =
"useItemEffect": {
"book": "core.ui.drawBook(0);",
"fly": "core.ui.drawFly(core.status.hero.flyRange.indexOf(core.status.floorId));",
- "earthquake": "core.removeBlockByIds(core.status.floorId, core.status.event.data);\ncore.drawMap(core.status.floorId, function () {\n core.drawHero(core.getHeroLoc('direction'), core.getHeroLoc('x'), core.getHeroLoc('y'), 'stop');\n core.updateFg();\n core.drawTip(core.material.items[itemId].name + '使用成功');\n});",
- "pickaxe": "core.removeBlockByIds(core.status.floorId, core.status.event.data);\ncore.drawMap(core.status.floorId, function () {\n core.drawHero(core.getHeroLoc('direction'), core.getHeroLoc('x'), core.getHeroLoc('y'), 'stop');\n core.updateFg();\n core.drawTip(core.material.items[itemId].name + '使用成功');\n});",
- "icePickaxe": "core.removeBlockByIds(core.status.floorId, core.status.event.data);\ncore.drawMap(core.status.floorId, function () {\n core.drawHero(core.getHeroLoc('direction'), core.getHeroLoc('x'), core.getHeroLoc('y'), 'stop');\n core.updateFg();\n core.drawTip(core.material.items[itemId].name + '使用成功');\n});",
- "snow": "core.removeBlockByIds(core.status.floorId, core.status.event.data);\ncore.drawMap(core.status.floorId, function () {\n core.drawHero(core.getHeroLoc('direction'), core.getHeroLoc('x'), core.getHeroLoc('y'), 'stop');\n core.updateFg();\n core.drawTip(core.material.items[itemId].name + '使用成功');\n});",
- "bigKey": "core.removeBlockByIds(core.status.floorId, core.status.event.data);\ncore.drawMap(core.status.floorId, function () {\n core.drawHero(core.getHeroLoc('direction'), core.getHeroLoc('x'), core.getHeroLoc('y'), 'stop');\n core.updateFg();\n core.drawTip(core.material.items[itemId].name + '使用成功');\n});",
- "bomb": "core.removeBlockByIds(core.status.floorId, core.status.event.data);\ncore.drawMap(core.status.floorId, function () {\n core.drawHero(core.getHeroLoc('direction'), core.getHeroLoc('x'), core.getHeroLoc('y'), 'stop');\n core.updateFg();\n core.drawTip(core.material.items[itemId].name + '使用成功');\n core.events.afterUseBomb();\n});",
- "hammer": "core.removeBlockByIds(core.status.floorId, core.status.event.data);\ncore.drawMap(core.status.floorId, function () {\n core.drawHero(core.getHeroLoc('direction'), core.getHeroLoc('x'), core.getHeroLoc('y'), 'stop');\n core.updateFg();\n core.drawTip(core.material.items[itemId].name + '使用成功');\n core.events.afterUseBomb();\n});",
- "centerFly": "core.clearMap('hero', 0, 0, 416, 416);\ncore.setHeroLoc('x', core.status.event.data.x);\ncore.setHeroLoc('y', core.status.event.data.y);\ncore.drawHero(core.getHeroLoc('direction'), core.getHeroLoc('x'), core.getHeroLoc('y'), 'stop');\ncore.drawTip(core.material.items[itemId].name + '使用成功');",
+ "earthquake": "core.removeBlockByIds(core.status.floorId, core.status.event.data);\ncore.drawMap(core.status.floorId, function () {\n core.drawHero();\n core.updateFg();\n core.drawTip(core.material.items[itemId].name + '使用成功');\n});",
+ "pickaxe": "core.removeBlockByIds(core.status.floorId, core.status.event.data);\ncore.drawMap(core.status.floorId, function () {\n core.drawHero();\n core.updateFg();\n core.drawTip(core.material.items[itemId].name + '使用成功');\n});",
+ "icePickaxe": "core.removeBlockByIds(core.status.floorId, core.status.event.data);\ncore.drawMap(core.status.floorId, function () {\n core.drawHero(), 'stop');\n core.updateFg();\n core.drawTip(core.material.items[itemId].name + '使用成功');\n});",
+ "snow": "core.removeBlockByIds(core.status.floorId, core.status.event.data);\ncore.drawMap(core.status.floorId, function () {\n core.drawHero();\n core.updateFg();\n core.drawTip(core.material.items[itemId].name + '使用成功');\n});",
+ "bigKey": "core.removeBlockByIds(core.status.floorId, core.status.event.data);\ncore.drawMap(core.status.floorId, function () {\n core.drawHero();\n core.updateFg();\n core.drawTip(core.material.items[itemId].name + '使用成功');\n});",
+ "bomb": "core.removeBlockByIds(core.status.floorId, core.status.event.data);\ncore.drawMap(core.status.floorId, function () {\n core.drawHero();\n core.updateFg();\n core.drawTip(core.material.items[itemId].name + '使用成功');\n core.events.afterUseBomb();\n});",
+ "hammer": "core.removeBlockByIds(core.status.floorId, core.status.event.data);\ncore.drawMap(core.status.floorId, function () {\n core.drawHero();\n core.updateFg();\n core.drawTip(core.material.items[itemId].name + '使用成功');\n core.events.afterUseBomb();\n});",
+ "centerFly": "core.clearMap('hero', 0, 0, 416, 416);\ncore.setHeroLoc('x', core.status.event.data.x);\ncore.setHeroLoc('y', core.status.event.data.y);\ncore.drawHero();\ncore.drawTip(core.material.items[itemId].name + '使用成功');",
"upFly": "var loc = {'direction': core.status.hero.loc.direction, 'x': core.status.event.data.x, 'y': core.status.event.data.y};\ncore.changeFloor(core.status.event.data.id, null, loc, null, function (){\n core.drawTip(core.material.items[itemId].name + '使用成功');\n core.replay();\n});",
"downFly": "var loc = {'direction': core.status.hero.loc.direction, 'x': core.status.event.data.x, 'y': core.status.event.data.y};\ncore.changeFloor(core.status.event.data.id, null, loc, null, function (){\n core.drawTip(core.material.items[itemId].name + '使用成功');\n core.replay();\n});",
"poisonWine": "core.setFlag('poison', false);",
diff --git a/更新说明.txt b/更新说明.txt
index 8f043eab..f9f338f8 100644
--- a/更新说明.txt
+++ b/更新说明.txt
@@ -1,6 +1,6 @@
HTML5魔塔样板V2.1.1
-改变勇士行走图
+改变勇士行走图 √
楼传器落点设置 √
录像回放从任意存档点开始
录像过程中允许存档