public Car() { stoppedState = new StoppedState(this); drivingState = new DrivingState(this); state = stoppedState; }
public Car() { EmptyTank = new EmptyTankState(this); FullTank = new FullTankState(this); EngineStarted = new EngineStartedState(this); DrivingState = new DrivingState(this); _currentState = EmptyTank; Gasoline = 0; }
public void RideToDestination(RouterPoint endPoint, double distanceCovered, DrivingState endState) { Latitude = endPoint.Latitude; Longitude = endPoint.Longitude; CurrentResolvedLocation = endPoint; int seconds = (int)(distanceCovered / carSpeedMeter + 1d); LocalTime = LocalTime.AddSeconds(seconds); State = endState; }
//Called to set approprite states when resetting a kart public bool ResettingKart() { if (drivingState != DrivingState.stopped) { drivingState = DrivingState.stopped; return true; } else return false; }
void Start() { effectsHandler = GetComponent<KartEffectHandler>(); //controller = GetComponent<CharacterController>(); drivingState = DrivingState.stopped; GameEvents.raceBegan += OnRaceBegan; GameEventsClient.raceBegan += OnRaceBegan; }
public Car() { Fuel = 0; EmptyTank = new EmptyTankState(this); TankWithFuel = new TankWithFuelState(this); EngineStarted = new EngineStartedState(this); Driving = new DrivingState(this); _currentState = EmptyTank; }
/// <summary> /// Compute update using the Intelligent Driver Model for car-following model and MOBIL lane change criterion /// </summary> /// <param name="deltaTime">Time since last update</param> public void Update(float deltaTime) { // Update using FSM and adjust the state accordingly for next update DrivingState drivingState = DrivingState.Update(deltaTime); if (drivingState != null) { DrivingState.OnExit(); DrivingState = drivingState; DrivingState.OnEnter(); } }
public void ReplaceState(DrivingState state) { if (state == null) { Debug.LogError ("Error: Attempting to replace driving state for car '" + m_car.name + "' with null state"); return; } if (m_states.Peek () != null) { m_states.Pop ().Exit (m_car); } m_states.Push (state); state.Enter (m_car); }
public void PushState(DrivingState state) { if (state == null) { Debug.LogError ("Error: Attempting to push null driving state onto car '" + m_car.name + "'"); return; } if (m_states.Peek () != null) { m_states.Peek ().Exit (m_car); } m_states.Push (state); state.Enter (m_car); }
// Start is called before the first frame update void Start() { trafficController = FindObjectOfType <LocalTraffic>(); actualTopSpeed = Random.Range(topSpeed - topSpeedDelta, topSpeed + topSpeedDelta); // Calculates initial random top speed State = DrivingState.MovingToNextPoint; // Set to start driving iAmTurningLeft = false; // Not turning left iAmAvoidingLeftPittsburghLeft = false; // Don't have to slow down to avoid a left turn upDir = this.transform.up; initialUpDir = this.transform.up; lastBankAngle = 0; }
//Disable kart after race is finished public void KartFinishedRace() { drivingState = DrivingState.stopped; }
IEnumerator ChangeMoveStateCoroutine( bool turnRight, bool turnLeft, bool slowingDown, bool pressedSlow, bool doubleTap ) { if(Network.isClient) yield return new WaitForSeconds(.1f); if(drivingState != DrivingState.stopped ) { if(slowingDown && !drifting) slowing = true; else slowing = false; if(turnRight && !turnLeft) { if(!pressedSlow) { if(drivingState != DrivingState.driftRight) { drivingState = DrivingState.right; drifting = false; holdDrift = false; } else { drifting = true; holdDrift = false; } } else { drivingState = DrivingState.driftRight; drifting = true; slowing = false; } } else if ( turnLeft && !turnRight ) { if(!pressedSlow) { if(drivingState != DrivingState.driftLeft) { drivingState = DrivingState.left; drifting = false; holdDrift = false; } else { drifting = true; holdDrift = false; } } else { drivingState = DrivingState.driftLeft; drifting = true; slowing = false; } } else if ( turnLeft && turnRight ) { if(drifting) { if(drivingState == DrivingState.driftLeft || drivingState == DrivingState.driftRight) { holdDrift = true; } } } else { drivingState = DrivingState.forward; drifting = false; holdDrift = false; } } }
//Activate a disabled kart public void ActivateKart() { drivingState = DrivingState.forward; }
/// <summary> /// Actions to perform when a car is being removed from the world /// </summary> public void Remove() { DrivingState.OnExit(); }