void StopMoving() { if (currentScalarState != ScalarMotionState.STOPPED) { webView.Eval("wsSendCommand('command', 'walkY 100');"); } currentScalarState = ScalarMotionState.STOPPED; }
void GoBackScalar() { if (currentScalarState == ScalarMotionState.BACK) { return; } else if (currentScalarState == ScalarMotionState.FORWARD) { StopMoving(); } webView.Eval("wsSendCommand('command', 'walkY 80');"); currentScalarState = ScalarMotionState.BACK; }
public MotionPage() { InitializeComponent(); var defaultColor = goForwardButton.BackgroundColor; rotationSlider.Maximum = 130; rotationSlider.Minimum = 70; rotationSlider.Value = 100; rotationSlider.ValueChanged += (sender, e) => { if (e.NewValue > 80 && e.NewValue < 110) { StopTranslation(); } else if (e.NewValue < 100) { TranslateLeft(); } else { TranslateRight(); } }; currentDirectionState = DirectionalMotionState.STRAIGHT; currentScalarState = ScalarMotionState.STOPPED; joyStickTranslation.OnValueChanged += (float xPos, float yPos) => { Debug.WriteLine("" + xPos + ", " + yPos); if (xPos > 0.5) { TranslateRight(); } else if (xPos < -0.5) { TranslateLeft(); } else { StopTranslation(); } if (yPos > 0.5) { GoBackScalar(); } else if (yPos < -0.5) { GoForwardScalar(); } else { StopMoving(); } }; joyStickRotation.OnValueChanged += (float xPos, float yPos) => { if (xPos > 0.5) { RotateRight(); } else if (xPos < -0.5) { RotateLeft(); } else { StopRotation(); } }; stopButton.Clicked += async(object sender, EventArgs e) => { StopMoving(); StopTranslation(); StopRotation(); await stopButton.AnimateButton(); goForwardButton.BackgroundColor = defaultColor; goBackButton.BackgroundColor = defaultColor; StopAnimationSpider(); }; goForwardButton.Clicked += async(object sender, EventArgs e) => { GoForwardScalar(); await goForwardButton.AnimateButton(); goForwardButton.BackgroundColor = Color.Red; goBackButton.BackgroundColor = defaultColor; if (!animating) { StartAnimationSpider(); } }; goBackButton.Clicked += async(object sender, EventArgs e) => { GoBackScalar(); await goBackButton.AnimateButton(); goForwardButton.BackgroundColor = defaultColor; goBackButton.BackgroundColor = Color.Red; if (!animating) { StartAnimationSpider(); } }; }