mirror of
https://github.com/motajs/template.git
synced 2026-11-11 13:34:31 +08:00
refactor: 怪物系统与勇士属性系统联动
This commit is contained in:
1 parent
92ff489811
commit
eaa725553b
23 files changed
+473
-381
No files matched your search
@@ -13,7 +13,7 @@ import {
|
||||
HeroState,
|
||||
IHeroState
|
||||
} from '@user/data-base';
|
||||
import { IEnemyAttributes } from './enemy/types';
|
||||
import { IEnemyAttr } from './enemy/types';
|
||||
import {
|
||||
CommonAuraConverter,
|
||||
EnemyLegacyBridge,
|
||||
@@ -24,7 +24,7 @@ import {
|
||||
registerSpecials
|
||||
} from './enemy';
|
||||
import { HERO_DEFAULT_ATTRIBUTE, TILE_HEIGHT, TILE_WIDTH } from './shared';
|
||||
import { IHeroAttributeObject } from './hero';
|
||||
import { IHeroAttr } from './hero';
|
||||
|
||||
export class CoreState implements ICoreState {
|
||||
readonly layer: ILayerState;
|
||||
@@ -32,10 +32,10 @@ export class CoreState implements ICoreState {
|
||||
readonly idNumberMap: Map<string, number>;
|
||||
readonly numberIdMap: Map<number, string>;
|
||||
|
||||
readonly hero: IHeroState<IHeroAttributeObject>;
|
||||
readonly hero: IHeroState<IHeroAttr>;
|
||||
|
||||
readonly enemyManager: IEnemyManager<IEnemyAttributes>;
|
||||
readonly enemyContext: IEnemyContext<IEnemyAttributes>;
|
||||
readonly enemyManager: IEnemyManager<IEnemyAttr>;
|
||||
readonly enemyContext: IEnemyContext<IEnemyAttr, IHeroAttr>;
|
||||
|
||||
constructor() {
|
||||
this.layer = new LayerState();
|
||||
@@ -43,6 +43,15 @@ export class CoreState implements ICoreState {
|
||||
this.idNumberMap = new Map();
|
||||
this.numberIdMap = new Map();
|
||||
|
||||
//#region 勇士初始化
|
||||
|
||||
const heroMover = new HeroMover();
|
||||
const heroAttribute = new HeroAttribute(HERO_DEFAULT_ATTRIBUTE);
|
||||
const heroState = new HeroState(heroMover, heroAttribute);
|
||||
this.hero = heroState;
|
||||
|
||||
//#endregion
|
||||
|
||||
//#region 怪物初始化
|
||||
|
||||
// 怪物管理器初始化
|
||||
@@ -56,7 +65,7 @@ export class CoreState implements ICoreState {
|
||||
registerSpecials(enemyManager);
|
||||
this.enemyManager = enemyManager;
|
||||
// 怪物上下文初始化
|
||||
const enemyContext = new EnemyContext<IEnemyAttributes>();
|
||||
const enemyContext = new EnemyContext<IEnemyAttr, IHeroAttr>();
|
||||
const damageSystem = new DamageSystem(enemyContext);
|
||||
const mapDamage = new MapDamage(enemyContext);
|
||||
mapDamage.useConverter(new MainMapDamageConverter());
|
||||
@@ -67,18 +76,10 @@ export class CoreState implements ICoreState {
|
||||
enemyContext.registerAuraConverter(new GuardAuraConverter());
|
||||
enemyContext.registerFinalEffect(new MainEnemyFinalEffect());
|
||||
enemyContext.resize(TILE_WIDTH, TILE_HEIGHT);
|
||||
enemyContext.bindHero(heroAttribute);
|
||||
this.enemyContext = enemyContext;
|
||||
|
||||
//#endregion
|
||||
|
||||
//#region 勇士初始化
|
||||
|
||||
const heroMover = new HeroMover();
|
||||
const heroAttribute = new HeroAttribute(HERO_DEFAULT_ATTRIBUTE);
|
||||
const heroState = new HeroState(heroMover, heroAttribute);
|
||||
this.hero = heroState;
|
||||
|
||||
//#endregion
|
||||
}
|
||||
|
||||
saveState(): IStateSaveData {
|
||||
|
||||
@@ -9,16 +9,18 @@ import {
|
||||
} from '@motajs/common';
|
||||
import {
|
||||
IAuraConverter,
|
||||
IEnemyHandler,
|
||||
IEnemyAuraView,
|
||||
IEnemyContext,
|
||||
IEnemySpecialModifier,
|
||||
IEnemyView,
|
||||
IReadonlyEnemyHandler,
|
||||
IReadonlyEnemy,
|
||||
ISpecial,
|
||||
IEnemy
|
||||
ISpecial
|
||||
} from '@user/data-base';
|
||||
import { IHaloValue } from './special';
|
||||
import { IEnemyAttributes } from './types';
|
||||
import { IEnemyAttr } from './types';
|
||||
import { IHeroAttr } from '../hero';
|
||||
|
||||
const FULL_RANGE = new FullRange();
|
||||
const RECT_RANGE = new RectRange();
|
||||
@@ -26,22 +28,24 @@ const MANHATTAN_RANGE = new ManhattanRange();
|
||||
|
||||
//#region 25-光环
|
||||
|
||||
export class CommonAuraConverter implements IAuraConverter<IEnemyAttributes> {
|
||||
export class CommonAuraConverter implements IAuraConverter<
|
||||
IEnemyAttr,
|
||||
IHeroAttr
|
||||
> {
|
||||
shouldConvert(special: ISpecial<any>): boolean {
|
||||
return special.code === 25;
|
||||
}
|
||||
|
||||
convert(
|
||||
special: ISpecial<IHaloValue>,
|
||||
enemy: IReadonlyEnemy<IEnemyAttributes>,
|
||||
locator: ITileLocator
|
||||
handler: IReadonlyEnemyHandler<IEnemyAttr, IHeroAttr>
|
||||
): CommonAura {
|
||||
return new CommonAura(enemy, special, locator);
|
||||
return new CommonAura(handler.enemy, special, handler.locator);
|
||||
}
|
||||
}
|
||||
|
||||
export class CommonAura implements IEnemyAuraView<
|
||||
IEnemyAttributes,
|
||||
IEnemyAttr,
|
||||
IRectRangeParam | IManhattanRangeParam | void,
|
||||
IHaloValue
|
||||
> {
|
||||
@@ -51,7 +55,7 @@ export class CommonAura implements IEnemyAuraView<
|
||||
readonly range: IRange<IRectRangeParam | IManhattanRangeParam | void>;
|
||||
|
||||
constructor(
|
||||
readonly enemy: IReadonlyEnemy<IEnemyAttributes>,
|
||||
readonly enemy: IReadonlyEnemy<IEnemyAttr>,
|
||||
readonly special: ISpecial<IHaloValue>,
|
||||
readonly locator: ITileLocator
|
||||
) {
|
||||
@@ -89,9 +93,10 @@ export class CommonAura implements IEnemyAuraView<
|
||||
}
|
||||
|
||||
apply(
|
||||
enemy: IEnemy<IEnemyAttributes>,
|
||||
baseEnemy: IReadonlyEnemy<IEnemyAttributes>
|
||||
handler: IEnemyHandler<IEnemyAttr, unknown>,
|
||||
baseEnemy: IReadonlyEnemy<IEnemyAttr>
|
||||
): void {
|
||||
const { enemy } = handler;
|
||||
const { hpBuff, atkBuff, defBuff } = this.special.value;
|
||||
|
||||
if (hpBuff !== 0) {
|
||||
@@ -110,7 +115,7 @@ export class CommonAura implements IEnemyAuraView<
|
||||
}
|
||||
}
|
||||
|
||||
applySpecial(): IEnemySpecialModifier<IEnemyAttributes> | null {
|
||||
applySpecial(): IEnemySpecialModifier<IEnemyAttr> | null {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@@ -119,23 +124,25 @@ export class CommonAura implements IEnemyAuraView<
|
||||
|
||||
//#region 26-支援
|
||||
|
||||
export class GuardAuraConverter implements IAuraConverter<IEnemyAttributes> {
|
||||
export class GuardAuraConverter implements IAuraConverter<
|
||||
IEnemyAttr,
|
||||
IHeroAttr
|
||||
> {
|
||||
shouldConvert(special: ISpecial<any>): boolean {
|
||||
return special.code === 26;
|
||||
}
|
||||
|
||||
convert(
|
||||
special: ISpecial<void>,
|
||||
enemy: IReadonlyEnemy<IEnemyAttributes>,
|
||||
locator: ITileLocator,
|
||||
context: IEnemyContext<IEnemyAttributes>
|
||||
handler: IReadonlyEnemyHandler<IEnemyAttr, IHeroAttr>,
|
||||
context: IEnemyContext<IEnemyAttr, IHeroAttr>
|
||||
): GuardAura {
|
||||
return new GuardAura(context, enemy, special, locator);
|
||||
return new GuardAura(context, handler.enemy, special, handler.locator);
|
||||
}
|
||||
}
|
||||
|
||||
export class GuardAura implements IEnemyAuraView<
|
||||
IEnemyAttributes,
|
||||
IEnemyAttr,
|
||||
IRectRangeParam,
|
||||
void
|
||||
> {
|
||||
@@ -144,11 +151,11 @@ export class GuardAura implements IEnemyAuraView<
|
||||
readonly couldApplySpecial: boolean = false;
|
||||
readonly range: IRange<IRectRangeParam> = RECT_RANGE;
|
||||
|
||||
private readonly sourceView: IEnemyView<IEnemyAttributes> | null;
|
||||
private readonly sourceView: IEnemyView<IEnemyAttr> | null;
|
||||
|
||||
constructor(
|
||||
context: IEnemyContext<IEnemyAttributes>,
|
||||
readonly enemy: IReadonlyEnemy<IEnemyAttributes>,
|
||||
context: IEnemyContext<IEnemyAttr, IHeroAttr>,
|
||||
readonly enemy: IReadonlyEnemy<IEnemyAttr>,
|
||||
readonly special: ISpecial<void>,
|
||||
readonly locator: ITileLocator
|
||||
) {
|
||||
@@ -164,19 +171,16 @@ export class GuardAura implements IEnemyAuraView<
|
||||
};
|
||||
}
|
||||
|
||||
apply(
|
||||
enemy: IEnemy<IEnemyAttributes>,
|
||||
_baseEnemy: IReadonlyEnemy<IEnemyAttributes>,
|
||||
locator: ITileLocator
|
||||
): void {
|
||||
apply(handler: IEnemyHandler<IEnemyAttr, IHeroAttr>): void {
|
||||
if (!this.sourceView) return;
|
||||
const { enemy, locator } = handler;
|
||||
if (locator.x === this.locator.x && locator.y === this.locator.y) {
|
||||
return;
|
||||
}
|
||||
enemy.getAttribute('guard').add(this.sourceView);
|
||||
}
|
||||
|
||||
applySpecial(): IEnemySpecialModifier<IEnemyAttributes> | null {
|
||||
applySpecial(): IEnemySpecialModifier<IEnemyAttr> | null {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,29 +1,28 @@
|
||||
import { IEnemy, IEnemyFinalEffect } from '@user/data-base';
|
||||
import { IEnemyAttributes } from './types';
|
||||
import { ITileLocator } from '@motajs/common';
|
||||
import { IEnemyFinalEffect, IEnemyHandler } from '@user/data-base';
|
||||
import { IEnemyAttr } from './types';
|
||||
import { IHeroAttr } from '../hero';
|
||||
|
||||
const HERO_STATUS_PLACEHOLDER = {
|
||||
atk: 0,
|
||||
def: 0
|
||||
} as const;
|
||||
|
||||
export class MainEnemyFinalEffect implements IEnemyFinalEffect<IEnemyAttributes> {
|
||||
export class MainEnemyFinalEffect implements IEnemyFinalEffect<
|
||||
IEnemyAttr,
|
||||
IHeroAttr
|
||||
> {
|
||||
readonly priority: number = 0;
|
||||
|
||||
apply(enemy: IEnemy<IEnemyAttributes>, _locator: ITileLocator): void {
|
||||
apply(handler: IEnemyHandler<IEnemyAttr, IHeroAttr>): void {
|
||||
const enemy = handler.enemy;
|
||||
const heroAtk = handler.hero.getFinalAttribute('atk');
|
||||
const heroDef = handler.hero.getFinalAttribute('def');
|
||||
|
||||
// 3-坚固
|
||||
if (enemy.hasSpecial(3)) {
|
||||
const target = Math.max(
|
||||
enemy.getAttribute('def'),
|
||||
HERO_STATUS_PLACEHOLDER.atk - 1
|
||||
);
|
||||
const target = Math.max(enemy.getAttribute('def'), heroAtk - 1);
|
||||
enemy.setAttribute('def', target);
|
||||
}
|
||||
|
||||
// 10-模仿
|
||||
if (enemy.hasSpecial(10)) {
|
||||
enemy.setAttribute('atk', HERO_STATUS_PLACEHOLDER.atk);
|
||||
enemy.setAttribute('def', HERO_STATUS_PLACEHOLDER.def);
|
||||
enemy.setAttribute('atk', heroAtk);
|
||||
enemy.setAttribute('def', heroDef);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,11 +1,11 @@
|
||||
import { IEnemyLegacyBridge } from '@user/data-base';
|
||||
import { IEnemyAttributes } from './types';
|
||||
import { IEnemyAttr } from './types';
|
||||
|
||||
export class EnemyLegacyBridge implements IEnemyLegacyBridge<IEnemyAttributes> {
|
||||
export class EnemyLegacyBridge implements IEnemyLegacyBridge<IEnemyAttr> {
|
||||
fromLegacyEnemy(
|
||||
enemy: Enemy,
|
||||
defaultAttr: Partial<IEnemyAttributes>
|
||||
): IEnemyAttributes {
|
||||
defaultAttr: Partial<IEnemyAttr>
|
||||
): IEnemyAttr {
|
||||
return {
|
||||
hp: enemy.hp ?? defaultAttr.hp ?? 0,
|
||||
atk: enemy.atk ?? defaultAttr.atk ?? 0,
|
||||
|
||||
@@ -11,17 +11,20 @@ import {
|
||||
RectRange,
|
||||
ITileLocator
|
||||
} from '@motajs/common';
|
||||
import { IReadonlyEnemy, ISpecial } from '@user/data-base';
|
||||
import {
|
||||
IEnemyContext,
|
||||
IMapDamageConverter,
|
||||
IMapDamageInfo,
|
||||
IMapDamageInfoExtra,
|
||||
IMapDamageReducer,
|
||||
IMapDamageView
|
||||
IReadonlyEnemyHandler,
|
||||
ISpecial,
|
||||
IMapDamageView,
|
||||
IReadonlyHeroAttribute
|
||||
} from '@user/data-base';
|
||||
import { IZoneValue } from './special';
|
||||
import { IEnemyAttributes, MapDamageType } from './types';
|
||||
import { IEnemyAttr, MapDamageType } from './types';
|
||||
import { IHeroAttr } from '../hero';
|
||||
|
||||
const RECT_RANGE = new RectRange();
|
||||
const MANHATTAN_RANGE = new ManhattanRange();
|
||||
@@ -33,7 +36,9 @@ const DIR4 = [...DIRECTION_MAPPER.map(InternalDirectionGroup.Dir4)];
|
||||
//#region 地图伤害
|
||||
|
||||
abstract class BaseMapDamageView<T> implements IMapDamageView<T> {
|
||||
constructor(protected readonly context: IEnemyContext<IEnemyAttributes>) {}
|
||||
constructor(
|
||||
protected readonly context: IEnemyContext<IEnemyAttr, IHeroAttr>
|
||||
) {}
|
||||
|
||||
abstract getRange(): IRange<T>;
|
||||
|
||||
@@ -80,7 +85,7 @@ export class ZoneDamageView extends BaseMapDamageView<
|
||||
IRectRangeParam | IManhattanRangeParam
|
||||
> {
|
||||
constructor(
|
||||
context: IEnemyContext<IEnemyAttributes>,
|
||||
context: IEnemyContext<IEnemyAttr, IHeroAttr>,
|
||||
private readonly locator: Readonly<ITileLocator>,
|
||||
private readonly special: Readonly<ISpecial<IZoneValue>>
|
||||
) {
|
||||
@@ -108,16 +113,14 @@ export class ZoneDamageView extends BaseMapDamageView<
|
||||
};
|
||||
}
|
||||
|
||||
getDamageWithoutCheck(
|
||||
_locator: ITileLocator
|
||||
): Readonly<IMapDamageInfo> | null {
|
||||
getDamageWithoutCheck(): Readonly<IMapDamageInfo> | null {
|
||||
return this.createInfo(this.special.value.zone, MapDamageType.Zone);
|
||||
}
|
||||
}
|
||||
|
||||
export class RepulseDamageView extends BaseMapDamageView<IManhattanRangeParam> {
|
||||
constructor(
|
||||
context: IEnemyContext<IEnemyAttributes>,
|
||||
context: IEnemyContext<IEnemyAttr, IHeroAttr>,
|
||||
private readonly locator: Readonly<ITileLocator>,
|
||||
private readonly special: Readonly<ISpecial<number>>
|
||||
) {
|
||||
@@ -151,7 +154,7 @@ export class RepulseDamageView extends BaseMapDamageView<IManhattanRangeParam> {
|
||||
|
||||
export class LaserDamageView extends BaseMapDamageView<IRayRangeParam> {
|
||||
constructor(
|
||||
context: IEnemyContext<IEnemyAttributes>,
|
||||
context: IEnemyContext<IEnemyAttr, IHeroAttr>,
|
||||
private readonly locator: Readonly<ITileLocator>,
|
||||
private readonly special: Readonly<ISpecial<number>>,
|
||||
private readonly dir: IDirectionDescriptor[] = DIR4
|
||||
@@ -171,23 +174,16 @@ export class LaserDamageView extends BaseMapDamageView<IRayRangeParam> {
|
||||
};
|
||||
}
|
||||
|
||||
getDamageWithoutCheck(
|
||||
locator: ITileLocator
|
||||
): Readonly<IMapDamageInfo> | null {
|
||||
if (locator.x === this.locator.x && locator.y === this.locator.y) {
|
||||
return null;
|
||||
}
|
||||
|
||||
getDamageWithoutCheck(): Readonly<IMapDamageInfo> | null {
|
||||
return this.createInfo(this.special.value, MapDamageType.Layer);
|
||||
}
|
||||
}
|
||||
|
||||
export class BetweenDamageView extends BaseMapDamageView<IManhattanRangeParam> {
|
||||
private static readonly DAMAGE = 1;
|
||||
|
||||
constructor(
|
||||
context: IEnemyContext<IEnemyAttributes>,
|
||||
private readonly locator: Readonly<ITileLocator>
|
||||
context: IEnemyContext<IEnemyAttr, IHeroAttr>,
|
||||
private readonly locator: Readonly<ITileLocator>,
|
||||
private readonly hero: IReadonlyHeroAttribute<IHeroAttr>
|
||||
) {
|
||||
super(context);
|
||||
}
|
||||
@@ -232,13 +228,14 @@ export class BetweenDamageView extends BaseMapDamageView<IManhattanRangeParam> {
|
||||
return null;
|
||||
}
|
||||
|
||||
return this.createInfo(BetweenDamageView.DAMAGE, MapDamageType.Between);
|
||||
const damage = this.hero.getFinalAttribute('hp');
|
||||
return this.createInfo(damage, MapDamageType.Between);
|
||||
}
|
||||
}
|
||||
|
||||
export class AmbushDamageView extends BaseMapDamageView<IManhattanRangeParam> {
|
||||
constructor(
|
||||
context: IEnemyContext<IEnemyAttributes>,
|
||||
context: IEnemyContext<IEnemyAttr, IHeroAttr>,
|
||||
private readonly locator: Readonly<ITileLocator>
|
||||
) {
|
||||
super(context);
|
||||
@@ -256,13 +253,7 @@ export class AmbushDamageView extends BaseMapDamageView<IManhattanRangeParam> {
|
||||
};
|
||||
}
|
||||
|
||||
getDamageWithoutCheck(
|
||||
locator: ITileLocator
|
||||
): Readonly<IMapDamageInfo> | null {
|
||||
if (locator.x === this.locator.x && locator.y === this.locator.y) {
|
||||
return null;
|
||||
}
|
||||
|
||||
getDamageWithoutCheck(): Readonly<IMapDamageInfo> | null {
|
||||
return this.createInfo(0, MapDamageType.Unknown, {
|
||||
catch: new Set([this.locator])
|
||||
});
|
||||
@@ -273,13 +264,16 @@ export class AmbushDamageView extends BaseMapDamageView<IManhattanRangeParam> {
|
||||
|
||||
//#region 转换器
|
||||
|
||||
export class MainMapDamageConverter implements IMapDamageConverter<IEnemyAttributes> {
|
||||
export class MainMapDamageConverter implements IMapDamageConverter<
|
||||
IEnemyAttr,
|
||||
IHeroAttr
|
||||
> {
|
||||
convert(
|
||||
enemy: IReadonlyEnemy<IEnemyAttributes>,
|
||||
locator: ITileLocator,
|
||||
context: IEnemyContext<IEnemyAttributes>
|
||||
handler: IReadonlyEnemyHandler<IEnemyAttr, IHeroAttr>,
|
||||
context: IEnemyContext<IEnemyAttr, IHeroAttr>
|
||||
): IMapDamageView<any>[] {
|
||||
const views: IMapDamageView<any>[] = [];
|
||||
const { enemy, locator } = handler;
|
||||
|
||||
const zone = enemy.getSpecial<IZoneValue>(15);
|
||||
if (zone) {
|
||||
@@ -287,7 +281,7 @@ export class MainMapDamageConverter implements IMapDamageConverter<IEnemyAttribu
|
||||
}
|
||||
|
||||
if (enemy.hasSpecial(16)) {
|
||||
views.push(new BetweenDamageView(context, locator));
|
||||
views.push(new BetweenDamageView(context, locator, handler.hero));
|
||||
}
|
||||
|
||||
const repulse = enemy.getSpecial<number>(18);
|
||||
@@ -313,10 +307,7 @@ export class MainMapDamageConverter implements IMapDamageConverter<IEnemyAttribu
|
||||
//#region 合并器
|
||||
|
||||
export class MainMapDamageReducer implements IMapDamageReducer {
|
||||
reduce(
|
||||
info: Iterable<Readonly<IMapDamageInfo>>,
|
||||
_locator: ITileLocator
|
||||
): Readonly<IMapDamageInfo> {
|
||||
reduce(info: Iterable<Readonly<IMapDamageInfo>>): Readonly<IMapDamageInfo> {
|
||||
let damage = 0;
|
||||
let type = MapDamageType.Unknown;
|
||||
let maxDamage = -Infinity;
|
||||
|
||||
@@ -4,7 +4,7 @@ import {
|
||||
IEnemyManager
|
||||
} from '@user/data-base';
|
||||
import { getHeroStatusOn } from '../legacy/hero';
|
||||
import { IEnemyAttributes } from './types';
|
||||
import { IEnemyAttr } from './types';
|
||||
|
||||
//#region 复合属性值类型
|
||||
|
||||
@@ -48,9 +48,7 @@ export interface IHaloValue {
|
||||
* 8. 重生属性:还在脚本编辑的 changingFloor
|
||||
* 9. 阻击 | 捕捉 的每步效果:packages-user/legacy-plugin-data/src/enemy/checkblock.ts
|
||||
*/
|
||||
export function registerSpecials(
|
||||
manager: IEnemyManager<IEnemyAttributes>
|
||||
): void {
|
||||
export function registerSpecials(manager: IEnemyManager<IEnemyAttr>): void {
|
||||
manager.setAttributeDefaults('guard', new Set());
|
||||
|
||||
// 0 - 空
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import { IEnemyView } from '@user/data-base';
|
||||
|
||||
export interface IEnemyAttributes {
|
||||
export interface IEnemyAttr {
|
||||
/** 怪物生命值 */
|
||||
hp: number;
|
||||
/** 怪物攻击力 */
|
||||
@@ -14,7 +14,7 @@ export interface IEnemyAttributes {
|
||||
/** 怪物加点量 */
|
||||
point: number;
|
||||
/** 支援来源怪物视图列表 */
|
||||
guard: Set<IEnemyView<IEnemyAttributes>>;
|
||||
guard: Set<IEnemyView<IEnemyAttr>>;
|
||||
}
|
||||
|
||||
export const enum MapDamageType {
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
//#region 勇士属性
|
||||
|
||||
export interface IHeroAttributeObject {
|
||||
export interface IHeroAttr {
|
||||
/** 勇士名称 */
|
||||
name: string;
|
||||
/** 勇士生命值 */
|
||||
|
||||
@@ -288,7 +288,7 @@ export class HeroMover extends ObjectMoverBase {
|
||||
protected async onMoveStart(controller: IMoveController): Promise<void> {
|
||||
this.beforeMoveSpeed = this.moveSpeed;
|
||||
if (!core.isReplaying() || core.status.replay.speed <= 12) {
|
||||
state.hero.startMove();
|
||||
state.hero.mover.startMove();
|
||||
}
|
||||
// 这里要检查前面那一格能不能走,不能走则不触发平滑视角,以避免撞墙上视角卡住
|
||||
if (!this.ignoreTerrain) {
|
||||
@@ -310,7 +310,7 @@ export class HeroMover extends ObjectMoverBase {
|
||||
protected async onMoveEnd(controller: IMoveController): Promise<void> {
|
||||
this.moveSpeed = this.beforeMoveSpeed;
|
||||
this.onSetMoveSpeed(this.moveSpeed, controller);
|
||||
await state.hero.endMove();
|
||||
await state.hero.mover.endMove();
|
||||
// viewport.sync('endMove');
|
||||
core.clearContinueAutomaticRoute();
|
||||
core.stopAutomaticRoute();
|
||||
@@ -442,19 +442,22 @@ export class HeroMover extends ObjectMoverBase {
|
||||
const replaying = core.isReplaying();
|
||||
if (replaying) {
|
||||
if (core.status.replay.speed > 12) {
|
||||
await state.hero.endMove();
|
||||
await state.hero.mover.endMove();
|
||||
await sleep(speed);
|
||||
state.hero.setPosition(x, y);
|
||||
state.hero.mover.setPosition(x, y);
|
||||
} else {
|
||||
state.hero.startMove();
|
||||
await state.hero.move(
|
||||
state.hero.mover.startMove();
|
||||
await state.hero.mover.move(
|
||||
fromDirectionString(moveDir),
|
||||
this.moveSpeed / core.status.replay.speed
|
||||
);
|
||||
}
|
||||
} else {
|
||||
state.hero.startMove();
|
||||
await state.hero.move(fromDirectionString(moveDir), this.moveSpeed);
|
||||
state.hero.mover.startMove();
|
||||
await state.hero.mover.move(
|
||||
fromDirectionString(moveDir),
|
||||
this.moveSpeed
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { IHeroAttributeObject } from './hero';
|
||||
import { IHeroAttr } from './hero';
|
||||
|
||||
/** 每个地图的默认宽度 */
|
||||
export const TILE_WIDTH = 13;
|
||||
@@ -11,7 +11,7 @@ export const TILE_HEIGHT = 13;
|
||||
export const DEFAULT_HERO_IMAGE: ImageIds = 'hero.png';
|
||||
|
||||
/** 勇士的初始属性,数值填多少目前都无所谓,因为最终会从旧样板读取,但是必须得填 */
|
||||
export const HERO_DEFAULT_ATTRIBUTE: IHeroAttributeObject = {
|
||||
export const HERO_DEFAULT_ATTRIBUTE: IHeroAttr = {
|
||||
name: '',
|
||||
hp: 1,
|
||||
hpmax: 0,
|
||||
|
||||
@@ -6,12 +6,12 @@ import {
|
||||
IHeroFollower,
|
||||
IHeroState
|
||||
} from '@user/data-base';
|
||||
import { IEnemyAttributes } from './enemy/types';
|
||||
import { IHeroAttributeObject } from './hero';
|
||||
import { IEnemyAttr } from './enemy/types';
|
||||
import { IHeroAttr } from './hero';
|
||||
|
||||
export interface IGameDataState {
|
||||
/** 怪物管理器 */
|
||||
readonly enemyManager: IEnemyManager<IEnemyAttributes>;
|
||||
readonly enemyManager: IEnemyManager<IEnemyAttr>;
|
||||
}
|
||||
|
||||
export interface IStateSaveData {
|
||||
@@ -23,7 +23,7 @@ export interface ICoreState {
|
||||
/** 地图状态 */
|
||||
readonly layer: ILayerState;
|
||||
/** 勇士状态 */
|
||||
readonly hero: IHeroState<IHeroAttributeObject>;
|
||||
readonly hero: IHeroState<IHeroAttr>;
|
||||
/** 朝向绑定 */
|
||||
readonly roleFace: IRoleFaceBinder;
|
||||
/** id 到图块数字的映射 */
|
||||
@@ -32,9 +32,9 @@ export interface ICoreState {
|
||||
readonly numberIdMap: Map<number, string>;
|
||||
|
||||
/** 怪物管理器 */
|
||||
readonly enemyManager: IEnemyManager<IEnemyAttributes>;
|
||||
readonly enemyManager: IEnemyManager<IEnemyAttr>;
|
||||
/** 怪物上下文 */
|
||||
readonly enemyContext: IEnemyContext<IEnemyAttributes>;
|
||||
readonly enemyContext: IEnemyContext<IEnemyAttr, IHeroAttr>;
|
||||
|
||||
/**
|
||||
* 保存状态
|
||||
|
||||
Reference in new issue
Block a user