Exemple #1
0
 public GameOptions(TypeOfGame typeOfGame, string player1Name, Brush player1Color, computerAI.Difficulty difficulty)
 {
     this._TypeOfGame = typeOfGame;
     this._Player1Name = player1Name;
     this._Player1Color = player1Color;
     this._Difficulty = difficulty;
 }
        private void btnQuickMatchAI_Click(object sender, RoutedEventArgs e)
        {
            //Human vs AI
            //Idieally all this options will be set from GUI and then extracted
            //and passed to the gameOptions constructor
            string player1Name = "Diego Castillo";
            bool isPlayer1Active = true;
            ImageBrush player1Image = new ImageBrush();
            player1Image.ImageSource = new BitmapImage(new Uri("pack://application:,,,/GUI/images/dragon1.jpg", UriKind.Absolute));
            Player player1 = new Player(player1Name, isPlayer1Active, player1Image);

            string computerPlayerName = "Miley Twerk";
            ImageBrush computerPlayerImage = new ImageBrush();
            computerPlayerImage.ImageSource = new BitmapImage(new Uri("pack://application:,,,/GUI/images/dragon2.jpg", UriKind.Absolute));
            computerAI.Difficulty difficulty = computerAI.Difficulty.Hard;
            computerAI computerPlayer = new computerAI(computerPlayerName, !isPlayer1Active, computerPlayerImage, difficulty);

            GameOptions gameOptions = new GameOptions(GameOptions.TypeOfGame.AI, player1, computerPlayer);
            Window gameWindow = new Game(gameOptions);
            App.Current.MainWindow = gameWindow;
            this.Hide();
            gameWindow.Show();
        }
Exemple #3
0
 public Game(GameOptions options)
 {
     InitializeComponent();
     gameOptions = options;
     PaintBoard();
     switch (gameOptions._TypeOfGame)
     {
         case GameOptions.TypeOfGame.QuickMatch:
             player1 = new Player(gameOptions._Player1Name, true, gameOptions._Player1Color);
             player2 = new Player(gameOptions._Player2Name, false, gameOptions._Player2Color);
             gameBrain = new GameBrain(player1);
             break;
         case GameOptions.TypeOfGame.AI:
             player1 = new Player(gameOptions._Player1Name, true, gameOptions._Player1Color);
             computerPlayer = new computerAI("I'm your boss", false, Brushes.Green, gameOptions._Difficulty);
             gameBrain = new GameBrain(player1, computerPlayer);
             if (!player1.ActivePlayer)
                 GetComputerMoveAsynchronously();
             break;
         default:
             break;
     }
     ShowActivePlayer();
 }
 public Game(GameOptions options)
 {
     InitializeComponent();
     gameOptions = options;
     PaintBoard();
     switch (gameOptions._TypeOfGame)
     {
         case GameOptions.TypeOfGame.QuickMatch:
             player1 = options._Player1;
             player2 = options._Player2;
             gameBrain = new GameBrain(player1);
             break;
         case GameOptions.TypeOfGame.AI:
             player1 = options._Player1;
             computerPlayer = options._ComputerPlayer;
             gameBrain = new GameBrain(player1, computerPlayer);
             if (!player1.ActivePlayer)
                 GetComputerMoveAsynchronously();
             break;
         default:
             break;
     }
     ShowActivePlayer();
 }
        public GamePage(GameOptions options)
        {
            InitializeComponent();
            CreateChildrenList();
            quotes = new Quotes();
            gameOptions = options;
            switch (gameOptions._TypeOfGame)
            {
                case GameOptions.TypeOfGame.QuickMatch:
                    SoundManager.backgroundMusicPlayer.Open(new Uri("GUI/Sounds/Gameplay.mp3", UriKind.Relative));
                    SoundManager.backgroundMusicPlayer.Play();
                    player1 = options._Player1;
                    player2 = options._Player2;
                    gameBrain = new GameBrain(player1);
                    Player1NameText.Text = player1.Name;
                    Player2NameText.Text = player2.Name;
                    isNetwork = false;
                    break;
                case GameOptions.TypeOfGame.Network:
                    SoundManager.backgroundMusicPlayer.Open(new Uri("GUI/Sounds/Gameplay.mp3", UriKind.Relative));
                    SoundManager.backgroundMusicPlayer.Play();
                    player1 = options._Player1;
                    player2 = options._Player2;
                    gameBrain = new GameBrain(player1);
                    Player1NameText.Text = player1.Name;
                    Player2NameText.Text = player2.Name;
                    networkUtil = options._NetworkUtil;
                    networkUtil.MoveReceived += new moveReceivedHandler(NetworkMoveReceived);
                    networkUtil.Disconnected += new peerDisconnectedHancler(PeerDisconnected);
                    isNetwork = true;
                    break;
                case GameOptions.TypeOfGame.AI:
                    SoundManager.backgroundMusicPlayer.Open(new Uri("GUI/Sounds/Gameplay.mp3", UriKind.Relative));
                    SoundManager.backgroundMusicPlayer.Play();
                    player1 = options._Player1;
                    computerPlayer = options._ComputerPlayer;
                    gameBrain = new GameBrain(player1, computerPlayer);
                    Player1NameText.Text = player1.Name;
                    Player2NameText.Text = computerPlayer.Name;
                    if (!player1.ActivePlayer)
                        GetComputerMoveAsynchronously();
                    isNetwork = false;
                    break;
                case GameOptions.TypeOfGame.Campaign:
                    profileManager = ProfileManager.InstanceCreator();
                    levelPlay = options._LevelPlay;
                    SetUpCampaign(options._LevelPlay);
                    player1 = options._Player1;
                    computerPlayer = options._ComputerPlayer;
                    gameBrain = new GameBrain(player1, computerPlayer);
                    Player1NameText.Text = player1.Name;
                    Player2NameText.Text = computerPlayer.Name;
                    if (!player1.ActivePlayer)
                        GetComputerMoveAsynchronously();
                    isNetwork = false;
                    break;

                default:
                    break;
            }
            ShowActivePlayer();
            if (File.Exists("C:\\Users\\Public\\Documents\\Dragon Horde\\" + player1.Name + ".png"))
            {
                System.Drawing.Image img = System.Drawing.Image.FromFile("C:\\Users\\Public\\Documents\\Dragon Horde\\" + player1.Name + ".png");
                System.Drawing.Bitmap bmp = new System.Drawing.Bitmap(img);
                BitmapSource bmpSrc = Imaging.CreateBitmapSourceFromHBitmap(bmp.GetHbitmap(),
                    IntPtr.Zero, Int32Rect.Empty, BitmapSizeOptions.FromEmptyOptions());
                bmp.Dispose();
                VikingButton.Background = new ImageBrush(bmpSrc);
            }

            vikingArmPivot = new Point(167 + 40, System.Windows.SystemParameters.PrimaryScreenHeight - 420 + 121);
            zero = new Point(0, 0);
            topRight = new Point(System.Windows.SystemParameters.PrimaryScreenWidth, 0);
            iceGiantArmPivot = new Point(System.Windows.SystemParameters.PrimaryScreenWidth - 261, System.Windows.SystemParameters.PrimaryScreenHeight - 600);

            unMuteMusicVol = SoundManager.musicVolume / 16;
            unMuteSoundVol = SoundManager.sfxVolume / 16;
            currentMusicVol = SoundManager.musicVolume / 16;
            currentSoundVol = SoundManager.sfxVolume / 16;
            restoreMusicVol(currentMusicVol);
            restoreSoundVol(currentSoundVol);

            Stream cur = File.OpenRead("GUI/images/MouseArrow.cur");
            this.Cursor = new Cursor(cur);

            InitializeDragonOrigins();
        }
        private void InitializeCampaignGame(computerAI.Difficulty difficultyLevel, int levelBeingPlay)
        {
            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 = difficultyLevel;

            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, levelBeingPlay);

            GamePage game = new GamePage(gameOptions);
            NavigationService.Navigate(game);
        }
 public GameOptions(TypeOfGame typeOfGame, Player player1, computerAI computerPlayer)
 {
     this._TypeOfGame = typeOfGame;
     this._Player1 = player1;
     this._ComputerPlayer = computerPlayer;
 }
 //Initializes a human vs computer game
 public GameBrain(Player player1, computerAI computerPlayer)
 {
     this.player1 = player1;
     this.player2 = computerPlayer;
     InitializeBoard();
 }
        public GameWindow(GameOptions options)
        {
            InitializeComponent();
            CreateChildrenList();
            quotes = new Quotes();
            SoundManager.backgroundMusicPlayer.Open(new Uri("GUI/Sounds/Gameplay.mp3", UriKind.Relative));
            SoundManager.backgroundMusicPlayer.Play();
            gameOptions = options;
            switch (gameOptions._TypeOfGame)
            {
                case GameOptions.TypeOfGame.QuickMatch:
                    player1 = options._Player1;
                    player2 = options._Player2;
                    gameBrain = new GameBrain(player1);
                    Player1NameText.Text = player1.Name;
                    Player2NameText.Text = player2.Name;
                    isNetwork = false;
                    break;
                case GameOptions.TypeOfGame.Network:
                    player1 = options._Player1;
                    player2 = options._Player2;
                    gameBrain = new GameBrain(player1);
                    Player1NameText.Text = player1.Name;
                    Player2NameText.Text = player2.Name;
                    networkUtil = options._NetworkUtil;
                    networkUtil.MoveReceived += new moveReceivedHandler(NetworkMoveReceived);
                    isNetwork = true;
                    break;
                case GameOptions.TypeOfGame.AI:
                    player1 = options._Player1;
                    computerPlayer = options._ComputerPlayer;
                    gameBrain = new GameBrain(player1, computerPlayer);
                    Player1NameText.Text = player1.Name;
                    Player2NameText.Text = computerPlayer.Name;
                    if (!player1.ActivePlayer)
                        GetComputerMoveAsynchronously();
                    isNetwork = false;
                    break;
                default:
                    break;
            }
            ShowActivePlayer();
            if(File.Exists(@"GUI\Images\CustomVikings\" + player1.Name + ".png"))
            {
                System.Drawing.Image img = System.Drawing.Image.FromFile(@"GUI\Images\CustomVikings\" + player1.Name + ".png");
                System.Drawing.Bitmap bmp = new System.Drawing.Bitmap(img);
                BitmapSource bmpSrc = Imaging.CreateBitmapSourceFromHBitmap(bmp.GetHbitmap(),
                    IntPtr.Zero, Int32Rect.Empty, BitmapSizeOptions.FromEmptyOptions());
                bmp.Dispose();
                VikingButton.Background = new ImageBrush(bmpSrc);
            }
            vikingArmPivot = new Point(167 + 40, this.Height - 420 + 121);
            zero = new Point(0, 0);
            topRight = new Point(Width, 0);
            iceGiantArmPivot = new Point(Width - 261, Height - 600);

            unMuteMusicVol = SoundManager.musicVolume / 16;
            unMuteSoundVol = SoundManager.sfxVolume / 16;
            currentMusicVol = SoundManager.musicVolume / 16;
            currentSoundVol = SoundManager.sfxVolume / 16;
            restoreMusicVol(currentMusicVol);
            restoreSoundVol(currentSoundVol);

            Stream cur = File.OpenRead("GUI/images/MouseArrow.cur");
            this.Cursor = new Cursor(cur);

            InitializeDragonOrigins();
            MakeDragonsVisble();
        }
        private void InitializePlayerVsComputerGame()
        {
            string player1Name = Player1NameTextBox.Text;

            bool isPlayer1Active;
            if (Player1MoveFirstOn.Visibility == Visibility.Visible)
                isPlayer1Active = true;
            else
                isPlayer1Active = false;

            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));
            Player player1 = new Player(player1Name.Trim(), isPlayer1Active, player1Image, player1ImageHover);

            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 (GameDifficultyBeginnerOn.Visibility == Visibility.Visible)
                difficulty = computerAI.Difficulty.Beginner;
            else if (GameDifficultyEasyOn.Visibility == Visibility.Visible)
                difficulty = computerAI.Difficulty.Easy;
            else if (GameDifficultyMediumOn.Visibility == Visibility.Visible)
                difficulty = computerAI.Difficulty.Medium;
            else if (GameDifficultyHardOn.Visibility == Visibility.Visible)
                difficulty = computerAI.Difficulty.Medium;
            else
                difficulty = computerAI.Difficulty.Hard;

            computerAI computerPlayer = new computerAI(computerPlayerName.Trim(), !isPlayer1Active, computerPlayerImage, computerPlayerImageHover, difficulty);
            GameOptions gameOptions = new GameOptions(GameOptions.TypeOfGame.AI, player1, computerPlayer);

            GamePage game = new GamePage(gameOptions);
            NavigationService.Navigate(game);
        }
        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();
            }
        }
 public GameOptions(TypeOfGame typeOfGame, Player player1, computerAI computerPlayer, int levelPlay)
 {
     this._TypeOfGame = typeOfGame;
     this._Player1 = player1;
     this._ComputerPlayer = computerPlayer;
     this._LevelPlay = levelPlay;
 }