Compare commits

..

1 Commits

Author SHA1 Message Date
AncTe
43583e0e31
Merge 43ad3fd83e into 1a569804d8 2026-05-12 09:27:12 +00:00
3 changed files with 41 additions and 24 deletions

View File

@ -245,7 +245,7 @@ export interface IMapDamageView<T = any> {
getDamageAt(locator: ITileLocator): Readonly<IMapDamageInfo> | null;
/**
*
*
* @param locator
*/
getDamageWithoutCheck(

View File

@ -7,7 +7,6 @@ import {
ITileLocator
} from '@motajs/common';
import { FaceDirection } from './types';
import { IFaceHandler } from './faceManager';
//#region 对象移动
@ -279,14 +278,6 @@ export abstract class ObjectMover<T extends IObjectMovable>
/** 是否调用了 `IMoverController.stop` 接口 */
private shouldStop: boolean = false;
/** 朝向处理 */
private readonly faceHandler: IFaceHandler<FaceDirection>;
constructor(faceHandler: IFaceHandler<FaceDirection>) {
super();
this.faceHandler = faceHandler;
}
protected createController(
hook: Partial<IObjectMoverHooks<T>>
): IHookController<IObjectMoverHooks<T>> {
@ -358,6 +349,34 @@ export abstract class ObjectMover<T extends IObjectMovable>
}
}
// TODO: 需要做一个朝向系统以解决朝向难以处理的问题
/**
*
* @param dir
*/
private getOppositeDirection(dir: FaceDirection): FaceDirection {
switch (dir) {
case FaceDirection.Left:
return FaceDirection.Right;
case FaceDirection.Up:
return FaceDirection.Down;
case FaceDirection.Right:
return FaceDirection.Left;
case FaceDirection.Down:
return FaceDirection.Up;
case FaceDirection.LeftUp:
return FaceDirection.RightDown;
case FaceDirection.RightUp:
return FaceDirection.LeftDown;
case FaceDirection.LeftDown:
return FaceDirection.RightUp;
case FaceDirection.RightDown:
return FaceDirection.LeftUp;
case FaceDirection.Unknown:
return FaceDirection.Unknown;
}
}
/**
*
* @param step
@ -378,7 +397,7 @@ export abstract class ObjectMover<T extends IObjectMovable>
case ObjectMoveStepType.Special: {
const dir = this.getCurrentDirection();
if (step.direction === ObjectSpecialStep.Backward) {
const opposite = this.faceHandler.opposite(dir);
const opposite = this.getOppositeDirection(dir);
this.moveDirection = opposite;
this.faceDirection = opposite;
} else {

View File

@ -1,4 +1,7 @@
import {
DirectionMapper,
IDirectionDescriptor,
InternalDirectionGroup,
IManhattanRangeParam,
IRange,
IRayRangeParam,
@ -6,8 +9,7 @@ import {
ManhattanRange,
RayRange,
RectRange,
ITileLocator,
IDirectionDescriptor
ITileLocator
} from '@motajs/common';
import {
IEnemyContext,
@ -19,9 +21,7 @@ import {
ISpecial,
IMapDamageView,
IReadonlyHeroAttribute,
IReadonlyEnemy,
IFaceHandler,
InternalFaceGroup
IReadonlyEnemy
} from '@user/data-base';
import { IZoneValue } from './special';
import { IEnemyAttr, MapDamageType } from './types';
@ -31,6 +31,9 @@ const RECT_RANGE = new RectRange();
const MANHATTAN_RANGE = new ManhattanRange();
const RAY_RANGE = new RayRange();
const DIRECTION_MAPPER = new DirectionMapper();
const DIR4 = [...DIRECTION_MAPPER.map(InternalDirectionGroup.Dir4)];
//#region 地图伤害
abstract class BaseMapDamageView<T> implements IMapDamageView<T> {
@ -151,17 +154,13 @@ export class RepulseDamageView extends BaseMapDamageView<IManhattanRangeParam> {
}
export class LaserDamageView extends BaseMapDamageView<IRayRangeParam> {
/** 激光方向列表 */
private readonly dirs: IDirectionDescriptor[];
constructor(
context: IEnemyContext<IEnemyAttr, IHeroAttr>,
private readonly locator: Readonly<ITileLocator>,
private readonly special: Readonly<ISpecial<number>>,
dir: IFaceHandler<number>
private readonly dir: IDirectionDescriptor[] = DIR4
) {
super(context);
this.dirs = [...dir.mapMovement()].map(v => v[1]);
}
getRange(): IRange<IRayRangeParam> {
@ -172,7 +171,7 @@ export class LaserDamageView extends BaseMapDamageView<IRayRangeParam> {
return {
cx: this.locator.x,
cy: this.locator.y,
dir: this.dirs
dir: this.dir
};
}
@ -310,8 +309,7 @@ export class MainMapDamageConverter implements IMapDamageConverter<
const laser = enemy.getSpecial<number>(24);
if (laser) {
const face = handler.data.faceManager.get(InternalFaceGroup.Dir4)!;
views.push(new LaserDamageView(context, locator, laser, face));
views.push(new LaserDamageView(context, locator, laser));
}
if (enemy.hasSpecial(27)) {