//returns true if game is over public override bool Clicked(SeaSquare square, bool automated) { if (automated) { _humanPlayer.ZmienTure(_computerPlayer); } else { if (square.Type != TypPowierzchni.Unknown) { MessageBox.Show("Please choose a new square"); return(false); } _humanPlayer.ZmienTure(square.Rzad, square.Kolumna, _computerPlayer); } if (_computerPlayer.NoShipsSadFace() && _computerPlayer.NoVehiclesSadFace() && _computerPlayer.NoPlanesSadFace()) { MessageBox.Show("You win!"); return(true); } else { _computerPlayer.ZmienGracza(_humanPlayer); if (_humanPlayer.NoShipsSadFace() && _humanPlayer.NoVehiclesSadFace() && _humanPlayer.NoPlanesSadFace()) { MessageBox.Show("You lose :("); return(true); } } return(false); }
//returns true if game is over public override bool Clicked(SeaSquare square, bool automated) { if (automated) { _humanPlayer.TakeTurnAutomated(_computerPlayer); } else { if (square.Type != SquareType.Unknown) { MessageBox.Show("Please choose a new square"); return(false); } _humanPlayer.TakeTurn(square.Row, square.Col, _computerPlayer); } if (_computerPlayer.NoShipsSadFace()) { MessageBox.Show("You win!"); return(true); } else { _computerPlayer.TakeTurn(_humanPlayer); if (_humanPlayer.NoShipsSadFace()) { MessageBox.Show("You lose :("); return(true); } } return(false); }
private void Item_PreviewMouseLeftButtonDown(object sender, MouseButtonEventArgs e) { GridVMBase vm = this.DataContext as GridVMBase; ListBoxItem item = sender as ListBoxItem; SeaSquare content = item.Content as SeaSquare; //XXX sometimes if you click really fast you can end up clicking on what the debugger says is a "ListBoxItem {DisconnectedItem} //hunting down the exact cause would take ages, and might even be a bug in WPF or something if (content == null) { return; } vm.Clicked(content); }
public override bool Clicked(SeaSquare content, bool automated) { return(false); }
public abstract bool Clicked(SeaSquare content, bool automated = false);