| | |
| | | let collection = UICollectionView(frame: .zero, collectionViewLayout: flowLayout) |
| | | collection.contentInset = UIEdgeInsets(top: 0, left: 35, bottom: 0, right: 35) |
| | | collection.register(UINib(nibName: "ListenFight_Game_CCell", bundle: nil), forCellWithReuseIdentifier: "_ListenFight_Game_CCell") |
| | | collection.isScrollEnabled = false |
| | | return collection |
| | | }() |
| | | |
| | |
| | | |
| | | override func viewDidLoad() { |
| | | super.viewDidLoad() |
| | | |
| | | #if DEBUG |
| | | listen1Model?.data?.time = 60 |
| | | #endif |
| | | |
| | | if listen1Model != nil{ |
| | | times = listen1Model?.data?.time ?? 10 |
| | |
| | | totalCount += 1 |
| | | rootViewModel.errorNum += 1 |
| | | label_class.text = "\(totalCount)" |
| | | |
| | | //答题完成 |
| | | if self.answerSet.count == 0{completeQuestion()} |
| | | } |
| | | //答题完成 |
| | | if self.answerSet.count == 0{ |
| | | timer?.invalidate() |
| | | completeQuestion() |
| | | } |
| | | } |
| | | |
| | | private func answerQuestion(){ |
| | | view.layoutIfNeeded() |
| | | |
| | | view.isUserInteractionEnabled = false |
| | | guard let row = viewModel.selectIndex.value?.row else { alertError(msg: "请选择");return } |
| | | |
| | | var answerType:Fight_lessonType = .none |
| | |
| | | case .success: |
| | | viewModel.answerType.accept(.success) |
| | | collectionView.reloadData() |
| | | rootViewModel.correctNum += 1 |
| | | if let cell = collectionView.dequeueReusableCell(withReuseIdentifier: "_ListenFight_Game_CCell", for: viewModel.selectIndex.value!) as? ListenFight_Game_CCell{ |
| | | let newRect = cell.contentView.convert(cell.bounds, from: self.collectionView) |
| | | let x = abs(newRect.origin.x) + self.collectionView.contentInset.left + 5 |
| | |
| | | self.voicePlayer.playerAt(url: self.currentAnswer?.correct) |
| | | self.timer?.fireDate = .distantFuture |
| | | //答题完成 |
| | | if self.answerSet.count == 0{ |
| | | self.completeQuestion() |
| | | } |
| | | // if self.answerSet.count == 0{ |
| | | // self.completeQuestion() |
| | | // } |
| | | } |
| | | } |
| | | } |
| | |
| | | |
| | | extension HomeListenGame_1_VC:VoicePlayerDelegate{ |
| | | func playComplete() { |
| | | view.isUserInteractionEnabled = true |
| | | view_studyHandleView.resetView() |
| | | |
| | | if viewModel.answerType.value == .success{ |
| | |
| | | self.timer?.fireDate = .distantPast |
| | | } |
| | | } |
| | | |
| | | |
| | | //答题完成 |
| | | if self.answerSet.count == 0{completeQuestion()} |
| | | } |
| | | |
| | | func playing() { |
| | | view.isUserInteractionEnabled = false |
| | | view_studyHandleView.playing() |
| | | } |
| | | |