Exemplo n.º 1
0
        /// <summary>
        /// Initializes gameplay phase
        /// </summary>
        /// <param name="difficulty">The chosen difficulty</param>
        /// <param name="buttons">The submitted placement of ships</param>
        /// <param name="name">The name of the player</param>
        public PlayGame(Difficulty difficulty, Button[] buttons, string name, Ship[] ships, MainWindow main)
        {
            InitializeComponent();

            this.main = main;
            // Set player name
            this.name = name.ToLower().Replace(' ', '_');

            // Set player and computer's ships
            shipsPlayer = ships;
            shipsComputer = new Ship[] {
                                        new Ship(ShipName.AIRCRAFT_CARRIER, 5),
                                        new Ship(ShipName.BATTLESHIP, 4),
                                        new Ship(ShipName.SUBMARINE, 3),
                                        new Ship(ShipName.CRUISER, 3),
                                        new Ship(ShipName.DESTROYER, 2)
            };

            // Set button field arrays
            buttonsPlayer = new Button[100];
            PlayerShips.Children.CopyTo(buttonsPlayer, 0);

            buttonsComputer = new Button[100];
            ComputerShips.Children.CopyTo(buttonsComputer, 0);

            common = new Common(ComputerShips, buttonsComputer);
            computerAI = new ComputerAI(this, difficulty);

            initializeGame(buttons);
        }
Exemplo n.º 2
0
 void System.Windows.Markup.IComponentConnector.Connect(int connectionId, object target) {
     switch (connectionId)
     {
     case 1:
     this.Window = ((BattleShip.MainWindow)(target));
     
     #line 7 "..\..\MainWindow.xaml"
     this.Window.Closing += new System.ComponentModel.CancelEventHandler(this.Window_Closing);
     
     #line default
     #line hidden
     return;
     case 2:
     this.LayoutRoot = ((System.Windows.Controls.Grid)(target));
     return;
     case 3:
     this.mainFrame = ((System.Windows.Controls.Frame)(target));
     return;
     }
     this._contentLoaded = true;
 }
Exemplo n.º 3
0
 void System.Windows.Markup.IComponentConnector.Connect(int connectionId, object target) {
     switch (connectionId)
     {
     case 1:
     this.mainWindow = ((BattleShip.MainWindow)(target));
     
     #line 6 "..\..\..\MainWindow.xaml"
     this.mainWindow.Loaded += new System.Windows.RoutedEventHandler(this.Window_Loaded);
     
     #line default
     #line hidden
     return;
     case 2:
     this.MainGrid = ((System.Windows.Controls.Grid)(target));
     return;
     case 3:
     this.TopPanel = ((System.Windows.Controls.DockPanel)(target));
     return;
     case 4:
     this.newGame = ((System.Windows.Controls.Button)(target));
     
     #line 14 "..\..\..\MainWindow.xaml"
     this.newGame.Click += new System.Windows.RoutedEventHandler(this.newGame_Click);
     
     #line default
     #line hidden
     return;
     case 5:
     this.Player1_Panel = ((System.Windows.Controls.DockPanel)(target));
     return;
     case 6:
     this.resetShips = ((System.Windows.Controls.Button)(target));
     
     #line 22 "..\..\..\MainWindow.xaml"
     this.resetShips.Click += new System.Windows.RoutedEventHandler(this.resetShips_Click);
     
     #line default
     #line hidden
     return;
     case 7:
     this.placeShips = ((System.Windows.Controls.Button)(target));
     
     #line 23 "..\..\..\MainWindow.xaml"
     this.placeShips.Click += new System.Windows.RoutedEventHandler(this.placeShips_Click);
     
     #line default
     #line hidden
     return;
     case 8:
     this.player1_Image = ((System.Windows.Controls.Image)(target));
     return;
     case 9:
     this.player1_Name = ((System.Windows.Controls.Label)(target));
     return;
     case 10:
     this.player1_Ships = ((System.Windows.Controls.StackPanel)(target));
     return;
     case 11:
     this.OpponentPanel = ((System.Windows.Controls.StackPanel)(target));
     return;
     case 12:
     this.player2_Image = ((System.Windows.Controls.Image)(target));
     return;
     case 13:
     this.player2_Name = ((System.Windows.Controls.Label)(target));
     return;
     case 14:
     this.player2_Ships = ((System.Windows.Controls.StackPanel)(target));
     return;
     case 15:
     this.notificationPanel = ((System.Windows.Controls.StackPanel)(target));
     return;
     case 16:
     this.shipBoard = ((System.Windows.Controls.Grid)(target));
     return;
     case 17:
     this.hitBoard = ((System.Windows.Controls.Grid)(target));
     return;
     }
     this._contentLoaded = true;
 }
Exemplo n.º 4
0
 public Human_Player(string PlayerName, string PlayerImgLoc)
 {
     this.wdw = new MainWindow(PlayerName, PlayerImgLoc);
 }