2018-04-15 06:54:35 +00:00
|
|
|
import * as tinycolor from 'tinycolor2';
|
|
|
|
|
2018-04-06 02:41:19 +00:00
|
|
|
import Station from './Station';
|
|
|
|
|
2018-04-09 22:35:30 +00:00
|
|
|
let trainCount = 0;
|
|
|
|
|
2018-04-06 02:41:19 +00:00
|
|
|
export default class Train {
|
|
|
|
public location: PIXI.Point;
|
|
|
|
public speed: number;
|
|
|
|
public origin: Station;
|
|
|
|
public destination: Station;
|
|
|
|
public passengers: number;
|
2018-04-09 22:35:30 +00:00
|
|
|
public id: number;
|
|
|
|
public label: PIXI.Text;
|
2018-04-15 06:54:35 +00:00
|
|
|
public color: tinycolorInstance;
|
2018-04-06 02:41:19 +00:00
|
|
|
|
|
|
|
constructor(location: PIXI.Point, speed: number, passengers: number, origin: Station,
|
2018-04-15 06:54:35 +00:00
|
|
|
destination: Station, color: tinycolorInstance) {
|
2018-04-06 02:41:19 +00:00
|
|
|
this.location = location;
|
|
|
|
this.speed = speed;
|
|
|
|
this.origin = origin;
|
|
|
|
this.destination = destination;
|
|
|
|
this.passengers = passengers;
|
2018-04-15 06:54:35 +00:00
|
|
|
this.color = color;
|
2018-04-09 22:35:30 +00:00
|
|
|
|
|
|
|
// for debugging
|
|
|
|
trainCount += 1;
|
|
|
|
this.id = trainCount;
|
|
|
|
this.label = new PIXI.Text(`${this.id}`, {
|
2018-04-10 03:56:04 +00:00
|
|
|
fill: '#AEAEAE',
|
2018-04-09 22:35:30 +00:00
|
|
|
fontFamily: 'monospace',
|
|
|
|
fontSize: '12px',
|
|
|
|
});
|
2018-04-06 02:41:19 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
public boardPassengers() {
|
|
|
|
if (this.location === this.origin.location) { // about to leave a station
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|