Exemple #1
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;
        }
Exemple #2
0
 private void HighlightTileSlot(TileSlot slot)
 {
     ClearTileSlotHighlights();
     slot.rect.Fill = new SolidColorBrush(Color.FromArgb(255, 154, 205, 50));
 }
Exemple #3
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;
 }
Exemple #4
0
        void CreateTileSlots()
        {
            int k = 1;
            for (int i = 0; i < 7; i++)
            {
                for (int j = 0; j < 11; j++)
                {

                    TileSlot t = new TileSlot();
                    t.number = k++;

                    _slots.Add(t);
                    gameSurface.Children.Add(t);

                    Canvas.SetLeft(t, 80 + j * 79);
                    Canvas.SetTop(t, 100 + i * 79);

                    t.N = (i == 0) ? null : FindSlotByNumber(t.number - TILES_IN_A_ROW);
                    if (t.N != null)
                        t.N.S = t;

                    t.S = null;

                    t.W = (j == 0) ? null : FindSlotByNumber(t.number - 1);
                    if (t.W != null)
                        t.W.E = t;

                    t.E = null;
                }
            }
        }