Merge branch 'master' of git.code.tencent.com:xian-ncc-da/xian-ncc-da-client
This commit is contained in:
commit
736ac691fe
@ -1,51 +0,0 @@
|
|||||||
import { Container } from '@pixi/display';
|
|
||||||
import { Graphics } from 'pixi.js';
|
|
||||||
import { Lamp } from './Lamp';
|
|
||||||
|
|
||||||
export enum LampEnum {
|
|
||||||
lampPostColor = '0xc0c0c0',
|
|
||||||
}
|
|
||||||
|
|
||||||
const lampConsts = {
|
|
||||||
verticalLampPostLength: 20,
|
|
||||||
levelLampPostLength: 5,
|
|
||||||
postLineWidth: 3,
|
|
||||||
lampRadius: 10,
|
|
||||||
};
|
|
||||||
|
|
||||||
export class LampBody extends Container {
|
|
||||||
lampNum = 1;
|
|
||||||
lampPost: Graphics = new Graphics();
|
|
||||||
lamps: Lamp[] = [];
|
|
||||||
|
|
||||||
constructor() {
|
|
||||||
super();
|
|
||||||
}
|
|
||||||
paint(lampNum: number) {
|
|
||||||
if (lampNum < 1) {
|
|
||||||
throw new Error('信号机灯数量异常');
|
|
||||||
}
|
|
||||||
this.lampNum = lampNum;
|
|
||||||
this.removeChildren(0);
|
|
||||||
this.lampPost = new Graphics();
|
|
||||||
this.lampPost
|
|
||||||
.lineStyle(lampConsts.postLineWidth, LampEnum.lampPostColor)
|
|
||||||
.moveTo(0, -lampConsts.verticalLampPostLength / 2)
|
|
||||||
.lineTo(0, lampConsts.verticalLampPostLength / 2)
|
|
||||||
.moveTo(0, 0)
|
|
||||||
.lineTo(lampConsts.levelLampPostLength, 0);
|
|
||||||
this.addChild(this.lampPost);
|
|
||||||
|
|
||||||
this.lamps = [];
|
|
||||||
for (let i = 0; i < this.lampNum; i++) {
|
|
||||||
const lamp = new Lamp();
|
|
||||||
const radiusX =
|
|
||||||
(1 + i * 2) * lampConsts.lampRadius + lampConsts.levelLampPostLength;
|
|
||||||
lamp.paint(radiusX, 0);
|
|
||||||
this.addChild(lamp);
|
|
||||||
this.lamps.push(lamp);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// setState() {}
|
|
||||||
}
|
|
Loading…
Reference in New Issue
Block a user