Пример #1
0
        public PlayerShip(int size, PlayingBoard b, UIElement imageToShow, double originalPositionX, double originalPositionY, Canvas canvas, BattleShipUI bsu) : base(b, size)
        {
            this.ImageToShow       = imageToShow;
            this.originalPositionX = originalPositionX;
            this.originalPositionY = originalPositionY;
            this.canvas            = canvas;
            this.bsu = bsu;

            imageToShow.AddHandler(Grid.MouseLeftButtonDownEvent, new MouseButtonEventHandler(Grab));
            imageToShow.AddHandler(Grid.MouseLeftButtonUpEvent, new MouseButtonEventHandler(Drop));
            imageToShow.AddHandler(Grid.MouseRightButtonDownEvent, new MouseButtonEventHandler(Turn));
            imageToShow.AddHandler(Grid.MouseMoveEvent, new MouseEventHandler(Move));
        }
Пример #2
0
        public BattleShipUI()
        {
            InitializeComponent();
            pb = new PlayingBoard(this);
            pb.Load();
            rb = new RadarBoard(this);
            rb.Load();
            p  = new HumanPlayer(rb);
            dp = new NotSmartPlayer(pb);

            Grid[] tempShips = { ShipSize30, ShipSize31, ShipSize2, ShipSize4, ShipSize5 };
            for (int i = 0; i < tempShips.Length; i++)
            {
                originalShipPositionX[i] = Canvas.GetLeft(tempShips[i]);
                originalShipPositionY[i] = Canvas.GetTop(tempShips[i]);
                allShips[i] = new PlayerShip(tempShips[i].RowDefinitions.Count, pb, tempShips[i], originalShipPositionX[i], originalShipPositionY[i], LayoutRoot, this);
            }
        }
Пример #3
0
 public NotSmartPlayer(PlayingBoard pb) : base(pb)
 {
 }