Ejemplo n.º 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;
        }