Пример #1
0
 public bool ValidatePotentialFacingTile(Tile tile)
 {
     throw new NotImplementedException("oh no!");
 }
Пример #2
0
 public Side(Terrain terrain)
 {
     Terrain = terrain;
     Id = Guid.NewGuid();
     FacingTile = null;
 }
Пример #3
0
        private bool IsValidSlot(TileSlot slot, Tile tile)
        {
            // flag to explore for adjacent files as we check for
            // other failure conditions
            bool adjacent = false;

            // if the target slot has a tile to the North
            // and if that tile has incompatible borders,
            // then reject
            if (slot.hasN() && slot.N.hasTile())
            {
                adjacent = true;
                if(slot.N.tile.borders.S != tile.borders.N)
                    return false;
            }

            if(slot.hasS() && slot.S.hasTile())
            {
                adjacent = true;
                if(slot.S.tile.borders.N != tile.borders.S)
                    return false;
            }

            if(slot.hasE() && slot.E.hasTile())
            {
                adjacent = true;
                if (slot.E.tile.borders.W != tile.borders.E)
                    return false;
            }

            if(slot.hasW() && slot.W.hasTile())
            {
                adjacent = true;
                if(slot.W.tile.borders.E != tile.borders.W)
                    return false;
            }

            // if no adjacent tiles were found, then the slot is not valid
            if(!adjacent)
                return false;

            return true;
        }
Пример #4
0
 private void InsertTileInSlot(TileSlot slot, Tile tile)
 {
     // position the tile on the slot
     // and tell the tile which slot its in
     Canvas.SetLeft(tile.rect, Canvas.GetLeft(slot) - 1);
     Canvas.SetTop(tile.rect, Canvas.GetTop(slot) - 1);
     tile.slot = slot;
 }
Пример #5
0
        private TileSlot FindNearestSlot(Tile tile)
        {
            double xCentre = Canvas.GetLeft(tile.rect) + tile.rect.Width / 2;
            double yCentre = Canvas.GetTop(tile.rect) + tile.rect.Height / 2;

            foreach (TileSlot slot in _slots)
            {
                // The plus/minus 1/2 accounts for the gap
                double x1Bound = Canvas.GetLeft(slot) - 1;
                double x2Bound = x1Bound + slot.rect.Width + 2;
                double y1Bound = Canvas.GetTop(slot) - 1;
                double y2Bound = y1Bound + slot.rect.Height + 2;

                if (xCentre >= x1Bound && xCentre <= x2Bound && yCentre >= y1Bound && yCentre <= y2Bound)
                    return slot;
            }

            return null;
        }
Пример #6
0
        void CreateTiles()
        {
            Dictionary<TileType, int> tileList = new Dictionary<TileType, int>();
            tileList.Add(TileType.A, 2);
            tileList.Add(TileType.B, 4);
            tileList.Add(TileType.C, 1);
            tileList.Add(TileType.D, 4);
            tileList.Add(TileType.E, 5);
            tileList.Add(TileType.F, 2);
            tileList.Add(TileType.G, 1);
            tileList.Add(TileType.H, 3);
            tileList.Add(TileType.I, 2);
            tileList.Add(TileType.J, 3);
            tileList.Add(TileType.K, 3);
            tileList.Add(TileType.L, 3);
            tileList.Add(TileType.M, 2);
            tileList.Add(TileType.N, 3);
            tileList.Add(TileType.O, 2);
            tileList.Add(TileType.P, 3);
            tileList.Add(TileType.Q, 1);
            tileList.Add(TileType.R, 3);
            tileList.Add(TileType.S, 2);
            tileList.Add(TileType.T, 1);
            tileList.Add(TileType.U, 8);
            tileList.Add(TileType.V, 9);
            tileList.Add(TileType.W, 4);
            tileList.Add(TileType.X, 1);

            foreach (Key key in tileList.Keys)
            {
                int numTiles = tileList[(TileType)key];

                for (int i = 0; i < numTiles; i++)
                {
                    Tile t = new Tile((TileType)key);

                    t.MouseLeftButtonUp += new MouseButtonEventHandler(rect_MouseLeftButtonUp);
                    t.MouseLeftButtonDown += new MouseButtonEventHandler(rect_MouseLeftButtonDown);
                    t.MouseMove += new MouseEventHandler(rect_MouseMove);

                    _tiles.Add(t);
                }
            }
        }
Пример #7
-1
        public void StartTurn(ref List<Tile> tiles, MainPage page)
        {
            mode = Mode.PlaceTile;
            // Deal the tile and remove it from the deck
            activeTile = tiles[0];
            tiles.RemoveAt(0);

            // Add the tile to the game surface
            page.gameSurface.Children.Add(activeTile);

            Canvas.SetLeft(activeTile.rect, 10);
            Canvas.SetTop(activeTile.rect, 10);
        }