Merge remote-tracking branch 'refs/remotes/ckcz123/master' into dev-2.0-201802102001
# Conflicts: # libs/icons.js # libs/maps.js
This commit is contained in:
commit
d0115230d7
@ -51,6 +51,7 @@ HTML5 canvas制作的魔塔样板,支持全平台游戏!
|
||||
|
||||
* [x] 改变图块(setBlock事件)。
|
||||
* [x] 同一个点的多事件处理(做法详见文档)。
|
||||
* [x] 现在可以支持滑冰和推箱子事件了。
|
||||
* [x] 地图中每个块的可通行方向控制(悬崖效果)。
|
||||
* [x] 动画支持带旋转和翻转的帧。
|
||||
* [x] 现在可以允许用户丢弃道具了(例如不会再使用的装备)。
|
||||
|
||||
@ -1197,6 +1197,51 @@ events.prototype.afterUseBomb = function () {
|
||||
}
|
||||
```
|
||||
|
||||
## 滑冰和推箱子事件
|
||||
|
||||
最新的样板还支持滑冰和推箱子事件。
|
||||
|
||||
滑冰事件的数字是167,trigger为ski。
|
||||
|
||||
当角色走上冰面时,将触发ski事件,并会一直向前滑行,直到撞上不可通行的块会触发事件(比如撞上怪物会触发battle,撞上门会触发openDoor等等),或者离开冰面为止。
|
||||
|
||||
!> 由于H5魔塔只有事件一层,因此滑冰的冰面上将无法摆放任何东西(如道具)。
|
||||
|
||||
!> 撞上怪物将触发battle进行战斗,此战斗的触发和直接撞上怪物相同(战斗前自动存档,打不过则无法战斗);如需不自动存档的强制战斗请使用自定义事件覆盖。开门同理。
|
||||
|
||||
关于推箱子,存在三种状态:花(168),箱子(169)和已经推到花的箱子(170)。
|
||||
|
||||
!> 推箱子的前方不允许存在任何事件(花除外),包括已经禁用的自定义事件。
|
||||
|
||||
推完箱子后将触发events.js中的afterPushBox事件,你可以在这里进行开门判断。
|
||||
|
||||
``` js
|
||||
////// 推箱子后的事件 //////
|
||||
events.prototype.afterPushBox = function () {
|
||||
|
||||
var noBoxLeft = function () {
|
||||
// 地图上是否还存在未推到的箱子,如果不存在则返回true,存在则返回false
|
||||
for (var i=0;i<core.status.thisMap.blocks.length;i++) {
|
||||
var block=core.status.thisMap.blocks[i];
|
||||
if (core.isset(block.event) && block.event.id=='box') return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
if (noBoxLeft()) {
|
||||
// 可以通过if语句来进行开门操作
|
||||
/*
|
||||
if (core.status.floorId=='xxx') { // 在某个楼层
|
||||
core.insertAction([ // 插入一条事件
|
||||
{"type": "openDoor", "loc": [x,y]} // 开门
|
||||
])
|
||||
}
|
||||
*/
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
|
||||
## 战前剧情
|
||||
|
||||
有时候光战后事件`afterBattle`是不够的,我们可能还需要战前剧情,例如Boss战之前和Boss进行一段对话。
|
||||
|
||||
@ -97,6 +97,7 @@ function core() {
|
||||
'destY': null,
|
||||
'autoStepRoutes': [],
|
||||
'moveStepBeforeStop': [],
|
||||
'lastDirection': null,
|
||||
'cursorX': null,
|
||||
'cursorY': null,
|
||||
},
|
||||
@ -1521,6 +1522,7 @@ core.prototype.stopAutomaticRoute = function () {
|
||||
core.status.automaticRoute.autoStepRoutes = [];
|
||||
core.status.automaticRoute.destX=null;
|
||||
core.status.automaticRoute.destY=null;
|
||||
core.status.automaticRoute.lastDirection = null;
|
||||
core.stopHero();
|
||||
if (core.status.automaticRoute.moveStepBeforeStop.length==0)
|
||||
core.canvas.ui.clearRect(0, 0, 416, 416);
|
||||
@ -1875,7 +1877,8 @@ core.prototype.moveAction = function (callback) {
|
||||
var y = core.getHeroLoc('y');
|
||||
var noPass = core.noPass(x + scan[direction].x, y + scan[direction].y), canMove = core.canMoveHero();
|
||||
if (noPass || !canMove) {
|
||||
core.status.route.push(direction);
|
||||
if (core.status.event.id!='ski')
|
||||
core.status.route.push(direction);
|
||||
core.status.automaticRoute.moveStepBeforeStop = [];
|
||||
if (canMove) // 非箭头:触发
|
||||
core.trigger(x + scan[direction].x, y + scan[direction].y);
|
||||
@ -1911,6 +1914,7 @@ core.prototype.moveAction = function (callback) {
|
||||
core.setHeroMoveInterval(direction, x, y, function () {
|
||||
if (core.status.automaticRoute.autoHeroMove) {
|
||||
core.status.automaticRoute.movedStep++;
|
||||
core.status.automaticRoute.lastDirection = core.getHeroLoc('direction');
|
||||
if (core.status.automaticRoute.destStep == core.status.automaticRoute.movedStep) {
|
||||
if (core.status.automaticRoute.autoStep == core.status.automaticRoute.autoStepRoutes.length) {
|
||||
core.clearContinueAutomaticRoute();
|
||||
@ -1927,7 +1931,8 @@ core.prototype.moveAction = function (callback) {
|
||||
else if (core.status.heroStop) {
|
||||
core.drawHero(core.getHeroLoc('direction'), core.getHeroLoc('x'), core.getHeroLoc('y'), 'stop');
|
||||
}
|
||||
core.status.route.push(direction);
|
||||
if (core.status.event.id!='ski')
|
||||
core.status.route.push(direction);
|
||||
core.trigger(core.getHeroLoc('x'), core.getHeroLoc('y'));
|
||||
core.checkBlock();
|
||||
if (core.isset(callback)) callback();
|
||||
|
||||
108
libs/events.js
108
libs/events.js
@ -45,6 +45,16 @@ events.prototype.init = function () {
|
||||
if (core.isset(callback))
|
||||
callback();
|
||||
},
|
||||
"ski": function (data, core, callback) {
|
||||
core.events.ski();
|
||||
if (core.isset(callback))
|
||||
callback();
|
||||
},
|
||||
"pushBox": function (data, core, callback) {
|
||||
core.events.pushBox(data);
|
||||
if (core.isset(callback))
|
||||
callback();
|
||||
},
|
||||
'action': function (data, core, callback) {
|
||||
core.events.doEvents(data.event.data, data.x, data.y);
|
||||
if (core.isset(callback)) callback();
|
||||
@ -902,6 +912,104 @@ events.prototype.afterChangeLight = function(x,y) {
|
||||
|
||||
}
|
||||
|
||||
////// 滑冰 //////
|
||||
events.prototype.ski = function (direction) {
|
||||
if (!core.isset(direction))
|
||||
direction = core.status.automaticRoute.lastDirection || core.getHeroLoc('direction');
|
||||
if (core.status.event.id!='ski') {
|
||||
core.waitHeroToStop(function () {
|
||||
core.status.event.id='ski';
|
||||
core.events.ski(direction);
|
||||
});
|
||||
}
|
||||
else {
|
||||
core.moveHero(direction, function () {
|
||||
if (core.status.event.id=='ski') {
|
||||
core.status.event.id=null;
|
||||
core.unLockControl();
|
||||
core.replay();
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
////// 推箱子 //////
|
||||
events.prototype.pushBox = function (data) {
|
||||
if (data.event.id!='box' && data.event.id!='boxed') return;
|
||||
|
||||
// 判断还能否前进,看看是否存在事件
|
||||
var scan = {
|
||||
'up': {'x': 0, 'y': -1},
|
||||
'left': {'x': -1, 'y': 0},
|
||||
'down': {'x': 0, 'y': 1},
|
||||
'right': {'x': 1, 'y': 0}
|
||||
};
|
||||
|
||||
var direction = core.getHeroLoc('direction'), nx=data.x+scan[direction].x, ny=data.y+scan[direction].y;
|
||||
|
||||
if (nx<0||nx>=12||ny<0||ny>=12) return;
|
||||
|
||||
var block = core.getBlock(nx, ny, null, false);
|
||||
if (block!=null && !(core.isset(block.block.event) && block.block.event.id=='flower'))
|
||||
return;
|
||||
|
||||
var blockIcon;
|
||||
if (block==null) {
|
||||
core.status.thisMap.blocks.push(core.maps.getBlock(nx, ny, 169));
|
||||
blockIcon=core.material.icons.terrains.box;
|
||||
}
|
||||
else {
|
||||
block.block.id=170;
|
||||
block.block.event=core.maps.getBlock(null,null,170).event;
|
||||
blockIcon=core.material.icons.terrains.boxed;
|
||||
}
|
||||
core.canvas.event.clearRect(nx * 32, ny * 32, 32, 32);
|
||||
core.canvas.event.drawImage(core.material.images.terrains, 0, blockIcon * 32, 32, 32, nx * 32, ny * 32, 32, 32);
|
||||
|
||||
if (data.event.id=='box') {
|
||||
core.removeBlock(data.x, data.y);
|
||||
}
|
||||
else {
|
||||
data.id=168;
|
||||
data.event=core.maps.getBlock(null,null,168).event;
|
||||
core.canvas.event.clearRect(data.x * 32, data.y * 32, 32, 32);
|
||||
core.canvas.event.drawImage(core.material.images.terrains, 0, core.material.icons.terrains.flower * 32, 32, 32, data.x * 32, data.y * 32, 32, 32);
|
||||
}
|
||||
|
||||
core.updateStatusBar();
|
||||
core.lockControl();
|
||||
core.eventMoveHero([direction], null, function () {
|
||||
core.unLockControl();
|
||||
core.events.afterPushBox();
|
||||
core.replay();
|
||||
})
|
||||
|
||||
}
|
||||
|
||||
////// 推箱子后的事件 //////
|
||||
events.prototype.afterPushBox = function () {
|
||||
|
||||
var noBoxLeft = function () {
|
||||
// 地图上是否还存在未推到的箱子,如果不存在则返回true,存在则返回false
|
||||
for (var i=0;i<core.status.thisMap.blocks.length;i++) {
|
||||
var block=core.status.thisMap.blocks[i];
|
||||
if (core.isset(block.event) && block.event.id=='box') return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
if (noBoxLeft()) {
|
||||
// 可以通过if语句来进行开门操作
|
||||
/*
|
||||
if (core.status.floorId=='xxx') { // 在某个楼层
|
||||
core.insertAction([ // 插入一条事件
|
||||
{"type": "openDoor", "loc": [x,y]} // 开门
|
||||
])
|
||||
}
|
||||
*/
|
||||
}
|
||||
}
|
||||
|
||||
////// 使用炸弹/圣锤后的事件 //////
|
||||
events.prototype.afterUseBomb = function () {
|
||||
|
||||
|
||||
@ -47,7 +47,11 @@ icons_4665ee12_3a1f_44a4_bea3_0fccba634dc1 =
|
||||
'arrowLeft': 37,
|
||||
'arrowRight': 38,
|
||||
'light': 39,
|
||||
'darkLight': 40
|
||||
'darkLight': 40,
|
||||
'ski': 41,
|
||||
'flower': 42,
|
||||
'box': 43,
|
||||
'boxed': 44
|
||||
},
|
||||
'animates': {
|
||||
'star': 0,
|
||||
|
||||
Binary file not shown.
|
Before Width: | Height: | Size: 27 KiB After Width: | Height: | Size: 28 KiB |
@ -122,6 +122,10 @@ maps_comment_90f36752_8815_4be8_b32b_d7fad1d0542e =
|
||||
'164':' 单向右箭头',
|
||||
'165':' 灯',
|
||||
'166':' 暗灯',
|
||||
'167':' 滑冰',
|
||||
'168':' 花',
|
||||
'169':' 箱子',
|
||||
'170':' 完成的箱子',
|
||||
|
||||
|
||||
////////////////////////// 怪物部分 //////////////////////////
|
||||
|
||||
@ -122,6 +122,10 @@ maps_90f36752_8815_4be8_b32b_d7fad1d0542e =
|
||||
'164':{'cls': 'terrains', 'id': 'arrowRight', 'noPass': false}, // 单向右箭头
|
||||
'165':{'cls': 'terrains', 'id': 'light', 'trigger': 'changeLight', 'noPass': false}, // 灯
|
||||
'166':{'cls': 'terrains', 'id': 'darkLight', 'noPass': true}, // 暗灯
|
||||
'167':{'cls': 'terrains', 'id': 'ski', 'trigger': 'ski', 'noPass': false}, // 滑冰
|
||||
'168':{'cls': 'terrains', 'id': 'flower', 'noPass': false}, // 花
|
||||
'169':{'cls': 'terrains', 'id': 'box', 'trigger': 'pushBox', 'noPass': true}, // 箱子
|
||||
'170':{'cls': 'terrains', 'id': 'boxed', 'trigger': 'pushBox', 'noPass': true}, // 完成的箱子
|
||||
|
||||
|
||||
////////////////////////// 怪物部分 //////////////////////////
|
||||
|
||||
Loading…
Reference in New Issue
Block a user