mirror of
https://github.com/unanmed/HumanBreak.git
synced 2025-01-19 12:49:25 +08:00
feat: 赏金属性 & 鼠标移动到怪物上显示光环
This commit is contained in:
parent
4189f80866
commit
3ea0ab07f0
@ -997,6 +997,9 @@ export function calDamageWith(
|
||||
let { atk, def, hpmax, mana, magicDef } = hero as HeroStatus;
|
||||
let { hp: monHp, atk: monAtk, def: monDef, special, enemy } = info;
|
||||
|
||||
// 赏金,优先级最高
|
||||
if (special.has(34)) return 0;
|
||||
|
||||
hpmax = Math.min(hpmax, def / 10);
|
||||
|
||||
let damage = 0;
|
||||
|
@ -280,5 +280,11 @@ export const specials: SpecialDeclaration[] = [
|
||||
return str;
|
||||
},
|
||||
color: '#fff866'
|
||||
},
|
||||
{
|
||||
code: 34,
|
||||
name: '赏金',
|
||||
desc: `怪物没有任何能力,也没有任何战利品,也无法让勇士恢复生命值,战斗伤害恒为0`,
|
||||
color: '#faff33'
|
||||
}
|
||||
];
|
||||
|
@ -1,5 +1,5 @@
|
||||
import { EventEmitter } from '../core/common/eventEmitter';
|
||||
import type { DamageEnemy } from './enemy/damage';
|
||||
import type { DamageEnemy, EnemyCollection } from './enemy/damage';
|
||||
|
||||
// ----- 加载事件
|
||||
interface GameLoadEvent {
|
||||
@ -91,12 +91,6 @@ export interface GameEvent {
|
||||
afterBattle: (enemy: DamageEnemy, x?: number, y?: number) => void;
|
||||
/** Emitted in libs/events.js changingFloor */
|
||||
changingFloor: (floorId: FloorIds, heroLoc: Loc) => void;
|
||||
|
||||
drawHero: (
|
||||
status?: Exclude<keyof MaterialIcon['hero']['down'], 'loc'>,
|
||||
offset?: number,
|
||||
frame?: number
|
||||
) => void;
|
||||
/** Emitted in libs/maps.js setBlock */
|
||||
setBlock: (
|
||||
x: number,
|
||||
@ -105,6 +99,8 @@ export interface GameEvent {
|
||||
newBlock: AllNumbers,
|
||||
oldBlock: AllNumbers
|
||||
) => void;
|
||||
/** Emitted in game/enemy/damage.ts */
|
||||
enemyExtract: (col: EnemyCollection) => void;
|
||||
}
|
||||
|
||||
export const hook = new EventEmitter<GameEvent>();
|
||||
@ -123,6 +119,9 @@ class GameListener extends EventEmitter<ListenerEvent> {
|
||||
|
||||
num: number = GameListener.num++;
|
||||
|
||||
mouseX: number = -1;
|
||||
mouseY: number = -1;
|
||||
|
||||
constructor() {
|
||||
super();
|
||||
if (main.replayChecking) return;
|
||||
@ -137,8 +136,6 @@ class GameListener extends EventEmitter<ListenerEvent> {
|
||||
|
||||
private init() {
|
||||
// ----- block
|
||||
let lastHoverX = -1;
|
||||
let lastHoverY = -1;
|
||||
|
||||
const data = core.canvas.data.canvas;
|
||||
|
||||
@ -165,19 +162,19 @@ class GameListener extends EventEmitter<ListenerEvent> {
|
||||
} = core.actions._getClickLoc(e.clientX, e.clientY);
|
||||
const [bx, by] = getBlockLoc(px, py, size);
|
||||
const blocks = core.getMapBlocksObj();
|
||||
if (lastHoverX !== bx || lastHoverY !== by) {
|
||||
const lastBlock = blocks[`${lastHoverX},${lastHoverY}`];
|
||||
if (this.mouseX !== bx || this.mouseY !== by) {
|
||||
const lastBlock = blocks[`${this.mouseX},${this.mouseY}`];
|
||||
const block = blocks[`${bx},${by}`];
|
||||
if (!!lastBlock) {
|
||||
this.emit('leaveBlock', lastBlock, e, false);
|
||||
}
|
||||
if (!!block) {
|
||||
this.emit('hoverBlock', block, e);
|
||||
lastHoverX = bx;
|
||||
lastHoverY = by;
|
||||
this.mouseX = bx;
|
||||
this.mouseY = by;
|
||||
} else {
|
||||
lastHoverX = -1;
|
||||
lastHoverY = -1;
|
||||
this.mouseX = -1;
|
||||
this.mouseY = -1;
|
||||
}
|
||||
}
|
||||
});
|
||||
@ -189,12 +186,12 @@ class GameListener extends EventEmitter<ListenerEvent> {
|
||||
)
|
||||
return;
|
||||
const blocks = core.getMapBlocksObj();
|
||||
const lastBlock = blocks[`${lastHoverX},${lastHoverY}`];
|
||||
const lastBlock = blocks[`${this.mouseX},${this.mouseY}`];
|
||||
if (!!lastBlock) {
|
||||
this.emit('leaveBlock', lastBlock, e, true);
|
||||
}
|
||||
lastHoverX = -1;
|
||||
lastHoverY = -1;
|
||||
this.mouseX = -1;
|
||||
this.mouseY = -1;
|
||||
});
|
||||
// click
|
||||
data.addEventListener('click', e => {
|
||||
|
@ -9,6 +9,8 @@ import {
|
||||
import { Sprite } from '@/core/render/sprite';
|
||||
import { Transform } from '@/core/render/transform';
|
||||
|
||||
const gameListener = Mota.require('var', 'gameListener');
|
||||
|
||||
export class LayerGroupHalo implements ILayerGroupRenderExtends {
|
||||
id: string = 'halo';
|
||||
|
||||
@ -16,6 +18,8 @@ export class LayerGroupHalo implements ILayerGroupRenderExtends {
|
||||
binder!: LayerGroupFloorBinder;
|
||||
halo!: Halo;
|
||||
|
||||
static sprites: Set<Halo> = new Set();
|
||||
|
||||
awake(group: LayerGroup): void {
|
||||
this.group = group;
|
||||
const ex = group.getExtends('floor-binder');
|
||||
@ -27,6 +31,7 @@ export class LayerGroupHalo implements ILayerGroupRenderExtends {
|
||||
this.halo.setZIndex(75);
|
||||
this.halo.binder = ex;
|
||||
group.appendChild(this.halo);
|
||||
LayerGroupHalo.sprites.add(this.halo);
|
||||
} else {
|
||||
logger.error(1401);
|
||||
group.removeExtends('halo');
|
||||
@ -35,6 +40,7 @@ export class LayerGroupHalo implements ILayerGroupRenderExtends {
|
||||
|
||||
onDestroy(group: LayerGroup): void {
|
||||
this.halo?.destroy();
|
||||
LayerGroupHalo.sprites.delete(this.halo);
|
||||
}
|
||||
}
|
||||
|
||||
@ -55,7 +61,7 @@ class Halo extends Sprite {
|
||||
binder!: LayerGroupFloorBinder;
|
||||
|
||||
constructor() {
|
||||
super('static', false);
|
||||
super('static', true);
|
||||
|
||||
this.setRenderFn((canvas, transform) => {
|
||||
this.drawHalo(canvas, transform);
|
||||
@ -89,17 +95,48 @@ class Halo extends Sprite {
|
||||
for (const halo of list) {
|
||||
if (halo.type === 'square') {
|
||||
const { x, y, d } = halo.data;
|
||||
const [color, border] = haloColor[halo.special];
|
||||
let [color, border] = haloColor[halo.special];
|
||||
let alpha = 0.1;
|
||||
let borderAlpha = 0.6;
|
||||
const { mouseX, mouseY } = gameListener;
|
||||
if (mouseX === halo.from?.x && mouseY === halo.from?.y) {
|
||||
alpha = 0.3;
|
||||
borderAlpha = 0.8;
|
||||
color = '#ff0';
|
||||
border = '#ff0';
|
||||
}
|
||||
const r = Math.floor(d / 2);
|
||||
const left = x - r;
|
||||
const top = y - r;
|
||||
ctx.fillStyle = color;
|
||||
ctx.strokeStyle = border ?? color;
|
||||
ctx.globalAlpha = 0.1;
|
||||
ctx.globalAlpha = alpha;
|
||||
ctx.fillRect(left * cell, top * cell, d * cell, d * cell);
|
||||
ctx.globalAlpha = 0.6;
|
||||
ctx.globalAlpha = borderAlpha;
|
||||
ctx.strokeRect(left * cell, top * cell, d * cell, d * cell);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function updateHalo(block: Block) {
|
||||
if (block.event.cls === 'enemys' || block.event.cls === 'enemy48') {
|
||||
LayerGroupHalo.sprites.forEach(v => {
|
||||
const floor = v.binder.getFloor();
|
||||
if (floor === core.status.floorId) {
|
||||
v.update();
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
Mota.require('var', 'hook').on('enemyExtract', col => {
|
||||
LayerGroupHalo.sprites.forEach(v => {
|
||||
const floor = v.binder.getFloor();
|
||||
if (col.floorId === floor) {
|
||||
v.update();
|
||||
}
|
||||
});
|
||||
});
|
||||
gameListener.on('hoverBlock', updateHalo);
|
||||
gameListener.on('leaveBlock', updateHalo);
|
||||
|
5
src/source/cls.d.ts
vendored
5
src/source/cls.d.ts
vendored
@ -633,6 +633,11 @@ interface IdToCls {
|
||||
E703: 'enemys';
|
||||
E704: 'enemys';
|
||||
E705: 'enemys';
|
||||
T706: 'terrains';
|
||||
E707: 'enemys';
|
||||
E708: 'enemys';
|
||||
E709: 'enemys';
|
||||
E710: 'enemys';
|
||||
X20032: 'tileset';
|
||||
X20033: 'tileset';
|
||||
X20034: 'tileset';
|
||||
|
10
src/source/maps.d.ts
vendored
10
src/source/maps.d.ts
vendored
@ -633,6 +633,11 @@ interface IdToNumber {
|
||||
E703: 703;
|
||||
E704: 704;
|
||||
E705: 705;
|
||||
T706: 706;
|
||||
E707: 707;
|
||||
E708: 708;
|
||||
E709: 709;
|
||||
E710: 710;
|
||||
X20032: 20032;
|
||||
X20033: 20033;
|
||||
X20034: 20034;
|
||||
@ -1351,6 +1356,11 @@ interface NumberToId {
|
||||
703: 'E703';
|
||||
704: 'E704';
|
||||
705: 'E705';
|
||||
706: 'T706';
|
||||
707: 'E707';
|
||||
708: 'E708';
|
||||
709: 'E709';
|
||||
710: 'E710';
|
||||
20032: 'X20032';
|
||||
20033: 'X20033';
|
||||
20034: 'X20034';
|
||||
|
Loading…
Reference in New Issue
Block a user