private void ContineAdventure_Click(object sender, RoutedEventArgs e) { SoundManager.playSFX(SoundManager.SoundType.Click); try { string profileName = ProfileList.SelectedValue.ToString().Trim(); if (profileName != "") { Pentago.GameCore.ProfileManager.Profile playerProfile = profileManager.SearchProfile(profileName); string player1Name = playerProfile.ProfileName; bool isPlayer1Active = true; ImageBrush player1Image = new ImageBrush(); player1Image.ImageSource = new BitmapImage(new Uri("pack://application:,,,/GUI/images/RedPup.png", UriKind.Absolute)); ImageBrush player1ImageHover = new ImageBrush(); player1ImageHover.ImageSource = new BitmapImage(new Uri("pack://application:,,,/GUI/images/RedPupHover.png", UriKind.Absolute)); string computerPlayerName = "Computer"; ImageBrush computerPlayerImage = new ImageBrush(); computerPlayerImage.ImageSource = new BitmapImage(new Uri("pack://application:,,,/GUI/images/BluePup.png", UriKind.Absolute)); ImageBrush computerPlayerImageHover = new ImageBrush(); computerPlayerImageHover.ImageSource = new BitmapImage(new Uri("pack://application:,,,/GUI/images/BluePupHover.png", UriKind.Absolute)); computerAI.Difficulty difficulty; if (playerProfile.CampaignProgress == 0) difficulty = computerAI.Difficulty.Beginner; else if (playerProfile.CampaignProgress == 1) difficulty = computerAI.Difficulty.Easy; else if (playerProfile.CampaignProgress == 2) difficulty = computerAI.Difficulty.Medium; else if (playerProfile.CampaignProgress == 3) difficulty = computerAI.Difficulty.Medium; else difficulty = computerAI.Difficulty.Hard; Player player1 = new Player(player1Name.Trim(), isPlayer1Active, player1Image, player1ImageHover); computerAI computerPlayer = new computerAI(computerPlayerName.Trim(), !isPlayer1Active, computerPlayerImage, computerPlayerImageHover, difficulty); GameOptions gameOptions = new GameOptions(GameOptions.TypeOfGame.Campaign, player1, computerPlayer); MapPage map = new MapPage(gameOptions); NavigationService.Navigate(map); } } catch { const string message = "Please, select a profile."; MessageWindow messageWindow = new MessageWindow(message, MessageBoxButton.OK); messageWindow.ShowDialog(); } }
private void SaveProfile_Click(object sender, RoutedEventArgs e) { SoundManager.playSFX(SoundManager.SoundType.Click); string newProfileName = NewProfileName.Text; newProfileName = newProfileName.Trim(); if (IsProfileNameValid(newProfileName)) { if (profileManager.IsProfileValid(newProfileName)) { List<Bitmap> images = new List<Bitmap>(); if (currentArmor1 != "Base") images.Add(new Bitmap(@"GUI\Images\" + currentArmor1)); if (currentBeard1 != "Base") images.Add(new Bitmap(@"GUI\Images\" + currentBeard1)); if (currentPant1 != "Base") images.Add(new Bitmap(@"GUI\Images\" + currentPant1)); var target = new Bitmap(@"GUI\Images\Armless.png"); var graphics = Graphics.FromImage(target); graphics.CompositingMode = System.Drawing.Drawing2D.CompositingMode.SourceOver; foreach (Bitmap image in images) graphics.DrawImage(image, 0, 0); if (!Directory.Exists("C:\\Users\\Public\\Documents\\Dragon Horde")) Directory.CreateDirectory("C:\\Users\\Public\\Documents\\Dragon Horde"); target.Save("C:\\Users\\Public\\Documents\\Dragon Horde\\" + newProfileName + ".png", System.Drawing.Imaging.ImageFormat.Png); //append to file profileManager.CreateNewProfile(newProfileName); const string message = "Your profile has been set up."; MessageWindow messageWindow = new MessageWindow(message, MessageBoxButton.OK); ExistingProfile_Click(sender, e); messageWindow.ShowDialog(); } else { const string message = "This profile name already exists, please create a new one."; MessageWindow messageWindow = new MessageWindow(message, MessageBoxButton.OK); messageWindow.ShowDialog(); } } else { const string message = "Please, verify name is alphanumeric, longer than 1 character and less than 15."; MessageWindow messageWindow = new MessageWindow(message, MessageBoxButton.OK); messageWindow.ShowDialog(); } }
private void Battle_Click(object sender, RoutedEventArgs e) { SoundManager.playSFX(SoundManager.SoundType.Click); if (ValidateNames()) { if (PlayerVsPlayerOn.Visibility == Visibility.Visible) InitializePlayerVsPlayerGame(); else if (PlayerVsPlayerOff.Visibility == Visibility.Visible) InitializePlayerVsComputerGame(); else Console.WriteLine("There is something wrong!"); } else { const string message = "Please, verify names are alphanumeric, longer than 1 character and less than 15."; MessageWindow messageWindow = new MessageWindow(message, MessageBoxButton.OK); messageWindow.ShowDialog(); } }
private void PeerDisconnected(object sender, EventArgs e) { this.Dispatcher.BeginInvoke(new Action(delegate() { MessageWindow message = new MessageWindow("Disconnected"); message.ShowDialog(); Window mainWindow = new MainMenu(); App.Current.MainWindow = mainWindow; mainWindow.Show(); this.Hide(); networkUtil.stop(); })); }