mirror of
https://github.com/motajs/template.git
synced 2026-11-02 23:14:34 +08:00
refactor: Range 接口重构
This commit is contained in:
1 parent
a24911400f
commit
4c0960fff7
5 files changed
+30
-34
No files matched your search
@@ -32,11 +32,11 @@ export class CommonAuraConverter implements IAuraConverter<IEnemyAttributes> {
|
||||
}
|
||||
|
||||
convert(
|
||||
special: ISpecial<any>,
|
||||
special: ISpecial<IHaloValue>,
|
||||
enemy: IReadonlyEnemy<IEnemyAttributes>,
|
||||
locator: ITileLocator
|
||||
): CommonAura {
|
||||
return new CommonAura(enemy, special as ISpecial<IHaloValue>, locator);
|
||||
return new CommonAura(enemy, special, locator);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -134,17 +134,12 @@ export class GuardAuraConverter implements IAuraConverter<IEnemyAttributes> {
|
||||
}
|
||||
|
||||
convert(
|
||||
special: ISpecial<any>,
|
||||
special: ISpecial<void>,
|
||||
enemy: IReadonlyEnemy<IEnemyAttributes>,
|
||||
locator: ITileLocator,
|
||||
context: IEnemyContext<IEnemyAttributes>
|
||||
): GuardAura {
|
||||
return new GuardAura(
|
||||
context,
|
||||
enemy,
|
||||
special as ISpecial<void>,
|
||||
locator
|
||||
);
|
||||
return new GuardAura(context, enemy, special, locator);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
export * from './aura';
|
||||
export * from './damage';
|
||||
export * from './mapSpecials';
|
||||
export * from './mapDamage';
|
||||
export * from './special';
|
||||
+3
-15
@@ -74,20 +74,6 @@ abstract class BaseMapDamageView<T> implements IMapDamageView<T> {
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* 判断一个点是否在上下文范围内
|
||||
* @param x 横坐标
|
||||
* @param y 纵坐标
|
||||
*/
|
||||
protected isInBounds(x: number, y: number): boolean {
|
||||
return (
|
||||
x >= 0 &&
|
||||
y >= 0 &&
|
||||
x < this.context.width &&
|
||||
y < this.context.height
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
export class ZoneDamageView extends BaseMapDamageView<
|
||||
@@ -232,7 +218,9 @@ export class BetweenDamageView extends BaseMapDamageView<IManhattanRangeParam> {
|
||||
|
||||
const otherX = locator.x + deltaX;
|
||||
const otherY = locator.y + deltaY;
|
||||
if (!this.isInBounds(otherX, otherY)) {
|
||||
const range = this.getRange();
|
||||
range.bindHost(this.context);
|
||||
if (!range.inBound(otherX, otherY)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user