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:
YouWei Zhao 2018-02-14 13:57:09 +08:00
commit d0115230d7
9 changed files with 175 additions and 3 deletions

View File

@ -51,6 +51,7 @@ HTML5 canvas制作的魔塔样板支持全平台游戏
* [x] 改变图块setBlock事件
* [x] 同一个点的多事件处理(做法详见文档)。
* [x] 现在可以支持滑冰和推箱子事件了。
* [x] 地图中每个块的可通行方向控制(悬崖效果)。
* [x] 动画支持带旋转和翻转的帧。
* [x] 现在可以允许用户丢弃道具了(例如不会再使用的装备)。

View File

@ -1197,6 +1197,51 @@ events.prototype.afterUseBomb = function () {
}
```
## 滑冰和推箱子事件
最新的样板还支持滑冰和推箱子事件。
滑冰事件的数字是167trigger为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进行一段对话。

View File

@ -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();

View File

@ -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 () {

View File

@ -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

View File

@ -122,6 +122,10 @@ maps_comment_90f36752_8815_4be8_b32b_d7fad1d0542e =
'164':' 单向右箭头',
'165':' 灯',
'166':' 暗灯',
'167':' 滑冰',
'168':' 花',
'169':' 箱子',
'170':' 完成的箱子',
////////////////////////// 怪物部分 //////////////////////////

View File

@ -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}, // 完成的箱子
////////////////////////// 怪物部分 //////////////////////////

View File

@ -2,6 +2,7 @@
改变图块setBlock事件
同一个点的多事件处理(做法详见文档)。
现在可以支持滑冰和推箱子事件了。
地图中每个块的可通行方向控制(悬崖效果)。
动画支持带旋转和翻转的帧。
现在可以允许用户丢弃道具了(例如不会再使用的装备)。