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); }
public void ClearCurrentPieces() { foreach (var piece in CurrentPieces) { piece.Deselected(); } CurrentPieces.Clear(); SelectedPiecesChanged?.Invoke(CurrentPieces); }
public void PreformMove(List <ISquarePiece> pieces) { foreach (var piece in pieces) { CurrentPieces.AddLast(piece); } ProcessSequenceCompleted(); SelectedPiecesChanged?.Invoke(CurrentPieces); }
public void RemovePiece(ISquarePiece piece) { var lastPiece = CurrentPieces.Last.Value; while (lastPiece != piece) { RemoveLastPiece(lastPiece); lastPiece = CurrentPieces.Last.Value; } SelectedPiecesChanged?.Invoke(CurrentPieces); }
public void Add(ISquarePiece squarePiece, bool checkForAdditional) { if (CurrentPieces.Contains(squarePiece)) { return; } CurrentPieces.AddLast(squarePiece); if (CurrentPieces.Count == 1 & checkForAdditional) { CheckForAdditionalPieces(); } SelectedPiecesChanged?.Invoke(CurrentPieces); }
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; }