private void StartLockRowShiftAndShowSolvedPopupWhenDone() { if (Model.LockGrid.RowCount > 1) { // Should the rows be shifted? // Shift the top row for (int col = 0; col < Model.LockGrid.ColCount; col++) { Sunfish.Views.Effects.TranslateBy shiftLock = new Sunfish.Views.Effects.TranslateBy (new Vector2 (0, SpaceBetweenLocks), LockShiftDelayMilliseconds); if (col == 0) { shiftLock.OnComplete = delegate { ExplodeLockDialsThenShowSolvedPopup(); }; } Views.Lock currentLockView = null; string lockViewKey = Models.Lock.GetRowColString (0, col); LockViewsDictionary.TryGetValue (lockViewKey, out currentLockView); currentLockView.StartEffect (shiftLock); } // Shift the bottom row if necessary if (Model.LockGrid.RowCount == 3) { for (int col = 0; col < Model.LockGrid.ColCount; col++) { Sunfish.Views.Effects.TranslateBy shiftLock = new Sunfish.Views.Effects.TranslateBy (new Vector2 (0, -SpaceBetweenLocks), LockShiftDelayMilliseconds); Views.Lock currentLockView = null; string lockViewKey = Models.Lock.GetRowColString (2, col); LockViewsDictionary.TryGetValue (lockViewKey, out currentLockView); currentLockView.StartEffect (shiftLock); } } PlaySoundEffect ("Shift1"); } else { ExplodeLockDialsThenShowSolvedPopup(); } }
private void StartLockColumnShift(int leftEndCol) { /* Step 1: Figure out how many x units to shift the columns by */ // Default x shift int xShift = SpaceBetweenLocks; // If there is an even number of columns, then the last shift should only be by half the SpaceBetweenLocks if (Model.LockGrid.ColCount % 2 == 0) { // Even number of columns // Is this the last column shift? if ((leftEndCol + 1) * 2 == Model.LockGrid.ColCount) { xShift = (int) (SpaceBetweenLocks * 0.5f); // When even } } /* Step 2: Start a TranslateBy effect on each of the appropriate locks (according to leftEndCol) */ // Shift the locks on the left side of the grid to the right for (int row = 0; row < Model.LockGrid.RowCount; row++) { for (int col = 0; col <= leftEndCol; col++) { Sunfish.Views.Effects.TranslateBy shiftLock = new Sunfish.Views.Effects.TranslateBy (new Vector2(xShift,0), LockShiftDelayMilliseconds); if (row == 0 && col == 0) { shiftLock.OnComplete = StartNextLockShiftOrShowSolvedPopup; } Views.Lock currentLockView = null; string lockViewKey = Models.Lock.GetRowColString (row, col); LockViewsDictionary.TryGetValue (lockViewKey, out currentLockView); currentLockView.StartEffect (shiftLock); } } // Shift the locks on the right side of the grid to the left int lastRightCol = Model.LockGrid.ColCount - 1 - leftEndCol; for (int row = 0; row < Model.LockGrid.RowCount; row++) { for (int col = Model.LockGrid.ColCount - 1; col >= lastRightCol; col--) { Sunfish.Views.Effects.TranslateBy shiftLock = new Sunfish.Views.Effects.TranslateBy (new Vector2(-xShift,0), LockShiftDelayMilliseconds); Views.Lock currentLockView = null; string lockViewKey = Models.Lock.GetRowColString (row, col); LockViewsDictionary.TryGetValue (lockViewKey, out currentLockView); currentLockView.StartEffect (shiftLock); } } PlaySoundEffect ("Shift1"); }