Пример #1
0
        public GameUnit(Unit unit, UnitPosition unitPosition)
        {
            Unit = unit;
            UnitPosition = unitPosition;

            absolutePoints = new Lazy<Point[]>(() => Unit.Points.Select(p => p.Rotate(UnitPosition.RotationCount, Unit.PivotPoint).Move(Unit.PivotPoint, UnitPosition.PivotLocation)).ToArray());
            orderedPoints = new Lazy<Point[]>(() => GetAbsolutePoints().OrderBy(x => x.Col).ThenBy(x => x.Row).Concat(new[] { UnitPosition.PivotLocation }).ToArray());
            hashCode = new Lazy<int>(() => GetOrderedPoints().Select((x, i) => ((x.Row * 1) ^ (x.Col * 3571)) * i).Aggregate(0, (x, y) => x ^ y));
        }
Пример #2
0
 public Game(Board board, GameUnit current, Unit[] unitsSequence, int currentUnitNumber, int lastUnitLinesCleared, int score, int problemId, long seed, string lastSymbols, int wordsMask)
     : this()
 {
     Board = board;
     Current = current;
     UnitsSequence = unitsSequence;
     CurrentUnitNumber = currentUnitNumber;
     LastUnitLinesCleared = lastUnitLinesCleared;
     Score = score;
     ProblemId = problemId;
     Seed = seed;
     LastSymbols = lastSymbols;
     WordsMask = wordsMask;
 }
Пример #3
0
 public Point GetPivotLocation(Unit unit)
 {
     var minCol = unit.Points.Min(x => x.Col);
     var maxCol = unit.Points.Max(x => x.Col);
     var colShift = (Board.Width - (maxCol - minCol + 1)) / 2;
     return unit.PivotPoint.Move(new Point(minCol, 0), new Point(colShift, 0));
 }