// This event was created so that other components, particularly the Booster, could have a way to manipulate the controller. // See the way that class uses this event. private void OnStateChanged(ControllerState newState) { ControllerStateChangedEventArgs e = new ControllerStateChangedEventArgs(newState, mState); mState = newState; ControllerStateChangedEventHandler handler = StateChanged; if (handler != null) { handler(this, e); } }
private void ControllerStateChangedHandler(object sender, ControllerStateChangedEventArgs e) { if (e.NewState == BipedControllerComponent.ControllerState.Boosting) { mBoostTime = 0.0f; mRegularSpeed = mBipedControl.RunSpeed; mBipedControl.RunSpeed = Speed; mRegularTurnLimit = mBipedControl.MaxTurnAnglePerTick; mBipedControl.MaxTurnAnglePerTick = TurnLimit; } else if (e.OldState == BipedControllerComponent.ControllerState.Boosting) { mBipedControl.RunSpeed = mRegularSpeed; mBipedControl.MaxTurnAnglePerTick = mRegularTurnLimit; } }