コード例 #1
0
        private void ProcessSequenceCompleted()
        {
            StoredMoves.Add(CurrentPieces.Select(x => x).ToList());

            if (StoredMoves.Count >= MovesAllowedPerTurn)
            {
                foreach (var currentMoves in StoredMoves)
                {
                    SequenceCompleted?.Invoke(currentMoves.ToArray());
                    LogUsedPieces(currentMoves);

                    foreach (var square in currentMoves)
                    {
                        if (square.OnCollection != null)
                        {
                            square.OnCollection.OnCollection();
                        }
                        square.DestroyPiece();
                    }
                }
                MoveCompleted?.Invoke();

                StoredMoves.Clear();
                ResetMovesAllowedPerTurn();
            }

            CurrentPieces.Clear();
            SelectedPiecesChanged?.Invoke(CurrentPieces);
        }
コード例 #2
0
 private void Printer_PrintFinished(object sender, PrintFinishedEventArgs e)
 {
     if (isPrinting)
     {
         PrintFinished?.Invoke(this, e);
         isPrinting = false;
         isHomed    = false;
     }
     if (isFilamentChanging && filamentChangeBegin)
     {
         FilamentChangeBegin?.Invoke(this, e);
         filamentChangeBegin = false;
         videoIsPlaying      = true;
         isHomed             = false;
     }
     if (isFilamentChanging && filamentChangeEnd)
     {
         FilamentChangeEnd?.Invoke(this, e);
         filamentChangeEnd = false;
         isHomed           = false;
     }
     if (isMovedManually)
     {
         isMovedManually = false;
         MoveCompleted?.Invoke(this, null);
     }
 }
コード例 #3
0
        public void Move(int discs, Stack <int> from, Stack <int> to, Stack <int> auxilary)
        {
            if (discs > 0)
            {
                Move(discs - 1, from, auxilary, to);

                to.Push(from.Pop());
                MovesCount++;
                MoveCompleted?.Invoke(this, EventArgs.Empty);
                Move(discs - 1, auxilary, to, from);
            }
        }
コード例 #4
0
        private void Move(int discs, Stack <int> from, Stack <int> to, Stack <int> temp)
        {
            if (discs > 0)
            {
                Move(discs - 1, from, temp, to);

                to.Push(from.Pop());
                MovesCount++;
                MoveCompleted?.Invoke(this, EventArgs.Empty);

                Move(discs - 1, temp, to, from);
            }
        }
コード例 #5
0
 protected void FireMoveCompleted()
 {
     MoveCompleted?.Invoke(this);
 }