Compare commits
6 Commits
Author | SHA1 | Date | |
---|---|---|---|
4a0d65683d | |||
|
a74efe77f0 | ||
|
e1c4cd8a1a | ||
|
3aa3038504 | ||
|
ea84c6ecdd | ||
|
12f0bdf6d2 |
@ -244,18 +244,25 @@ export class SectionGraphicHitArea implements IHitArea {
|
|||||||
function buildAbsorbablePositions(section: Section): AbsorbablePosition[] {
|
function buildAbsorbablePositions(section: Section): AbsorbablePosition[] {
|
||||||
const aps: AbsorbablePosition[] = [];
|
const aps: AbsorbablePosition[] = [];
|
||||||
|
|
||||||
const sections = section.queryStore.queryByType<Section>(Section.Type);
|
const [ps, pe] = [
|
||||||
sections.forEach((other) => {
|
section.localToCanvasPoint(section.getStartPoint()),
|
||||||
const [ps, pe] = [
|
section.localToCanvasPoint(section.getEndPoint()),
|
||||||
other.localToCanvasPoint(other.getStartPoint()),
|
];
|
||||||
other.localToCanvasPoint(other.getEndPoint()),
|
const { width, height } = section.getGraphicApp().canvas;
|
||||||
];
|
const xs = new AbsorbableLine({ x: 0, y: ps.y }, { x: width, y: ps.y });
|
||||||
const { width, height } = section.getGraphicApp().canvas;
|
const ys = new AbsorbableLine({ x: ps.x, y: 0 }, { x: ps.x, y: height });
|
||||||
const xs = new AbsorbableLine({ x: 0, y: ps.y }, { x: width, y: ps.y });
|
const xe = new AbsorbableLine({ x: 0, y: pe.y }, { x: width, y: pe.y });
|
||||||
const ys = new AbsorbableLine({ x: ps.x, y: 0 }, { x: ps.x, y: height });
|
const ye = new AbsorbableLine({ x: pe.x, y: 0 }, { x: pe.x, y: height });
|
||||||
const xe = new AbsorbableLine({ x: 0, y: pe.y }, { x: width, y: pe.y });
|
aps.push(xs, ys, xe, ye);
|
||||||
const ye = new AbsorbableLine({ x: pe.x, y: 0 }, { x: pe.x, y: height });
|
const sections = section.queryStore
|
||||||
aps.push(xs, ys, xe, ye);
|
.queryByType<Section>(Section.Type)
|
||||||
|
.filter((g) => g.datas.sectionType == SectionType.Physical);
|
||||||
|
sections.forEach((item) => {
|
||||||
|
if (item.id !== section.id) {
|
||||||
|
item.localToCanvasPoints(...item.datas.points).forEach((p) => {
|
||||||
|
aps.push(new AbsorbablePoint(p));
|
||||||
|
});
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
const turnouts = section.queryStore.queryByType<Turnout>(Turnout.Type);
|
const turnouts = section.queryStore.queryByType<Turnout>(Turnout.Type);
|
||||||
|
@ -1,101 +0,0 @@
|
|||||||
import { Container } from '@pixi/display';
|
|
||||||
import { Graphics } from 'pixi.js';
|
|
||||||
|
|
||||||
const lampConsts = {
|
|
||||||
lampRadius: 8,
|
|
||||||
logicModeLineWidth: 2,
|
|
||||||
logicModeDistance: 5,
|
|
||||||
logicModeColor: '0x000000',
|
|
||||||
lampLineWidth: 1,
|
|
||||||
lampLineColor: '0x3149c3',
|
|
||||||
lampBadColor: '0xFF0000',
|
|
||||||
badStart: 10,
|
|
||||||
badEnd: 15,
|
|
||||||
};
|
|
||||||
|
|
||||||
export class Lamp extends Container {
|
|
||||||
circleLamp: Graphics = new Graphics();
|
|
||||||
logicMode: Graphics = new Graphics();
|
|
||||||
lampBad: Graphics = new Graphics();
|
|
||||||
radiusX = 0;
|
|
||||||
radiusY = 0;
|
|
||||||
|
|
||||||
constructor() {
|
|
||||||
super();
|
|
||||||
this.addChild(this.circleLamp);
|
|
||||||
this.addChild(this.logicMode);
|
|
||||||
this.addChild(this.lampBad);
|
|
||||||
}
|
|
||||||
paint(radiusX: number, radiusY: number) {
|
|
||||||
this.radiusX = radiusX;
|
|
||||||
this.radiusY = radiusY;
|
|
||||||
this.createLamp();
|
|
||||||
}
|
|
||||||
createLampBad() {
|
|
||||||
this.lampBad.clear();
|
|
||||||
this.lampBad.lineStyle(lampConsts.lampLineWidth, lampConsts.lampBadColor);
|
|
||||||
this.lampBad.moveTo(this.radiusX + lampConsts.badStart, this.radiusY);
|
|
||||||
this.lampBad.lineTo(this.radiusX + lampConsts.badEnd, this.radiusY);
|
|
||||||
this.lampBad.moveTo(this.radiusX - lampConsts.badStart, this.radiusY);
|
|
||||||
this.lampBad.lineTo(this.radiusX - lampConsts.badEnd, this.radiusY);
|
|
||||||
this.lampBad.moveTo(this.radiusX, this.radiusY + lampConsts.badStart);
|
|
||||||
this.lampBad.lineTo(this.radiusX, this.radiusY + lampConsts.badEnd);
|
|
||||||
this.lampBad.moveTo(this.radiusX, this.radiusY - lampConsts.badStart);
|
|
||||||
this.lampBad.lineTo(this.radiusX, this.radiusY - lampConsts.badEnd);
|
|
||||||
const xieStart = Math.sin(Math.PI / 4) * lampConsts.badStart;
|
|
||||||
const xieEnd = Math.sin(Math.PI / 4) * lampConsts.badEnd;
|
|
||||||
this.lampBad.moveTo(this.radiusX + xieStart, this.radiusY + xieStart);
|
|
||||||
this.lampBad.lineTo(this.radiusX + xieEnd, this.radiusY + xieEnd);
|
|
||||||
this.lampBad.moveTo(this.radiusX + xieStart, this.radiusY - xieStart);
|
|
||||||
this.lampBad.lineTo(this.radiusX + xieEnd, this.radiusY - xieEnd);
|
|
||||||
|
|
||||||
this.lampBad.moveTo(this.radiusX - xieStart, this.radiusY - xieStart);
|
|
||||||
this.lampBad.lineTo(this.radiusX - xieEnd, this.radiusY - xieEnd);
|
|
||||||
this.lampBad.moveTo(this.radiusX - xieStart, this.radiusY + xieStart);
|
|
||||||
this.lampBad.lineTo(this.radiusX - xieEnd, this.radiusY + xieEnd);
|
|
||||||
}
|
|
||||||
createLamp(color?: string) {
|
|
||||||
this.circleLamp.clear();
|
|
||||||
this.circleLamp.lineStyle(
|
|
||||||
lampConsts.lampLineWidth,
|
|
||||||
lampConsts.lampLineColor
|
|
||||||
);
|
|
||||||
if (!color) {
|
|
||||||
color = '0X' + this.getCanvas().backgroundColor.substring(1);
|
|
||||||
}
|
|
||||||
this.circleLamp.beginFill(color, 1);
|
|
||||||
this.circleLamp.drawCircle(
|
|
||||||
this.radiusX,
|
|
||||||
this.radiusY,
|
|
||||||
lampConsts.lampRadius
|
|
||||||
);
|
|
||||||
this.circleLamp.endFill();
|
|
||||||
}
|
|
||||||
createLogicMode() {
|
|
||||||
this.logicMode
|
|
||||||
.clear()
|
|
||||||
.lineStyle(lampConsts.logicModeLineWidth, lampConsts.logicModeColor)
|
|
||||||
.moveTo(
|
|
||||||
this.radiusX - lampConsts.logicModeDistance,
|
|
||||||
this.radiusY + lampConsts.logicModeDistance
|
|
||||||
)
|
|
||||||
.lineTo(
|
|
||||||
this.radiusX + lampConsts.logicModeDistance,
|
|
||||||
this.radiusY - lampConsts.logicModeDistance
|
|
||||||
)
|
|
||||||
.moveTo(
|
|
||||||
this.radiusX - lampConsts.logicModeDistance,
|
|
||||||
this.radiusY - lampConsts.logicModeDistance
|
|
||||||
)
|
|
||||||
.lineTo(
|
|
||||||
this.radiusX + lampConsts.logicModeDistance,
|
|
||||||
this.radiusY + lampConsts.logicModeDistance
|
|
||||||
);
|
|
||||||
}
|
|
||||||
logicModeClear() {
|
|
||||||
this.logicMode.clear();
|
|
||||||
}
|
|
||||||
lampClear() {
|
|
||||||
this.circleLamp.clear();
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,6 +1,5 @@
|
|||||||
import { Graphics, Point } from 'pixi.js';
|
import { Graphics, Point } from 'pixi.js';
|
||||||
import { calculateMirrorPoint, GraphicAnimation, JlGraphic } from 'jl-graphic';
|
import { calculateMirrorPoint, GraphicAnimation, JlGraphic } from 'jl-graphic';
|
||||||
import { Lamp } from './Lamp';
|
|
||||||
import { ISignalState } from './Signal';
|
import { ISignalState } from './Signal';
|
||||||
|
|
||||||
export enum LampEnum {
|
export enum LampEnum {
|
||||||
@ -10,6 +9,7 @@ export enum LampEnum {
|
|||||||
yellowLamp = '0XFFFF00',
|
yellowLamp = '0XFFFF00',
|
||||||
whiteLamp = '0XFFFFFF',
|
whiteLamp = '0XFFFFFF',
|
||||||
blueLamp = '0x3149c3',
|
blueLamp = '0x3149c3',
|
||||||
|
closeLamp = '0x000000',
|
||||||
}
|
}
|
||||||
|
|
||||||
const lampConsts = {
|
const lampConsts = {
|
||||||
@ -17,6 +17,14 @@ const lampConsts = {
|
|||||||
levelLampPostLength: 4,
|
levelLampPostLength: 4,
|
||||||
postLineWidth: 3,
|
postLineWidth: 3,
|
||||||
lampRadius: 8,
|
lampRadius: 8,
|
||||||
|
logicModeLineWidth: 2,
|
||||||
|
logicModeDistance: 5,
|
||||||
|
logicModeColor: '0x000000',
|
||||||
|
lampLineWidth: 1,
|
||||||
|
lampLineColor: '0x3149c3',
|
||||||
|
lampBadColor: '0xFF0000',
|
||||||
|
badStart: 10,
|
||||||
|
badEnd: 15,
|
||||||
};
|
};
|
||||||
|
|
||||||
const anmiationNameConst = {
|
const anmiationNameConst = {
|
||||||
@ -31,23 +39,31 @@ export class LampMainBody extends JlGraphic {
|
|||||||
static Type = 'LampMainBody';
|
static Type = 'LampMainBody';
|
||||||
lampNum = 1;
|
lampNum = 1;
|
||||||
lampPost: Graphics = new Graphics();
|
lampPost: Graphics = new Graphics();
|
||||||
lamps: Lamp[] = [];
|
// lamps: Lamp[] = [];
|
||||||
|
lamps: Graphics = new Graphics();
|
||||||
|
logicMode: Graphics = new Graphics();
|
||||||
mirror = false;
|
mirror = false;
|
||||||
deltaTime = 0;
|
deltaTime = 0;
|
||||||
states: ISignalState | null = null;
|
states: ISignalState | null = null;
|
||||||
|
|
||||||
constructor() {
|
constructor() {
|
||||||
super(LampMainBody.Type);
|
super(LampMainBody.Type);
|
||||||
|
this.addChild(this.lampPost);
|
||||||
|
this.addChild(this.lamps);
|
||||||
|
this.addChild(this.logicMode);
|
||||||
}
|
}
|
||||||
paint(lampNum: number, mirror: boolean, states: ISignalState) {
|
paint(lampNum: number, mirror: boolean, states: ISignalState) {
|
||||||
|
this.lampPost.clear();
|
||||||
|
|
||||||
|
this.logicMode.clear();
|
||||||
this.mirror = mirror;
|
this.mirror = mirror;
|
||||||
this.states = states;
|
this.states = states;
|
||||||
if (lampNum < 1) {
|
if (lampNum < 1) {
|
||||||
throw new Error('信号机灯数量异常');
|
throw new Error('信号机灯数量异常');
|
||||||
}
|
}
|
||||||
this.lampNum = lampNum;
|
this.lampNum = lampNum;
|
||||||
this.removeChildren(0);
|
// this.removeChildren(0);
|
||||||
this.lampPost = new Graphics();
|
// this.lampPost = new Graphics();
|
||||||
let lpp = new Point(lampConsts.levelLampPostLength, 0);
|
let lpp = new Point(lampConsts.levelLampPostLength, 0);
|
||||||
if (mirror) {
|
if (mirror) {
|
||||||
lpp = calculateMirrorPoint(new Point(0, 0), lpp);
|
lpp = calculateMirrorPoint(new Point(0, 0), lpp);
|
||||||
@ -58,39 +74,81 @@ export class LampMainBody extends JlGraphic {
|
|||||||
.lineTo(0, lampConsts.verticalLampPostLength / 2)
|
.lineTo(0, lampConsts.verticalLampPostLength / 2)
|
||||||
.moveTo(0, 0)
|
.moveTo(0, 0)
|
||||||
.lineTo(lpp.x, lpp.y);
|
.lineTo(lpp.x, lpp.y);
|
||||||
this.addChild(this.lampPost);
|
// this.addChild(this.lampPost);
|
||||||
|
|
||||||
this.lamps = [];
|
// this.lamps = [];
|
||||||
for (let i = 0; i < this.lampNum; i++) {
|
// for (let i = 0; i < this.lampNum; i++) {
|
||||||
const lamp = new Lamp();
|
// const lamp = new Lamp();
|
||||||
this.addChild(lamp);
|
// // this.addChild(lamp);
|
||||||
|
// const radiusX =
|
||||||
|
// (1 + i * 2) * lampConsts.lampRadius + lampConsts.levelLampPostLength;
|
||||||
|
// let lrp = new Point(radiusX, 0);
|
||||||
|
// if (mirror) {
|
||||||
|
// lrp = calculateMirrorPoint(new Point(0, 0), lrp);
|
||||||
|
// }
|
||||||
|
// lamp.paint(lrp.x, lrp.y);
|
||||||
|
// // this.lamps.push(lamp);
|
||||||
|
// }
|
||||||
|
this.chagneState(this.states);
|
||||||
|
}
|
||||||
|
paintLamp(colors: string[], lampNum?: number) {
|
||||||
|
this.lamps.clear();
|
||||||
|
this.lamps.lineStyle(
|
||||||
|
lampConsts.lampLineWidth,
|
||||||
|
lampConsts.lampLineColor
|
||||||
|
);
|
||||||
|
const number = lampNum || this.lampNum
|
||||||
|
for (let i = 0; i < number; i++) {
|
||||||
const radiusX =
|
const radiusX =
|
||||||
(1 + i * 2) * lampConsts.lampRadius + lampConsts.levelLampPostLength;
|
(1 + i * 2) * lampConsts.lampRadius +
|
||||||
|
lampConsts.levelLampPostLength;
|
||||||
let lrp = new Point(radiusX, 0);
|
let lrp = new Point(radiusX, 0);
|
||||||
if (mirror) {
|
if (this.mirror) {
|
||||||
lrp = calculateMirrorPoint(new Point(0, 0), lrp);
|
lrp = calculateMirrorPoint(new Point(0, 0), lrp);
|
||||||
}
|
}
|
||||||
lamp.paint(lrp.x, lrp.y);
|
const color = colors[i] ? colors[i] : LampEnum.closeLamp;
|
||||||
this.lamps.push(lamp);
|
this.lamps.beginFill(color, 1);
|
||||||
|
this.lamps.drawCircle(
|
||||||
|
lrp.x,
|
||||||
|
lrp.y,
|
||||||
|
lampConsts.lampRadius
|
||||||
|
);
|
||||||
|
this.lamps.endFill();
|
||||||
|
if (this.states?.extinguish) {
|
||||||
|
this.logicMode
|
||||||
|
.lineStyle(lampConsts.logicModeLineWidth, lampConsts.logicModeColor)
|
||||||
|
.moveTo(
|
||||||
|
lrp.x - lampConsts.logicModeDistance,
|
||||||
|
lrp.y + lampConsts.logicModeDistance
|
||||||
|
)
|
||||||
|
.lineTo(
|
||||||
|
lrp.x + lampConsts.logicModeDistance,
|
||||||
|
lrp.y - lampConsts.logicModeDistance
|
||||||
|
)
|
||||||
|
.moveTo(
|
||||||
|
lrp.x - lampConsts.logicModeDistance,
|
||||||
|
lrp.y - lampConsts.logicModeDistance
|
||||||
|
)
|
||||||
|
.lineTo(
|
||||||
|
lrp.x + lampConsts.logicModeDistance,
|
||||||
|
lrp.y + lampConsts.logicModeDistance
|
||||||
|
);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
this.chagneState(this.states);
|
|
||||||
}
|
}
|
||||||
setBlueShow() {
|
setBlueShow() {
|
||||||
this.stopAnmiation();
|
this.stopAnmiation();
|
||||||
this.lamps.forEach((lamp) => {
|
this.paintLamp([LampEnum.blueLamp, LampEnum.blueLamp, LampEnum.blueLamp]);
|
||||||
lamp.createLamp(LampEnum.blueLamp);
|
|
||||||
lamp.logicModeClear();
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
doRepaint() {
|
doRepaint() {
|
||||||
// this.paint(this.lampNum, this.mirror, this.states);
|
// this.paint(this.lampNum, this.mirror, this.states);
|
||||||
}
|
}
|
||||||
stopAnmiation() {
|
stopAnmiation() {
|
||||||
const redFlashA = this.animation(anmiationNameConst.signaRedFlash);
|
const redFlashA = this.animation(anmiationNameConst.signaRedFlash + this.states?.code);
|
||||||
const greenFlashA = this.animation(anmiationNameConst.signalGreenFlash);
|
const greenFlashA = this.animation(anmiationNameConst.signalGreenFlash + this.states?.code);
|
||||||
const blueFlashA = this.animation(anmiationNameConst.signalBlueFlash);
|
const blueFlashA = this.animation(anmiationNameConst.signalBlueFlash + this.states?.code);
|
||||||
const yellowFlashA = this.animation(anmiationNameConst.signalYellowFlash);
|
const yellowFlashA = this.animation(anmiationNameConst.signalYellowFlash + this.states?.code);
|
||||||
const whiteFlashA = this.animation(anmiationNameConst.signalWhiteFlash);
|
const whiteFlashA = this.animation(anmiationNameConst.signalWhiteFlash + this.states?.code);
|
||||||
if (redFlashA) {
|
if (redFlashA) {
|
||||||
redFlashA.pause();
|
redFlashA.pause();
|
||||||
}
|
}
|
||||||
@ -109,18 +167,13 @@ export class LampMainBody extends JlGraphic {
|
|||||||
}
|
}
|
||||||
chagneState(states: ISignalState) {
|
chagneState(states: ISignalState) {
|
||||||
this.stopAnmiation();
|
this.stopAnmiation();
|
||||||
if (states.extinguish) {
|
|
||||||
this.lamps.forEach((lamp) => lamp.createLogicMode());
|
|
||||||
} else {
|
|
||||||
this.lamps.forEach((lamp) => lamp.logicModeClear());
|
|
||||||
}
|
|
||||||
if (states.redOpen) {
|
if (states.redOpen) {
|
||||||
this.lamps[0].createLamp(LampEnum.redLamp);
|
this.paintLamp([LampEnum.redLamp]);
|
||||||
} else if (states.redFlash) {
|
} else if (states.redFlash) {
|
||||||
let redFlashA = this.animation(anmiationNameConst.signaRedFlash);
|
let redFlashA = this.animation(anmiationNameConst.signaRedFlash + states.code);
|
||||||
if (!redFlashA) {
|
if (!redFlashA) {
|
||||||
redFlashA = this.createFlashAnmiation(
|
redFlashA = this.createFlashAnmiation(
|
||||||
anmiationNameConst.signaRedFlash,
|
anmiationNameConst.signaRedFlash + states.code,
|
||||||
LampEnum.redLamp,
|
LampEnum.redLamp,
|
||||||
0
|
0
|
||||||
);
|
);
|
||||||
@ -128,12 +181,12 @@ export class LampMainBody extends JlGraphic {
|
|||||||
this.addAnimation(redFlashA);
|
this.addAnimation(redFlashA);
|
||||||
redFlashA.resume();
|
redFlashA.resume();
|
||||||
} else if (states.greenOpen) {
|
} else if (states.greenOpen) {
|
||||||
this.lamps[1].createLamp(LampEnum.greenLamp);
|
this.paintLamp([LampEnum.closeLamp, LampEnum.greenLamp]);
|
||||||
} else if (states.greenFlash) {
|
} else if (states.greenFlash) {
|
||||||
let greenFlashA = this.animation(anmiationNameConst.signalGreenFlash);
|
let greenFlashA = this.animation(anmiationNameConst.signalGreenFlash + states.code);
|
||||||
if (!greenFlashA) {
|
if (!greenFlashA) {
|
||||||
greenFlashA = this.createFlashAnmiation(
|
greenFlashA = this.createFlashAnmiation(
|
||||||
anmiationNameConst.signalGreenFlash,
|
anmiationNameConst.signalGreenFlash + states.code,
|
||||||
LampEnum.greenLamp,
|
LampEnum.greenLamp,
|
||||||
1
|
1
|
||||||
);
|
);
|
||||||
@ -141,12 +194,12 @@ export class LampMainBody extends JlGraphic {
|
|||||||
this.addAnimation(greenFlashA);
|
this.addAnimation(greenFlashA);
|
||||||
greenFlashA.resume();
|
greenFlashA.resume();
|
||||||
} else if (states.yellowOpen) {
|
} else if (states.yellowOpen) {
|
||||||
this.lamps[1].createLamp(LampEnum.yellowLamp);
|
this.paintLamp([LampEnum.closeLamp, LampEnum.yellowLamp]);
|
||||||
} else if (states.yellowFlash) {
|
} else if (states.yellowFlash) {
|
||||||
let yellowFlashA = this.animation(anmiationNameConst.signalYellowFlash);
|
let yellowFlashA = this.animation(anmiationNameConst.signalYellowFlash + states.code);
|
||||||
if (!yellowFlashA) {
|
if (!yellowFlashA) {
|
||||||
yellowFlashA = this.createFlashAnmiation(
|
yellowFlashA = this.createFlashAnmiation(
|
||||||
anmiationNameConst.signalYellowFlash,
|
anmiationNameConst.signalYellowFlash + states.code,
|
||||||
LampEnum.yellowLamp,
|
LampEnum.yellowLamp,
|
||||||
1
|
1
|
||||||
);
|
);
|
||||||
@ -154,12 +207,12 @@ export class LampMainBody extends JlGraphic {
|
|||||||
this.addAnimation(yellowFlashA);
|
this.addAnimation(yellowFlashA);
|
||||||
yellowFlashA.resume();
|
yellowFlashA.resume();
|
||||||
} else if (states.blueOpen) {
|
} else if (states.blueOpen) {
|
||||||
this.lamps.forEach((lamp) => lamp.createLamp(LampEnum.blueLamp));
|
this.paintLamp([LampEnum.blueLamp, LampEnum.blueLamp, LampEnum.blueLamp]);
|
||||||
} else if (states.blueFlash) {
|
} else if (states.blueFlash) {
|
||||||
let blueFlashA = this.animation(anmiationNameConst.signalBlueFlash);
|
let blueFlashA = this.animation(anmiationNameConst.signalBlueFlash + states.code);
|
||||||
if (!blueFlashA) {
|
if (!blueFlashA) {
|
||||||
blueFlashA = this.createFlashAnmiation(
|
blueFlashA = this.createFlashAnmiation(
|
||||||
anmiationNameConst.signalBlueFlash,
|
anmiationNameConst.signalBlueFlash + states.code,
|
||||||
LampEnum.blueLamp,
|
LampEnum.blueLamp,
|
||||||
0
|
0
|
||||||
);
|
);
|
||||||
@ -167,13 +220,12 @@ export class LampMainBody extends JlGraphic {
|
|||||||
this.addAnimation(blueFlashA);
|
this.addAnimation(blueFlashA);
|
||||||
blueFlashA.resume();
|
blueFlashA.resume();
|
||||||
} else if (states.whiteOpen) {
|
} else if (states.whiteOpen) {
|
||||||
this.lamps[0].createLamp(LampEnum.whiteLamp);
|
this.paintLamp([LampEnum.whiteLamp], 1);
|
||||||
this.lamps[1].visible = false;
|
|
||||||
} else if (states.whiteFlash) {
|
} else if (states.whiteFlash) {
|
||||||
let whiteFlashA = this.animation(anmiationNameConst.signalWhiteFlash);
|
let whiteFlashA = this.animation(anmiationNameConst.signalWhiteFlash + states.code);
|
||||||
if (!whiteFlashA) {
|
if (!whiteFlashA) {
|
||||||
whiteFlashA = this.createFlashAnmiation(
|
whiteFlashA = this.createFlashAnmiation(
|
||||||
anmiationNameConst.signalWhiteFlash,
|
anmiationNameConst.signalWhiteFlash + states.code,
|
||||||
LampEnum.whiteLamp,
|
LampEnum.whiteLamp,
|
||||||
0
|
0
|
||||||
);
|
);
|
||||||
@ -181,16 +233,15 @@ export class LampMainBody extends JlGraphic {
|
|||||||
this.addAnimation(whiteFlashA);
|
this.addAnimation(whiteFlashA);
|
||||||
whiteFlashA.resume();
|
whiteFlashA.resume();
|
||||||
} else if (states.callon) {
|
} else if (states.callon) {
|
||||||
this.lamps[0].createLamp(LampEnum.redLamp);
|
this.paintLamp([LampEnum.redLamp, LampEnum.yellowLamp]);
|
||||||
this.lamps[1].createLamp(LampEnum.yellowLamp);
|
|
||||||
} else if (states.yellowYellow) {
|
} else if (states.yellowYellow) {
|
||||||
this.lamps[0].createLamp(LampEnum.yellowLamp);
|
this.paintLamp([LampEnum.yellowLamp, LampEnum.yellowLamp]);
|
||||||
this.lamps[1].createLamp(LampEnum.yellowLamp);
|
|
||||||
} else if (states.yellowGreen) {
|
} else if (states.yellowGreen) {
|
||||||
this.lamps[0].createLamp(LampEnum.yellowLamp);
|
this.paintLamp([LampEnum.yellowLamp, LampEnum.greenLamp]);
|
||||||
this.lamps[1].createLamp(LampEnum.greenLamp);
|
|
||||||
} else if (states.lampFailure) {
|
} else if (states.lampFailure) {
|
||||||
this.lamps[0].createLamp(LampEnum.redLamp);
|
this.paintLamp([LampEnum.redLamp]);
|
||||||
|
} else {
|
||||||
|
this.paintLamp([]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
createFlashAnmiation(
|
createFlashAnmiation(
|
||||||
@ -198,18 +249,17 @@ export class LampMainBody extends JlGraphic {
|
|||||||
color: string,
|
color: string,
|
||||||
lampIndex: number
|
lampIndex: number
|
||||||
): GraphicAnimation {
|
): GraphicAnimation {
|
||||||
const bgColor = '0X' + this.getCanvas().backgroundColor.substring(1);
|
|
||||||
const flashAnmiation = GraphicAnimation.init({
|
const flashAnmiation = GraphicAnimation.init({
|
||||||
name: name,
|
name: name,
|
||||||
run: (dt: number) => {
|
run: (dt: number) => {
|
||||||
this.deltaTime += dt;
|
this.deltaTime += dt;
|
||||||
if (this.deltaTime > 60) {
|
if (this.deltaTime > 60) {
|
||||||
|
const colors = ['', '', ''];
|
||||||
this.deltaTime = 0;
|
this.deltaTime = 0;
|
||||||
this.lamps[lampIndex].createLamp(color);
|
colors[lampIndex] = color;
|
||||||
|
this.paintLamp(colors);
|
||||||
} else if (this.deltaTime > 30) {
|
} else if (this.deltaTime > 30) {
|
||||||
this.lamps.forEach((lamp) => {
|
this.paintLamp([]);
|
||||||
lamp.createLamp(bgColor);
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
Loading…
Reference in New Issue
Block a user