Exemplo n.º 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);
        }
Exemplo n.º 2
0
 public void ClearCurrentPieces()
 {
     foreach (var piece in CurrentPieces)
     {
         piece.Deselected();
     }
     CurrentPieces.Clear();
     SelectedPiecesChanged?.Invoke(CurrentPieces);
 }
Exemplo n.º 3
0
        public void PreformMove(List <ISquarePiece> pieces)
        {
            foreach (var piece in pieces)
            {
                CurrentPieces.AddLast(piece);
            }

            ProcessSequenceCompleted();
            SelectedPiecesChanged?.Invoke(CurrentPieces);
        }
Exemplo n.º 4
0
        public void RemovePiece(ISquarePiece piece)
        {
            var lastPiece = CurrentPieces.Last.Value;

            while (lastPiece != piece)
            {
                RemoveLastPiece(lastPiece);
                lastPiece = CurrentPieces.Last.Value;
            }

            SelectedPiecesChanged?.Invoke(CurrentPieces);
        }
Exemplo n.º 5
0
        public void Add(ISquarePiece squarePiece, bool checkForAdditional)
        {
            if (CurrentPieces.Contains(squarePiece))
            {
                return;
            }

            CurrentPieces.AddLast(squarePiece);

            if (CurrentPieces.Count == 1 & checkForAdditional)
            {
                CheckForAdditionalPieces();
            }

            SelectedPiecesChanged?.Invoke(CurrentPieces);
        }
Exemplo n.º 6
0
        void Update()
        {
            if (CurrentPieces.Count == 0)
            {
                return;
            }

            if (GameManager.Instance.GamePaused)
            {
                return;
            }

            if (CancelButton.MouseOver)
            {
                return;
            }

            if (MenuProvider.Instance.OnDisplay)
            {
                return;
            }

            if (!Input.GetMouseButton(0))
            {
                if (CurrentPieces.Count > 1)
                {
                    CheckForAdditionalPieces();
                    ProcessSequenceCompleted();
                }
                else
                {
                    var firstPiece = CurrentPieces.First.Value;
                    firstPiece.Deselected();
                }

                CurrentPieces.Clear();
                SelectedPiecesChanged?.Invoke(CurrentPieces);
            }

            lastMousePostion = Input.mousePosition;
        }