private void FindBestMoveEnd <Igra>(Igra cookieCallBack, MoveExt move) { if (move != null) { while (CBoard.CurrentPlayer == Igrac2PlayerE(trenutniIgrac)) { CBoard.CancelSearch(); //Prekidamo pretragu najboljeg poteza CBoard.DoMove(move); //Igramo potez PrikaziTablu(); //Prikazujemo u tabli ono sto smo odigrali ZvukFigure(); listePoteza.Add(new ListaPoteza(CBoard.GetHumanPos(move), PlayerE2Igrac(Igrac2PlayerE(trenutniIgrac)).ToString(), TipIgraca.Masina.ToString())); if (CBoard.CurrentPlayer == ChessBoard.PlayerE.Black) { StopericaPublic.Stop1(); StopericaPublic.Start2(); } if (CBoard.CurrentPlayer == ChessBoard.PlayerE.White) { StopericaPublic.Stop2(); StopericaPublic.Start1(); } } if (move.Move.Type == Move.TypeE.PieceEaten) { SahovskeFigurice = new SahovskeFigurice { Pozicija = Int2Pozicija(move.Move.EndPos), TipFigurice = PieceE2Figurice(move.Move.OriginalPiece), Igrac = PieceE2Igrac(move.Move.OriginalPiece) }; if (trenutniIgrac == Igrac.Beli) { konteinerCrni.Add(SahovskeFigurice); PrikazPojedenihCrnihFigura(); } else { konteinerBeli.Add(SahovskeFigurice); PrikazPojedenihBelihFigura(); } PrikaziTablu(); } } }
public Igra() { this.CBoard = new ChessBoard(); this.SahovskeFigurice = new SahovskeFigurice(); this.PoljeSvetlo = new PoljeSvetlo(); this.PoljeTamno = new PoljeTamno(); Thread thread = new Thread(delegate() { while (true) { Thread.Sleep(500); if (StopericaPublic.Elapsed1 < TimeSpan.Zero) { StopericaPublic.Stop1(); if (MessageBox.Show("Vreme je isteklo Belom igracu", "sss", MessageBoxButton.OK) == MessageBoxResult.OK) { StopericaPublic.Reset1(); StopericaPublic.Stop1(); Rezultat = ChessBoard.GameResultE.OnGoing; Rezultat = CBoard.GetCurrentResult(); } } else if (StopericaPublic.Elapsed2 < TimeSpan.Zero) { StopericaPublic.Stop2(); if (MessageBox.Show("Vreme je isteklo CRNOM igracu", "sss", MessageBoxButton.OK) == MessageBoxResult.OK) { StopericaPublic.Reset2(); StopericaPublic.Stop2(); Rezultat = ChessBoard.GameResultE.OnGoing; Rezultat = CBoard.GetCurrentResult(); } } } }); thread.IsBackground = true; thread.Start(); }