Ejemplo n.º 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));
        }
Ejemplo n.º 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);
            }
        }
Ejemplo n.º 3
0
 public NotSmartPlayer(PlayingBoard pb) : base(pb)
 {
 }