더 빨리 가고 싶어서 하는 경우
좌회전 등을 하기 위해 필연적으로 변경해야 하는 경우
isSafeLaneDecision: function ( i ) {
if ( this.lane + i < 0 || this.lane + i >= this.location.laneCount ) {
return false;
}
if ( this.location.vehicleAtLocation( this.lane + i, this.localY ) ) {
return false;
}
var vehicleSideBehind = this.location.vehicleBehindLocation( this.lane + i, this.localY );
if ( !vehicleSideBehind ) {
return true;
}
var s = vehicleSideBehind.speed;
if ( this.speed === 0 ) return true;
if ( s > 3 * this.speed ) {
return false;
}
if ( this.gammaSide( i ) <= this.safetyDistance * 0.5 ) {
return false;
}
return true;
}
updateLocation: function ( deltaTime ) {
switch ( this.location.type ) {
case "Road":
var newLocalY = this.localY + this.speedY * deltaTime;
var diff = newLocalY + this.length - this.location.length;
if ( diff < 0 ) {
this.localY = newLocalY;
} else {
this.location.vehiclesCount--;
this.setLocation( this.locationTo, this.lane, diff );
}
break;
default:
break;
}
}