This commit is contained in:
joylink_zhaoerwei 2024-01-12 11:17:09 +08:00
parent 2ca2c58435
commit 910306d3bf
5 changed files with 39 additions and 36 deletions

View File

@ -42,9 +42,9 @@ class THPlatform extends JlPlatform {
this.codeGraphic.draw(); this.codeGraphic.draw();
this.lozengeGraphic.draw(); this.lozengeGraphic.draw();
if (this.datas.direction == 'down') { if (this.datas.direction == 'down') {
this.doorGraphic.changePosition(); this.doorGraphic.changePosition(this.position);
this.codeGraphic.changePosition(); this.codeGraphic.changePosition(this.position);
this.lozengeGraphic.changePosition(); this.lozengeGraphic.changePosition(this.position);
} }
//门的状态 //门的状态
if (this.datas.hasdoor) { if (this.datas.hasdoor) {

View File

@ -1,5 +1,5 @@
import { JlGraphic, VectorText } from 'jl-graphic'; import { JlGraphic, VectorText } from 'jl-graphic';
import { Container, Graphics } from 'pixi.js'; import { Container, Graphics, IPointData } from 'pixi.js';
import { IPlatformData, PlatformConstsConfig } from './PlatformConfig'; import { IPlatformData, PlatformConstsConfig } from './PlatformConfig';
declare class RectGraphic extends Container { declare class RectGraphic extends Container {
platformConsts: PlatformConstsConfig; platformConsts: PlatformConstsConfig;
@ -16,7 +16,7 @@ export declare class DoorGraphic extends Container {
stateFillColor?: string; stateFillColor?: string;
constructor(platformConsts: PlatformConstsConfig); constructor(platformConsts: PlatformConstsConfig);
draw(): void; draw(): void;
changePosition(): void; changePosition(platformPos: IPointData): void;
clear(): void; clear(): void;
} }
export declare class CodeGraphic extends Container { export declare class CodeGraphic extends Container {
@ -28,7 +28,7 @@ export declare class CodeGraphic extends Container {
circle: Graphics; circle: Graphics;
constructor(platformConsts: PlatformConstsConfig); constructor(platformConsts: PlatformConstsConfig);
draw(): void; draw(): void;
changePosition(): void; changePosition(platformPos: IPointData): void;
clear(): void; clear(): void;
} }
export declare class LozengeGraphic extends Container { export declare class LozengeGraphic extends Container {
@ -36,7 +36,7 @@ export declare class LozengeGraphic extends Container {
lozenge: Graphics; lozenge: Graphics;
constructor(platformConsts: PlatformConstsConfig); constructor(platformConsts: PlatformConstsConfig);
draw(): void; draw(): void;
changePosition(): void; changePosition(platformPos: IPointData): void;
clear(): void; clear(): void;
} }
export declare class DoorCodeLozenge extends Container { export declare class DoorCodeLozenge extends Container {
@ -45,7 +45,7 @@ export declare class DoorCodeLozenge extends Container {
lozengeGraphic: LozengeGraphic; lozengeGraphic: LozengeGraphic;
codeGraphic: CodeGraphic; codeGraphic: CodeGraphic;
constructor(platformConsts: PlatformConstsConfig); constructor(platformConsts: PlatformConstsConfig);
draw(hasDoor: boolean, direction: string): void; draw(hasDoor: boolean, direction: string, platformPos: IPointData): void;
} }
export declare abstract class JlPlatform extends JlGraphic { export declare abstract class JlPlatform extends JlGraphic {
static Type: string; static Type: string;

View File

@ -64,8 +64,8 @@ class DoorGraphic extends Container {
.lineTo(doorConsts.doorOpenSpacing, 0); .lineTo(doorConsts.doorOpenSpacing, 0);
this.position.set(0, -platformConsts.height / 2 - doorConsts.doorPlatformSpacing); this.position.set(0, -platformConsts.height / 2 - doorConsts.doorPlatformSpacing);
} }
changePosition() { changePosition(platformPos) {
this.doorGraphic.position.copyFrom(calculateMirrorPoint(new Point(0, 0), this.position)); this.position.copyFrom(calculateMirrorPoint(new Point(0, 0), platformPos));
} }
clear() { clear() {
this.doorGraphic.clear(); this.doorGraphic.clear();
@ -141,7 +141,7 @@ class CodeGraphic extends Container {
runTime.visible = false; runTime.visible = false;
this.position.set(0, 0); this.position.set(0, 0);
} }
changePosition() { changePosition(platformPos) {
const platformConsts = this.platformConsts; const platformConsts = this.platformConsts;
const codeConsts = platformConsts.codeGraphic; const codeConsts = platformConsts.codeGraphic;
const psChange = [ const psChange = [
@ -152,7 +152,7 @@ class CodeGraphic extends Container {
]; ];
psChange.forEach((g) => { psChange.forEach((g) => {
if (g) { if (g) {
g.position.copyFrom(calculateMirrorPoint(new Point(0, 0), g.position)); g.position.copyFrom(calculateMirrorPoint(new Point(0, 0), platformPos));
} }
}); });
this.circle.position.set(platformConsts.width / 2 + this.circle.position.set(platformConsts.width / 2 +
@ -191,8 +191,8 @@ class LozengeGraphic extends Container {
LozengeConsts.doorPlatformSpacing - LozengeConsts.doorPlatformSpacing -
platformConsts.height / 3); platformConsts.height / 3);
} }
changePosition() { changePosition(platformPos) {
this.position.copyFrom(calculateMirrorPoint(new Point(0, 0), this.position)); this.position.copyFrom(calculateMirrorPoint(new Point(0, 0), platformPos));
} }
clear() { clear() {
this.lozenge.clear(); this.lozenge.clear();
@ -213,7 +213,7 @@ class DoorCodeLozenge extends Container {
this.codeGraphic = new CodeGraphic(this.platformConsts); this.codeGraphic = new CodeGraphic(this.platformConsts);
this.addChild(this.codeGraphic); this.addChild(this.codeGraphic);
} }
draw(hasDoor, direction) { draw(hasDoor, direction, platformPos) {
this.doorGraphic.clear(); this.doorGraphic.clear();
if (hasDoor) { if (hasDoor) {
this.doorGraphic.draw(); this.doorGraphic.draw();
@ -221,9 +221,9 @@ class DoorCodeLozenge extends Container {
this.codeGraphic.draw(); this.codeGraphic.draw();
this.lozengeGraphic.draw(); this.lozengeGraphic.draw();
if (direction == 'down') { if (direction == 'down') {
this.doorGraphic.changePosition(); this.doorGraphic.changePosition(platformPos);
this.codeGraphic.changePosition(); this.codeGraphic.changePosition(platformPos);
this.lozengeGraphic.changePosition(); this.lozengeGraphic.changePosition(platformPos);
} }
} }
} }

View File

@ -88,9 +88,9 @@ export class THPlatform extends JlPlatform {
this.codeGraphic.draw(); this.codeGraphic.draw();
this.lozengeGraphic.draw(); this.lozengeGraphic.draw();
if (this.datas.direction == 'down') { if (this.datas.direction == 'down') {
this.doorGraphic.changePosition(); this.doorGraphic.changePosition(this.position);
this.codeGraphic.changePosition(); this.codeGraphic.changePosition(this.position);
this.lozengeGraphic.changePosition(); this.lozengeGraphic.changePosition(this.position);
} }
//门的状态 //门的状态
if (this.datas.hasdoor) { if (this.datas.hasdoor) {

View File

@ -5,7 +5,14 @@ import {
distance2, distance2,
getRectangleCenter, getRectangleCenter,
} from 'jl-graphic'; } from 'jl-graphic';
import { Container, Graphics, Rectangle, Color, Point } from 'pixi.js'; import {
Container,
Graphics,
Rectangle,
Color,
Point,
IPointData,
} from 'pixi.js';
import { import {
CodeConstsConfig, CodeConstsConfig,
DoorConstsConfig, DoorConstsConfig,
@ -82,10 +89,8 @@ export class DoorGraphic extends Container {
-platformConsts.height / 2 - doorConsts.doorPlatformSpacing, -platformConsts.height / 2 - doorConsts.doorPlatformSpacing,
); );
} }
changePosition() { changePosition(platformPos: IPointData) {
this.doorGraphic.position.copyFrom( this.position.copyFrom(calculateMirrorPoint(new Point(0, 0), platformPos));
calculateMirrorPoint(new Point(0, 0), this.position),
);
} }
clear(): void { clear(): void {
this.doorGraphic.clear(); this.doorGraphic.clear();
@ -176,7 +181,7 @@ export class CodeGraphic extends Container {
runTime.visible = false; runTime.visible = false;
this.position.set(0, 0); this.position.set(0, 0);
} }
changePosition() { changePosition(platformPos: IPointData) {
const platformConsts = this.platformConsts; const platformConsts = this.platformConsts;
const codeConsts = platformConsts.codeGraphic as CodeConstsConfig; const codeConsts = platformConsts.codeGraphic as CodeConstsConfig;
const psChange = [ const psChange = [
@ -187,7 +192,7 @@ export class CodeGraphic extends Container {
]; ];
psChange.forEach((g) => { psChange.forEach((g) => {
if (g) { if (g) {
g.position.copyFrom(calculateMirrorPoint(new Point(0, 0), g.position)); g.position.copyFrom(calculateMirrorPoint(new Point(0, 0), platformPos));
} }
}); });
this.circle.position.set( this.circle.position.set(
@ -237,10 +242,8 @@ export class LozengeGraphic extends Container {
platformConsts.height / 3, platformConsts.height / 3,
); );
} }
changePosition() { changePosition(platformPos: IPointData) {
this.position.copyFrom( this.position.copyFrom(calculateMirrorPoint(new Point(0, 0), platformPos));
calculateMirrorPoint(new Point(0, 0), this.position),
);
} }
clear(): void { clear(): void {
this.lozenge.clear(); this.lozenge.clear();
@ -262,7 +265,7 @@ export class DoorCodeLozenge extends Container {
this.codeGraphic = new CodeGraphic(this.platformConsts); this.codeGraphic = new CodeGraphic(this.platformConsts);
this.addChild(this.codeGraphic); this.addChild(this.codeGraphic);
} }
draw(hasDoor: boolean, direction: string) { draw(hasDoor: boolean, direction: string, platformPos: IPointData) {
this.doorGraphic.clear(); this.doorGraphic.clear();
if (hasDoor) { if (hasDoor) {
this.doorGraphic.draw(); this.doorGraphic.draw();
@ -270,9 +273,9 @@ export class DoorCodeLozenge extends Container {
this.codeGraphic.draw(); this.codeGraphic.draw();
this.lozengeGraphic.draw(); this.lozengeGraphic.draw();
if (direction == 'down') { if (direction == 'down') {
this.doorGraphic.changePosition(); this.doorGraphic.changePosition(platformPos);
this.codeGraphic.changePosition(); this.codeGraphic.changePosition(platformPos);
this.lozengeGraphic.changePosition(); this.lozengeGraphic.changePosition(platformPos);
} }
} }
} }