信号机调整

This commit is contained in:
fan 2023-12-25 18:11:51 +08:00
parent 409d78ca79
commit 0aa6808ddd
2 changed files with 144 additions and 8 deletions

View File

@ -56,6 +56,25 @@ export class LampMainBody extends Container {
this.lamps.push(lamp);
}
}
setStateBlueShow() {
this.lamps.forEach(lamp =>{
lamp.createLamp(SignalColorEnum.blueLamp);
})
}
setStateLampBad() {
this.lamps.forEach(lamp => {
lamp.createLampBad();
})
}
setStateLogic() {
this.lamps.forEach(lamp => {
lamp.createLogicMode();
})
}
setStateH() {
this.lamps[0].createLamp(SignalColorEnum.redLamp);
this.lamps.forEach((lamp, index) => {

View File

@ -1,5 +1,5 @@
import { GraphicData, calculateMirrorPoint } from 'jl-graphic'
import { Graphics, Point, Container } from 'pixi.js';
import { GraphicData, calculateMirrorPoint, JlGraphic } from 'jl-graphic'
import { Graphics, Point } from 'pixi.js';
import { SignalCode } from './SignalCode';
import { LampMainBody } from './LampMainBody';
@ -47,13 +47,21 @@ export const signalConsts = {
lampLineWidth: 1,
};
const anmiationNameConst = {
signaRedFlash: 'signal_red_flash',
signalGreenFlash: 'signal_green_flash',
signalYellowFlash: 'signal_yellow_flash',
signalWhiteFlash: 'signal_white_flash',
signalBlueFlash: 'signal_blue_flash',
};
export interface ISignalData extends GraphicData {
code: string
mirror: boolean;
mt: Model
}
export class Signal extends Container {
export class Signal extends JlGraphic {
static Type = 'signal';
datas: ISignalData;
signalCode: SignalCode = new SignalCode();
@ -63,7 +71,7 @@ export class Signal extends Container {
blockedMode: Graphics = new Graphics();
constructor(datas: ISignalData) {
super();
super(Signal.Type);
this.datas = datas;
this.addChild(this.humanControl);
this.addChild(this.fleetMode);
@ -89,7 +97,32 @@ export class Signal extends Container {
}
}
createFleetMode(): void {
stopAnmiation() {
const redFlashA = this.animation(anmiationNameConst.signaRedFlash);
const greenFlashA = this.animation(anmiationNameConst.signalGreenFlash);
const blueFlashA = this.animation(anmiationNameConst.signalBlueFlash);
const yellowFlashA = this.animation(anmiationNameConst.signalYellowFlash);
const whiteFlashA = this.animation(anmiationNameConst.signalWhiteFlash);
if (redFlashA) {
redFlashA.pause();
}
if (greenFlashA) {
greenFlashA.pause();
}
if (blueFlashA) {
blueFlashA.pause();
}
if (yellowFlashA) {
yellowFlashA.pause();
}
if (whiteFlashA) {
whiteFlashA.pause();
}
}
/** 设置状态自动进路 */
setStateFleetMode(): void {
const mirror = this.datas.mirror;
this.fleetMode.beginFill(SignalColorEnum.fleetModeColor, 1);
let lmp = new Point(
@ -110,8 +143,8 @@ export class Signal extends Container {
);
this.fleetMode.endFill();
}
createHumanControl(): void {
/** 设置状态人工控 */
setStateHumanControl(): void {
const mirror = this.datas.mirror;
this.humanControl.beginFill(SignalColorEnum.humanControlColor, 1);
if (this.humanControl.drawRegularPolygon) {
@ -129,31 +162,115 @@ export class Signal extends Container {
}
this.humanControl.endFill();
}
/** 设置状态封锁 */
setStateBlocked() {
this.signalCode.createBlockedMode();
}
/** 设置状态蓝显 */
setStateBlueShow() {
this.lampMainBody.setStateBlueShow();
}
/** 设置状态信号机损坏 */
setStateSignalBad() {
this.lampMainBody.setStateLampBad();
}
/** 设置状态逻辑点灯 */
setStateLogic() {
this.lampMainBody.setStateLogic();
}
/** 设置状态红灯 */
setStateH() {
this.lampMainBody.setStateH();
}
/** 设置状态绿灯 */
setStateL() {
this.lampMainBody.setStateL();
}
/** 设置状态黄灯 */
setStateU() {
this.lampMainBody.setStateU();
}
/** 设置状态红黄灯 */
setStateHu() {
this.lampMainBody.setStateHu();
}
/** 设置状态白灯 */
setStateA() {
this.lampMainBody.setStateA();
}
/** 设置状态蓝灯 */
setStateB() {
this.lampMainBody.setStateB();
}
/** 设置状态灯位关闭 */
setStateOff() {
this.lampMainBody.setStateOff();
}
/** 设置状态红闪 */
setStateRedFlash() {
let redFlashA = this.animation(anmiationNameConst.signaRedFlash);
if (!redFlashA) {
redFlashA = this.lampMainBody.createFlashAnmiation(
anmiationNameConst.signaRedFlash,
SignalColorEnum.redLamp,
0
);
}
this.addAnimation(redFlashA);
redFlashA.resume();
}
/** 设置状态绿闪 */
setStateGreenFlash() {
let greenFlashA = this.animation(anmiationNameConst.signalGreenFlash);
if (!greenFlashA) {
greenFlashA = this.lampMainBody.createFlashAnmiation(
anmiationNameConst.signalGreenFlash,
SignalColorEnum.greenLamp,
1
);
}
this.addAnimation(greenFlashA);
greenFlashA.resume();
}
/** 设置状态黄闪 */
setStateYellowFlash() {
let yellowFlashA = this.animation(anmiationNameConst.signalYellowFlash);
if (!yellowFlashA) {
yellowFlashA = this.lampMainBody.createFlashAnmiation(
anmiationNameConst.signalYellowFlash,
SignalColorEnum.yellowLamp,
2
);
}
this.addAnimation(yellowFlashA);
yellowFlashA.resume();
}
/** 设置状态蓝闪 */
setStateBlueFlash() {
let blueFlashA = this.animation(anmiationNameConst.signalBlueFlash);
if (!blueFlashA) {
blueFlashA = this.lampMainBody.createFlashAnmiation(
anmiationNameConst.signalBlueFlash,
SignalColorEnum.blueLamp,
0
);
}
this.addAnimation(blueFlashA);
blueFlashA.resume();
}
/** 设置状态白闪 */
setStateWhiteFlash() {
let whiteFlashA = this.animation(anmiationNameConst.signalWhiteFlash);
if (!whiteFlashA) {
whiteFlashA = this.lampMainBody.createFlashAnmiation(
anmiationNameConst.signalWhiteFlash,
SignalColorEnum.whiteLamp,
0
);
}
this.addAnimation(whiteFlashA);
whiteFlashA.resume();
}
}