mirror of
https://github.com/motajs/template.git
synced 2026-05-24 21:11:12 +08:00
Compare commits
1 Commits
44c1bd16e8
...
43583e0e31
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
43583e0e31 |
@ -245,7 +245,7 @@ export interface IMapDamageView<T = any> {
|
|||||||
getDamageAt(locator: ITileLocator): Readonly<IMapDamageInfo> | null;
|
getDamageAt(locator: ITileLocator): Readonly<IMapDamageInfo> | null;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 获取指定位置的地图伤害,不会对坐标进行判断
|
* 获取指定位置的地图伤害,会对坐标进行判断
|
||||||
* @param locator 伤害位置
|
* @param locator 伤害位置
|
||||||
*/
|
*/
|
||||||
getDamageWithoutCheck(
|
getDamageWithoutCheck(
|
||||||
|
|||||||
@ -7,7 +7,6 @@ import {
|
|||||||
ITileLocator
|
ITileLocator
|
||||||
} from '@motajs/common';
|
} from '@motajs/common';
|
||||||
import { FaceDirection } from './types';
|
import { FaceDirection } from './types';
|
||||||
import { IFaceHandler } from './faceManager';
|
|
||||||
|
|
||||||
//#region 对象移动
|
//#region 对象移动
|
||||||
|
|
||||||
@ -279,14 +278,6 @@ export abstract class ObjectMover<T extends IObjectMovable>
|
|||||||
/** 是否调用了 `IMoverController.stop` 接口 */
|
/** 是否调用了 `IMoverController.stop` 接口 */
|
||||||
private shouldStop: boolean = false;
|
private shouldStop: boolean = false;
|
||||||
|
|
||||||
/** 朝向处理 */
|
|
||||||
private readonly faceHandler: IFaceHandler<FaceDirection>;
|
|
||||||
|
|
||||||
constructor(faceHandler: IFaceHandler<FaceDirection>) {
|
|
||||||
super();
|
|
||||||
this.faceHandler = faceHandler;
|
|
||||||
}
|
|
||||||
|
|
||||||
protected createController(
|
protected createController(
|
||||||
hook: Partial<IObjectMoverHooks<T>>
|
hook: Partial<IObjectMoverHooks<T>>
|
||||||
): IHookController<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 当前步骤
|
* @param step 当前步骤
|
||||||
@ -378,7 +397,7 @@ export abstract class ObjectMover<T extends IObjectMovable>
|
|||||||
case ObjectMoveStepType.Special: {
|
case ObjectMoveStepType.Special: {
|
||||||
const dir = this.getCurrentDirection();
|
const dir = this.getCurrentDirection();
|
||||||
if (step.direction === ObjectSpecialStep.Backward) {
|
if (step.direction === ObjectSpecialStep.Backward) {
|
||||||
const opposite = this.faceHandler.opposite(dir);
|
const opposite = this.getOppositeDirection(dir);
|
||||||
this.moveDirection = opposite;
|
this.moveDirection = opposite;
|
||||||
this.faceDirection = opposite;
|
this.faceDirection = opposite;
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
@ -1,4 +1,7 @@
|
|||||||
import {
|
import {
|
||||||
|
DirectionMapper,
|
||||||
|
IDirectionDescriptor,
|
||||||
|
InternalDirectionGroup,
|
||||||
IManhattanRangeParam,
|
IManhattanRangeParam,
|
||||||
IRange,
|
IRange,
|
||||||
IRayRangeParam,
|
IRayRangeParam,
|
||||||
@ -6,8 +9,7 @@ import {
|
|||||||
ManhattanRange,
|
ManhattanRange,
|
||||||
RayRange,
|
RayRange,
|
||||||
RectRange,
|
RectRange,
|
||||||
ITileLocator,
|
ITileLocator
|
||||||
IDirectionDescriptor
|
|
||||||
} from '@motajs/common';
|
} from '@motajs/common';
|
||||||
import {
|
import {
|
||||||
IEnemyContext,
|
IEnemyContext,
|
||||||
@ -19,9 +21,7 @@ import {
|
|||||||
ISpecial,
|
ISpecial,
|
||||||
IMapDamageView,
|
IMapDamageView,
|
||||||
IReadonlyHeroAttribute,
|
IReadonlyHeroAttribute,
|
||||||
IReadonlyEnemy,
|
IReadonlyEnemy
|
||||||
IFaceHandler,
|
|
||||||
InternalFaceGroup
|
|
||||||
} from '@user/data-base';
|
} from '@user/data-base';
|
||||||
import { IZoneValue } from './special';
|
import { IZoneValue } from './special';
|
||||||
import { IEnemyAttr, MapDamageType } from './types';
|
import { IEnemyAttr, MapDamageType } from './types';
|
||||||
@ -31,6 +31,9 @@ const RECT_RANGE = new RectRange();
|
|||||||
const MANHATTAN_RANGE = new ManhattanRange();
|
const MANHATTAN_RANGE = new ManhattanRange();
|
||||||
const RAY_RANGE = new RayRange();
|
const RAY_RANGE = new RayRange();
|
||||||
|
|
||||||
|
const DIRECTION_MAPPER = new DirectionMapper();
|
||||||
|
const DIR4 = [...DIRECTION_MAPPER.map(InternalDirectionGroup.Dir4)];
|
||||||
|
|
||||||
//#region 地图伤害
|
//#region 地图伤害
|
||||||
|
|
||||||
abstract class BaseMapDamageView<T> implements IMapDamageView<T> {
|
abstract class BaseMapDamageView<T> implements IMapDamageView<T> {
|
||||||
@ -151,17 +154,13 @@ export class RepulseDamageView extends BaseMapDamageView<IManhattanRangeParam> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export class LaserDamageView extends BaseMapDamageView<IRayRangeParam> {
|
export class LaserDamageView extends BaseMapDamageView<IRayRangeParam> {
|
||||||
/** 激光方向列表 */
|
|
||||||
private readonly dirs: IDirectionDescriptor[];
|
|
||||||
|
|
||||||
constructor(
|
constructor(
|
||||||
context: IEnemyContext<IEnemyAttr, IHeroAttr>,
|
context: IEnemyContext<IEnemyAttr, IHeroAttr>,
|
||||||
private readonly locator: Readonly<ITileLocator>,
|
private readonly locator: Readonly<ITileLocator>,
|
||||||
private readonly special: Readonly<ISpecial<number>>,
|
private readonly special: Readonly<ISpecial<number>>,
|
||||||
dir: IFaceHandler<number>
|
private readonly dir: IDirectionDescriptor[] = DIR4
|
||||||
) {
|
) {
|
||||||
super(context);
|
super(context);
|
||||||
this.dirs = [...dir.mapMovement()].map(v => v[1]);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
getRange(): IRange<IRayRangeParam> {
|
getRange(): IRange<IRayRangeParam> {
|
||||||
@ -172,7 +171,7 @@ export class LaserDamageView extends BaseMapDamageView<IRayRangeParam> {
|
|||||||
return {
|
return {
|
||||||
cx: this.locator.x,
|
cx: this.locator.x,
|
||||||
cy: this.locator.y,
|
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);
|
const laser = enemy.getSpecial<number>(24);
|
||||||
if (laser) {
|
if (laser) {
|
||||||
const face = handler.data.faceManager.get(InternalFaceGroup.Dir4)!;
|
views.push(new LaserDamageView(context, locator, laser));
|
||||||
views.push(new LaserDamageView(context, locator, laser, face));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (enemy.hasSpecial(27)) {
|
if (enemy.hasSpecial(27)) {
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user