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-06 02:41:19 +00:00
|
|
|
|
|
|
|
constructor(location: PIXI.Point, speed: number, passengers: number, origin: Station,
|
|
|
|
destination: Station) {
|
|
|
|
this.location = location;
|
|
|
|
this.speed = speed;
|
|
|
|
this.origin = origin;
|
|
|
|
this.destination = destination;
|
|
|
|
this.passengers = passengers;
|
2018-04-09 22:35:30 +00:00
|
|
|
|
|
|
|
// for debugging
|
|
|
|
trainCount += 1;
|
|
|
|
this.id = trainCount;
|
|
|
|
this.label = new PIXI.Text(`${this.id}`, {
|
|
|
|
fill: 'white',
|
|
|
|
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
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|