private void ExecuteMovesOnBoard(MoveSet moveSet) { while (moveSet.fromBoardToBoardMoves.Count > 0) { var cmd = moveSet.fromBoardToBoardMoves.Dequeue(); FigureItems[cmd.fromPosition.x, cmd.fromPosition.y].MoveFigureToPosition(cmd.toPosition.x, cmd.toPosition.y); FigureItems[cmd.toPosition.x, cmd.toPosition.y] = FigureItems[cmd.fromPosition.x, cmd.fromPosition.y]; } boardUpdateStage = BoardUpdateStage.MovesOnBoard_WaitForEnd; }
private void ExecuteDestroyMatches(MoveSet moveSet) { while (moveSet.fromBoardToCemeteryMoves.Count > 0) { var cmd = moveSet.fromBoardToCemeteryMoves.Dequeue(); FigureItems[cmd.fromPosition.x, cmd.fromPosition.y].KillIfOnBoard(); BoardItems[cmd.fromPosition.x, cmd.fromPosition.y].Highlight(); } boardUpdateStage = BoardUpdateStage.DestroyMatches_WaitForEnd; }
private void ExecuteInstanceNewToQueues(MoveSet moveSet) { while (moveSet.fromInstancerToQueueMoves.Count > 0) { var cmd = moveSet.fromInstancerToQueueMoves.Dequeue(); var buffer_arr = gameSession.Board.FigureBuffers[cmd.toPosition.x].ToArray(); int delta_size = buffer_arr.Length - figureQueues[cmd.toPosition.x].Count; for (int i = delta_size; i > 0; i--) { var figure_type = buffer_arr[buffer_arr.Length - i].FigureType; InstantiateQueueFigureItem(figure_type, cmd.toPosition.x, buffer_arr.Length - i); } } boardUpdateStage = BoardUpdateStage.InstanceNewToQueues_WaitForEnd; }
private void ExecuteHandleMove(MoveSet moveSet) { if (moveSet.fromBoardToBoardMoveHandle.fromPosition.x != -1) { var cmd = moveSet.fromBoardToBoardMoveHandle; FigureItems[cmd.fromPosition.x, cmd.fromPosition.y].MoveFigureToPosition(cmd.toPosition.x, cmd.toPosition.y); FigureItems[cmd.toPosition.x, cmd.toPosition.y].MoveFigureToPosition(cmd.fromPosition.x, cmd.fromPosition.y); IFigureItem temp = FigureItems[cmd.fromPosition.x, cmd.fromPosition.y]; FigureItems[cmd.fromPosition.x, cmd.fromPosition.y] = FigureItems[cmd.toPosition.x, cmd.toPosition.y]; FigureItems[cmd.toPosition.x, cmd.toPosition.y] = temp; boardUpdateStage = BoardUpdateStage.HandleMove_WaitForEnd; } else { boardUpdateStage = BoardUpdateStage.DestroyMatches; } }
private void ExecuteMovesFromQueuesToBoard(MoveSet moveSet) { while (moveSet.fromQueueToBoardMoves.Count > 0) { var cmd = moveSet.fromQueueToBoardMoves.Dequeue(); FigureItems[cmd.toPosition.x, cmd.toPosition.y] = figureQueues[cmd.fromPosition.x].Dequeue(); FigureItems[cmd.toPosition.x, cmd.toPosition.y].MoveFromQueueToBoard(); FigureItems[cmd.toPosition.x, cmd.toPosition.y].MoveFigureToPosition(cmd.toPosition.x, cmd.toPosition.y); for (int i = 0; i < figureQueues[cmd.fromPosition.x].Count; i++) { var figureItem = figureQueues[cmd.fromPosition.x].Dequeue(); figureItem.MoveFigureToPosition(figureItem.Position.x, figureItem.Position.y - 1); figureQueues[cmd.fromPosition.x].Enqueue(figureItem); } } boardUpdateStage = BoardUpdateStage.MovesFromQueuesToBoard_WaitForEnd; }
private void ExecuteMovesInQueues(MoveSet moveSet) { boardUpdateStage = BoardUpdateStage.MovesInQueues_WaitForEnd; }