mirror of
https://github.com/unanmed/HumanBreak.git
synced 2025-10-08 11:21:47 +08:00
refactor: 将渲染端使用 core._WIDTH_ 等接口的换为 shared 接口
This commit is contained in:
parent
206bed7dc0
commit
aef630006c
@ -19,6 +19,7 @@ import {
|
||||
Layer,
|
||||
calNeedRenderOf
|
||||
} from './layer';
|
||||
import { MAP_BLOCK_WIDTH, MAP_HEIGHT, MAP_WIDTH } from '../shared';
|
||||
|
||||
/**
|
||||
* 根据伤害大小获取颜色
|
||||
@ -167,9 +168,9 @@ export class Damage extends RenderItem<EDamageEvent> {
|
||||
constructor() {
|
||||
super('absolute', false, true);
|
||||
|
||||
this.block = new BlockCacher(0, 0, core._WIDTH_, 1);
|
||||
this.block = new BlockCacher(0, 0, MAP_BLOCK_WIDTH, 1);
|
||||
this.type = 'absolute';
|
||||
this.size(core._PX_, core._PY_);
|
||||
this.size(MAP_WIDTH, MAP_HEIGHT);
|
||||
this.setHD(true);
|
||||
this.setAntiAliasing(true);
|
||||
}
|
||||
|
@ -3,6 +3,12 @@ import { HeroRenderer } from './hero';
|
||||
import { ILayerGroupRenderExtends, LayerGroup } from './layer';
|
||||
import { LayerGroupFloorBinder } from './layer';
|
||||
import { hyper, TimingFn } from 'mutate-animate';
|
||||
import {
|
||||
MAP_BLOCK_HEIGHT,
|
||||
MAP_BLOCK_WIDTH,
|
||||
MAP_HEIGHT,
|
||||
MAP_WIDTH
|
||||
} from '../shared';
|
||||
|
||||
export class FloorViewport implements ILayerGroupRenderExtends {
|
||||
id: string = 'viewport';
|
||||
@ -62,8 +68,8 @@ export class FloorViewport implements ILayerGroupRenderExtends {
|
||||
this.enabled = true;
|
||||
const { x, y } = core.status.hero.loc;
|
||||
const { x: nx, y: ny } = this.group.camera;
|
||||
const halfWidth = core._PX_ / 2;
|
||||
const halfHeight = core._PY_ / 2;
|
||||
const halfWidth = MAP_WIDTH / 2;
|
||||
const halfHeight = MAP_HEIGHT / 2;
|
||||
const cell = this.group.cellSize;
|
||||
const half = cell / 2;
|
||||
this.applyPosition(
|
||||
@ -94,8 +100,8 @@ export class FloorViewport implements ILayerGroupRenderExtends {
|
||||
getBoundedPosition(x: number, y: number) {
|
||||
if (!this.checkDependency()) return { x, y };
|
||||
if (!this.boundX && !this.boundY) return { x, y };
|
||||
const width = core._WIDTH_;
|
||||
const height = core._HEIGHT_;
|
||||
const width = MAP_BLOCK_WIDTH;
|
||||
const height = MAP_BLOCK_HEIGHT;
|
||||
const minX = (width - 1) / 2;
|
||||
const minY = (height - 1) / 2;
|
||||
const floor = core.status.maps[this.binder!.getFloor()];
|
||||
@ -201,7 +207,7 @@ export class FloorViewport implements ILayerGroupRenderExtends {
|
||||
this.applyPosition(nx, ny);
|
||||
|
||||
if (ending) {
|
||||
if (this.ox === xTarget && this.oy == yTarget) {
|
||||
if (this.ox === xTarget && this.oy === yTarget) {
|
||||
this.hero!.off('moveTick', this.movingFramer);
|
||||
return;
|
||||
}
|
||||
@ -276,8 +282,8 @@ export class FloorViewport implements ILayerGroupRenderExtends {
|
||||
private applyPosition(x: number, y: number) {
|
||||
if (!this.enabled) return;
|
||||
if (x === this.nx && y === this.ny) return;
|
||||
const halfWidth = core._PX_ / 2;
|
||||
const halfHeight = core._PY_ / 2;
|
||||
const halfWidth = MAP_WIDTH / 2;
|
||||
const halfHeight = MAP_HEIGHT / 2;
|
||||
const cell = this.group.cellSize;
|
||||
const half = cell / 2;
|
||||
this.nx = x;
|
||||
|
@ -9,6 +9,7 @@ import {
|
||||
LayerGroupFloorBinder,
|
||||
FloorViewport
|
||||
} from './elements';
|
||||
import { MAP_WIDTH } from './shared';
|
||||
|
||||
const loopMaps = MiscData.loopMaps;
|
||||
|
||||
@ -71,13 +72,13 @@ function enableLoopMapElement(floorId: FloorIds) {
|
||||
// 这个是计算循环地图应该显示在哪
|
||||
const [, y2] = transform.transformed(x1 - testPos, 0);
|
||||
camera.reset();
|
||||
camera.translate(core._PX_ - testPos, y2);
|
||||
loopLayer.pos(transform.x - core._PX_, 0);
|
||||
camera.translate(MAP_WIDTH - testPos, y2);
|
||||
loopLayer.pos(transform.x - MAP_WIDTH, 0);
|
||||
loopLayer.show();
|
||||
loopLayer.update(loopLayer);
|
||||
} else {
|
||||
const [x2, y2] = transform.transformed(testPos, 0);
|
||||
if (x2 < core._PX_) {
|
||||
if (x2 < MAP_WIDTH) {
|
||||
// 这个不用做其他运算,可以直接显示
|
||||
camera.reset();
|
||||
camera.translate(0, y2);
|
||||
|
@ -7,9 +7,9 @@ import { Font } from '@motajs/render-style';
|
||||
|
||||
/** 每个格子的宽高 */
|
||||
export const CELL_SIZE = 32;
|
||||
/** 地图格子宽度,此处仅影响画面,不影响游戏内逻辑,游戏内逻辑地图大小请在 core.js 中修改 */
|
||||
/** 地图格子宽度,此处仅影响画面,可能不影响游戏内的部分逻辑,游戏内逻辑地图大小请在 core.js 中修改 */
|
||||
export const MAP_BLOCK_WIDTH = 15;
|
||||
/** 地图格子高度,此处仅影响画面,不影响游戏内逻辑,游戏内逻辑地图大小请在 core.js 中修改 */
|
||||
/** 地图格子高度,此处仅影响画面,可能不影响游戏内的部分逻辑,游戏内逻辑地图大小请在 core.js 中修改 */
|
||||
export const MAP_BLOCK_HEIGHT = 15;
|
||||
/** 地图像素宽度 */
|
||||
export const MAP_WIDTH = CELL_SIZE * MAP_BLOCK_WIDTH;
|
||||
|
Loading…
Reference in New Issue
Block a user