private bool CheckSchaak() { Point VijandelijkeKoningLocatie = new Point(); foreach (SchaakStuk stuk in Bord) { if ((stuk.kleur == HuidigeSpeler && stuk.type == Type.Koning)) { VijandelijkeKoningLocatie = stuk.locatie; } } foreach (SchaakStuk stuk in Bord) { if (stuk.kleur != HuidigeSpeler) { WisselBeurt(); VindLocaties(stuk.locatie); WisselBeurt(); foreach (Point locatie in SlaanLocaties) { if (locatie == VijandelijkeKoningLocatie) { AnimatieFuncties.SetSchaak(VijandelijkeKoningLocatie, scherm.SchaakBox); return(true); } } } } return(false); }
public bool VerwerkKlik(Point locatie) { Rectangle ControleBord; if (speler1Wit && HuidigeSpeler == Kleur.Wit || !speler1Wit && HuidigeSpeler == Kleur.Zwart) { ControleBord = SchaakbordRenderFuncties.controleBord1; } else { ControleBord = SchaakbordRenderFuncties.controleBord2; } if (InBox(locatie, ControleBord) && CheckKleur(LocatienaarPunt(locatie, ControleBord))) { GeselecteerdeLocatie = LocatienaarPunt(locatie, ControleBord); VindLocaties(GeselecteerdeLocatie); } else if (InBox(locatie, ControleBord) && ActieToegestaan(LoopLocaties, LocatienaarPunt(locatie, ControleBord))) { AnimatieFuncties.RemoveSchaak(scherm.SchaakBox); foreach (SchaakStuk stuk in Bord) { if (stuk.locatie == GeselecteerdeLocatie) { StukheeftBewogen = stuk.HeeftBewogen; OudPunt = stuk.locatie; stuk.HeeftBewogen = true; stuk.locatie = LocatienaarPunt(locatie, ControleBord); if (CheckSchaak()) { stuk.HeeftBewogen = StukheeftBewogen; stuk.locatie = OudPunt; SlaanLocaties.Clear(); LoopLocaties.Clear(); break; } WisselBeurt(); GeselecteerdeLocatie = new Point(0, 0); CheckSchaak(); SchaakStuk lopendstuk = new SchaakStuk(Type.Pion, Kleur.Zwart, new Point(0, 0)); foreach (SchaakStuk speelstuk in Bord) { if (speelstuk.locatie == stuk.locatie) { lopendstuk = speelstuk; } } SoundFuncties.PlayLoopSound(scherm.player, lopendstuk.type); GeselecteerdeLocatie = new Point(0, 0); } } } else if (InBox(locatie, ControleBord) && ActieToegestaan(SlaanLocaties, LocatienaarPunt(locatie, ControleBord))) { AnimatieFuncties.RemoveSchaak(scherm.SchaakBox); int count = 0; foreach (SchaakStuk stuk in Bord) { if (stuk.locatie == LocatienaarPunt(locatie, ControleBord)) { break; } count++; } RemovedPiece = Bord[count]; Bord.RemoveAt(count); foreach (SchaakStuk stuk in Bord) { if (stuk.locatie == GeselecteerdeLocatie) { StukheeftBewogen = stuk.HeeftBewogen; OudPunt = stuk.locatie; stuk.HeeftBewogen = true; stuk.locatie = LocatienaarPunt(locatie, ControleBord); if (CheckSchaak()) { stuk.HeeftBewogen = StukheeftBewogen; stuk.locatie = OudPunt; Bord.Add(RemovedPiece); GeselecteerdeLocatie = new Point(0, 0); SlaanLocaties.Clear(); LoopLocaties.Clear(); break; } WisselBeurt(); GeselecteerdeLocatie = new Point(0, 0); CheckSchaak(); SchaakStuk lopendstuk = new SchaakStuk(Type.Pion, Kleur.Zwart, new Point(0, 0)); foreach (SchaakStuk speelstuk in Bord) { if (speelstuk.locatie == stuk.locatie) { lopendstuk = speelstuk; } } SoundFuncties.PlayLoopSound(scherm.player, lopendstuk.type); SoundFuncties.PlayAanvalSound(scherm.player, lopendstuk.type); } } } else { return(false); } return(true); }