|
|
|
|
import type { EntityId } from 'db://assets/mx/module/battle';
|
|
|
|
|
import { BattleBuffCarryStore } from '../../manager/battleBuff/BattleBuffCarryStore';
|
|
|
|
|
import { rollCarriedKillCoinBonus } from '../../manager/battleBuff/BattleBuffPassiveSkillUtil';
|
|
|
|
|
import type { ProjectBattleHandle } from '../../battle/runtime/BattleRuntime';
|
|
|
|
|
import type { CocosBagBoardView } from '../../battle/view/CocosBagBoardView';
|
|
|
|
|
import type { BattlePeachCoinFlyPresenter } from './BattlePeachCoinFlyPresenter';
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 赏金令:击杀小怪概率额外金币飞币表现。
|
|
|
|
|
*/
|
|
|
|
|
export class BattleGameKillPeachPresenter {
|
|
|
|
|
private _battle: ProjectBattleHandle | null = null;
|
|
|
|
|
private _bagView: CocosBagBoardView | null = null;
|
|
|
|
|
private _coinFly: BattlePeachCoinFlyPresenter | null = null;
|
|
|
|
|
private _resolveDeathWorldPos: ((victim: EntityId) => import('cc').Vec3 | null) | null = null;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 绑定击杀事件上下文。
|
|
|
|
|
* @param battle 战斗
|
|
|
|
|
* @param bagView 棋盘
|
|
|
|
|
* @param coinFly 飞币
|
|
|
|
|
* @param resolveDeathWorldPos 死亡世界坐标
|
|
|
|
|
*/
|
|
|
|
|
bind(
|
|
|
|
|
battle: ProjectBattleHandle,
|
|
|
|
|
bagView: CocosBagBoardView | null,
|
|
|
|
|
coinFly: BattlePeachCoinFlyPresenter | null,
|
|
|
|
|
resolveDeathWorldPos: (victim: EntityId) => import('cc').Vec3 | null,
|
|
|
|
|
): void {
|
|
|
|
|
this.unbind();
|
|
|
|
|
this._battle = battle;
|
|
|
|
|
this._bagView = bagView;
|
|
|
|
|
this._coinFly = coinFly;
|
|
|
|
|
this._resolveDeathWorldPos = resolveDeathWorldPos;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/** 解除绑定 */
|
|
|
|
|
unbind(): void {
|
|
|
|
|
this._battle = null;
|
|
|
|
|
this._bagView = null;
|
|
|
|
|
this._coinFly = null;
|
|
|
|
|
this._resolveDeathWorldPos = null;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* EntityKilled:本机赏金令额外金币。
|
|
|
|
|
* @param killer 击杀者
|
|
|
|
|
* @param victim 死亡实体
|
|
|
|
|
*/
|
|
|
|
|
onEntityKilled(killer: EntityId, victim: EntityId): void {
|
|
|
|
|
const battle = this._battle;
|
|
|
|
|
if (!battle) return;
|
|
|
|
|
if (!battle.isSmallMonsterVictim(victim)) return;
|
|
|
|
|
const ownerId = battle.resolveKillPeachOwnerPlayerId(killer, victim);
|
|
|
|
|
if (ownerId !== battle.localPlayerId) return;
|
|
|
|
|
const bonus = rollCarriedKillCoinBonus(BattleBuffCarryStore.getPassives(ownerId));
|
|
|
|
|
if (bonus <= 0) return;
|
|
|
|
|
const from = this._resolveDeathWorldPos?.(victim);
|
|
|
|
|
if (!from) {
|
|
|
|
|
console.log('[KillCoin] 击杀额外金币无死亡坐标', victim);
|
|
|
|
|
battle.addPlayerGold(ownerId, bonus);
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
this._coinFly?.playKillDrop(from, bonus);
|
|
|
|
|
battle.addPlayerGold(ownerId, bonus);
|
|
|
|
|
}
|
|
|
|
|
}
|