怪物详细信息使用drawTextContent绘制

This commit is contained in:
ckcz123 2020-05-14 21:50:37 +08:00
parent b4c6e2e90a
commit 8484ff65b7
4 changed files with 22 additions and 29 deletions

View File

@ -239,6 +239,10 @@ core.prototype._init_flags = function () {
core.values = core.clone(core.data.values);
core.firstData = core.clone(core.data.firstData);
this._init_sys_flags();
// 让你总是拼错!
window.on = true;
window.off = false;
core.dom.versionLabel.innerText = core.firstData.version;
core.dom.logoLabel.innerText = core.firstData.title;

View File

@ -86,7 +86,7 @@ enemys.prototype.getSpecialHint = function (enemy, special) {
var hints = [];
for (var i = 0; i < specials.length; i++) {
if (this.hasSpecial(enemy, specials[i][0]))
hints.push(this._calSpecialContent(enemy, specials[i][1]) + "" + this._calSpecialContent(enemy, specials[i][2]));
hints.push("\r[#FF6A6A]\\d"+this._calSpecialContent(enemy, specials[i][1]) + "\\d\r[]" + this._calSpecialContent(enemy, specials[i][2]));
}
return hints;
}
@ -94,7 +94,7 @@ enemys.prototype.getSpecialHint = function (enemy, special) {
if (specials == null) return "";
for (var i = 0; i < specials.length; i++) {
if (special == specials[i][0])
return this._calSpecialContent(enemy, specials[i][1]) + "" + this._calSpecialContent(enemy, specials[i][2]);
return "\r[#FF6A6A]\\d"+this._calSpecialContent(enemy, specials[i][1]) + "\\d\r[]" + this._calSpecialContent(enemy, specials[i][2]);
}
return "";
}

View File

@ -1875,8 +1875,8 @@ ui.prototype.drawBookDetail = function (index) {
var left = 10, width = this.PIXEL - 2 * left, right = left + width;
var content_left = left + 25, validWidth = right - content_left - 13;
var contents = core.splitLines("data", content, validWidth, this._buildFont(16, false));
var height = Math.max(24 * contents.length + 55, 80), top = (this.PIXEL - height) / 2, bottom = top + height;
var height = Math.max(this.getTextContentHeight(content, {fontSize: 16, lineHeight: 24, maxWidth: validWidth}) + 58, 80),
top = (this.PIXEL - height) / 2, bottom = top + height;
core.setAlpha('data', 0.9);
core.fillRect('data', left, top, width, height, '#000000');
@ -1884,7 +1884,7 @@ ui.prototype.drawBookDetail = function (index) {
core.strokeRect('data', left - 1, top - 1, width + 1, height + 1,
core.status.globalAttribute.borderColor, 2);
this._drawBookDetail_drawContent(enemy, contents, {top: top, content_left: content_left, bottom: bottom});
this._drawBookDetail_drawContent(enemy, content, {top: top, content_left: content_left, bottom: bottom, validWidth: validWidth});
}
ui.prototype._drawBookDetail_getInfo = function (index) {
@ -1917,7 +1917,7 @@ ui.prototype._drawBookDetail_mofang = function (enemy, texts) {
var hp = enemy.hp;
var delta = core.status.hero.atk - core.status.hero.def;
if (delta<hp && hp<=10000 && hp>0) {
texts.push("模仿临界计算器:(当前攻防差"+core.formatBigNumber(delta)+"");
texts.push("\r[#FF6A6A]\\d模仿临界计算器:\\d\r[](当前攻防差"+core.formatBigNumber(delta)+"");
var u = [];
this._drawBookDetail_mofang_getArray(hp).forEach(function (t) {
if (u.length < 20) u.push(t);
@ -1968,7 +1968,7 @@ ui.prototype._drawBookDetail_vampire = function (enemy, texts) {
}
core.status.hero.hp = start;
if (core.canBattle(enemy.id)) {
texts.push("打死该怪物最低需要生命值:"+core.formatBigNumber(start));
texts.push("\r[#FF6A6A]\\d打死该怪物最低需要生命值:\\d\r[]"+core.formatBigNumber(start));
}
core.status.hero.hp = nowHp;
}
@ -1977,19 +1977,19 @@ ui.prototype._drawBookDetail_vampire = function (enemy, texts) {
ui.prototype._drawBookDetail_hatred = function (enemy, texts) {
if (core.enemys.hasSpecial(enemy.special, 17)) {
texts.push("当前仇恨伤害值:"+core.getFlag('hatred', 0));
texts.push("\r[#FF6A6A]\\d当前仇恨伤害值:\\d\r[]"+core.getFlag('hatred', 0));
}
}
ui.prototype._drawBookDetail_turnAndCriticals = function (enemy, floorId, texts) {
var damageInfo = core.getDamageInfo(enemy, null, null, null, floorId);
texts.push("战斗回合数:"+((damageInfo||{}).turn||0));
texts.push("\r[#FF6A6A]\\d战斗回合数:\\d\r[]"+((damageInfo||{}).turn||0));
// 临界表
var criticals = core.enemys.nextCriticals(enemy, 8, null, null, floorId).map(function (v) {
return core.formatBigNumber(v[0])+":"+core.formatBigNumber(v[1]);
});
while (criticals[0]=='0:0') criticals.shift();
texts.push("临界表:"+JSON.stringify(criticals));
texts.push("\r[#FF6A6A]\\d临界表:\\d\r[]"+JSON.stringify(criticals));
var prevInfo = core.getDamageInfo(enemy, {atk: core.status.hero.atk-1}, null, null, floorId);
if (prevInfo != null && damageInfo != null) {
if (damageInfo.damage != null) damageInfo = damageInfo.damage;
@ -2000,26 +2000,14 @@ ui.prototype._drawBookDetail_turnAndCriticals = function (enemy, floorId, texts)
}
}
ui.prototype._drawBookDetail_drawContent = function (enemy, contents, pos) {
ui.prototype._drawBookDetail_drawContent = function (enemy, content, pos) {
// 名称
core.setTextAlign('data', 'left');
core.fillText('data', enemy.name, pos.content_left, pos.top + 30, '#FFD700', this._buildFont(22, true));
var content_top = pos.top + 57;
var content_top = pos.top + 44;
for (var i=0;i<contents.length;i++) {
var text=contents[i];
var index=text.indexOf("");
if (index>=0) {
var x1 = text.substring(0, index+1);
core.fillText('data', x1, pos.content_left, content_top, '#FF6A6A', this._buildFont(16, true));
var len=core.calWidth('data', x1);
core.fillText('data', text.substring(index+1), pos.content_left+len, content_top, '#FFFFFF', this._buildFont(16, false));
}
else {
core.fillText('data', contents[i], pos.content_left, content_top, '#FFFFFF', this._buildFont(16, false));
}
content_top+=24;
}
this.drawTextContent('data', content, {left: pos.content_left, top: content_top, maxWidth: pos.validWidth,
fontSize: 16, lineHeight: 24});
}
////// 绘制楼层传送器 //////

View File

@ -31,10 +31,11 @@
初始化&读档优化:不一次读取全部楼层并创建
(已完成!) 绿钥匙进状态栏
(已完成!) 图块ID不可全数字
怪物详细信息富文本化
(已完成!) 怪物详细信息富文本化
(已完成!) for和forEach事件
(已完成!) 转向:顺时针/逆时针/反向
事件转向
(已完成!) 事件转向
(已完成!) 修复core.removeBlock隐藏和删除问题
(已完成!) 合并数值操作事件
(已完成!) fromLoad聚集问题
(已完成!) 注释优化
@ -74,7 +75,7 @@
(已完成!) 22. betweenAttackMax在被四个怪同时夹击时比如上下楼后或通过事件使勇士和其中一只怪重合了目前是以上下方向的怪为准建议在表格注释中予以强调更合理的做法是在两种怪的战损中取max或min
(不处理) 23. displayIdInBook属性不能用于夹击QAQ同时建议给core.getBlockId()追加一个“如果是怪物是否按displayIdInBook进行映射”的参数。此外此属性会导致core.hasEnemyLeft()在指定id时失真不一定是坏事
(已完成!) 24. core.hasEnemyLeft()不应该调用core.getCurrentEnemys()因为后者是用于手册的它为了按伤害升序排列而调用了core.getDamageInfo()而core.getDamageInfo()又会调用core.getEnemyInfo()但作者完全可能在core.getDamageInfo()或core.getEnemyInfo()中使用core.hasEnemyLeft()判断特定id的怪物是否存在从而实现一些类似光环的效果如协同这样就会造成死递归
25. 建议新增一个类似“勇士转向”的事件指令————“图块转向”用于NPC甚至怪物比如基于索引/数字对4取余毕竟用转变图块的话不够通用
(已完成!) 25. 建议新增一个类似“勇士转向”的事件指令————“图块转向”用于NPC甚至怪物比如基于索引/数字对4取余毕竟用转变图块的话不够通用
(已完成!) 26. “勇士转向”会导致跟随者聚集这不利于演出建议改成像core.turnHero()一样不聚集跟随者
(已完成!) 27. 勇士后退时跟随者很鬼畜,建议优化(每步聚集算是一种简陋的办法)
(不处理) 28. 勇士的移动帧只有2建议改为允许作者指定