From 50babed47ab38769f79c36be807c5f92e71c84d6 Mon Sep 17 00:00:00 2001 From: ckcz123 Date: Mon, 17 Dec 2018 15:47:02 +0800 Subject: [PATCH] Docs --- docs/api.md | 21 ++++++++++----------- libs/core.js | 4 ++-- libs/maps.js | 26 +++++++++++++------------- project/functions.js | 26 +++++++++++++------------- 4 files changed, 38 insertions(+), 39 deletions(-) diff --git a/docs/api.md b/docs/api.md index 7fe0257c..15477fdd 100644 --- a/docs/api.md +++ b/docs/api.md @@ -184,12 +184,6 @@ core.trigger(x, y) [异步] 触发某个地点的事件。 -core.clearMap(mapName) -清空某个画布图层。 -mapName可为'bg', 'event', 'hero', 'event2', 'fg', 'damage', 'animate', 'weather', 'ui', 'data', 'all'之一。 -如果mapName为'all',则为清空所有画布;否则只清空对应的画布。 - - core.drawBlock(block) 重绘某个图块。block应为core.status.thisMap.blocks中的一项。 @@ -473,6 +467,16 @@ core.maps.removeBlockByIds(floorId, ids) ui.js主要用来进行UI窗口的绘制,比如对话框、怪物手册、楼传器、存读档界面等等。 +core.ui.getContextByName(name) +根据画布名找到一个画布的context;支持系统画布和自定义画布。如果不存在画布返回null。 + + +core.clearMap(name) +清空某个画布图层。 +name为画布名,可以是系统画布之一,也可以是任意自定义动态创建的画布名。 +如果name也可以是'all',若为all则为清空除色调层外的所有系统画布。 + + core.ui.fillText(name, text, x, y, style, font) 在某个画布上绘制一段文字。 name为画布名,可以是系统画布之一,也可以是任意自定义动态创建的画布名。(下同) @@ -543,17 +547,12 @@ core.ui.deleteAllCanvas() 清空所有的自定义画布。 - core.ui.drawThumbnail(floorId, canvas, blocks, x, y, size, heroLoc, heroIcon) 绘制一个缩略图,比如楼传器界面,存读档界面等情况。 floorId为目标楼层ID,canvas为要绘制到的图层,blocks为要绘制的所有图块。 x,y为该图层开始绘制的起始点坐标,size为每一格的像素,heroLoc为勇士坐标,heroIcon为勇士图标。 - - - - ========== core.utils.XXX 工具类的辅助函数 ========== utils.js主要用来进行一些辅助函数的计算。 diff --git a/libs/core.js b/libs/core.js index 9280b192..238ee2de 100644 --- a/libs/core.js +++ b/libs/core.js @@ -738,8 +738,8 @@ core.prototype.drawBlock = function (block, animate, dx, dy) { } ////// 绘制某张地图 ////// -core.prototype.drawMap = function (mapName, callback) { - core.maps.drawMap(mapName, callback); +core.prototype.drawMap = function (floorId, callback) { + core.maps.drawMap(floorId, callback); } ////// 绘制Autotile ////// diff --git a/libs/maps.js b/libs/maps.js index dc360888..96825f5d 100644 --- a/libs/maps.js +++ b/libs/maps.js @@ -474,9 +474,9 @@ maps.prototype.drawBgFgMap = function (floorId, canvas, name, animate) { } ////// 绘制某张地图 ////// -maps.prototype.drawMap = function (mapName, callback) { - mapName = mapName || core.status.floorId; - if (!core.isset(mapName)) { +maps.prototype.drawMap = function (floorId, callback) { + floorId = floorId || core.status.floorId; + if (!core.isset(floorId)) { if (core.isset(callback)) callback(); return; @@ -485,10 +485,10 @@ maps.prototype.drawMap = function (mapName, callback) { core.removeGlobalAnimate(null, null, true); var drawBg = function(){ - var width = core.floors[mapName].width || 13; - var height = core.floors[mapName].height || 13; + var width = core.floors[floorId].width || 13; + var height = core.floors[floorId].height || 13; - var groundId = (core.status.maps||core.floors)[mapName].defaultGround || "ground"; + var groundId = (core.status.maps||core.floors)[floorId].defaultGround || "ground"; var blockIcon = core.material.icons.terrains[groundId]; for (var x = 0; x < width; x++) { for (var y = 0; y < height; y++) { @@ -497,8 +497,8 @@ maps.prototype.drawMap = function (mapName, callback) { } var images = []; - if (core.isset(core.status.maps[mapName].images)) { - images = core.status.maps[mapName].images; + if (core.isset(core.status.maps[floorId].images)) { + images = core.status.maps[floorId].images; if (typeof images == 'string') { images = [[0, 0, images]]; } @@ -507,7 +507,7 @@ maps.prototype.drawMap = function (mapName, callback) { if (typeof t == 'string') t = [0,0,t]; var dx=parseInt(t[0]), dy=parseInt(t[1]), p=t[2]; if (core.isset(dx) && core.isset(dy) && - !core.hasFlag("floorimg_"+mapName+"_"+dx+"_"+dy) && + !core.hasFlag("floorimg_"+floorId+"_"+dx+"_"+dy) && core.isset(core.material.images.images[p])) { var image = core.material.images.images[p]; if (!t[3]) { @@ -537,8 +537,8 @@ maps.prototype.drawMap = function (mapName, callback) { } }); - core.maps.drawBgFgMap(mapName, core.canvas.bg, "bg", true); - core.maps.drawBgFgMap(mapName, core.canvas.fg, "fg", true); + core.maps.drawBgFgMap(floorId, core.canvas.bg, "bg", true); + core.maps.drawBgFgMap(floorId, core.canvas.fg, "fg", true); } if (main.mode=='editor'){ @@ -554,8 +554,8 @@ maps.prototype.drawMap = function (mapName, callback) { drawBg(); } - core.status.floorId = mapName; - core.status.thisMap = core.status.maps[mapName]; + core.status.floorId = floorId; + core.status.thisMap = core.status.maps[floorId]; var drawEvent = function(){ var mapData = core.status.maps[core.status.floorId]; diff --git a/project/functions.js b/project/functions.js index 6d6083e2..6bcaa815 100644 --- a/project/functions.js +++ b/project/functions.js @@ -423,12 +423,12 @@ var functions_d6ad677b_427a_4623_b50f_a445a3b0ef8a = var mon_hp = enemy.hp, mon_atk = enemy.atk, mon_def = enemy.def, mon_special = enemy.special; var mon_money = enemy.money, mon_experience = enemy.experience, mon_point = enemy.point; // 模仿 - if (this.hasSpecial(mon_special, 10)) { + if (core.hasSpecial(mon_special, 10)) { mon_atk = hero_atk; mon_def = hero_def; } // 坚固 - if (this.hasSpecial(mon_special, 3) && mon_def < hero_atk - 1) { + if (core.hasSpecial(mon_special, 3) && mon_def < hero_atk - 1) { mon_def = hero_atk - 1; } @@ -464,7 +464,7 @@ var functions_d6ad677b_427a_4623_b50f_a445a3b0ef8a = // TODO:可以在这里新增其他的怪物数据变化 // 比如仿攻(怪物攻击不低于勇士攻击): - // if (this.hasSpecial(mon_special, 27) && mon_atk < hero_atk) { + // if (core.hasSpecial(mon_special, 27) && mon_atk < hero_atk) { // mon_atk = hero_atk; // } // 也可以按需增加各种自定义内容(比如幻塔的魔杖效果等) @@ -512,14 +512,14 @@ var functions_d6ad677b_427a_4623_b50f_a445a3b0ef8a = } // 如果是无敌属性,且勇士未持有十字架 - if (this.hasSpecial(mon_special, 20) && !core.hasItem("cross")) + if (core.hasSpecial(mon_special, 20) && !core.hasItem("cross")) return null; // 不可战斗 // 战前造成的额外伤害(可被魔防抵消) var init_damage = 0; // 吸血 - if (this.hasSpecial(mon_special, 11)) { + if (core.hasSpecial(mon_special, 11)) { var vampire_damage = hero_hp * enemy.value; // 如果有神圣盾免疫吸血等可以在这里写 @@ -537,28 +537,28 @@ var functions_d6ad677b_427a_4623_b50f_a445a3b0ef8a = // 每回合怪物对勇士造成的战斗伤害 var per_damage = mon_atk - hero_def; // 魔攻:战斗伤害就是怪物攻击力 - if (this.hasSpecial(mon_special, 2)) per_damage = mon_atk; + if (core.hasSpecial(mon_special, 2)) per_damage = mon_atk; // 战斗伤害不能为负值 if (per_damage < 0) per_damage = 0; // 2连击 & 3连击 & N连击 - if (this.hasSpecial(mon_special, 4)) per_damage *= 2; - if (this.hasSpecial(mon_special, 5)) per_damage *= 3; - if (this.hasSpecial(mon_special, 6)) per_damage *= (enemy.n||4); + if (core.hasSpecial(mon_special, 4)) per_damage *= 2; + if (core.hasSpecial(mon_special, 5)) per_damage *= 3; + if (core.hasSpecial(mon_special, 6)) per_damage *= (enemy.n||4); // 每回合的反击伤害;反击是按照勇士的攻击次数来计算回合 var counterDamage = 0; - if (this.hasSpecial(mon_special, 8)) counterDamage += Math.floor(core.values.counterAttack * hero_atk); + if (core.hasSpecial(mon_special, 8)) counterDamage += Math.floor(core.values.counterAttack * hero_atk); // 先攻 - if (this.hasSpecial(mon_special, 1)) init_damage += per_damage; + if (core.hasSpecial(mon_special, 1)) init_damage += per_damage; // 破甲 - if (this.hasSpecial(mon_special, 7)) + if (core.hasSpecial(mon_special, 7)) init_damage += Math.floor(core.values.breakArmor * hero_def); // 净化 - if (this.hasSpecial(mon_special, 9)) + if (core.hasSpecial(mon_special, 9)) init_damage += Math.floor(core.values.purify * hero_mdef); // 勇士每回合对怪物造成的伤害