| | |
| | | }() |
| | | |
| | | private var timer:Timer? |
| | | private var times:Int = 600 |
| | | private var times:Int = 120 |
| | | private var voicePlayer = VoicePlayer.share() |
| | | |
| | | required init(listen1Model:Listen1Model){ |
| | |
| | | for v in listen1Model.voiceList{ |
| | | v.type = 2 // 音频标识 |
| | | } |
| | | times = listen1Model.data?.answerTime ?? 120 |
| | | |
| | | datas.append(contentsOf: listen1Model.photoList) |
| | | datas.append(contentsOf: listen1Model.voiceList) |
| | |
| | | |
| | | view.addSubview(label_time) |
| | | label_time.snp.makeConstraints { make in |
| | | make.left.equalTo(label_surplusTitle.snp.right).offset(0) |
| | | make.left.equalTo(label_surplusTitle.snp.right).offset(5) |
| | | make.centerY.equalTo(label_surplusTitle) |
| | | make.height.equalTo(44) |
| | | } |
| | |
| | | timer = Timer(timeInterval: 1.0, target: self, selector: #selector(runloopTime), userInfo: nil, repeats: true) |
| | | } |
| | | timer?.fire() |
| | | RunLoop.current.add(timer!, forMode: .default) |
| | | RunLoop.current.add(timer!, forMode: .common) |
| | | } |
| | | |
| | | @objc private func runloopTime(){ |
| | |
| | | if times == 0{ |
| | | timer?.fireDate = .distantFuture |
| | | DispatchQueue.main.asyncAfter(deadline: .now()+3) { |
| | | self.times = 10 |
| | | self.timer?.fireDate = .distantPast |
| | | CommonAlertView.showSimple(content: "答题时间已结束,停止作答", completeTitle: "查看成绩") { |
| | | self.rootViewModel.answerItems[0] = self.listen1Model |
| | | NotificationCenter.default.post(name: NextLession_Noti, object: ["gameId":self.listen1Model.data!.id,"gameIntegral":self.listen1Model.data!.answerIntegral]) |
| | | } |
| | | } |
| | | } |
| | | } |
| | |
| | | lastM?.model.isOpen = true |
| | | selectModels.removeAll() |
| | | print("相同") |
| | | self.rootViewModel.insertCorrectAnswer(teamId: "\(listen1Model.data!.id)", answerId: firstM!.model.id) |
| | | viewModel.answerType.accept(.success) |
| | | rootViewModel.correctNum += 1 |
| | | voicePlayer.playSuccessVoice() |
| | | self.selectModels.removeAll() |
| | | let firstIndexCell = self.collectionView.cellForItem(at: firstM!.indexPath) as! ListenFight_Game_Pocket_CCell |
| | | let secondIndexCell = self.collectionView.cellForItem(at: lastM!.indexPath) as! ListenFight_Game_Pocket_CCell |
| | | firstIndexCell.setState(success: true) |
| | | secondIndexCell.setState(success: true) |
| | | DispatchQueue.main.asyncAfter(deadline: .now()+1.0) { |
| | | self.view.isUserInteractionEnabled = true |
| | | } |
| | | |
| | | }else{ |
| | | print("不相同") |
| | | viewModel.answerType.accept(.fail) |
| | |
| | | |
| | | let firstIndexCell = self.collectionView.cellForItem(at: firstIndex!) as! ListenFight_Game_Pocket_CCell |
| | | let secondIndexCell = self.collectionView.cellForItem(at: secondIndex!) as! ListenFight_Game_Pocket_CCell |
| | | firstIndexCell.setState(success: false) |
| | | secondIndexCell.setState(success: false) |
| | | |
| | | self.view.isUserInteractionEnabled = false |
| | | DispatchQueue.main.asyncAfter(deadline: .now()+3.0){ |
| | | firstIndexCell.toBackAction(self.view) |
| | | secondIndexCell.toBackAction(self.view) |
| | | self.selectModels.removeAll() |
| | | } |
| | | DispatchQueue.main.asyncAfter(wallDeadline: .now()+3.7){ |
| | | self.view.isUserInteractionEnabled = true |
| | | } |
| | | } |
| | | } |
| | | |
| | | let surplusListCount = datas.filter({$0.isOpen == false}).count |
| | | if surplusListCount == 0{ |
| | | NotificationCenter.default.post(name: NextLession_Noti, object: ["gameId":listen1Model.data!.id,"gameIntegral":listen1Model.data!.integral]) |
| | | rootViewModel.answerItems[0] = self.listen1Model |
| | | NotificationCenter.default.post(name: NextLession_Noti, object: ["gameId":listen1Model.data!.id,"gameIntegral":listen1Model.data!.answerIntegral]) |
| | | timer?.invalidate() |
| | | } |
| | | print("剩余:\(surplusListCount)") |
| | |
| | | |
| | | if selectModels.count == 1{ |
| | | let cell = self.collectionView.cellForItem(at: indexPath) as! ListenFight_Game_Pocket_CCell |
| | | cell.toFromAction(self.view) |
| | | cell.toFromAction(self.view,c: true) |
| | | |
| | | if model.type == 2{ |
| | | //播放 |
| | |
| | | |
| | | extension HomeListenGame_2_VC:VoicePlayerDelegate{ |
| | | func playComplete() { |
| | | view.isUserInteractionEnabled = true |
| | | // view.isUserInteractionEnabled = true |
| | | //正在播放的语音Cell要归位 |
| | | if let index = currentPayCellIndex{ |
| | | let cell = collectionView.cellForItem(at: index) as! ListenFight_Game_Pocket_CCell |
| | | cell.cellResotePay() |
| | | view.isUserInteractionEnabled = true |
| | | } |
| | | checking() |
| | | } |
| | | |
| | | func playing() { |
| | | view.isUserInteractionEnabled = false |
| | | // view.isUserInteractionEnabled = false |
| | | } |
| | | |
| | | } |