private void Awake() { _inputState = GetComponent <InputState> (); _walkBehavior = GetComponent <WalkBehavior> (); _animator = GetComponent <Animator> (); _collisionState = GetComponent <CollisionState> (); }
/// <summary> /// This is where all sensors and motors are stopped /// </summary> public void DisconnectAll() { // Stop sensing if (LightIntensitySensor.IsSensing()) { LightIntensitySensor.StopSensing(); } if (SoundLevelSensor.IsSensing()) { SoundLevelSensor.StopSensing(); } if (SoundRatioSensor.IsSensing()) { SoundRatioSensor.StopSensing(); } if (UltrasonicSensor.IsSensing()) { UltrasonicSensor.StopSensing(); } if (TouchSensor.IsSensing()) { TouchSensor.StopSensing(); } //TODO clear sensors? // Stop behaviors if (WalkBehavior.IsWalking) { WalkBehavior.Stop(); } // Stop motors if (MotorTail.IsRunning) { MotorTail.Stop(); } if (MotorRight.IsRunning) { MotorRight.Stop(); } if (MotorLeft.IsRunning) { MotorLeft.Stop(); } System.Threading.Thread.Sleep(1000); Brick.Disconnect(); IsConnectionStarted = false; }