/** * Method to move the pipes. **/ private void HandlePipeMovement() { for (int i = 0; i < pipeList.Count; i++) { Pipe pipe = pipeList[i]; bool isToTheRightOfBird = pipe.GetXPosition() > BIRD_X_POSITION; pipe.Move(); if (isToTheRightOfBird && pipe.GetXPosition() <= BIRD_X_POSITION && pipe.IsBottom()) { // Pipe passed Bird pipesPassedCount++; SoundManager.PlaySound(SoundManager.Sound.Score); } if (pipe.GetXPosition() < PIPE_DESTROY_X_POSITION) { // Destroy Pipe pipe.DestroySelf(); pipeList.Remove(pipe); i--; } } for (int i = 0; i < middlePipeList.Count; i++) { MiddlePipe middlePipe = middlePipeList[i]; middlePipe.Move(); if (middlePipe.GetXPosition() < PIPE_DESTROY_X_POSITION) { // Destroy Pipe middlePipe.DestroySelf(); middlePipeList.Remove(middlePipe); i--; } } }