void OnDataContextIndexChanged(Cell cell, PolyominoIndex polyominoIndex)
 { IndexChanged?.Invoke(this); }
예제 #2
0
 public static ConsoleColor ToColor(PolyominoIndex polyominoIndex)
 {
     Contract.Assert((int)polyominoIndex >= 0 && (int)polyominoIndex < ColorNumber);
     return(colors[(int)polyominoIndex]);
 }
예제 #3
0
 public static ConsoleColor PolyominoIndexToColor(PolyominoIndex polyominoIndex)
 {
     return(Palette.ToColor(polyominoIndex));
 }
 public static Brush ToBrush(PolyominoIndex polyominoIndex)
 {
     Contract.Assert((int)polyominoIndex >= 0 && (int)polyominoIndex < ColorNumber);
     return brushes[(int)polyominoIndex];
 }
 public static Brush PolyominoIndexToBrush(PolyominoIndex polyominoIndex)
 { return Palette.ToBrush(polyominoIndex); }
 static void RemoveRow(PolyominoIndex[,] cellsClone, int y)
 {
     for (var yIndex = y; yIndex > 0; yIndex--)
         Enumerable.Range(0, cellsClone.GetLength(0)).ForEach(x => cellsClone[x, yIndex] = cellsClone[x, yIndex - 1]);
     Enumerable.Range(0, cellsClone.GetLength(0)).ForEach(x => cellsClone[x, 0] = 0);
 }
 public static ConsoleColor PolyominoIndexToColor(PolyominoIndex polyominoIndex)
 { return Palette.ToColor(polyominoIndex); }
예제 #8
0
 void OnDataContextIndexChanged(Cell cell, PolyominoIndex polyominoIndex)
 {
     OnPropertyChanged(() => Color);
 }
예제 #9
0
 void OnDataContextIndexChanged(Cell cell, PolyominoIndex polyominoIndex)
 {
     IndexChanged?.Invoke(this);
 }
 public void Erase(PolyominoIndex[,] cellsClone)
 {
     AllPoints.Where(point => this[point])
              .ForEach(point => cellsClone.Set(GetPosition(point), PolyominoIndex.None));
 }
 public bool Place(PolyominoIndex[,] cellsClone, Point<int> position)
 {
     var placeablePoints = PlaceablePoints(shape, cellsClone, position);
     if (placeablePoints == null)
         return false;
     placeablePoints.ForEach(point => cellsClone.Set(Tetromono.GetPosition(position, point), Index));
     Position = position;
     return true;
 }
 public bool Move(PolyominoIndex[,] cellsClone, Point<int> position)
 {
     Erase(cellsClone);
     return Place(cellsClone, position);
 }
 static IEnumerable<Point<int>> PlaceablePoints(bool[,] shape, PolyominoIndex[,] cellsClone, Point<int> position)
 {
     var exsitingPoints = shape.AllPoints().Where(point => shape.Get(point)).ToList();
     PolyominoIndex shapeIndex;
     var placeablePoints = exsitingPoints.Where(point => cellsClone.TryGet(GetPosition(position, point), out shapeIndex) ? shapeIndex == PolyominoIndex.None : false).ToList();
     return exsitingPoints.Count == placeablePoints.Count ? placeablePoints : null;
 }
        public bool Turn(PolyominoIndex[,] cellsClone, bool clockwise = true)
        {
            Erase(cellsClone);

            var newShape = Turn(clockwise);
            var placeablePoints = PlaceablePoints(newShape, cellsClone, Position);
            if (placeablePoints == null)
                return false;
            placeablePoints.ForEach(point => cellsClone.Set(Tetromono.GetPosition(Position, point), Index));
            shape = newShape;
            return true;
        }
예제 #15
0
 public static Brush ToBrush(PolyominoIndex polyominoIndex)
 {
     Contract.Assert((int)polyominoIndex >= 0 && (int)polyominoIndex < ColorNumber);
     return(brushes[(int)polyominoIndex]);
 }
 public static ConsoleColor ToColor(PolyominoIndex polyominoIndex)
 {
     Contract.Assert((int)polyominoIndex >= 0 && (int)polyominoIndex < ColorNumber);
     return colors[(int)polyominoIndex];
 }
예제 #17
0
 public static Brush PolyominoIndexToBrush(PolyominoIndex polyominoIndex)
 {
     return(Palette.ToBrush(polyominoIndex));
 }
 void OnDataContextIndexChanged(Cell cell, PolyominoIndex polyominoIndex)
 { OnPropertyChanged(() => Color); }