Ejemplo n.º 1
0
 private void SkipClick(object Sender, RoutedEventArgs e)
 {
     try
     {
         Game.skip();
         Error.Visibility = System.Windows.Visibility.Hidden;
         Selected = BoardPoint.Error;
     }
     catch (Exceptions.IllegalMoveException ime)
     {
         setError(ime.Message);
     }
     NewTurn();
 }
Ejemplo n.º 2
0
 private void InitializeGame()
 {
     Game = new GameController();
     Selected = BoardPoint.Error;
     Dice.Data = Game.DiceRoll.ToString();
     boardCanvasTranslator = new BoardCanvasTranslator(BoardCanvas, Game.Board);
     UpdateInfoPanels();
 }
Ejemplo n.º 3
0
 private BoardPoint pixelCoordsToBlockCoords(BoardPoint p)
 {
     return new BoardPoint(
         p.X / BoardCanvas.TileSize,
         p.Y / BoardCanvas.TileSize
     );
 }
Ejemplo n.º 4
0
 private void CanvasClick(object sender, MouseButtonEventArgs e)
 {
     if (Error.Visibility == System.Windows.Visibility.Visible) Error.Visibility = System.Windows.Visibility.Hidden;
     var clicked = pixelCoordsToBlockCoords(e.GetPosition(BoardCanvas).toGamePoint());
     // No currently selected tile
     if (Selected == BoardPoint.Error) Selected = Game.pieceExistsAt(clicked) ? clicked : BoardPoint.Error;
     // Clicked same tile, deselect
     else if (Selected == clicked) Selected = BoardPoint.Error;
     // Selected exists, new tile selected. Attempt to move, and if successful, deselect
     else if (Selected != BoardPoint.Error)
     {
         try
         {
             if (Game.move(Selected, clicked))
             {
                 Selected = BoardPoint.Error;
                 NewTurn();
             }
         }
         catch(Game.Exceptions.IllegalMoveException ime)
         {
             setError(ime.Message);
         }
     }
 }
Ejemplo n.º 5
0
 public bool check(GamePoint position)
 {
     if (!blocks.ContainsKey(position)) throw new ArgumentOutOfRangeException("invalid index");
     return blocks[position] == BlockType.Path;
 }
Ejemplo n.º 6
0
        private void drawOutline(Color c, GamePoint p, DrawingContext dc )
        {
            if (p == GamePoint.Error) return;
            Brush selection_brush = new SolidColorBrush(c);
            Pen selection_pen = new Pen(selection_brush, 2.0);

            Point start = new Point(p.X * _tileSize, p.Y * _tileSize);
            Point[] points = new Point[]
            {
                new Point( start.X, start.Y ),
                new Point( start.X+_tileSize, start.Y ),
                new Point( start.X+_tileSize, start.Y+_tileSize ),
                new Point( start.X, start.Y+_tileSize )
            };

            for (int i = 0; i < points.Length; i++)
            {
                dc.DrawLine(selection_pen, points[i], points[(i + 1) % points.Length]);
            }
        }
Ejemplo n.º 7
0
 public void addText(string s, GamePoint p)
 {
     BoardText[p] = s;
     InvalidateVisual();
 }
Ejemplo n.º 8
0
 public void addBlock(BlockType block, GamePoint p)
 {
     BoardBlocks[p] = block;
     this.InvalidateVisual();
 }