public void ParseInput(IBuffer data) { DataReader reader = DataReader.FromBuffer(data); var reportID = reader.ReadByte(); var a = reader.ReadByte(); var b = reader.ReadByte(); var c = reader.ReadByte(); byte[] dataBuffer = new byte[] { reportID, a, b, c }; string action = ""; switch (dataBuffer[0]) { case 0x30: action = "Button pressed: "; switch (dataBuffer[2]) { case 0x00: action = "Button released"; if (IsBheld) { if ((SpearHandler.State == GameState.Idle) && (SatanController.CurrentPlayer != null) && (SatanController.DirectionLocation != null)) { SpearHandler.StartThrow(); } } IsAheld = false; IsBheld = false; break; case 0x04: if (IsBheld && !IsAheld) { return; } action += "B"; IsBheld = true; break; case 0x08: if (IsAheld && !IsBheld) { return; } action += "A"; IsAheld = true; break; case 0x0C: action += "A and B"; IsBheld = true; IsAheld = true; break; } break; } System.Diagnostics.Debug.WriteLine(action); }
private async void SaveButton_Click(object sender, RoutedEventArgs e) { if (NameTextBox.Text == string.Empty) { await SatanController.ShowMessageAsync("Error", "No valid name entered"); return; } SpearHandler.Score.Name = NameTextBox.Text; HighscoreIO.SaveHighscoreObj(SpearHandler.Score); SpearHandler.Score = new HighscoreObj(); SpearHandler.PropertyChanged(); }