mirror of
https://github.com/motajs/template.git
synced 2026-05-02 12:23:13 +08:00
reafactor: 目录结构修改
This commit is contained in:
parent
63e1a01fab
commit
6c1acb990e
@ -1,5 +1,4 @@
|
|||||||
import { IRange, logger } from '@motajs/common';
|
import { IRange, ITileLocator, logger } from '@motajs/common';
|
||||||
import { ITileLocator } from '@user/types';
|
|
||||||
import {
|
import {
|
||||||
IAuraConverter,
|
IAuraConverter,
|
||||||
IAuraView,
|
IAuraView,
|
||||||
|
|||||||
@ -1,5 +1,4 @@
|
|||||||
import { logger } from '@motajs/common';
|
import { logger, ITileLocator } from '@motajs/common';
|
||||||
import { ITileLocator } from '@user/types';
|
|
||||||
import {
|
import {
|
||||||
IEnemyContext,
|
IEnemyContext,
|
||||||
IEnemyView,
|
IEnemyView,
|
||||||
|
|||||||
@ -1,5 +1,4 @@
|
|||||||
import { IRange } from '@motajs/common';
|
import { IRange, ITileLocator } from '@motajs/common';
|
||||||
import { ITileLocator } from '@user/types';
|
|
||||||
|
|
||||||
export interface ISpecial<T = void> {
|
export interface ISpecial<T = void> {
|
||||||
/** 特殊属性代码 */
|
/** 特殊属性代码 */
|
||||||
|
|||||||
@ -1,4 +1,4 @@
|
|||||||
import { ITileLocator } from '@user/types';
|
import { ITileLocator } from '@motajs/common';
|
||||||
import { IMapLocIndexer } from './types';
|
import { IMapLocIndexer } from './types';
|
||||||
|
|
||||||
export class MapLocIndexer implements IMapLocIndexer {
|
export class MapLocIndexer implements IMapLocIndexer {
|
||||||
|
|||||||
@ -6,4 +6,4 @@
|
|||||||
"@user/data-base": "workspace:*",
|
"@user/data-base": "workspace:*",
|
||||||
"@user/data-utils": "workspace:*"
|
"@user/data-utils": "workspace:*"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,12 +1,13 @@
|
|||||||
import { ICoreState, IGameDataState, IStateSaveData } from './types';
|
import { ICoreState, IStateSaveData } from './types';
|
||||||
import { IHeroState, HeroState } from './hero';
|
import { IHeroState, HeroState } from './hero';
|
||||||
import { ILayerState, LayerState } from './map';
|
import { ILayerState, LayerState } from './map';
|
||||||
import { IRoleFaceBinder, RoleFaceBinder } from './common';
|
import { IRoleFaceBinder, RoleFaceBinder } from './common';
|
||||||
import { GameDataState } from './data';
|
|
||||||
import {
|
import {
|
||||||
DamageSystem,
|
DamageSystem,
|
||||||
EnemyContext,
|
EnemyContext,
|
||||||
|
EnemyManager,
|
||||||
IEnemyContext,
|
IEnemyContext,
|
||||||
|
IEnemyManager,
|
||||||
MapDamage
|
MapDamage
|
||||||
} from '@user/data-base';
|
} from '@user/data-base';
|
||||||
import { IEnemyAttributes } from './enemy/types';
|
import { IEnemyAttributes } from './enemy/types';
|
||||||
@ -15,16 +16,19 @@ import {
|
|||||||
GuardAuraConverter,
|
GuardAuraConverter,
|
||||||
MainEnemyFinalEffect,
|
MainEnemyFinalEffect,
|
||||||
MainMapDamageConverter,
|
MainMapDamageConverter,
|
||||||
MainMapDamageReducer
|
MainMapDamageReducer,
|
||||||
|
registerSpecials
|
||||||
} from './enemy';
|
} from './enemy';
|
||||||
|
import { TILE_HEIGHT, TILE_WIDTH } from './shared';
|
||||||
|
|
||||||
export class CoreState implements ICoreState {
|
export class CoreState implements ICoreState {
|
||||||
readonly layer: ILayerState;
|
readonly layer: ILayerState;
|
||||||
readonly hero: IHeroState;
|
readonly hero: IHeroState;
|
||||||
readonly roleFace: IRoleFaceBinder;
|
readonly roleFace: IRoleFaceBinder;
|
||||||
readonly data: IGameDataState;
|
|
||||||
readonly idNumberMap: Map<string, number>;
|
readonly idNumberMap: Map<string, number>;
|
||||||
readonly numberIdMap: Map<number, string>;
|
readonly numberIdMap: Map<number, string>;
|
||||||
|
|
||||||
|
readonly enemyManager: IEnemyManager<IEnemyAttributes>;
|
||||||
readonly enemyContext: IEnemyContext<IEnemyAttributes>;
|
readonly enemyContext: IEnemyContext<IEnemyAttributes>;
|
||||||
|
|
||||||
constructor() {
|
constructor() {
|
||||||
@ -33,8 +37,10 @@ export class CoreState implements ICoreState {
|
|||||||
this.roleFace = new RoleFaceBinder();
|
this.roleFace = new RoleFaceBinder();
|
||||||
this.idNumberMap = new Map();
|
this.idNumberMap = new Map();
|
||||||
this.numberIdMap = new Map();
|
this.numberIdMap = new Map();
|
||||||
this.data = new GameDataState();
|
|
||||||
|
|
||||||
|
// 怪物管理器初始化
|
||||||
|
this.enemyManager = new EnemyManager();
|
||||||
|
registerSpecials(this.enemyManager);
|
||||||
// 怪物上下文初始化
|
// 怪物上下文初始化
|
||||||
const enemyContext = new EnemyContext<IEnemyAttributes>();
|
const enemyContext = new EnemyContext<IEnemyAttributes>();
|
||||||
const damageSystem = new DamageSystem(enemyContext);
|
const damageSystem = new DamageSystem(enemyContext);
|
||||||
@ -46,7 +52,7 @@ export class CoreState implements ICoreState {
|
|||||||
enemyContext.registerAuraConverter(new CommonAuraConverter());
|
enemyContext.registerAuraConverter(new CommonAuraConverter());
|
||||||
enemyContext.registerAuraConverter(new GuardAuraConverter());
|
enemyContext.registerAuraConverter(new GuardAuraConverter());
|
||||||
enemyContext.registerFinalEffect(new MainEnemyFinalEffect());
|
enemyContext.registerFinalEffect(new MainEnemyFinalEffect());
|
||||||
enemyContext.resize(core._WIDTH_, core._HEIGHT_);
|
enemyContext.resize(TILE_WIDTH, TILE_HEIGHT);
|
||||||
this.enemyContext = enemyContext;
|
this.enemyContext = enemyContext;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -1,13 +0,0 @@
|
|||||||
import { EnemyManager, IEnemyManager } from '@user/data-base';
|
|
||||||
import { IEnemyAttributes } from './enemy/types';
|
|
||||||
import { IGameDataState } from './types';
|
|
||||||
import { registerSpecials } from './enemy';
|
|
||||||
|
|
||||||
export class GameDataState implements IGameDataState {
|
|
||||||
readonly enemyManager: IEnemyManager<IEnemyAttributes>;
|
|
||||||
|
|
||||||
constructor() {
|
|
||||||
this.enemyManager = new EnemyManager<IEnemyAttributes>();
|
|
||||||
registerSpecials(this.enemyManager);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@ -3,6 +3,7 @@ import {
|
|||||||
IManhattanRangeParam,
|
IManhattanRangeParam,
|
||||||
IRange,
|
IRange,
|
||||||
IRectRangeParam,
|
IRectRangeParam,
|
||||||
|
ITileLocator,
|
||||||
ManhattanRange,
|
ManhattanRange,
|
||||||
RectRange
|
RectRange
|
||||||
} from '@motajs/common';
|
} from '@motajs/common';
|
||||||
@ -17,7 +18,6 @@ import {
|
|||||||
IEnemy
|
IEnemy
|
||||||
} from '@user/data-base';
|
} from '@user/data-base';
|
||||||
import { IHaloValue } from './special';
|
import { IHaloValue } from './special';
|
||||||
import { ITileLocator } from '@user/types';
|
|
||||||
import { IEnemyAttributes } from './types';
|
import { IEnemyAttributes } from './types';
|
||||||
|
|
||||||
const FULL_RANGE = new FullRange();
|
const FULL_RANGE = new FullRange();
|
||||||
|
|||||||
@ -1,6 +1,6 @@
|
|||||||
import { IEnemy, IEnemyFinalEffect } from '@user/data-base';
|
import { IEnemy, IEnemyFinalEffect } from '@user/data-base';
|
||||||
import { IEnemyAttributes } from './types';
|
import { IEnemyAttributes } from './types';
|
||||||
import { ITileLocator } from '@user/types';
|
import { ITileLocator } from '@motajs/common';
|
||||||
|
|
||||||
const HERO_STATUS_PLACEHOLDER = {
|
const HERO_STATUS_PLACEHOLDER = {
|
||||||
atk: 0,
|
atk: 0,
|
||||||
|
|||||||
@ -8,9 +8,9 @@ import {
|
|||||||
IRectRangeParam,
|
IRectRangeParam,
|
||||||
ManhattanRange,
|
ManhattanRange,
|
||||||
RayRange,
|
RayRange,
|
||||||
RectRange
|
RectRange,
|
||||||
|
ITileLocator
|
||||||
} from '@motajs/common';
|
} from '@motajs/common';
|
||||||
import { ITileLocator } from '@user/types';
|
|
||||||
import { IReadonlyEnemy, ISpecial } from '@user/data-base';
|
import { IReadonlyEnemy, ISpecial } from '@user/data-base';
|
||||||
import {
|
import {
|
||||||
IEnemyContext,
|
IEnemyContext,
|
||||||
|
|||||||
@ -1,2 +1,7 @@
|
|||||||
|
/** 每个地图的默认宽度 */
|
||||||
|
export const TILE_WIDTH = 13;
|
||||||
|
/** 每个地图的默认高度 */
|
||||||
|
export const TILE_HEIGHT = 13;
|
||||||
|
|
||||||
/** 默认的勇士图片 */
|
/** 默认的勇士图片 */
|
||||||
export const DEFAULT_HERO_IMAGE: ImageIds = 'hero.png';
|
export const DEFAULT_HERO_IMAGE: ImageIds = 'hero.png';
|
||||||
|
|||||||
@ -21,13 +21,13 @@ export interface ICoreState {
|
|||||||
readonly hero: IHeroState;
|
readonly hero: IHeroState;
|
||||||
/** 朝向绑定 */
|
/** 朝向绑定 */
|
||||||
readonly roleFace: IRoleFaceBinder;
|
readonly roleFace: IRoleFaceBinder;
|
||||||
/** 游戏数据状态 */
|
|
||||||
readonly data: IGameDataState;
|
|
||||||
/** id 到图块数字的映射 */
|
/** id 到图块数字的映射 */
|
||||||
readonly idNumberMap: Map<string, number>;
|
readonly idNumberMap: Map<string, number>;
|
||||||
/** 图块数字到 id 的映射 */
|
/** 图块数字到 id 的映射 */
|
||||||
readonly numberIdMap: Map<number, string>;
|
readonly numberIdMap: Map<number, string>;
|
||||||
|
|
||||||
|
/** 怪物管理器 */
|
||||||
|
readonly enemyManager: IEnemyManager<IEnemyAttributes>;
|
||||||
/** 怪物上下文 */
|
/** 怪物上下文 */
|
||||||
readonly enemyContext: IEnemyContext<IEnemyAttributes>;
|
readonly enemyContext: IEnemyContext<IEnemyAttributes>;
|
||||||
|
|
||||||
|
|||||||
@ -1,3 +0,0 @@
|
|||||||
{
|
|
||||||
"name": "@user/types"
|
|
||||||
}
|
|
||||||
@ -1,87 +0,0 @@
|
|||||||
// todo: 2.C
|
|
||||||
|
|
||||||
export interface IEnemyInfo {}
|
|
||||||
|
|
||||||
export interface IDamageInfo {}
|
|
||||||
|
|
||||||
export interface IDamageEnemy {
|
|
||||||
/** 原始怪物信息 */
|
|
||||||
readonly enemy: Enemy;
|
|
||||||
/** 该怪物所属的怪物列表 */
|
|
||||||
readonly collection: IEnemyCollection | null;
|
|
||||||
/** 怪物横坐标 */
|
|
||||||
readonly x: number | undefined;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 获取怪物属性信息
|
|
||||||
*/
|
|
||||||
getEnemyInfo(): IEnemyInfo;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 获取这个怪物的伤害信息
|
|
||||||
*/
|
|
||||||
getDamageInfo(): IDamageInfo;
|
|
||||||
}
|
|
||||||
|
|
||||||
export interface IMapDamage {
|
|
||||||
/** 伤害类型 */
|
|
||||||
readonly type: string;
|
|
||||||
/** 伤害值 */
|
|
||||||
readonly damage: number;
|
|
||||||
/** 伤害优先级 */
|
|
||||||
readonly priority: number;
|
|
||||||
}
|
|
||||||
|
|
||||||
export interface IMapDamageSummary {
|
|
||||||
/** 该点的总伤害 */
|
|
||||||
readonly totalDamage: number;
|
|
||||||
/** 该点的伤害信息 */
|
|
||||||
readonly damages: IMapDamage[];
|
|
||||||
}
|
|
||||||
|
|
||||||
export interface IEnemyCollection {
|
|
||||||
/** 怪物列表,索引为 x + width * y,值表示该点对应的怪物 */
|
|
||||||
readonly list: Map<number, IDamageEnemy>;
|
|
||||||
|
|
||||||
/** 楼层 id */
|
|
||||||
readonly floorId: FloorIds;
|
|
||||||
/** 楼层宽度 */
|
|
||||||
readonly width: number;
|
|
||||||
/** 楼层高度 */
|
|
||||||
readonly height: number;
|
|
||||||
|
|
||||||
/** 地图伤害 */
|
|
||||||
readonly mapDamage: Map<number, IMapDamageSummary>;
|
|
||||||
|
|
||||||
/** 用于计算本怪物列表中怪物信息的勇士属性 */
|
|
||||||
readonly hero: HeroStatus;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 获取一点的怪物信息,不存在时返回 null
|
|
||||||
* @param x 怪物横坐标
|
|
||||||
* @param y 怪物纵坐标
|
|
||||||
*/
|
|
||||||
getEnemy(x: number, y: number): IDamageEnemy | null;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 获取一点的地图伤害信息,每一点都包含地图伤害对象,传入地图外坐标时返回 null
|
|
||||||
* @param x 横坐标
|
|
||||||
* @param y 纵坐标
|
|
||||||
*/
|
|
||||||
getMapDamage(x: number, y: number): IMapDamageSummary | null;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 重置此地图的怪物信息,并重新计算
|
|
||||||
*/
|
|
||||||
refresh(): void;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 复制这个怪物列表,同时将复制后的列表中勇士属性设为指定值
|
|
||||||
* @param status 新的勇士属性
|
|
||||||
*/
|
|
||||||
with(status: HeroStatus): IEnemyCollection;
|
|
||||||
}
|
|
||||||
|
|
||||||
export interface IDamageSystem {
|
|
||||||
readonly collections: Map<FloorIds, IEnemyCollection>;
|
|
||||||
}
|
|
||||||
@ -1,2 +0,0 @@
|
|||||||
export * from './enemy';
|
|
||||||
export * from './spatial';
|
|
||||||
@ -1,6 +0,0 @@
|
|||||||
export interface ITileLocator {
|
|
||||||
/** 图块所在横坐标 */
|
|
||||||
x: number;
|
|
||||||
/** 图块所在纵坐标 */
|
|
||||||
y: number;
|
|
||||||
}
|
|
||||||
@ -135,6 +135,13 @@ export interface IRayRangeParam {
|
|||||||
|
|
||||||
//#region 实用接口
|
//#region 实用接口
|
||||||
|
|
||||||
|
export interface ITileLocator {
|
||||||
|
/** 图块所在横坐标 */
|
||||||
|
x: number;
|
||||||
|
/** 图块所在纵坐标 */
|
||||||
|
y: number;
|
||||||
|
}
|
||||||
|
|
||||||
export const enum InternalDirectionGroup {
|
export const enum InternalDirectionGroup {
|
||||||
/** 上下左右四方向 */
|
/** 上下左右四方向 */
|
||||||
Dir4,
|
Dir4,
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user