// // PIFullScreenBannerAnimation.m // YuMi // // Created by duoban on 2023/7/12. // #import "XPRoomAnimationView.h" ///Third #import #import #import #import #import "QGVAPConfigModel.h" #import "UIView+VAP.h" #import ///Tool #import "XPGiftStorage.h" #import "YUMIMacroUitls.h" #import "ThemeColor+Room.h" #import "NetImageView.h" #import "XPRoomGiftAnimationParser.h" #import "XCCurrentVCStackManager.h" #import "AccountInfoStorage.h" #import "ClientConfig.h" ///Model #import "MicroQueueModel.h" #import "MicroStateModel.h" #import "UserInfoModel.h" #import "GiftReceiveInfoModel.h" #import "GiftInfoModel.h" #import "RoomInfoModel.h" #import "AttachmentModel.h" #import "XPGiftBigPrizeModel.h" #import "XPGiftBannerUserInfoModel.h" #import "GiftReceiveInfoModel.h" #import "XPMessageRemoteExtModel.h" #import "DatingInfoModel.h" #import "AcrossRoomPKPrizeModel.h" #import "RoomHalfHourRankModel.h" #import "ClientConfig.h" ///View #import "XPRoomGiftBroadcastView.h" #import "XPRoomCandyGiftView.h" #import "XPRoomDatingAnimationView.h" #import "XPRoomNobleLevelUpView.h" #import "QGVAPWrapView.h" #import "XPAcrossRoomPKPrizeView.h" #import "XPRoomViewController.h" #import "XPRoomAnchorRankBannerView.h" #import "XPRoomEnterHideTipView.h" #import "XPRoomLuckyBigPrizeView.h" #import "XPRoomGiftCompoundView.h" #import "XPSailingAnimationView.h" #import "XPRoomGraffitiGiftAnimationView.h" #import "XPRoomStarKitchenBannerView.h" #import "XPWebViewController.h" #import "PIBaseAnimationViewModel.h" #import "PIFullScreenBannerAnimation.h" #import "XPSkillCardPlayerManager.h" #import "XPTreasureFairyGiftView.h" #import "XPRoomTarrowBannerView.h" #import "PIRoomGiftBroadcastWindow.h" #import "PIUniversalBannerModel.h" #import "PIUniversalBannerView.h" @interface PIFullScreenBannerAnimation() ///礼物飘屏 PresentAchieveAbstractMatrix @property(nonatomic,strong) NSMutableArray *animationListA; ///玩法飘屏 YUMIPresentBigCaptureMatrix @property(nonatomic,strong) NSMutableArray *animationListB; ///礼物飘屏正在播放中 @property(nonatomic,assign) BOOL isPlayOfA; ///玩法飘屏正在播放中 @property(nonatomic,assign) BOOL isPlayOfB; ///animationListA播放完后,如果有animationListB,那么要在animationListA的位置上播放animationListB,只播放一次 //@property(nonatomic,assign) BOOL isAnimationListAFinish; @property(nonatomic,assign) CGFloat broadCastHieght; @end @implementation PIFullScreenBannerAnimation - (void)createGiftBroadcastViewAnimation:(GiftReceiveInfoModel *)giftModel { self.isPlayOfA = YES; XPRoomGiftBroadcastView * view = [[XPRoomGiftBroadcastView alloc] init]; view.delegate = self; view.frame = CGRectMake(KScreenWidth, 35 + statusbarHeight, KScreenWidth, kGetScaleWidth(69)); view.broadcastModel = giftModel; [kWindow addSubview:view]; [self beginGiftBraodcastViewAnimation:view notifyStaySecond:giftModel.notifyStaySecond]; } - (void)beginGiftBraodcastViewAnimation:(XPRoomGiftBroadcastView *)view notifyStaySecond:(int)notifyStaySecond{ CGFloat startTime = notifyStaySecond > 0 ? notifyStaySecond : 3.0; POPSpringAnimation *springAnimation = [POPSpringAnimation animationWithPropertyNamed:kPOPViewCenter]; springAnimation.springSpeed = 12; springAnimation.springBounciness = 10.f; springAnimation.fromValue = [NSValue valueWithCGPoint:view.center]; springAnimation.toValue = [NSValue valueWithCGPoint:CGPointMake(0 + view.frame.size.width / 2, view.center.y)]; [springAnimation setCompletionBlock:^(POPAnimation *anim, BOOL finished) { if (finished) { [self removeGiftBroadcastOutAnimation:view stayTime:startTime]; } }]; [view pop_addAnimation:springAnimation forKey:@"spingOutAnimation"]; } - (void)removeGiftBroadcastOutAnimation:(XPRoomGiftBroadcastView *)view stayTime:(CGFloat)stayTime{ POPBasicAnimation *moveAnimation = [POPBasicAnimation animationWithPropertyNamed:kPOPViewCenter]; moveAnimation.fromValue = [NSValue valueWithCGPoint:view.center]; moveAnimation.toValue = [NSValue valueWithCGPoint:CGPointMake(-KScreenWidth/2, view.center.y)]; moveAnimation.beginTime = CACurrentMediaTime() + stayTime; moveAnimation.duration = 0.5; moveAnimation.repeatCount = 1; moveAnimation.removedOnCompletion = YES; @kWeakify(self); [moveAnimation setCompletionBlock:^(POPAnimation *anim, BOOL finished) { @kStrongify(self); if (finished) { [view removeFromSuperview]; self.isPlayOfA = NO; if (self.animationListA.count > 0) { [self.animationListA removeObjectAtIndex:0]; } if(self.animationListB.count > 0){ // self.isAnimationListAFinish = YES; [self playAnimationWithModel]; return; } if (self.animationListA.count > 0 && self.isPlayOfB == NO && self.isPlayOfA == NO) { [self createGiftBroadcastViewAnimation:self.animationListA.firstObject]; } } }]; [view pop_addAnimation:moveAnimation forKey:@"moveOutAnimation"]; } ///点击了进入房间 - (void)xPRoomGiftBroadcastView:(XPRoomGiftBroadcastView *)view enterRoom:(NSString *)roomUid roomName:(NSString *)roomName{ id isShowBroadcastView = [[NSUserDefaults standardUserDefaults]valueForKey:@"kSaveBrooadcastSelectState"]; if(isShowBroadcastView == nil){ PIRoomGiftBroadcastWindow *broadcastView = [[PIRoomGiftBroadcastWindow alloc] initWithFrame:CGRectMake(0, 0, KScreenWidth, KScreenHeight)]; broadcastView.roodUid = roomUid; broadcastView.roomName = roomName; broadcastView.delegate = self; [kWindow addSubview:broadcastView]; return; } if (roomUid.length > 0) { dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.7 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{ [XPRoomViewController openRoom:roomUid viewController:[XCCurrentVCStackManager shareManager].getCurrentVC]; }); } } #pragma mark -PIRoomGiftBroadcastWindowDelegate -(void)confirmLeaveForTheRoom:(NSString *_Nonnull)roomUid{ if (roomUid.length > 0) { dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.7 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{ [XPRoomViewController openRoom:roomUid viewController:[XCCurrentVCStackManager shareManager].getCurrentVC]; }); } } ///收到了礼物 - (void)receiveGift:(GiftReceiveInfoModel *)receiveInfo { ///CPU警告的时候 需要停止接收动画 GiftReceiveInfoModel *giftNotifyInfo = receiveInfo; if (self.animationListA.count == 0 && self.isPlayOfB == NO && self.isPlayOfA == NO) { [self createGiftBroadcastViewAnimation:giftNotifyInfo]; } [self.animationListA addObject:giftNotifyInfo]; } -(void)playAnimationACompletion{ PIBaseAnimationViewModel *model = self.animationListB.firstObject; if(model.type == GiftBannerType_Lucky){ [self createBigPrizeAnimation:model]; }else if (model.type == GiftBannerType_Love){ [self createCandyTreeBannerAnimation:model]; }else if(model.type == GiftBannerType_Nobleman){ [self createNobleLevelUpBannerAnimation:model]; }else if(model.type == GiftBannerType_kitchen){ [self createStarKitchenBannerAnimation:model]; }else if(model.type == GiftBannerType_AnchorHour){ [self createAnchorHourRankAnimation:model]; }else if(model.type == GiftBannerType_LicneseHour){ [self createAnchorHourRankAnimation:model]; }else if(model.type == GiftBannerType_Fairy){ [self createTreasureFairyBannerAnimation:model]; }else if(model.type == GiftBannerType_Tarrow){ [self createBigPrizeAnimation:model]; }else if(model.type == GiftBannerType_Common_H5){ [self createCommonH5BannerAnimation:model]; } } -(void)playAnimationWithModel{ // if(self.isAnimationListAFinish == YES)return; if(self.animationListB.count <= 0){ if(self.animationListA.count > 0 && self.isPlayOfB == NO && self.isPlayOfA == NO){ [self createGiftBroadcastViewAnimation:self.animationListA.firstObject]; } return; } if(self.isPlayOfB == YES)return; PIBaseAnimationViewModel *model = self.animationListB.firstObject; if(model.type == GiftBannerType_Lucky){ [self createBigPrizeAnimation:model]; }else if (model.type == GiftBannerType_Love){ [self createCandyTreeBannerAnimation:model]; }else if(model.type == GiftBannerType_Nobleman){ [self createNobleLevelUpBannerAnimation:model]; }else if(model.type == GiftBannerType_kitchen){ [self createStarKitchenBannerAnimation:model]; }else if(model.type == GiftBannerType_AnchorHour){ [self createAnchorHourRankAnimation:model]; }else if(model.type == GiftBannerType_LicneseHour){ [self createAnchorHourRankAnimation:model]; }else if(model.type == GiftBannerType_Fairy){ [self createTreasureFairyBannerAnimation:model]; }else if(model.type == GiftBannerType_Tarrow){ [self createBigPrizeAnimation:model]; }else if(model.type == GiftBannerType_Common_H5){ [self createCommonH5BannerAnimation:model]; }else if (model.type == GiftBannerType_General_Floating_Screen){ [self createGeneralFloatingScreenAnimation:model]; } } #pragma mark - 通用飘屏 -(void)receiveRoomGeneralFloatingScreen:(AttachmentModel *)attacment{ PIBaseAnimationViewModel *roomGraffiti = [PIBaseAnimationViewModel new]; roomGraffiti.data = attacment.data; roomGraffiti.type = GiftBannerType_General_Floating_Screen; roomGraffiti.first = attacment.first; roomGraffiti.second = attacment.second; if(self.animationListB.count == 0 && self.isPlayOfB == NO){ [self createGeneralFloatingScreenAnimation:roomGraffiti]; } [self.animationListB addObject:roomGraffiti]; } - (void)createGeneralFloatingScreenAnimation:(PIBaseAnimationViewModel *)attacment{ self.isPlayOfB = YES; CGFloat top = self.isPlayOfA == YES ? (self.broadCastHieght + statusbarHeight) : (kNavigationHeight + 15); PIUniversalBannerModel *model = [PIUniversalBannerModel modelWithDictionary:attacment.data]; BOOL isSvga = [model.resourceType isEqualToString:@"SVGA"]; __block PIUniversalBannerView *bannerView; if (isSvga == YES) { SVGAParser *parser = [SVGAParser new]; [parser parseWithURL:[NSURL URLWithString:model.resourceContent] completionBlock:^(SVGAVideoEntity * _Nonnull videoItem) { model.videoItem = videoItem; bannerView = [[PIUniversalBannerView alloc]initWithFrame:CGRectMake(KScreenWidth, top, kGetScaleWidth(model.resourceWidth), kGetScaleWidth(model.resourceHeight)) ]; [self showGeneralFloatingScreenView:bannerView model:model]; } failureBlock:^(NSError * _Nonnull error) { [bannerView removeFromSuperview]; self.isPlayOfB = NO; if(self.animationListB.count > 0){ [self.animationListB removeObjectAtIndex:0]; } [self playAnimationWithModel]; }]; }else{ NetImageView *imageView = [NetImageView new]; [imageView loadImageWithUrl:model.resourceContent completion:^(UIImage * _Nonnull image, NSURL * _Nonnull url) { model.image = image; CGFloat width = image.size.width <= 0 ? kGetScaleWidth(60) : image.size.width; CGFloat height = image.size.height ; CGFloat getHeigth = KScreenWidth * height / width; bannerView = [[PIUniversalBannerView alloc]initWithFrame:CGRectMake(KScreenWidth, top, KScreenWidth, getHeigth) ]; [self showGeneralFloatingScreenView:bannerView model:model]; } fail:^(NSError * _Nonnull error) { self.isPlayOfB = NO; if(self.animationListB.count > 0){ [self.animationListB removeObjectAtIndex:0]; } [self playAnimationWithModel]; }]; } } -(void)showGeneralFloatingScreenView:(PIUniversalBannerView *)bannerView model:(PIUniversalBannerModel *)model{ BOOL isSvga = [model.resourceType isEqualToString:@"SVGA"]; bannerView.isSvga = isSvga; bannerView.model = model; bannerView.delegate = self; [kWindow addSubview:bannerView]; POPSpringAnimation *springAnimation = [POPSpringAnimation animationWithPropertyNamed:kPOPViewCenter]; springAnimation.springSpeed = 12; springAnimation.springBounciness = 10.f; springAnimation.fromValue = [NSValue valueWithCGPoint:bannerView.center]; springAnimation.toValue = [NSValue valueWithCGPoint:CGPointMake(bannerView.frame.size.width / 2, bannerView.center.y)]; [springAnimation setCompletionBlock:^(POPAnimation *anim, BOOL finished) { if (finished) { POPBasicAnimation *moveAnimation = [POPBasicAnimation animationWithPropertyNamed:kPOPViewCenter]; moveAnimation.fromValue = [NSValue valueWithCGPoint:CGPointMake(0, bannerView.center.y)]; moveAnimation.toValue = [NSValue valueWithCGPoint:CGPointMake(-KScreenWidth/2, bannerView.center.y)]; moveAnimation.beginTime = CACurrentMediaTime() + 3; moveAnimation.duration = 0.5; moveAnimation.repeatCount = 1; moveAnimation.removedOnCompletion = YES; @kWeakify(self); [moveAnimation setCompletionBlock:^(POPAnimation *anim, BOOL finished) { @kStrongify(self); if (finished) { [bannerView removeFromSuperview]; self.isPlayOfB = NO; if(self.animationListB.count > 0){ [self.animationListB removeObjectAtIndex:0]; } [self playAnimationWithModel]; } }]; [bannerView pop_addAnimation:moveAnimation forKey:@"moveOutAnimation"]; } }]; [bannerView pop_addAnimation:springAnimation forKey:@"starKitchenOutAnimation"]; } #pragma mark - PIUniversalBannerViewDelegate - (void)pIUniversalBannerView:(PIUniversalBannerView *)view didClick:(PIUniversalBannerModel *)model{ if (model.skipType == 2){ [XPRoomViewController openRoom:model.skipContent viewController:[XCCurrentVCStackManager shareManager].getCurrentVC]; }else if (model.skipType == 3){ XPWebViewController * webVC = [[XPWebViewController alloc] init]; webVC.isPush = YES; webVC.url = model.skipContent; [[XCCurrentVCStackManager shareManager].getCurrentVC.navigationController pushViewController:webVC animated:YES]; } } #pragma mark - 收到h5通用飘屏 -(void)receiveCommonH5Banner:(AttachmentModel *)attachment{ PIBaseAnimationViewModel *giftNotifyInfo = [PIBaseAnimationViewModel modelWithJSON:attachment.data]; giftNotifyInfo.type = GiftBannerType_Common_H5; giftNotifyInfo.second = attachment.second; if (self.animationListB.count == 0 && self.isPlayOfB == NO) { [self createCommonH5BannerAnimation:giftNotifyInfo]; } [self.animationListB addObject:giftNotifyInfo]; } - (void)createCommonH5BannerAnimation:(PIBaseAnimationViewModel *)attatchment { CGFloat kscale = (CGFloat)55 / (CGFloat)375; self.isPlayOfB = YES; CGFloat top = self.isPlayOfA == YES ? (self.broadCastHieght + statusbarHeight) : (kNavigationHeight + 15); XPRoomTarrowBannerView *tarrowVeiw = [[XPRoomTarrowBannerView alloc]initWithFrame:CGRectMake(KScreenWidth, top, KScreenWidth , KScreenWidth * kscale)isH5:YES]; tarrowVeiw.isBig = attatchment.second == Custom_Message_Sub_Common_H5_Advanced; tarrowVeiw.giftH5Info = attatchment; [kWindow addSubview:tarrowVeiw]; POPSpringAnimation *springAnimation = [POPSpringAnimation animationWithPropertyNamed:kPOPViewCenter]; springAnimation.springSpeed = 12; springAnimation.springBounciness = 10.f; springAnimation.fromValue = [NSValue valueWithCGPoint:tarrowVeiw.center]; springAnimation.toValue = [NSValue valueWithCGPoint:CGPointMake(tarrowVeiw.frame.size.width / 2, tarrowVeiw.center.y)]; [springAnimation setCompletionBlock:^(POPAnimation *anim, BOOL finished) { if (finished) { POPBasicAnimation *moveAnimation = [POPBasicAnimation animationWithPropertyNamed:kPOPViewCenter]; moveAnimation.fromValue = [NSValue valueWithCGPoint:CGPointMake(0, tarrowVeiw.center.y)]; moveAnimation.toValue = [NSValue valueWithCGPoint:CGPointMake(-KScreenWidth/2,tarrowVeiw.center.y)]; moveAnimation.beginTime = CACurrentMediaTime() + 3; moveAnimation.duration = 0.5; moveAnimation.repeatCount = 1; moveAnimation.removedOnCompletion = YES; @kWeakify(self); [moveAnimation setCompletionBlock:^(POPAnimation *anim, BOOL finished) { @kStrongify(self); if (finished) { [tarrowVeiw removeFromSuperview]; self.isPlayOfB = NO; if (self.animationListB.count > 0) { [self.animationListB removeObjectAtIndex:0]; } // if(self. isAnimationListAFinish == YES){ // // [self playAnimationWithModel]; // self.isAnimationListAFinish = NO; // return; // } [self playAnimationWithModel]; } }]; [tarrowVeiw pop_addAnimation:moveAnimation forKey:@"moveOutAnimation"]; } }]; [tarrowVeiw pop_addAnimation:springAnimation forKey:@"candyTreespingOutAnimation"]; } #pragma mark - 收到塔罗飘屏 -(void)receiveTarotBanner:(AttachmentModel *)attachment{ PIBaseAnimationViewModel *giftNotifyInfo = [PIBaseAnimationViewModel modelWithJSON:attachment.data]; giftNotifyInfo.type = GiftBannerType_Tarrow; giftNotifyInfo.second = attachment.second; if (self.animationListB.count == 0 && self.isPlayOfB == NO) { [self createTarotBannerAnimation:giftNotifyInfo]; } [self.animationListB addObject:giftNotifyInfo]; } - (void)createTarotBannerAnimation:(PIBaseAnimationViewModel *)attatchment { CGFloat kscale = (CGFloat)55 / (CGFloat)375; self.isPlayOfB = YES; CGFloat top = self.isPlayOfA == YES ? (self.broadCastHieght + statusbarHeight) : (kNavigationHeight + 15); XPRoomTarrowBannerView *tarrowVeiw = [[XPRoomTarrowBannerView alloc]initWithFrame:CGRectMake(KScreenWidth, top, KScreenWidth , KScreenWidth * kscale) isH5:NO]; tarrowVeiw.isBig = attatchment.second == Custom_Message_Sub_Tarot_Advanced; tarrowVeiw.giftInfo = attatchment; [kWindow addSubview:tarrowVeiw]; POPSpringAnimation *springAnimation = [POPSpringAnimation animationWithPropertyNamed:kPOPViewCenter]; springAnimation.springSpeed = 12; springAnimation.springBounciness = 10.f; springAnimation.fromValue = [NSValue valueWithCGPoint:tarrowVeiw.center]; springAnimation.toValue = [NSValue valueWithCGPoint:CGPointMake(tarrowVeiw.frame.size.width / 2, tarrowVeiw.center.y)]; [springAnimation setCompletionBlock:^(POPAnimation *anim, BOOL finished) { if (finished) { POPBasicAnimation *moveAnimation = [POPBasicAnimation animationWithPropertyNamed:kPOPViewCenter]; moveAnimation.fromValue = [NSValue valueWithCGPoint:CGPointMake(0, tarrowVeiw.center.y)]; moveAnimation.toValue = [NSValue valueWithCGPoint:CGPointMake(-KScreenWidth/2,tarrowVeiw.center.y)]; moveAnimation.beginTime = CACurrentMediaTime() + 3; moveAnimation.duration = 0.5; moveAnimation.repeatCount = 1; moveAnimation.removedOnCompletion = YES; @kWeakify(self); [moveAnimation setCompletionBlock:^(POPAnimation *anim, BOOL finished) { @kStrongify(self); if (finished) { [tarrowVeiw removeFromSuperview]; self.isPlayOfB = NO; if (self.animationListB.count > 0) { [self.animationListB removeObjectAtIndex:0]; } // if(self. isAnimationListAFinish == YES){ // // [self playAnimationWithModel]; // self.isAnimationListAFinish = NO; // return; // } [self playAnimationWithModel]; } }]; [tarrowVeiw pop_addAnimation:moveAnimation forKey:@"moveOutAnimation"]; } }]; [tarrowVeiw pop_addAnimation:springAnimation forKey:@"candyTreespingOutAnimation"]; } #pragma mark - 夺宝精灵横幅 - (void)receiveTreasureFairyGiftHighLevel:(AttachmentModel *)attatchment { PIBaseAnimationViewModel *giftModel = [PIBaseAnimationViewModel new]; giftModel.data = attatchment.data; giftModel.second = attatchment.second; giftModel.first = attatchment.first; giftModel.type = GiftBannerType_Fairy; if (self.animationListB.count == 0 && self.isPlayOfB == NO) { [self createTreasureFairyBannerAnimation:giftModel]; } [self.animationListB addObject:giftModel]; } - (void)createTreasureFairyBannerAnimation:(PIBaseAnimationViewModel *)attatchment { CGFloat kscale = (CGFloat)60 / (CGFloat)375; self.isPlayOfB = YES; CGFloat top = self.isPlayOfA == YES ? (self.broadCastHieght + statusbarHeight) : (kNavigationHeight + 15); XPTreasureFairyGiftView *treasureView = [[XPTreasureFairyGiftView alloc] initWithFrame:CGRectMake(KScreenWidth, top, KScreenWidth , KScreenWidth * kscale)]; //最大礼物 if ((attatchment.second == Custom_Message_Sub_Treasure_Fairy_Draw_Gift_L5) || (attatchment.second == Custom_Message_Sub_Treasure_Fairy_Convert_L3)) { treasureView.isMaxLargeGift = YES; }else{ treasureView.isMaxLargeGift = NO; } if ((attatchment.second == Custom_Message_Sub_Treasure_Fairy_Draw_Gift_L4) || (attatchment.second == Custom_Message_Sub_Treasure_Fairy_Draw_Gift_L5)) { treasureView.isDrawGift = YES; //抽奖 }else{ treasureView.isDrawGift = NO; //召唤 } treasureView.treasureInfo = attatchment.data; [kWindow addSubview:treasureView]; POPSpringAnimation *springAnimation = [POPSpringAnimation animationWithPropertyNamed:kPOPViewCenter]; springAnimation.springSpeed = 12; springAnimation.springBounciness = 10.f; springAnimation.fromValue = [NSValue valueWithCGPoint:treasureView.center]; springAnimation.toValue = [NSValue valueWithCGPoint:CGPointMake(treasureView.frame.size.width / 2, treasureView.center.y)]; [springAnimation setCompletionBlock:^(POPAnimation *anim, BOOL finished) { if (finished) { POPBasicAnimation *moveAnimation = [POPBasicAnimation animationWithPropertyNamed:kPOPViewCenter]; moveAnimation.fromValue = [NSValue valueWithCGPoint:CGPointMake(0, treasureView.center.y)]; moveAnimation.toValue = [NSValue valueWithCGPoint:CGPointMake(-KScreenWidth/2, treasureView.center.y)]; moveAnimation.beginTime = CACurrentMediaTime() + 3; moveAnimation.duration = 0.5; moveAnimation.repeatCount = 1; moveAnimation.removedOnCompletion = YES; @kWeakify(self); [moveAnimation setCompletionBlock:^(POPAnimation *anim, BOOL finished) { @kStrongify(self); if (finished) { [treasureView removeFromSuperview]; self.isPlayOfB = NO; if (self.animationListB.count > 0) { [self.animationListB removeObjectAtIndex:0]; } // if(self. isAnimationListAFinish == YES){ // // [self playAnimationWithModel]; // self.isAnimationListAFinish = NO; // return; // } [self playAnimationWithModel]; } }]; [treasureView pop_addAnimation:moveAnimation forKey:@"moveOutAnimation"]; } }]; [treasureView pop_addAnimation:springAnimation forKey:@"candyTreespingOutAnimation"]; } #pragma mark - 福袋中 四级奖品 - (void)receiveLuckyGiftBigPrize:(AttachmentModel *)attachment { if ( attachment.second == Custom_Message_Sub_Room_Gift_LuckBag_FullScree) { PIBaseAnimationViewModel * prizeModel = [PIBaseAnimationViewModel modelWithDictionary:attachment.data]; prizeModel.type = GiftBannerType_Lucky; prizeModel.isInRoomVisiable = attachment.second == Custom_Message_Sub_Room_Gift_LuckBag; if(self.animationListB.count == 0 && self.isPlayOfB == NO){ [self createBigPrizeAnimation:prizeModel]; } [self.animationListB addObject:prizeModel]; } } - (void)createBigPrizeAnimation:(PIBaseAnimationViewModel *)prizeModel { self.isPlayOfB = YES; CGFloat top = self.isPlayOfA == YES ? (self.broadCastHieght + statusbarHeight) : (kNavigationHeight + 15); XPRoomLuckyBigPrizeView * luckyGiftEffectView = [[XPRoomLuckyBigPrizeView alloc] initWithFrame:CGRectMake(KScreenWidth, top, 375, 71)]; luckyGiftEffectView.delegate = self; [kWindow addSubview:luckyGiftEffectView]; luckyGiftEffectView.giftInfo = prizeModel; POPSpringAnimation *springAnimation = [POPSpringAnimation animationWithPropertyNamed:kPOPViewCenter]; springAnimation.springSpeed = 12; springAnimation.springBounciness = 10.f; springAnimation.fromValue = [NSValue valueWithCGPoint:luckyGiftEffectView.center]; springAnimation.toValue = [NSValue valueWithCGPoint:CGPointMake(KScreenWidth / 2, luckyGiftEffectView.center.y)]; dispatch_after(dispatch_time(DISPATCH_TIME_NOW, 7 * NSEC_PER_SEC), dispatch_get_main_queue(), ^{ POPBasicAnimation *moveAnimation = [POPBasicAnimation animationWithPropertyNamed:kPOPViewCenter]; moveAnimation.fromValue = [NSValue valueWithCGPoint:CGPointMake(0, luckyGiftEffectView.center.y)]; moveAnimation.toValue = [NSValue valueWithCGPoint:CGPointMake(-KScreenWidth/2, luckyGiftEffectView.center.y)]; moveAnimation.beginTime = CACurrentMediaTime(); moveAnimation.duration = 0.5; moveAnimation.repeatCount = 1; moveAnimation.removedOnCompletion = YES; @kWeakify(self); [moveAnimation setCompletionBlock:^(POPAnimation *anim, BOOL finished) { @kStrongify(self); if (finished) { [luckyGiftEffectView removeFromSuperview]; if (self.animationListB.count > 0) { [self.animationListB removeObjectAtIndex:0]; } self.isPlayOfB = NO; // if(self.isAnimationListAFinish == YES){ // self.isAnimationListAFinish = NO; // [self playAnimationWithModel]; // return; // } [self playAnimationWithModel]; } }]; [luckyGiftEffectView pop_addAnimation:moveAnimation forKey:@"moveOutAnimation"]; }); [luckyGiftEffectView pop_addAnimation:springAnimation forKey:@"nobleLevelUpspingOutAnimation"]; } #pragma mark - XPRoomLuckyBigPrizeViewDelegate - (void)xPRoomLuckyBigPrizeView:(XPRoomLuckyBigPrizeView *)view luckyGiftInfo:(PIBaseAnimationViewModel *)giftInfo { id isShowBroadcastView = [[NSUserDefaults standardUserDefaults]valueForKey:@"kSaveLuckSelectState"]; if(isShowBroadcastView == nil){ PIRoomGiftBroadcastWindow *broadcastView = [[PIRoomGiftBroadcastWindow alloc] initWithFrame:CGRectMake(0, 0, KScreenWidth, KScreenHeight)]; broadcastView.isLuck = YES; broadcastView.roodUid = giftInfo.roomUid; broadcastView.roomName = giftInfo.roomTitle; broadcastView.delegate = self; [kWindow addSubview:broadcastView]; return; } if (!giftInfo.isInRoomVisiable && giftInfo.roomUid.length > 0 ) { [XPRoomViewController openRoom:giftInfo.roomUid viewController:[XCCurrentVCStackManager shareManager].getCurrentVC]; } } #pragma mark - 糖果树横幅动画 - (void)receiveCandyTreeGiftHighLevle:(AttachmentModel *)attatchment { PIBaseAnimationViewModel *giftModel = [PIBaseAnimationViewModel new]; giftModel.data = attatchment.data; giftModel.second = attatchment.second; giftModel.first = attatchment.first; giftModel.type = GiftBannerType_Love; if (self.animationListB.count == 0 && self.isPlayOfB == NO) { [self createCandyTreeBannerAnimation:giftModel]; } [self.animationListB addObject:giftModel]; } - (void)createCandyTreeBannerAnimation:(PIBaseAnimationViewModel *)attatchment { CGFloat kscale = (CGFloat)60 / (CGFloat)375; self.isPlayOfB = YES; CGFloat top = self.isPlayOfA == YES ? (self.broadCastHieght + statusbarHeight) : (kNavigationHeight + 15); XPRoomCandyGiftView *candyTreeView = [[XPRoomCandyGiftView alloc] initWithFrame:CGRectMake(KScreenWidth, top, KScreenWidth , KScreenWidth * kscale)]; candyTreeView.isMaxLargeGift = attatchment.second == Custom_Message_Sub_Look_Love_InRoom_NeedAllMicSend; candyTreeView.candyInfo = attatchment.data; [kWindow addSubview:candyTreeView]; POPSpringAnimation *springAnimation = [POPSpringAnimation animationWithPropertyNamed:kPOPViewCenter]; springAnimation.springSpeed = 12; springAnimation.springBounciness = 10.f; springAnimation.fromValue = [NSValue valueWithCGPoint:candyTreeView.center]; springAnimation.toValue = [NSValue valueWithCGPoint:CGPointMake(candyTreeView.frame.size.width / 2, candyTreeView.center.y)]; [springAnimation setCompletionBlock:^(POPAnimation *anim, BOOL finished) { if (finished) { POPBasicAnimation *moveAnimation = [POPBasicAnimation animationWithPropertyNamed:kPOPViewCenter]; moveAnimation.fromValue = [NSValue valueWithCGPoint:CGPointMake(0, candyTreeView.center.y)]; moveAnimation.toValue = [NSValue valueWithCGPoint:CGPointMake(-KScreenWidth/2, candyTreeView.center.y)]; moveAnimation.beginTime = CACurrentMediaTime() + 3; moveAnimation.duration = 0.5; moveAnimation.repeatCount = 1; moveAnimation.removedOnCompletion = YES; @kWeakify(self); [moveAnimation setCompletionBlock:^(POPAnimation *anim, BOOL finished) { @kStrongify(self); if (finished) { [candyTreeView removeFromSuperview]; self.isPlayOfB = NO; if (self.animationListB.count > 0) { [self.animationListB removeObjectAtIndex:0]; } // if(self. isAnimationListAFinish == YES){ // // [self playAnimationWithModel]; // self.isAnimationListAFinish = NO; // return; // } [self playAnimationWithModel]; } }]; [candyTreeView pop_addAnimation:moveAnimation forKey:@"moveOutAnimation"]; } }]; [candyTreeView pop_addAnimation:springAnimation forKey:@"candyTreespingOutAnimation"]; } #pragma mark - 贵族升级 - (void)receiveNobleLevelUp:(AttachmentModel *)attachment { [[NetImageView new]loadImageWithUrl:attachment.data[@"avatar"] completion:^(UIImage * _Nonnull image, NSURL * _Nonnull url) { PIBaseAnimationViewModel *nobleModel = [PIBaseAnimationViewModel new]; nobleModel.data = attachment.data; nobleModel.type = GiftBannerType_Nobleman; if (self.animationListB.count == 0 && self.isPlayOfB == NO) { [self createNobleLevelUpBannerAnimation:nobleModel]; } [self.animationListB addObject:nobleModel]; }]; } - (void)createNobleLevelUpBannerAnimation:(PIBaseAnimationViewModel *)model { self.isPlayOfB = YES; CGFloat top = self.isPlayOfA == YES ? (self.broadCastHieght + statusbarHeight) : (kNavigationHeight + 15); XPRoomNobleLevelUpView *nobleLevelUpView = [[XPRoomNobleLevelUpView alloc] initWithFrame:CGRectMake(KScreenWidth, top, KScreenWidth, 90)]; nobleLevelUpView.nobleInfo = model.data; [kWindow addSubview:nobleLevelUpView]; @kWeakify(self); @kWeakify(nobleLevelUpView); nobleLevelUpView.completionBlock = ^{ @kStrongify(self); @kStrongify(nobleLevelUpView); POPSpringAnimation *springAnimation = [POPSpringAnimation animationWithPropertyNamed:kPOPViewCenter]; springAnimation.springSpeed = 12; springAnimation.springBounciness = 10.f; springAnimation.fromValue = [NSValue valueWithCGPoint:nobleLevelUpView.center]; springAnimation.toValue = [NSValue valueWithCGPoint:CGPointMake(nobleLevelUpView.frame.size.width / 2, nobleLevelUpView.center.y)]; dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(6.0 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{ POPBasicAnimation *moveAnimation = [POPBasicAnimation animationWithPropertyNamed:kPOPViewCenter]; moveAnimation.fromValue = [NSValue valueWithCGPoint:CGPointMake(0, nobleLevelUpView.center.y)]; moveAnimation.toValue = [NSValue valueWithCGPoint:CGPointMake(-KScreenWidth/2, nobleLevelUpView.center.y)]; moveAnimation.beginTime = CACurrentMediaTime() + 3; moveAnimation.duration = 0.5; moveAnimation.repeatCount = 1; moveAnimation.removedOnCompletion = YES; @kWeakify(self); [moveAnimation setCompletionBlock:^(POPAnimation *anim, BOOL finished) { @kStrongify(self); if (finished) { self.isPlayOfB = NO; [nobleLevelUpView removeFromSuperview]; if (self.animationListB.count > 0) { [self.animationListB removeObjectAtIndex:0]; } // if(self.isAnimationListAFinish == YES){ // // [self playAnimationWithModel]; // self.isAnimationListAFinish = NO; // return; // } [self playAnimationWithModel]; } }]; [nobleLevelUpView pop_addAnimation:moveAnimation forKey:@"moveOutAnimation"]; }); [nobleLevelUpView pop_addAnimation:springAnimation forKey:@"nobleLevelUpspingOutAnimation"]; }; } #pragma mark - 收到星级厨房飘屏 -(void)receiveRoomGraffitiStarKitchen:(AttachmentModel *)attacment{ PIBaseAnimationViewModel *roomGraffiti = [PIBaseAnimationViewModel new]; roomGraffiti.data = attacment.data; roomGraffiti.type = GiftBannerType_kitchen; roomGraffiti.first = attacment.first; roomGraffiti.second = attacment.second; if(self.animationListB.count == 0 && self.isPlayOfB == NO){ [self createStarKitchenBannerAnimation:roomGraffiti]; } [self.animationListB addObject:roomGraffiti]; } - (void)createStarKitchenBannerAnimation:(PIBaseAnimationViewModel *)attacment{ self.isPlayOfB = YES; CGFloat top = self.isPlayOfA == YES ? (self.broadCastHieght + statusbarHeight) : (kNavigationHeight + 15); XPRoomStarKitchenBannerView *starKitchenView = [[XPRoomStarKitchenBannerView alloc]initWithFrame:CGRectMake(0, top, KScreenWidth, kGetScaleWidth(60))]; starKitchenView.isSvga = attacment.second == Custom_Message_Sub_Star_Kitchen_FullScreen; XPRoomStarKitchenModel *starModel = [XPRoomStarKitchenModel modelWithDictionary:attacment.data]; starKitchenView.delegate = self; starKitchenView.starModel = starModel; [kWindow addSubview:starKitchenView]; POPSpringAnimation *springAnimation = [POPSpringAnimation animationWithPropertyNamed:kPOPViewCenter]; springAnimation.springSpeed = 12; springAnimation.springBounciness = 10.f; springAnimation.fromValue = [NSValue valueWithCGPoint:starKitchenView.center]; springAnimation.toValue = [NSValue valueWithCGPoint:CGPointMake(starKitchenView.frame.size.width / 2, starKitchenView.center.y)]; [springAnimation setCompletionBlock:^(POPAnimation *anim, BOOL finished) { if (finished) { POPBasicAnimation *moveAnimation = [POPBasicAnimation animationWithPropertyNamed:kPOPViewCenter]; moveAnimation.fromValue = [NSValue valueWithCGPoint:CGPointMake(0, starKitchenView.center.y)]; moveAnimation.toValue = [NSValue valueWithCGPoint:CGPointMake(-KScreenWidth/2, starKitchenView.center.y)]; moveAnimation.beginTime = CACurrentMediaTime() + 3; moveAnimation.duration = 0.5; moveAnimation.repeatCount = 1; moveAnimation.removedOnCompletion = YES; @kWeakify(self); [moveAnimation setCompletionBlock:^(POPAnimation *anim, BOOL finished) { @kStrongify(self); if (finished) { [starKitchenView removeFromSuperview]; self.isPlayOfB = NO; if(self.animationListB.count > 0){ [self.animationListB removeObjectAtIndex:0]; } // if(self. isAnimationListAFinish == YES){ // // [self playAnimationWithModel]; // self.isAnimationListAFinish = NO; // return; // } [self playAnimationWithModel]; } }]; [starKitchenView pop_addAnimation:moveAnimation forKey:@"moveOutAnimation"]; } }]; [starKitchenView pop_addAnimation:springAnimation forKey:@"starKitchenOutAnimation"]; } #pragma mark - XPRoomStarKitchenBannerViewDelegate - (void)xPRoomStarKitchenBannerView:(XPRoomStarKitchenBannerView *)view didClick:(XPRoomStarKitchenModel *)starModel{ if(starModel.skipUrl == nil || starModel.skipUrl.length == 0)return; XPWebViewController * webVC = [[XPWebViewController alloc] init]; webVC.isPush = YES; webVC.roomUid = starModel.roomUid; webVC.url = starModel.skipUrl; [[XCCurrentVCStackManager shareManager].getCurrentVC.navigationController pushViewController:webVC animated:YES]; } #pragma mark - XPRoomAnchorRankBannerViewDelegate - (void)xPRoomAnchorRankBannerView:(XPRoomAnchorRankBannerView *)view rankInfo:(RoomHalfHourRankModel *)rankInfo{ [XPRoomViewController openRoom:rankInfo.uid viewController:[XCCurrentVCStackManager shareManager].getCurrentVC]; } #pragma mark - 个播小时榜飘屏或牌照房小时榜飘屏 - (void)receiveAnchorHourRank:(AttachmentModel *)attachment { PIBaseAnimationViewModel *anchorModel =[PIBaseAnimationViewModel new]; anchorModel.data = attachment.data; anchorModel.type = GiftBannerType_AnchorHour; if(self.animationListB.count == 0 && self.isPlayOfB == NO){ [self createAnchorHourRankAnimation:anchorModel]; } [self.animationListB addObject:anchorModel]; } - (void)createAnchorHourRankAnimation:(PIBaseAnimationViewModel *)attachment { self.isPlayOfB = YES; CGFloat top = self.isPlayOfA == YES ? (self.broadCastHieght + statusbarHeight) : (kNavigationHeight + 15); XPRoomAnchorRankBannerView *anchorRankView = [[XPRoomAnchorRankBannerView alloc] initWithFrame:CGRectMake(KScreenWidth,top, KScreenWidth, kGetScaleWidth(55))]; anchorRankView.anchorRankInfo = [RoomHalfHourRankModel modelWithDictionary:attachment.data]; anchorRankView.delegate = self; UITapGestureRecognizer *tap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(gotoTopRankAnchorRoom:)]; [anchorRankView addGestureRecognizer:tap]; [kWindow addSubview:anchorRankView]; POPSpringAnimation *springAnimation = [POPSpringAnimation animationWithPropertyNamed:kPOPViewCenter]; springAnimation.springSpeed = 12; springAnimation.springBounciness = 10.f; springAnimation.fromValue = [NSValue valueWithCGPoint:anchorRankView.center]; springAnimation.toValue = [NSValue valueWithCGPoint:CGPointMake(anchorRankView.frame.size.width / 2, anchorRankView.center.y)]; [springAnimation setCompletionBlock:^(POPAnimation *anim, BOOL finished) { if (finished) { POPBasicAnimation *moveAnimation = [POPBasicAnimation animationWithPropertyNamed:kPOPViewCenter]; moveAnimation.fromValue = [NSValue valueWithCGPoint:CGPointMake(0, anchorRankView.center.y)]; moveAnimation.toValue = [NSValue valueWithCGPoint:CGPointMake(-KScreenWidth/2, anchorRankView.center.y)]; moveAnimation.beginTime = CACurrentMediaTime() + 3; moveAnimation.duration = 0.5; moveAnimation.repeatCount = 1; moveAnimation.removedOnCompletion = YES; [moveAnimation setCompletionBlock:^(POPAnimation *anim, BOOL finished) { [anchorRankView removeFromSuperview]; self.isPlayOfB = NO; if(self.animationListB.count > 0){ [self.animationListB removeObjectAtIndex:0]; } // if(self.isAnimationListAFinish == YES){ // self.isAnimationListAFinish = NO; // [self playAnimationWithModel]; // return; // } [self playAnimationWithModel]; }]; [anchorRankView pop_addAnimation:moveAnimation forKey:@"moveOutAnimation"]; } }]; [anchorRankView pop_addAnimation:springAnimation forKey:@"nobleLevelUpspingOutAnimation"]; } - (void)gotoTopRankAnchorRoom:(UITapGestureRecognizer *)tap { XPRoomAnchorRankBannerView * view = (XPRoomAnchorRankBannerView *)tap.view; if (view.anchorRankInfo.uid.integerValue > 0) { [XPRoomViewController openRoom:view.anchorRankInfo.uid viewController:[XCCurrentVCStackManager shareManager].getCurrentVC]; } } #pragma mark - 懒加载 - (NSMutableArray *)animationListA{ if(!_animationListA){ _animationListA = [NSMutableArray array]; } return _animationListA; } - (NSMutableArray *)animationListB{ if(!_animationListB){ _animationListB = [NSMutableArray array]; } return _animationListB; } - (CGFloat)broadCastHieght{ if(_broadCastHieght == 0){ _broadCastHieght = 190 - 150 + kGetScaleWidth(69); } return _broadCastHieght; } @end