Merge remote-tracking branch 'refs/remotes/ckcz123/v2.0' into v2.0-editor-docs-20180313
This commit is contained in:
commit
ba3ff6e178
@ -67,6 +67,7 @@ HTML5 canvas制作的魔塔样板,支持全平台游戏!
|
||||
* [x] 全GUI造塔,现在用户无需打开任何文件直接编辑JS代码了。
|
||||
* [x] 整体改变目录架构,将数据和逻辑进行分离
|
||||
* [x] 支持48x32的怪物和NPC素材
|
||||
* [x] 支持插件编写,用户可以根据需求来写插件了
|
||||
* [x] 加点改成系统开关进行处理,怪物手册会列出加点值
|
||||
* [x] 支持带有血量上限的塔
|
||||
* [x] 增加前景图片绘制
|
||||
|
||||
@ -273,6 +273,7 @@ core.prototype.init = function (coreData, callback) {
|
||||
core.material.ground = new Image();
|
||||
core.material.ground.src = "project/images/ground.png";
|
||||
|
||||
|
||||
core.loader.load(function () {
|
||||
console.log(core.material);
|
||||
// 设置勇士高度
|
||||
@ -280,6 +281,11 @@ core.prototype.init = function (coreData, callback) {
|
||||
core.setRequestAnimationFrame();
|
||||
core.showStartAnimate();
|
||||
|
||||
|
||||
|
||||
if (core.isset(functions_d6ad677b_427a_4623_b50f_a445a3b0ef8a.plugins))
|
||||
core.plugin = new functions_d6ad677b_427a_4623_b50f_a445a3b0ef8a.plugins.plugin();
|
||||
|
||||
if (core.isset(callback)) callback();
|
||||
|
||||
});
|
||||
|
||||
@ -71,6 +71,10 @@ events.prototype.getEvents = function (eventName) {
|
||||
return this.events[eventName];
|
||||
}
|
||||
|
||||
events.prototype.initGame = function () {
|
||||
return this.eventdata.initGame();
|
||||
}
|
||||
|
||||
////// 游戏开始事件 //////
|
||||
events.prototype.startGame = function (hard) {
|
||||
|
||||
|
||||
253
libs/items.js
253
libs/items.js
@ -7,32 +7,13 @@ items.prototype.init = function () {
|
||||
this.items = items_296f5d02_12fd_4166_a7c1_b5e830c9ee3a.items;
|
||||
this.itemEffect = items_296f5d02_12fd_4166_a7c1_b5e830c9ee3a.itemEffect;
|
||||
this.itemEffectTip = items_296f5d02_12fd_4166_a7c1_b5e830c9ee3a.itemEffectTip;
|
||||
this.useItemEffect = items_296f5d02_12fd_4166_a7c1_b5e830c9ee3a.useItem;
|
||||
this.canUseItemEffect = items_296f5d02_12fd_4166_a7c1_b5e830c9ee3a.canUseItem;
|
||||
//delete(items_296f5d02_12fd_4166_a7c1_b5e830c9ee3a);
|
||||
}
|
||||
|
||||
////// 获得所有道具 //////
|
||||
items.prototype.getItems = function () {
|
||||
// 大黄门钥匙?钥匙盒?
|
||||
if (core.flags.bigKeyIsBox)
|
||||
this.items['bigKey'] = {'cls': 'items', 'name': '钥匙盒'};
|
||||
// 面前的墙?四周的墙?
|
||||
if (core.flags.pickaxeFourDirections)
|
||||
this.items.pickaxe.text = "可以破坏勇士四周的墙";
|
||||
if (core.flags.bombFourDirections)
|
||||
this.items.bomb.text = "可以炸掉勇士四周的怪物";
|
||||
if (core.flags.equipment) {
|
||||
this.items.sword1 = {'cls': 'constants', 'name': '铁剑', 'text': '一把很普通的铁剑,攻击+'+core.values.sword1};
|
||||
this.items.sword2 = {'cls': 'constants', 'name': '银剑', 'text': '一把很普通的银剑,攻击+'+core.values.sword2};
|
||||
this.items.sword3 = {'cls': 'constants', 'name': '骑士剑', 'text': '一把很普通的骑士剑,攻击+'+core.values.sword3};
|
||||
this.items.sword4 = {'cls': 'constants', 'name': '圣剑', 'text': '一把很普通的圣剑,攻击+'+core.values.sword4};
|
||||
this.items.sword5 = {'cls': 'constants', 'name': '神圣剑', 'text': '一把很普通的神圣剑,攻击+'+core.values.sword5};
|
||||
this.items.shield1 = {'cls': 'constants', 'name': '铁盾', 'text': '一个很普通的铁盾,防御+'+core.values.shield1};
|
||||
this.items.shield2 = {'cls': 'constants', 'name': '银盾', 'text': '一个很普通的银盾,防御+'+core.values.shield2};
|
||||
this.items.shield3 = {'cls': 'constants', 'name': '骑士盾', 'text': '一个很普通的骑士盾,防御+'+core.values.shield3};
|
||||
this.items.shield4 = {'cls': 'constants', 'name': '圣盾', 'text': '一个很普通的圣盾,防御+'+core.values.shield4};
|
||||
this.items.shield5 = {'cls': 'constants', 'name': '神圣盾', 'text': '一个很普通的神圣盾,防御+'+core.values.shield5};
|
||||
}
|
||||
|
||||
return this.items;
|
||||
}
|
||||
|
||||
@ -66,72 +47,8 @@ items.prototype.useItem = function (itemId, callback) {
|
||||
}
|
||||
var itemCls = core.material.items[itemId].cls;
|
||||
|
||||
if (itemId=='book') core.ui.drawBook(0);
|
||||
if (itemId=='fly') core.ui.drawFly(core.status.hero.flyRange.indexOf(core.status.floorId));
|
||||
if (itemId == 'earthquake' || itemId == 'bomb' || itemId == 'pickaxe' || itemId=='icePickaxe'
|
||||
|| itemId == 'snow' || itemId == 'hammer' || itemId=='bigKey') {
|
||||
// 消除当前层的某些块
|
||||
core.removeBlockByIds(core.status.floorId, core.status.event.data);
|
||||
core.drawMap(core.status.floorId, function () {
|
||||
core.drawHero(core.getHeroLoc('direction'), core.getHeroLoc('x'), core.getHeroLoc('y'), 'stop');
|
||||
core.updateFg();
|
||||
core.drawTip(core.material.items[itemId].name + "使用成功");
|
||||
|
||||
if (itemId == 'bomb' || itemId == 'hammer')
|
||||
core.events.afterUseBomb();
|
||||
});
|
||||
}
|
||||
if (itemId == 'centerFly') {
|
||||
// 对称飞
|
||||
core.clearMap('hero', 0, 0, 416, 416);
|
||||
core.setHeroLoc('x', core.status.event.data.x);
|
||||
core.setHeroLoc('y', core.status.event.data.y);
|
||||
core.drawHero(core.getHeroLoc('direction'), core.getHeroLoc('x'), core.getHeroLoc('y'), 'stop');
|
||||
core.drawTip(core.material.items[itemId].name + "使用成功");
|
||||
}
|
||||
if (itemId == 'upFly' || itemId == 'downFly') {
|
||||
// 上楼器/下楼器
|
||||
core.changeFloor(core.status.event.data.id, null, {'direction': core.status.hero.loc.direction, 'x': core.status.event.data.x, 'y': core.status.event.data.y}, null, function (){
|
||||
core.drawTip(core.material.items[itemId].name + "使用成功");
|
||||
core.replay();
|
||||
});
|
||||
}
|
||||
if (itemId == 'poisonWine') core.setFlag('poison', false);
|
||||
if (itemId == 'weakWine') {
|
||||
core.setFlag('weak', false);
|
||||
core.status.hero.atk += core.values.weakValue;
|
||||
core.status.hero.def += core.values.weakValue;
|
||||
}
|
||||
if (itemId == 'curseWine') core.setFlag('curse', false);
|
||||
if (itemId == 'superWine') {
|
||||
core.setFlag('poison', false);
|
||||
if (core.hasFlag('weak')) {
|
||||
core.setFlag('weak', false);
|
||||
core.status.hero.atk += core.values.weakValue;
|
||||
core.status.hero.def += core.values.weakValue;
|
||||
}
|
||||
core.setFlag('curse', false);
|
||||
}
|
||||
|
||||
// 剑
|
||||
if (itemId.indexOf("sword")==0) {
|
||||
var now=core.getFlag('sword', 'sword0'); // 当前装备剑的ID
|
||||
core.status.hero.atk -= core.values[now];
|
||||
core.setItem(now, 1);
|
||||
core.status.hero.atk += core.values[itemId];
|
||||
core.setItem(itemId, 0);
|
||||
core.setFlag('sword', itemId);
|
||||
core.drawTip("已装备"+core.material.items[itemId].name);
|
||||
}
|
||||
// 盾
|
||||
if (itemId.indexOf("shield")==0) {
|
||||
var now=core.getFlag('shield', 'shield0');
|
||||
core.status.hero.def -= core.values[now];
|
||||
core.setItem(now, 1);
|
||||
core.status.hero.def += core.values[itemId];
|
||||
core.setItem(itemId, 0);
|
||||
core.setFlag('shield', itemId);
|
||||
core.drawTip("已装备"+core.material.items[itemId].name);
|
||||
if (itemId in this.useItemEffect) {
|
||||
eval(this.useItemEffect[itemId]);
|
||||
}
|
||||
|
||||
core.updateStatusBar();
|
||||
@ -155,167 +72,9 @@ items.prototype.canUseItem = function (itemId) {
|
||||
// 没有道具
|
||||
if (!core.hasItem(itemId)) return false;
|
||||
|
||||
if (itemId == 'book') return true;
|
||||
if (itemId == 'fly') return core.status.hero.flyRange.indexOf(core.status.floorId)>=0;
|
||||
if (itemId == 'pickaxe') {
|
||||
// 破墙镐
|
||||
var ids = [];
|
||||
for (var i in core.status.thisMap.blocks) {
|
||||
var block = core.status.thisMap.blocks[i];
|
||||
if (core.isset(block.event) && !(core.isset(block.enable) && !block.enable) &&
|
||||
(block.event.id == 'yellowWall' || block.event.id=='whiteWall' || block.event.id=='blueWall')) // 能破哪些墙
|
||||
{
|
||||
// 四个方向
|
||||
if (core.flags.pickaxeFourDirections) {
|
||||
if (Math.abs(block.x-core.status.hero.loc.x)+Math.abs(block.y-core.status.hero.loc.y)<=1) {
|
||||
ids.push(i);
|
||||
}
|
||||
}
|
||||
else {
|
||||
if (block.x == core.nextX() && block.y == core.nextY()) {
|
||||
ids.push(i);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (ids.length>0) {
|
||||
core.status.event.data = ids;
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
if (itemId in this.canUseItemEffect) {
|
||||
return eval(this.canUseItemEffect[itemId]);
|
||||
}
|
||||
if (itemId == 'icePickaxe') {
|
||||
// 破冰镐
|
||||
for (var i in core.status.thisMap.blocks) {
|
||||
var block = core.status.thisMap.blocks[i];
|
||||
if (core.isset(block.event) && !(core.isset(block.enable) && !block.enable) && block.x==core.nextX() && block.y==core.nextY() && block.event.id=='ice') {
|
||||
core.status.event.data = [i];
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
if (itemId == 'bomb') {
|
||||
// 炸弹
|
||||
var ids = [];
|
||||
for (var i in core.status.thisMap.blocks) {
|
||||
var block = core.status.thisMap.blocks[i];
|
||||
if (core.isset(block.event) && !(core.isset(block.enable) && !block.enable) && block.event.cls.indexOf('enemy')==0 && Math.abs(block.x-core.status.hero.loc.x)+Math.abs(block.y-core.status.hero.loc.y)<=1) {
|
||||
var enemy = core.material.enemys[block.event.id];
|
||||
if (core.isset(enemy.bomb) && !enemy.bomb) continue;
|
||||
if (core.flags.bombFourDirections || (block.x==core.nextX() && block.y==core.nextY()))
|
||||
ids.push(i);
|
||||
}
|
||||
}
|
||||
if (ids.length>0) {
|
||||
core.status.event.data = ids;
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
if (itemId == 'hammer') {
|
||||
// 圣锤
|
||||
for (var i in core.status.thisMap.blocks) {
|
||||
var block = core.status.thisMap.blocks[i];
|
||||
if (core.isset(block.event) && !(core.isset(block.enable) && !block.enable) && block.event.cls.indexOf('enemy')==0 && block.x==core.nextX() && block.y==core.nextY()) {
|
||||
var enemy = core.material.enemys[block.event.id];
|
||||
if (core.isset(enemy.bomb) && !enemy.bomb) continue;
|
||||
core.status.event.data = [i];
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
if (itemId == 'earthquake') {
|
||||
var ids = []
|
||||
for (var i in core.status.thisMap.blocks) {
|
||||
var block = core.status.thisMap.blocks[i];
|
||||
if (core.isset(block.event) && !(core.isset(block.enable) && !block.enable) && (block.event.id == 'yellowWall' || block.event.id == 'blueWall' || block.event.id == 'whiteWall'))
|
||||
ids.push(i);
|
||||
}
|
||||
if (ids.length>0) {
|
||||
core.status.event.data = ids;
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
if (itemId == 'centerFly') {
|
||||
// 中心对称
|
||||
var toX = 12 - core.getHeroLoc('x'), toY = 12-core.getHeroLoc('y');
|
||||
var block = core.getBlock(toX, toY);
|
||||
if (block==null) {
|
||||
core.status.event.data = {'x': toX, 'y': toY};
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
if (itemId == 'upFly') {
|
||||
// 上楼器
|
||||
var floorId = core.status.floorId;
|
||||
var index = core.floorIds.indexOf(floorId);
|
||||
if (index==core.floorIds.length-1) return false;
|
||||
var toId = core.floorIds[index+1];
|
||||
var toX = core.getHeroLoc('x'), toY = core.getHeroLoc('y');
|
||||
|
||||
var block = core.getBlock(toX, toY, toId);
|
||||
if (block==null) {
|
||||
core.status.event.data = {'id': toId, 'x': toX, 'y': toY};
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
if (itemId == 'downFly') {
|
||||
// 下楼器
|
||||
var floorId = core.status.floorId;
|
||||
var index = core.floorIds.indexOf(floorId);
|
||||
if (index==0) return false;
|
||||
var toId = core.floorIds[index-1];
|
||||
var toX = core.getHeroLoc('x'), toY = core.getHeroLoc('y');
|
||||
|
||||
var block = core.getBlock(toX, toY, toId);
|
||||
if (block==null) {
|
||||
core.status.event.data = {'id': toId, 'x': toX, 'y': toY};
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
if (itemId=='snow') {
|
||||
// 冰冻徽章
|
||||
var ids = [];
|
||||
for (var i in core.status.thisMap.blocks) {
|
||||
var block = core.status.thisMap.blocks[i];
|
||||
if (core.isset(block.event) && !(core.isset(block.enable) && !block.enable) && block.event.id == 'lava' && Math.abs(block.x-core.status.hero.loc.x)+Math.abs(block.y-core.status.hero.loc.y)<=1) {
|
||||
ids.push(i);
|
||||
}
|
||||
}
|
||||
if (ids.length>0) {
|
||||
core.status.event.data = ids;
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
if (itemId=='bigKey') {
|
||||
// 大黄门钥匙
|
||||
var ids = [];
|
||||
for (var i in core.status.thisMap.blocks) {
|
||||
var block = core.status.thisMap.blocks[i];
|
||||
if (core.isset(block.event) && !(core.isset(block.enable) && !block.enable) && block.event.id == 'yellowDoor') {
|
||||
ids.push(i);
|
||||
}
|
||||
}
|
||||
if (ids.length>0) {
|
||||
core.status.event.data = ids;
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
if (itemId=='poisonWine') return core.hasFlag('poison');
|
||||
if (itemId=='weakWine') return core.hasFlag('weak');
|
||||
if (itemId=='curseWine') return core.hasFlag('curse');
|
||||
if (itemId=='superWine') return core.hasFlag('poison') || core.hasFlag('weak') || core.hasFlag('curse');
|
||||
|
||||
// 剑盾
|
||||
if (itemId.indexOf("sword")==0 || itemId.indexOf("shield")==0) return true;
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -8,7 +8,9 @@ comment_c456ea59_6018_45ef_8bcc_211a24c627dc =
|
||||
'isEquipment': '物品是否属于装备(仅在core.flags.equipment时有效)\n$select({\"values\":[true,false]})$end'
|
||||
},
|
||||
'itemEffect':'cls为items的即捡即用类物品的效果,执行时会对这里的字符串执行eval()',
|
||||
'itemEffectTip':'cls为items的即捡即用类物品,在获得时左上角额外显示的文字,执行时会对这里的字符串执行eval()得到字符串'
|
||||
'itemEffectTip':'cls为items的即捡即用类物品,在获得时左上角额外显示的文字,执行时会对这里的字符串执行eval()得到字符串',
|
||||
'useItem':'cls为tools或contants时的使用物品效果,执行时会对这里的字符串执行eval()',
|
||||
'canUseItem':'cls为tools或contants时能否使用物品的判断,执行时会return这里的字符串执行eval()后的结果',
|
||||
},
|
||||
"items_template" : {'cls': 'items', 'name': '新物品'},
|
||||
"enemys" : {
|
||||
|
||||
@ -147,7 +147,7 @@ data_a1e2fb4a_e986_4524_b0da_9b7ba7c0874d =
|
||||
"pickaxeFourDirections": true,
|
||||
"bombFourDirections": true,
|
||||
"bigKeyIsBox": false,
|
||||
"equipment": false,
|
||||
"equipment": true,
|
||||
"enableDeleteItem": true,
|
||||
"enableAddPoint": false,
|
||||
"enableNegativeDamage": true,
|
||||
|
||||
@ -1,6 +1,7 @@
|
||||
functions_comment_c456ea59_6018_45ef_8bcc_211a24c627dc =
|
||||
{
|
||||
"events" : {
|
||||
"initGame": "游戏开始前的一些初始化操作",
|
||||
"setInitData" : "不同难度分别设置初始属性",
|
||||
"win" : "游戏获胜事件",
|
||||
"lose" : "游戏失败事件",
|
||||
@ -17,5 +18,8 @@ functions_comment_c456ea59_6018_45ef_8bcc_211a24c627dc =
|
||||
},
|
||||
"ui" : {
|
||||
"drawAbout" : "绘制“关于”界面"
|
||||
},
|
||||
"plugins": {
|
||||
"plugin": "自定义插件编写"
|
||||
}
|
||||
}
|
||||
@ -1,6 +1,33 @@
|
||||
functions_d6ad677b_427a_4623_b50f_a445a3b0ef8a =
|
||||
{
|
||||
"events":{
|
||||
////// 游戏开始前的一些初始化操作 //////
|
||||
"initGame": function() {
|
||||
// 游戏开始前的一些初始化操作
|
||||
|
||||
// 根据flag来对道具进行修改
|
||||
if (core.flags.bigKeyIsBox)
|
||||
core.material.items.bigKey = {'cls': 'items', 'name': '钥匙盒'};
|
||||
// 面前的墙?四周的墙?
|
||||
if (core.flags.pickaxeFourDirections)
|
||||
core.material.items.pickaxe.text = "可以破坏勇士四周的墙";
|
||||
if (core.flags.bombFourDirections)
|
||||
core.material.items.bomb.text = "可以炸掉勇士四周的怪物";
|
||||
if (core.flags.equipment) {
|
||||
core.material.items.sword1 = {'cls': 'constants', 'name': '铁剑', 'text': '一把很普通的铁剑'};
|
||||
core.material.items.sword2 = {'cls': 'constants', 'name': '银剑', 'text': '一把很普通的银剑'};
|
||||
core.material.items.sword3 = {'cls': 'constants', 'name': '骑士剑', 'text': '一把很普通的骑士剑'};
|
||||
core.material.items.sword4 = {'cls': 'constants', 'name': '圣剑', 'text': '一把很普通的圣剑'};
|
||||
core.material.items.sword5 = {'cls': 'constants', 'name': '神圣剑', 'text': '一把很普通的神圣剑'};
|
||||
core.material.items.shield1 = {'cls': 'constants', 'name': '铁盾', 'text': '一个很普通的铁盾'};
|
||||
core.material.items.shield2 = {'cls': 'constants', 'name': '银盾', 'text': '一个很普通的银盾'};
|
||||
core.material.items.shield3 = {'cls': 'constants', 'name': '骑士盾', 'text': '一个很普通的骑士盾'};
|
||||
core.material.items.shield4 = {'cls': 'constants', 'name': '圣盾', 'text': '一个很普通的圣盾'};
|
||||
core.material.items.shield5 = {'cls': 'constants', 'name': '神圣盾', 'text': '一个很普通的神圣盾'};
|
||||
}
|
||||
|
||||
|
||||
},
|
||||
////// 不同难度分别设置初始属性 //////
|
||||
"setInitData":function (hard) {
|
||||
// 不同难度分别设置初始属性
|
||||
@ -262,40 +289,80 @@ functions_d6ad677b_427a_4623_b50f_a445a3b0ef8a =
|
||||
////// 读档事件后,载入事件前,可以执行的操作 //////
|
||||
"afterLoadData" : function(data) {
|
||||
// 读档事件后,载入事件前,可以执行的操作
|
||||
// 可以在这里对怪物数据进行动态修改,详见文档——事件——怪物数据的动态修改
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
},
|
||||
"ui":{
|
||||
////// 绘制“关于”界面 //////
|
||||
"drawAbout" : function() {
|
||||
// 绘制“关于”界面
|
||||
|
||||
if (!core.isPlaying()) {
|
||||
core.status.event = {'id': null, 'data': null};
|
||||
core.dom.startPanel.style.display = 'none';
|
||||
}
|
||||
core.lockControl();
|
||||
core.status.event.id = 'about';
|
||||
|
||||
core.clearMap('ui', 0, 0, 416, 416);
|
||||
var left = 48, top = 36, right = 416 - 2 * left, bottom = 416 - 2 * top;
|
||||
|
||||
core.setAlpha('ui', 0.85);
|
||||
core.fillRect('ui', left, top, right, bottom, '#000000');
|
||||
core.setAlpha('ui', 1);
|
||||
core.strokeRect('ui', left - 1, top - 1, right + 1, bottom + 1, '#FFFFFF', 2);
|
||||
|
||||
var text_start = left + 24;
|
||||
|
||||
// 名称
|
||||
core.canvas.ui.textAlign = "left";
|
||||
core.fillText('ui', "HTML5 魔塔样板", text_start, top+35, "#FFD700", "bold 22px Verdana");
|
||||
core.fillText('ui', "版本: "+core.firstData.version, text_start, top + 80, "#FFFFFF", "bold 17px Verdana");
|
||||
core.fillText('ui', "作者: 艾之葵", text_start, top + 112);
|
||||
core.fillText('ui', 'HTML5魔塔交流群:539113091', text_start, top+112+32);
|
||||
// TODO: 写自己的“关于”页面,每次增加32像素即可
|
||||
if (!core.isPlaying()) {
|
||||
core.status.event = {'id': null, 'data': null};
|
||||
core.dom.startPanel.style.display = 'none';
|
||||
}
|
||||
core.lockControl();
|
||||
core.status.event.id = 'about';
|
||||
|
||||
core.clearMap('ui', 0, 0, 416, 416);
|
||||
var left = 48, top = 36, right = 416 - 2 * left, bottom = 416 - 2 * top;
|
||||
|
||||
core.setAlpha('ui', 0.85);
|
||||
core.fillRect('ui', left, top, right, bottom, '#000000');
|
||||
core.setAlpha('ui', 1);
|
||||
core.strokeRect('ui', left - 1, top - 1, right + 1, bottom + 1, '#FFFFFF', 2);
|
||||
|
||||
var text_start = left + 24;
|
||||
|
||||
// 名称
|
||||
core.canvas.ui.textAlign = "left";
|
||||
core.fillText('ui', "HTML5 魔塔样板", text_start, top+35, "#FFD700", "bold 22px Verdana");
|
||||
core.fillText('ui', "版本: "+core.firstData.version, text_start, top + 80, "#FFFFFF", "bold 17px Verdana");
|
||||
core.fillText('ui', "作者: 艾之葵", text_start, top + 112);
|
||||
core.fillText('ui', 'HTML5魔塔交流群:539113091', text_start, top+112+32);
|
||||
// TODO: 写自己的“关于”页面,每次增加32像素即可
|
||||
}
|
||||
},
|
||||
"plugins": {
|
||||
"plugin": function () {
|
||||
////// 插件编写,可以在这里写自己额外需要执行的脚本 //////
|
||||
|
||||
// 在这里写的代码,在所有模块加载完毕后,游戏开始前会被执行
|
||||
console.log("插件编写测试");
|
||||
// 可以写一些其他的被直接执行的代码
|
||||
|
||||
|
||||
// 在这里写所有需要自定义的函数
|
||||
// 写法必须是 this.xxx = function (args) { ...
|
||||
// 如果不写this的话,函数将无法被外部所访问
|
||||
this.test = function () {
|
||||
console.log("插件函数执行测试");
|
||||
}
|
||||
|
||||
this.useEquipment = function (itemId) { // 使用装备
|
||||
if (itemId.indexOf("sword")==0) {
|
||||
var now=core.getFlag('sword', 'sword0'); // 当前装备剑的ID
|
||||
core.status.hero.atk -= core.values[now];
|
||||
core.setItem(now, 1);
|
||||
core.status.hero.atk += core.values[itemId];
|
||||
core.setItem(itemId, 0);
|
||||
core.setFlag('sword', itemId);
|
||||
core.drawTip("已装备"+core.material.items[itemId].name);
|
||||
}
|
||||
if (itemId.indexOf("shield")==0) {
|
||||
var now=core.getFlag('shield', 'shield0');
|
||||
core.status.hero.def -= core.values[now];
|
||||
core.setItem(now, 1);
|
||||
core.status.hero.def += core.values[itemId];
|
||||
core.setItem(itemId, 0);
|
||||
core.setFlag('shield', itemId);
|
||||
core.drawTip("已装备"+core.material.items[itemId].name);
|
||||
}
|
||||
}
|
||||
|
||||
// 可以在任何地方(如afterXXX或自定义脚本事件)调用函数,方法为 core.plugin.xxx();
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -112,6 +112,69 @@ items_296f5d02_12fd_4166_a7c1_b5e830c9ee3a =
|
||||
"bigKey":"',全钥匙+1'",
|
||||
"superPotion":"',生命值翻倍'",
|
||||
"moneyPocket":"',金币+'+core.values.moneyPocket",
|
||||
},
|
||||
|
||||
"useItem": {
|
||||
"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 + '使用成功');",
|
||||
"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);",
|
||||
"weakWine": "core.setFlag('weak', false);\ncore.status.hero.atk += core.values.weakValue;\ncore.status.hero.def += core.values.weakValue;",
|
||||
"curseWine": "core.setFlag('curse', false);",
|
||||
"superWine": "core.setFlag('poison', false);\nif (core.hasFlag('weak')) {\n core.setFlag('weak', false);\n core.status.hero.atk += core.values.weakValue;\n core.status.hero.def += core.values.weakValue;\n}\ncore.setFlag('curse', false);",
|
||||
"sword0": "core.plugin.useEquipment(itemId)",
|
||||
"sword1": "core.plugin.useEquipment(itemId)",
|
||||
"sword2": "core.plugin.useEquipment(itemId)",
|
||||
"sword3": "core.plugin.useEquipment(itemId)",
|
||||
"sword4": "core.plugin.useEquipment(itemId)",
|
||||
"sword5": "core.plugin.useEquipment(itemId)",
|
||||
"shield0": "core.plugin.useEquipment(itemId)",
|
||||
"shield1": "core.plugin.useEquipment(itemId)",
|
||||
"shield2": "core.plugin.useEquipment(itemId)",
|
||||
"shield3": "core.plugin.useEquipment(itemId)",
|
||||
"shield4": "core.plugin.useEquipment(itemId)",
|
||||
"shield5": "core.plugin.useEquipment(itemId)",
|
||||
},
|
||||
|
||||
"canUseItem": {
|
||||
"book": "true",
|
||||
"fly": "core.status.hero.flyRange.indexOf(core.status.floorId)>=0",
|
||||
"pickaxe": "var able=false;\nvar ids = [];\nfor (var i in core.status.thisMap.blocks) {\n var block = core.status.thisMap.blocks[i];\n if (core.isset(block.event) && !(core.isset(block.enable) && !block.enable) &&\n (block.event.id == 'yellowWall' || block.event.id=='whiteWall' || block.event.id=='blueWall')) // 能破哪些墙\n {\n // 四个方向\n if (core.flags.pickaxeFourDirections) {\n if (Math.abs(block.x-core.status.hero.loc.x)+Math.abs(block.y-core.status.hero.loc.y)<=1) {\n ids.push(i);\n }\n }\n else {\n if (block.x == core.nextX() && block.y == core.nextY()) {\n ids.push(i);\n }\n }\n }\n}\nif (ids.length>0) {\n core.status.event.data = ids;\n able=true;\n}\nable",
|
||||
"icePickaxe": "var able=false;\nfor (var i in core.status.thisMap.blocks) {\n var block = core.status.thisMap.blocks[i];\n if (core.isset(block.event) && !(core.isset(block.enable) && !block.enable) && block.x==core.nextX() && block.y==core.nextY() && block.event.id=='ice') {\n core.status.event.data = [i];\n able=true;\n }\n}\nable",
|
||||
"bomb": "var able=false;\nvar ids = [];\nfor (var i in core.status.thisMap.blocks) {\n var block = core.status.thisMap.blocks[i];\n if (core.isset(block.event) && !(core.isset(block.enable) && !block.enable) && block.event.cls.indexOf('enemy')==0 && Math.abs(block.x-core.status.hero.loc.x)+Math.abs(block.y-core.status.hero.loc.y)<=1) {\n var enemy = core.material.enemys[block.event.id];\n if (core.isset(enemy.bomb) && !enemy.bomb) continue;\n if (core.flags.bombFourDirections || (block.x==core.nextX() && block.y==core.nextY()))\n ids.push(i);\n }\n}\nif (ids.length>0) {\n core.status.event.data = ids;\n able=true;\n}\nable",
|
||||
"hammer": "var able=false;\nfor (var i in core.status.thisMap.blocks) {\n var block = core.status.thisMap.blocks[i];\n if (core.isset(block.event) && !(core.isset(block.enable) && !block.enable) && block.event.cls.indexOf('enemy')==0 && block.x==core.nextX() && block.y==core.nextY()) {\n var enemy = core.material.enemys[block.event.id];\n if (core.isset(enemy.bomb) && !enemy.bomb) continue;\n core.status.event.data = [i];\n able=true;\n }\n}\nable",
|
||||
"earthquake": "var able=false;\nvar ids = [];\nfor (var i in core.status.thisMap.blocks) {\n var block = core.status.thisMap.blocks[i];\n if (core.isset(block.event) && !(core.isset(block.enable) && !block.enable) && (block.event.id == 'yellowWall' || block.event.id == 'blueWall' || block.event.id == 'whiteWall')) // 能炸的墙壁\n ids.push(i);\n}\nif (ids.length>0) {\n core.status.event.data = ids;\n able=true;\n}\nable",
|
||||
"centerFly": "var able=false;\nvar toX = 12 - core.getHeroLoc('x'), toY = 12-core.getHeroLoc('y');\nvar block = core.getBlock(toX, toY);\nif (block==null) {\n core.status.event.data = {'x': toX, 'y': toY};\n able = true;\n}\nable",
|
||||
"upFly": "var able=false;\nvar floorId = core.status.floorId, index = core.floorIds.indexOf(floorId);\nif (index<core.floorIds.length-1) {\n\tvar toId = core.floorIds[index+1], toX = core.getHeroLoc('x'), toY = core.getHeroLoc('y');\n\tif (core.getBlock(toX, toY, toId)==null) {\n\t\tcore.status.event.data = {'id': toId, 'x': toX, 'y': toY};\n\t\table=true;\n\t}\n}\nable",
|
||||
"downFly": "var able=false;\nvar floorId = core.status.floorId, index = core.floorIds.indexOf(floorId);\nif (index>0) {\n\tvar toId = core.floorIds[index-1], toX = core.getHeroLoc('x'), toY = core.getHeroLoc('y');\n\tif (core.getBlock(toX, toY, toId)==null) {\n\t\tcore.status.event.data = {'id': toId, 'x': toX, 'y': toY};\n\t\table=true;\n\t}\n}\nable",
|
||||
"snow": "var able=false;\nvar ids = [];\nfor (var i in core.status.thisMap.blocks) {\n var block = core.status.thisMap.blocks[i];\n if (core.isset(block.event) && !(core.isset(block.enable) && !block.enable) && block.event.id == 'lava' && Math.abs(block.x-core.status.hero.loc.x)+Math.abs(block.y-core.status.hero.loc.y)<=1) {\n ids.push(i);\n }\n}\nif (ids.length>0) {\n core.status.event.data = ids;\n able=true;\n}\nable",
|
||||
"bigKey": "var able=false;\nvar ids = [];\nfor (var i in core.status.thisMap.blocks) {\n var block = core.status.thisMap.blocks[i];\n if (core.isset(block.event) && !(core.isset(block.enable) && !block.enable) && block.event.id == 'yellowDoor') {\n ids.push(i);\n }\n}\nif (ids.length>0) {\n core.status.event.data = ids;\n able=true;\n}\nable",
|
||||
"poisonWine": "core.hasFlag('poison')",
|
||||
"weakWine": "core.hasFlag('weak')",
|
||||
"curseWine": "core.hasFlag('curse')",
|
||||
"superWine": "core.hasFlag('poison') || core.hasFlag('weak') || core.hasFlag('curse')",
|
||||
"sword0": "true",
|
||||
"sword1": "true",
|
||||
"sword2": "true",
|
||||
"sword3": "true",
|
||||
"sword4": "true",
|
||||
"sword5": "true",
|
||||
"shield0": "true",
|
||||
"shield1": "true",
|
||||
"shield2": "true",
|
||||
"shield3": "true",
|
||||
"shield4": "true",
|
||||
"shiled5": "true",
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
Loading…
Reference in New Issue
Block a user