Skip to content

Commit

Permalink
调整参数,同时根据网友建议,新建建筑时添加检查,禁止用建筑把怪物包围起来。
Browse files Browse the repository at this point in the history
  • Loading branch information
oldj committed Jan 1, 2011
1 parent 0cbdbaa commit e460edf
Show file tree
Hide file tree
Showing 6 changed files with 45 additions and 6 deletions.
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,8 @@ HTML5 塔防游戏
更新历史:
----------

- 2010-12-29 根据网友建议,增加生命自动恢复功能(每隔 5 波生命恢复 5 点,每隔 10 波生命恢复 10 点)。调整参数,减小了激光枪的射程,增强了重机枪的威力。(v0.1.12)。
- 2011-01-01 调整参数,同时根据网友建议,新建建筑时添加检查,禁止用建筑把怪物包围起来(v0.1.14)。
- 2010-12-29 根据网友建议,增加生命自动恢复功能(每隔 5 波生命恢复 5 点,每隔 10 波生命恢复 10 点)。调整参数,减小了激光枪的射程,增强了重机枪的威力(v0.1.12)。
- 2010-12-18 添加新武器“激光枪”(v0.1.8.0)。
- 2010-12-12 暂停图片资源版本分支的开发,继续优化、开发圈圈版(v0.1.7.0)。
- 2010-11-28 第一个图片资源版本(v0.2.1.3267)。
Expand Down
2 changes: 2 additions & 0 deletions src/js/td-data-stage-1.js
Original file line number Diff line number Diff line change
Expand Up @@ -271,6 +271,8 @@ _TD.a.push(function (TD) {
// 没有造成伤害
if (wave < 5) {
TD.difficulty *= 1.05;
} else if (TD.difficulty > 30) {
TD.difficulty *= 1.1;
} else {
TD.difficulty *= 1.2;
}
Expand Down
1 change: 1 addition & 0 deletions src/js/td-msg.js
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ _TD.a.push(function (TD) {
"button_pause_desc_0": "游戏暂停",
"button_pause_desc_1": "游戏继续",
"blocked": "不能在这儿修建建筑,起点与终点之间至少要有一条路可到达!",
"monster_be_blocked": "不能在这儿修建建筑,有怪物被围起来了!",
"_": "ERROR"
};

Expand Down
20 changes: 16 additions & 4 deletions src/js/td-obj-grid.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,8 @@ _TD.a.push(function (TD) {
checkBlock: function () {
if (this.is_entrance || this.is_exit) return true;

var _this = this,
var is_blocked,
_this = this,
fw = new TD.FindWay(
this.map.grid_x, this.map.grid_y,
this.map.entrance.mx, this.map.entrance.my,
Expand All @@ -60,7 +61,19 @@ _TD.a.push(function (TD) {
}
);

return fw.is_blocked;
is_blocked = fw.is_blocked;

if (!is_blocked) {
is_blocked = !!this.map.anyMonster(function (obj) {
return obj.chkIfBlocked(_this.mx, _this.my);
});
if (is_blocked)
this._block_msg = TD._t("monster_be_blocked");
} else {
this._block_msg = TD._t("blocked");
}

return is_blocked;
},

/**
Expand Down Expand Up @@ -238,8 +251,7 @@ _TD.a.push(function (TD) {
// 如果处于建设模式下,并且点击在主地图的空格子上,则尝试建设指定建筑
if (this.checkBlock()) {
// 起点与终点之间被阻塞,不能修建
var msg = TD._t("blocked");
this.scene.panel.balloontip.msg(msg, this);
this.scene.panel.balloontip.msg(this._block_msg, this);
} else {
// 购买建筑
this.buyBuilding(this.map.pre_building.type);
Expand Down
23 changes: 23 additions & 0 deletions src/js/td-obj-monster.js
Original file line number Diff line number Diff line change
Expand Up @@ -195,6 +195,29 @@ _TD.a.push(function (TD) {
// this.getToward(); // 在这个版本中暂时没有用
},

/**
* 检查假如在地图 (x, y) 的位置修建建筑,是否会阻塞当前怪物
* @param mx {Number} 地图的 x 坐标
* @param my {Number} 地图的 y 坐标
* @return {Boolean}
*/
chkIfBlocked: function (mx, my) {

var _this = this,
fw = new TD.FindWay(
this.map.grid_x, this.map.grid_y,
this.grid.mx, this.grid.my,
this.map.exit.mx, this.map.exit.my,
function (x, y) {
return !(x == mx && y == my) &&
_this.map.checkPassable(x, y);
}
);

return fw.is_blocked;

},

/**
* 怪物前进的道路被阻塞(被建筑包围了)
*/
Expand Down
2 changes: 1 addition & 1 deletion src/js/td.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ var _TD = {
delete this.init; // 一旦初始化运行,即删除这个入口引用,防止初始化方法被再次调用

var i, TD = {
version: "0.1.13", // 版本命名规范参考:https://semver.org/
version: "0.1.14", // 版本命名规范参考:https://semver.org/
is_debug: !!is_debug,
is_paused: true,
width: 16, // 横向多少个格子
Expand Down

0 comments on commit e460edf

Please sign in to comment.