mirror of
https://github.com/unanmed/HumanBreak.git
synced 2026-11-03 01:54:58 +08:00
fix: 显伤
This commit is contained in:
1 parent
12c009dab6
commit
a19656e7c1
8 files changed
+179
-206
No files matched your search
+31
-33
@@ -62,14 +62,12 @@ export class FloorItemDetail implements ILayerGroupRenderExtends {
|
||||
|
||||
static listened: Set<FloorItemDetail> = new Set();
|
||||
|
||||
private onBeforeDamageRender = (need: Set<number>) => {
|
||||
private onBeforeDamageRender = (block: number) => {
|
||||
if (!mainSetting.getValue('screen.itemDetail')) return;
|
||||
need.forEach(v => {
|
||||
if (this.dirtyBlock.has(v)) {
|
||||
this.sprite.block.clearCache(v, 1);
|
||||
}
|
||||
});
|
||||
this.render(need);
|
||||
if (this.dirtyBlock.has(block)) {
|
||||
this.sprite.block.clearCache(block, 1);
|
||||
this.render(block);
|
||||
}
|
||||
};
|
||||
|
||||
private onUpdateMapSize = (width: number, height: number) => {
|
||||
@@ -87,7 +85,7 @@ export class FloorItemDetail implements ILayerGroupRenderExtends {
|
||||
};
|
||||
|
||||
private listen() {
|
||||
this.sprite.on('beforeDamageRender', this.onBeforeDamageRender);
|
||||
this.sprite.on('dirtyUpdate', this.onBeforeDamageRender);
|
||||
this.sprite.on('setMapSize', this.onUpdateMapSize);
|
||||
this.sprite.on('updateBlocks', this.onUpdateBlocks);
|
||||
this.damage.on('update', this.onUpdate);
|
||||
@@ -215,32 +213,32 @@ export class FloorItemDetail implements ILayerGroupRenderExtends {
|
||||
* 计算并渲染指定格子里面的物品
|
||||
* @param block 需要渲染的格子
|
||||
*/
|
||||
render(block: Set<number>) {
|
||||
this.calAllItems(block);
|
||||
render(block: number) {
|
||||
this.calAllItems(new Set([block]));
|
||||
const data = this.detailData;
|
||||
block.forEach(v => {
|
||||
if (!this.dirtyBlock.has(v)) return;
|
||||
this.dirtyBlock.delete(v);
|
||||
const info = data.get(v);
|
||||
if (!info) return;
|
||||
info.forEach(({ x, y, diff }) => {
|
||||
let n = 0;
|
||||
for (const [key, value] of Object.entries(diff)) {
|
||||
if (!value) continue;
|
||||
const color = FloorItemDetail.detailColor[key] ?? '#fff';
|
||||
const text = value.toString();
|
||||
const renderable: DamageRenderable = {
|
||||
x: x * this.sprite.cellSize + 2,
|
||||
y: y * this.sprite.cellSize + 31 - n * 10,
|
||||
text,
|
||||
color,
|
||||
align: 'left',
|
||||
baseline: 'alphabetic'
|
||||
};
|
||||
this.sprite.renderable.get(v)?.add(renderable);
|
||||
n++;
|
||||
}
|
||||
});
|
||||
|
||||
if (!this.dirtyBlock.has(block)) return;
|
||||
this.dirtyBlock.delete(block);
|
||||
const info = data.get(block);
|
||||
if (!info) return;
|
||||
|
||||
info.forEach(({ x, y, diff }) => {
|
||||
let n = 0;
|
||||
for (const [key, value] of Object.entries(diff)) {
|
||||
if (!value) continue;
|
||||
const color = FloorItemDetail.detailColor[key] ?? '#fff';
|
||||
const text = value.toString();
|
||||
const renderable: DamageRenderable = {
|
||||
x: x * this.sprite.cellSize + 2,
|
||||
y: y * this.sprite.cellSize + 31 - n * 10,
|
||||
text,
|
||||
color,
|
||||
align: 'left',
|
||||
baseline: 'alphabetic'
|
||||
};
|
||||
this.sprite.renderable.get(block)?.add(renderable);
|
||||
n++;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@@ -100,7 +100,9 @@ export class Portal extends Sprite {
|
||||
this.particleSetting = mainSetting.getSetting('fx.portalParticle')!;
|
||||
|
||||
this.delegation = this.delegateTicker(() => {
|
||||
if (this.particleSetting.value) this.update(this);
|
||||
if (this.particleSetting.value && this.renderable.size > 0) {
|
||||
this.update(this);
|
||||
}
|
||||
});
|
||||
|
||||
this.setRenderFn((canvas, transform) => {
|
||||
|
||||
@@ -37,56 +37,6 @@ export function init() {
|
||||
checkMockery(loc, forceMockery);
|
||||
checkHunt(loc);
|
||||
};
|
||||
|
||||
control.prototype._drawDamage_draw = function (
|
||||
ctx: CanvasRenderingContext2D,
|
||||
onMap: boolean,
|
||||
floorId: FloorIds
|
||||
) {
|
||||
if (!core.hasItem('book')) return;
|
||||
drawHalo(ctx, onMap, floorId);
|
||||
|
||||
core.setFont(ctx, "14px 'normal'");
|
||||
core.setTextAlign(ctx, 'center');
|
||||
core.setTextBaseline(ctx, 'middle');
|
||||
core.status.damage.extraData.forEach(function (one) {
|
||||
var px = one.px,
|
||||
py = one.py;
|
||||
if (onMap && core.bigmap.v2) {
|
||||
px -= core.bigmap.posX * 32;
|
||||
py -= core.bigmap.posY * 32;
|
||||
if (
|
||||
px < -32 ||
|
||||
px > core._PX_ + 32 ||
|
||||
py < -32 ||
|
||||
py > core._PY_ + 32
|
||||
)
|
||||
return;
|
||||
}
|
||||
var alpha = core.setAlpha(ctx, one.alpha);
|
||||
core.fillBoldText(ctx, one.text, px, py, one.color as string);
|
||||
core.setAlpha(ctx, alpha);
|
||||
});
|
||||
|
||||
core.setTextAlign(ctx, 'left');
|
||||
core.setTextBaseline(ctx, 'alphabetic');
|
||||
core.status.damage.data.forEach(function (one) {
|
||||
var px = one.px,
|
||||
py = one.py;
|
||||
if (onMap && core.bigmap.v2) {
|
||||
px -= core.bigmap.posX * 32;
|
||||
py -= core.bigmap.posY * 32;
|
||||
if (
|
||||
px < -32 * 2 ||
|
||||
px > core._PX_ + 32 ||
|
||||
py < -32 ||
|
||||
py > core._PY_ + 32
|
||||
)
|
||||
return;
|
||||
}
|
||||
core.fillBoldText(ctx, one.text, px, py, one.color as string);
|
||||
});
|
||||
};
|
||||
}
|
||||
|
||||
function checkMockery(loc: string, force: boolean = false) {
|
||||
|
||||
@@ -420,11 +420,11 @@ export function init() {
|
||||
function generateJumpFn(dx: number, dy: number): TimingFn<3> {
|
||||
const distance = Math.hypot(dx, dy);
|
||||
const peak = 3 + distance;
|
||||
const k = dy / dx;
|
||||
|
||||
return (progress: number) => {
|
||||
const x = dx * progress;
|
||||
const y = k * x + (progress ** 2 - progress) * peak;
|
||||
const y = progress * dy + (progress ** 2 - progress) * peak;
|
||||
|
||||
return [x, y, Math.ceil(y)];
|
||||
};
|
||||
}
|
||||
@@ -766,15 +766,17 @@ export function init() {
|
||||
|
||||
const promise = Promise.all(
|
||||
items.map(v => {
|
||||
return v.moveAs(index, ex, ey, fn, time);
|
||||
return v.moveAs(index, ex, ey, fn, time, keep);
|
||||
})
|
||||
);
|
||||
|
||||
core.updateStatusBar();
|
||||
core.removeBlock(sx, sy);
|
||||
await promise;
|
||||
if (keep) {
|
||||
core.setBlock(block.id, ex, ey);
|
||||
}
|
||||
core.updateStatusBar();
|
||||
|
||||
callback?.();
|
||||
};
|
||||
|
||||
@@ -22,12 +22,13 @@ export function init() {
|
||||
floor.enemy.extract();
|
||||
floor.enemy.calRealAttribute();
|
||||
floor.enemy.calMapDamage();
|
||||
floor.enemy.emit('calculated');
|
||||
core.status.damage.data = [];
|
||||
|
||||
floor.enemy.render(true);
|
||||
// floor.enemy.render(true);
|
||||
|
||||
getItemDetail(floorId, onMap); // 宝石血瓶详细信息
|
||||
this.drawDamage(ctx, floorId);
|
||||
// this.drawDamage(ctx, floorId);
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user