void app_OnEndGameEnd(GeniusTetrisPlayer arg1, string arg2) { //Sorted player by their score CollectionViewSource sortedCollection = new CollectionViewSource(); ObservableCollection <ScorePlayer> allplayers = new ObservableCollection <ScorePlayer>(app.GameMembersList.Select(x => ScorePlayer.FromPlayer(x))); app.CurrentPlayer.Score = app.CurrentGame.Score; var Me = ScorePlayer.FromPlayer(app.CurrentPlayer); Me.IsYou = true; allplayers.Add(Me); foreach (var teamGrp in allplayers.GroupBy(x => x.TeamName)) { var teamScore = teamGrp.Sum(x => x.Score); foreach (var player in teamGrp) { player.TeamScore = teamScore; } } sortedCollection.Source = allplayers; var grp = new PropertyGroupDescription("TeamName"); sortedCollection.GroupDescriptions.Add(grp); sortedCollection.SortDescriptions.Add(new SortDescription("Score", ListSortDirection.Descending)); ScoresDlgUC dlg = new ScoresDlgUC(); dlg.DataContext = sortedCollection; ModalService.ShowModal(dlg); }
private void TransformPlayers(Ladder ladder, Dictionary <string, LadderStanding> playerStandings, Games.Team team, ScoreTeam scoreTeam) { foreach (var player in team.Players) { var scorePlayer = new ScorePlayer(player.UserId); // TODO: This makes individual queries, optimize //var standing = this.unitOfWork.Ladders.GetUserStanding(ladder.Id, player.UserId); var standing = this.unitOfWork.GetGenericRepository <LadderStanding>() .Query() .FirstOrDefault(x => x.LadderId == ladder.Id && x.UserId == player.UserId); if (standing != null) { Log.Info().Message("Found ladder standing for {0} {1}", ladder.Id, player.UserId).Write(); // Player has already competed in this ladder scorePlayer.Rating = standing.Rating; scorePlayer.Vol = standing.Vol; scorePlayer.Rd = standing.Rd; } playerStandings.Add(player.UserId, standing); scoreTeam.Players.Add(scorePlayer); } }
/// <summary> /// Cleans up resources. /// </summary> /// <param name="cleanAll">true to explicitly dispose managed resources; false otherwise.</param> protected virtual void Dispose(bool cleanAll) { player = null; if (cleanAll) { data = null; } }
/// <summary> /// Plays the current note through the default MIDI channel. /// </summary> /// <param name="note"></param> public void PlayNote(Note note) { if (player == null) { player = new MidiTaskScorePlayer(data); } player.PlayElement(note); }
public void playMatch() { Player[] players = new Player[2]; players[0] = this.player1; players[1] = this.player2; ScorePlayer score = new ScorePlayer(players[0], players[1], true); Console.WriteLine("Score:" + score.score()); }
/// <summary> /// Resets the MidiScoreTaskPlayer to a clean state. /// </summary> public void ResetPlayer() { if (player != null) { ((IDisposable)player).Dispose(); } player = null; player = new MidiTaskScorePlayer(data); }
public void Setup() { foreach (Player p in gamemanager.playersAtStart) { ScorePlayer sp = Instantiate(scoreplayerprefab, transform).GetComponent <ScorePlayer>(); sp.playercolor.color = p.color; sp.scoreText.text = "" + 0; scoreplayers.Add(sp); } }
public void playNeural() { FeedforwardNetwork network = loadNetwork(); Player[] players = new Player[2]; players[0] = new PlayerNeural(network); players[1] = new PlayerMinMax(); ScorePlayer score = new ScorePlayer(players[0], players[1], true); score.score(); }
/// <summary> /// Loads the viewer with a Score object generated from the specified MusicXml file. /// </summary> public void loadFile(string fileName) { this.fileName = fileName; if (File.Exists(fileName)) { // Parser instance converts between Score object and MusicXML var parser = new MusicXmlParser(); Score score = parser.Parse(XDocument.Load(fileName)); // Load the content of the specified file into Data data = null; Data = score; // Get the key signature keySig = (Key)score.FirstStaff.Elements.First(k => k.GetType() == typeof(Key)); if (KeySig == null) { KeySig = new Key(0); } // Get the time signature timeSig = (TimeSignature)score.FirstStaff.Elements.First(k => k.GetType() == typeof(TimeSignature)); if (timeSig == null) { timeSig = TimeSignature.CommonTime; } // Set up the back end data model staves = null; staves = new List <LStaff>(); foreach (var staff in score.Staves) { LStaff ls = null; List <LMeasure> measures = new List <LMeasure>(); foreach (var measure in staff.Measures) { LMeasure m = new LMeasure(measure.Elements, ls, timeSig.WholeNoteCapacity); measures.Add(m); } ls = new LStaff(staff, measures); this.staves.Add(ls); } player = new MidiTaskScorePlayer(data); updateView(); } else { throw new FileNotFoundException(fileName + " not found."); //This and any parser exceptions will be caught by the calling function } }
override public void CalculateCost() { // update the network with the new gene values this.UpdateNetwork(); PlayerNeural player1 = new PlayerNeural(this.Network); Player player2; player2 = (Player)Assembly.GetExecutingAssembly().CreateInstance(this.getTicTacToeGenetic().getOpponent().FullName); ScorePlayer score = new ScorePlayer(player1, player2, false); double cost = score.score(); // sometimes the score will be zero, just due to "luck" // if this is the case, try once more if (cost < 0.00001) { cost = score.score(); } this.Cost = cost; }
private void BtnScoreLoad_Click(object sender, EventArgs e) { if (!CheckPlayEnvironment()) { return; } var audioFileName = txtAudioFileName.Text; var audioFileInfo = new FileInfo(audioFileName); var audioFileExtension = audioFileInfo.Extension.ToLowerInvariant(); if (audioFileExtension == ExtensionAcb) { _audioFileStream = File.Open(audioFileName, FileMode.Open, FileAccess.Read); _musicWaveStream = LiveMusicWaveStream.FromAcbStream(_audioFileStream, audioFileName, DefaultCgssDecodeParams); PlayerSettings.MusicFileOffset = TimeSpan.Zero; } else if (audioFileExtension == ExtensionWav) { _audioFileStream = File.Open(audioFileName, FileMode.Open, FileAccess.Read); _musicWaveStream = LiveMusicWaveStream.FromWaveStream(_audioFileStream); PlayerSettings.MusicFileOffset = TimeSpan.FromSeconds( (double)HcaEncoderInfo.EncoderDelayInSamples / _musicWaveStream.WaveFormat.SampleRate); } else if (audioFileExtension == ExtensionHca) { _audioFileStream = File.Open(audioFileName, FileMode.Open, FileAccess.Read); _musicWaveStream = LiveMusicWaveStream.FromHcaStream(_audioFileStream, DefaultCgssDecodeParams); PlayerSettings.MusicFileOffset = TimeSpan.Zero; } else { throw new ArgumentOutOfRangeException(nameof(audioFileExtension), $"Unsupported audio format: '{audioFileExtension}'."); } _scorePlayer = new ScorePlayer(); _scorePlayer.PlaybackStopped += MusicPlayer_PlaybackStopped; _scorePlayer.AddInputStream(_musicWaveStream, PlayerSettings.MusicVolume); _sfxManager = new SfxManager(_scorePlayer); PreloadNoteSounds(); _sfxBufferTime = 0d; _scorePlayer.PositionChanged += MusicPlayer_PositionChanged; var sfxDirName = string.Format(SoundEffectAudioDirectoryNameFormat, cboSoundEffect.SelectedIndex.ToString("00")); _currentTapHcaFileName = $"{sfxDirName}/{TapHcaName}"; _currentFlickHcaFileName = $"{sfxDirName}/{FlickHcaName}"; Score score; var scoreFileName = txtScoreFileName.Text; var scoreFileExtension = new FileInfo(scoreFileName).Extension.ToLowerInvariant(); if (scoreFileExtension == ExtensionBdb) { score = Score.FromBdbFile(scoreFileName, (Difficulty)(cboDifficulty.SelectedIndex + 1)); } else if (scoreFileExtension == ExtensionCsv) { score = Score.FromCsvFile(scoreFileName); } else { throw new ArgumentException("What?", nameof(scoreFileExtension)); } _score = score; editor.Score = _score; SetControlsEnabled(ViewerState.Loaded); lblSong.Text = string.Format(SongTipFormat, _musicWaveStream.HcaName); timer.Start(); }
void Awake() { rgb = GetComponent <Rigidbody>(); scorePlayer = GetComponent <ScorePlayer>(); }
private void button_click(object sender, EventArgs e) { player = ((Button)sender).Text; Random r = new Random(); random = r.Next(0, 3); switch (random) { case 0: pc = "Rock"; pictureBox5.ImageLocation = "C:\\Users\\omkar\\OneDrive\\Documents\\GitHub\\C-Sharp\\StonePaperScissors\\game\\rock.png"; timer1.Stop(); if (player == "Rock") { pictureBox4.ImageLocation = "C:\\Users\\omkar\\OneDrive\\Documents\\GitHub\\C-Sharp\\StonePaperScissors\\game\\rock.png"; MessageBox.Show("Draw"); timer1.Start(); } if (player == "Scissors") { pictureBox4.ImageLocation = "C:\\Users\\omkar\\OneDrive\\Documents\\GitHub\\C-Sharp\\StonePaperScissors\\game\\scissors.png"; MessageBox.Show("PC wins"); ScorePc++; PlayerScore.Text = ScorePlayer.ToString(); CompScore.Text = ScorePc.ToString(); timer1.Start(); } if (player == "Paper") { pictureBox4.ImageLocation = "C:\\Users\\omkar\\OneDrive\\Documents\\GitHub\\C-Sharp\\StonePaperScissors\\game\\paper.png"; MessageBox.Show("Player wins"); ScorePlayer++; PlayerScore.Text = ScorePlayer.ToString(); CompScore.Text = ScorePc.ToString(); timer1.Start(); } break; case 1: pc = "Paper"; pictureBox5.ImageLocation = "C:\\Users\\omkar\\OneDrive\\Documents\\GitHub\\C-Sharp\\StonePaperScissors\\game\\paper.png"; timer1.Stop(); if (player == "Rock") { pictureBox4.ImageLocation = "C:\\Users\\omkar\\OneDrive\\Documents\\GitHub\\C-Sharp\\StonePaperScissors\\game\\rock.png"; MessageBox.Show("PC wins"); ScorePc++; PlayerScore.Text = ScorePlayer.ToString(); CompScore.Text = ScorePc.ToString(); timer1.Start(); } if (player == "Scissors") { pictureBox4.ImageLocation = "C:\\Users\\omkar\\OneDrive\\Documents\\GitHub\\C-Sharp\\StonePaperScissors\\game\\scissors.png"; MessageBox.Show("Player wins"); ScorePlayer++; PlayerScore.Text = ScorePlayer.ToString(); CompScore.Text = ScorePc.ToString(); timer1.Start(); } if (player == "Paper") { pictureBox4.ImageLocation = "C:\\Users\\omkar\\OneDrive\\Documents\\GitHub\\C-Sharp\\StonePaperScissors\\game\\paper.png"; MessageBox.Show("Draw"); timer1.Start(); } break; case 2: pc = "Scissors"; pictureBox5.ImageLocation = "C:\\Users\\omkar\\OneDrive\\Documents\\GitHub\\C-Sharp\\StonePaperScissors\\game\\scissors.png"; timer1.Stop(); if (player == "Rock") { pictureBox4.ImageLocation = "C:\\Users\\omkar\\OneDrive\\Documents\\GitHub\\C-Sharp\\StonePaperScissors\\game\\rock.png"; MessageBox.Show("Player wins"); ScorePlayer++; PlayerScore.Text = ScorePlayer.ToString(); CompScore.Text = ScorePc.ToString(); timer1.Start(); } if (player == "Scissors") { pictureBox4.ImageLocation = "C:\\Users\\omkar\\OneDrive\\Documents\\GitHub\\C-Sharp\\StonePaperScissors\\game\\scissors.png"; MessageBox.Show("Draw"); timer1.Start(); } if (player == "Paper") { pictureBox4.ImageLocation = "C:\\Users\\omkar\\OneDrive\\Documents\\GitHub\\C-Sharp\\StonePaperScissors\\game\\paper.png"; MessageBox.Show("PC wins"); ScorePc++; PlayerScore.Text = ScorePlayer.ToString(); CompScore.Text = ScorePc.ToString(); timer1.Start(); } break; } }