public void VerplaatsVierkant(PionViewModel vierkant, GameViewModel gm) { if (gm.SpelGestart) { if (vierkant.isMoveable && SelectedVierkant1 == null && vierkant.Team == gm.PlayingTeam) { isBeurtGedaan = false; SelectedVierkant1 = vierkant; ShowWhereCanGo(vierkant, gm.PlayingTeam); } else if (vierkant.Karakter != "obstacle" && SelectedVierkant1 != null) { SelectedVierkant2 = vierkant; if (SelectedVierkant1.id == SelectedVierkant2.id) //Deselecteren { SelectedVierkant2 = null; SelectedVierkant1 = null; } else { #region ATTACK_RULES if (SelectedVierkant2.Karakter == "Flag") //Checken of vlag { DisableAll(); gm.UnhideAll("Blue"); gm.UnhideAll("Red"); gm.SpelGestart = false; if (SelectedVierkant2.Team == "Red") { MessageBox.Show("Blue team won!"); IncreaseScore(gm.RecentsteSessie.team2_Speler); } else if (SelectedVierkant2.Team == "Blue") { MessageBox.Show("Red team won!"); IncreaseScore(gm.RecentsteSessie.team1_Speler); } } if (SelectedVierkant2.Karakter == "grey") { RemoveSecond(gm.PlayingTeam); isBeurtGedaan = true; } else if (SelectedVierkant1.Karakter == "Spy" && SelectedVierkant2.Karakter == "Marshall") //Spion regel { AddToGraveyard(SelectedVierkant2); history.Add("Spy murdered Marshall"); RemoveSecond(gm.PlayingTeam); isBeurtGedaan = true; } else if (SelectedVierkant1.Karakter == "Miner" && SelectedVierkant2.Karakter == "Bomb") //Mineur en bom regel { AddToGraveyard(SelectedVierkant2); history.Add("Miner defused Bomb"); RemoveSecond(gm.PlayingTeam); isBeurtGedaan = true; } else if (NameToNumber(SelectedVierkant1.Karakter) > NameToNumber(SelectedVierkant2.Karakter)) { AddToGraveyard(SelectedVierkant2); history.Add(SelectedVierkant1.Karakter + " defeated " + SelectedVierkant2.Karakter); RemoveSecond(gm.PlayingTeam); isBeurtGedaan = true; } else if (NameToNumber(SelectedVierkant1.Karakter) < NameToNumber(SelectedVierkant2.Karakter)) { AddToGraveyard(SelectedVierkant1); history.Add(SelectedVierkant2.Karakter + " defeated " + SelectedVierkant1.Karakter); RemoveFirst(); isBeurtGedaan = true; } else if (NameToNumber(SelectedVierkant1.Karakter) == NameToNumber(SelectedVierkant2.Karakter)) { movable_red_on_board--; movable_blue_on_board--; red_graveyard.Add(SelectedVierkant1.Karakter); blue_graveyard.Add(SelectedVierkant2.Karakter); history.Add(SelectedVierkant1.Karakter + " defeated " + SelectedVierkant2.Karakter); RemoveBoth(); isBeurtGedaan = true; } if (movable_blue_on_board == 0 && movable_red_on_board == 0) { MessageBox.Show("Tie! All movable soldies were killed"); gm.SpelGestart = false; gm.UnhideAll("Blue"); gm.UnhideAll("Red"); } else if (movable_blue_on_board == 0) { MessageBox.Show("Red team (" + gm.RecentsteSessie.team1_Speler + ") won! All blue soldiers were killed"); gm.SpelGestart = false; gm.UnhideAll("Blue"); gm.UnhideAll("Red"); IncreaseScore(gm.RecentsteSessie.team1_Speler); //Messenger.Default.Send<GameFinishedMessage>(new GameFinishedMessage()); } else if (movable_red_on_board == 0) { MessageBox.Show("Blue team (" + gm.RecentsteSessie.team2_Speler + ") won! All red soldiers were killed"); gm.SpelGestart = false; gm.UnhideAll("Blue"); gm.UnhideAll("Red"); IncreaseScore(gm.RecentsteSessie.team2_Speler); //Messenger.Default.Send<GameFinishedMessage>(new GameFinishedMessage()); } #endregion } gm.History = history; gm.ListView = red_graveyard; gm.ListViewBlue = blue_graveyard; EnableAll(); RemoveBorderAll(); } if (gm.PlayingTeam == "Red" && isBeurtGedaan && gm.SpelGestart) { gm.HideAll("Red"); gm.UnhideAll("Blue"); gm.DisableAll("Red"); gm.EnableAll("Blue"); isBeurtGedaan = false; gm.PlayingTeam = "Blue"; gm.Info = "It is " + gm.RecentsteSessie.team2_Speler + "'s turn"; } else if (gm.PlayingTeam == "Blue" && isBeurtGedaan && gm.SpelGestart) { gm.HideAll("Blue"); gm.UnhideAll("Red"); gm.DisableAll("Blue"); gm.EnableAll("Red"); isBeurtGedaan = false; gm.PlayingTeam = "Red"; gm.Info = "It is " + gm.RecentsteSessie.team1_Speler + "'s turn"; } else if (!gm.SpelGestart) { gm.UnhideAll("Blue"); gm.UnhideAll("Red"); } } }
/* public void DisableAll(string team) * { * if (team == "Blue") * * foreach (PionViewModel p in GeheugenVierkanten) * if (p.Team == "Blue") * p.isSelectable = false; * * if (team == "Red") * * foreach (PionViewModel p in GeheugenVierkanten) * if (p.Team == "Red") * p.isSelectable = false; * } * public void EnableAll(string team) * { * if (team == "Blue") * * foreach (PionViewModel p in GeheugenVierkanten) * if (p.Team == "Blue") * p.isSelectable = true; * * if (team == "Red") * * foreach (PionViewModel p in GeheugenVierkanten) * if (p.Team == "Red") * p.isSelectable = true; * * OnPropertyChanged("GeheugenVierkanten"); * }*/ public void PutOnBoard(string Karakter, GameViewModel gm, PionViewModel vierkant) { if (gm.PlayingTeam == "Red") { gm.ListView.Remove(Karakter); } else if (gm.PlayingTeam == "Blue") { gm.ListViewBlue.Remove(Karakter); } string[] imageNames = { "01_Spy_", "02_Scout_", "03_Miner_", "04_Sergent_", "05_Lieutenant_", "06_Captain_", "07_Major_", "08_Colonel_", "09_General_", "10_Marshall_", "11_Bomb_", "12_Flag_" }; string image = string.Empty; if (Karakter == "Spy") { image = imageNames[0]; } else if (Karakter == "Scout") { image = imageNames[1]; } else if (Karakter == "Miner") { image = imageNames[2]; } else if (Karakter == "Sergent") { image = imageNames[3]; } else if (Karakter == "Lieutenant") { image = imageNames[4]; } else if (Karakter == "Captain") { image = imageNames[5]; } else if (Karakter == "Major") { image = imageNames[6]; } else if (Karakter == "Colonel") { image = imageNames[7]; } else if (Karakter == "General") { image = imageNames[8]; } else if (Karakter == "Marshall") { image = imageNames[9]; } else if (Karakter == "Bomb") { image = imageNames[10]; } else if (Karakter == "Flag") { image = imageNames[11]; } vierkant.VierkantFoto = Path.Combine(Environment.CurrentDirectory + "/images/" + image + gm.PlayingTeam + ".png"); vierkant.Karakter = Karakter; if (Karakter != "Bomb" && Karakter != "Flag") { vierkant.isMoveable = true; } else { vierkant.isMoveable = false; } }
//vierkant matchen aan karakter public void PlaceVierkant(PionViewModel vierkant, GameViewModel gm) { if (vierkant.Karakter == "grey" && gm.PlaatsenOpBord) { if (gm.SelectedKarakter == "Spy") { PutOnBoard("Spy", gm, vierkant); } if (gm.SelectedKarakter == "Scout") { PutOnBoard("Scout", gm, vierkant); } if (gm.SelectedKarakter == "Miner") { PutOnBoard("Miner", gm, vierkant); } if (gm.SelectedKarakter == "Sergent") { PutOnBoard("Sergent", gm, vierkant); } if (gm.SelectedKarakter == "Lieutenant") { PutOnBoard("Lieutenant", gm, vierkant); } if (gm.SelectedKarakter == "Captain") { PutOnBoard("Captain", gm, vierkant); } if (gm.SelectedKarakter == "Major") { PutOnBoard("Major", gm, vierkant); } if (gm.SelectedKarakter == "Colonel") { PutOnBoard("Colonel", gm, vierkant); } if (gm.SelectedKarakter == "General") { PutOnBoard("General", gm, vierkant); } if (gm.SelectedKarakter == "Marshall") { PutOnBoard("Marshall", gm, vierkant); } if (gm.SelectedKarakter == "Bomb") { PutOnBoard("Bomb", gm, vierkant); } if (gm.SelectedKarakter == "Flag") { PutOnBoard("Flag", gm, vierkant); } if (gm.PlayingTeam == "Red") { gm.SelectedKarakter = gm.ListView[0]; } else { gm.SelectedKarakter = gm.ListViewBlue[0]; } vierkant.Team = gm.PlayingTeam; gm.placed_sum++; } }