This commit is contained in:
ckcz123 2018-12-17 15:47:02 +08:00
parent fa6d503aac
commit 50babed47a
4 changed files with 38 additions and 39 deletions

View File

@ -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) core.drawBlock(block)
重绘某个图块。block应为core.status.thisMap.blocks中的一项。 重绘某个图块。block应为core.status.thisMap.blocks中的一项。
@ -473,6 +467,16 @@ core.maps.removeBlockByIds(floorId, ids)
ui.js主要用来进行UI窗口的绘制比如对话框、怪物手册、楼传器、存读档界面等等。 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) core.ui.fillText(name, text, x, y, style, font)
在某个画布上绘制一段文字。 在某个画布上绘制一段文字。
name为画布名可以是系统画布之一也可以是任意自定义动态创建的画布名。下同 name为画布名可以是系统画布之一也可以是任意自定义动态创建的画布名。下同
@ -543,17 +547,12 @@ core.ui.deleteAllCanvas()
清空所有的自定义画布。 清空所有的自定义画布。
core.ui.drawThumbnail(floorId, canvas, blocks, x, y, size, heroLoc, heroIcon) core.ui.drawThumbnail(floorId, canvas, blocks, x, y, size, heroLoc, heroIcon)
绘制一个缩略图,比如楼传器界面,存读档界面等情况。 绘制一个缩略图,比如楼传器界面,存读档界面等情况。
floorId为目标楼层IDcanvas为要绘制到的图层blocks为要绘制的所有图块。 floorId为目标楼层IDcanvas为要绘制到的图层blocks为要绘制的所有图块。
x,y为该图层开始绘制的起始点坐标size为每一格的像素heroLoc为勇士坐标heroIcon为勇士图标。 x,y为该图层开始绘制的起始点坐标size为每一格的像素heroLoc为勇士坐标heroIcon为勇士图标。
========== core.utils.XXX 工具类的辅助函数 ========== ========== core.utils.XXX 工具类的辅助函数 ==========
utils.js主要用来进行一些辅助函数的计算。 utils.js主要用来进行一些辅助函数的计算。

View File

@ -738,8 +738,8 @@ core.prototype.drawBlock = function (block, animate, dx, dy) {
} }
////// 绘制某张地图 ////// ////// 绘制某张地图 //////
core.prototype.drawMap = function (mapName, callback) { core.prototype.drawMap = function (floorId, callback) {
core.maps.drawMap(mapName, callback); core.maps.drawMap(floorId, callback);
} }
////// 绘制Autotile ////// ////// 绘制Autotile //////

View File

@ -474,9 +474,9 @@ maps.prototype.drawBgFgMap = function (floorId, canvas, name, animate) {
} }
////// 绘制某张地图 ////// ////// 绘制某张地图 //////
maps.prototype.drawMap = function (mapName, callback) { maps.prototype.drawMap = function (floorId, callback) {
mapName = mapName || core.status.floorId; floorId = floorId || core.status.floorId;
if (!core.isset(mapName)) { if (!core.isset(floorId)) {
if (core.isset(callback)) if (core.isset(callback))
callback(); callback();
return; return;
@ -485,10 +485,10 @@ maps.prototype.drawMap = function (mapName, callback) {
core.removeGlobalAnimate(null, null, true); core.removeGlobalAnimate(null, null, true);
var drawBg = function(){ var drawBg = function(){
var width = core.floors[mapName].width || 13; var width = core.floors[floorId].width || 13;
var height = core.floors[mapName].height || 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]; var blockIcon = core.material.icons.terrains[groundId];
for (var x = 0; x < width; x++) { for (var x = 0; x < width; x++) {
for (var y = 0; y < height; y++) { for (var y = 0; y < height; y++) {
@ -497,8 +497,8 @@ maps.prototype.drawMap = function (mapName, callback) {
} }
var images = []; var images = [];
if (core.isset(core.status.maps[mapName].images)) { if (core.isset(core.status.maps[floorId].images)) {
images = core.status.maps[mapName].images; images = core.status.maps[floorId].images;
if (typeof images == 'string') { if (typeof images == 'string') {
images = [[0, 0, images]]; images = [[0, 0, images]];
} }
@ -507,7 +507,7 @@ maps.prototype.drawMap = function (mapName, callback) {
if (typeof t == 'string') t = [0,0,t]; if (typeof t == 'string') t = [0,0,t];
var dx=parseInt(t[0]), dy=parseInt(t[1]), p=t[2]; var dx=parseInt(t[0]), dy=parseInt(t[1]), p=t[2];
if (core.isset(dx) && core.isset(dy) && 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])) { core.isset(core.material.images.images[p])) {
var image = core.material.images.images[p]; var image = core.material.images.images[p];
if (!t[3]) { 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(floorId, core.canvas.bg, "bg", true);
core.maps.drawBgFgMap(mapName, core.canvas.fg, "fg", true); core.maps.drawBgFgMap(floorId, core.canvas.fg, "fg", true);
} }
if (main.mode=='editor'){ if (main.mode=='editor'){
@ -554,8 +554,8 @@ maps.prototype.drawMap = function (mapName, callback) {
drawBg(); drawBg();
} }
core.status.floorId = mapName; core.status.floorId = floorId;
core.status.thisMap = core.status.maps[mapName]; core.status.thisMap = core.status.maps[floorId];
var drawEvent = function(){ var drawEvent = function(){
var mapData = core.status.maps[core.status.floorId]; var mapData = core.status.maps[core.status.floorId];

View File

@ -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_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; 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_atk = hero_atk;
mon_def = hero_def; 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; mon_def = hero_atk - 1;
} }
@ -464,7 +464,7 @@ var functions_d6ad677b_427a_4623_b50f_a445a3b0ef8a =
// TODO可以在这里新增其他的怪物数据变化 // 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; // 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; // 不可战斗 return null; // 不可战斗
// 战前造成的额外伤害(可被魔防抵消) // 战前造成的额外伤害(可被魔防抵消)
var init_damage = 0; var init_damage = 0;
// 吸血 // 吸血
if (this.hasSpecial(mon_special, 11)) { if (core.hasSpecial(mon_special, 11)) {
var vampire_damage = hero_hp * enemy.value; 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; 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; if (per_damage < 0) per_damage = 0;
// 2连击 & 3连击 & N连击 // 2连击 & 3连击 & N连击
if (this.hasSpecial(mon_special, 4)) per_damage *= 2; if (core.hasSpecial(mon_special, 4)) per_damage *= 2;
if (this.hasSpecial(mon_special, 5)) per_damage *= 3; if (core.hasSpecial(mon_special, 5)) per_damage *= 3;
if (this.hasSpecial(mon_special, 6)) per_damage *= (enemy.n||4); if (core.hasSpecial(mon_special, 6)) per_damage *= (enemy.n||4);
// 每回合的反击伤害;反击是按照勇士的攻击次数来计算回合 // 每回合的反击伤害;反击是按照勇士的攻击次数来计算回合
var counterDamage = 0; 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); 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); init_damage += Math.floor(core.values.purify * hero_mdef);
// 勇士每回合对怪物造成的伤害 // 勇士每回合对怪物造成的伤害