From f963f0ed8133503ca37bd382a23acc451464aba3 Mon Sep 17 00:00:00 2001 From: edwinQQQ Date: Thu, 16 Jan 2025 16:00:12 +0800 Subject: [PATCH] =?UTF-8?q?=E5=AE=8C=E6=88=90=E6=88=BF=E9=97=B4=E5=8A=A8?= =?UTF-8?q?=E7=94=BB=E7=B1=BB=E9=87=8D=E6=9E=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../AnimationView/GameUniversalBannerView.m | 8 +- .../View/AnimationView/RoomAnimationView.m | 1398 ++++++++++++++++- .../View/AnimationView/XPRoomAnimationView.m | 4 +- 3 files changed, 1336 insertions(+), 74 deletions(-) diff --git a/YuMi/Modules/YMRoom/View/AnimationView/GameUniversalBannerView.m b/YuMi/Modules/YMRoom/View/AnimationView/GameUniversalBannerView.m index 77e08f45..b0791264 100644 --- a/YuMi/Modules/YMRoom/View/AnimationView/GameUniversalBannerView.m +++ b/YuMi/Modules/YMRoom/View/AnimationView/GameUniversalBannerView.m @@ -38,20 +38,22 @@ CGFloat height = kGetScaleWidth(70); PIUniversalBannerModel *model = [PIUniversalBannerModel modelWithDictionary:attachment.data]; - GameUniversalBannerView *bannerView = [[GameUniversalBannerView alloc] initWithFrame:CGRectMake(KScreenWidth, 80, width, height)]; + GameUniversalBannerView *bannerView = [[GameUniversalBannerView alloc] initWithFrame:CGRectMake(KScreenWidth, 0, width, height)]; bannerView.model = model; bannerView.completeDisplay = complete; bannerView.didTapGo = go; bannerView.gameID = model.skipContent; [superView addSubview:bannerView]; + // TODO: 添加手势 | 调整为 pop 动画 + @kWeakify(bannerView); [UIView animateWithDuration:0.25 animations:^{ - bannerView.center = CGPointMake(superView.center.x, height/2 + 80); + bannerView.center = CGPointMake(superView.center.x, height/2 + 0); } completion:^(BOOL finished) { dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(2.5 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{ [UIView animateWithDuration:0.25 delay:0 options:UIViewAnimationOptionCurveEaseInOut animations:^{ - bannerView.frame = CGRectMake(-KScreenWidth, 80, width, height); + bannerView.frame = CGRectMake(-KScreenWidth, 0, width, height); } completion:^(BOOL finished) { @kStrongify(bannerView); [bannerView removeFromSuperview]; diff --git a/YuMi/Modules/YMRoom/View/AnimationView/RoomAnimationView.m b/YuMi/Modules/YMRoom/View/AnimationView/RoomAnimationView.m index 51a9828a..80ff8f7d 100644 --- a/YuMi/Modules/YMRoom/View/AnimationView/RoomAnimationView.m +++ b/YuMi/Modules/YMRoom/View/AnimationView/RoomAnimationView.m @@ -11,6 +11,7 @@ #import #import #import +#import #import "UIView+VAP.h" @@ -45,6 +46,27 @@ #import "LuckyGiftWinningBannerView.h" #import "RoomHighValueGiftBannerAnimation.h" +#import "XCCurrentVCStackManager.h" + +// Old Methods +#import "DatingInfoModel.h" +#import "XPWebViewController.h" +#import "XPRoomCandyGiftView.h" +#import "XPSailingAnimationView.h" +#import "AcrossRoomPKPrizeModel.h" +#import "XPRoomNobleLevelUpView.h" +#import "XPRoomTarrowBannerView.h" +#import "XPRoomGiftCompoundView.h" +#import "XPRoomGiftBroadcastView.h" +#import "XPRoomLuckyBigPrizeView.h" +#import "XPTreasureFairyGiftView.h" +#import "XPAcrossRoomPKPrizeView.h" +#import "PIRoomGiftBroadcastWindow.h" +#import "XPRoomDatingAnimationView.h" +#import "XPRoomAnchorRankBannerView.h" +#import "XPRoomStarKitchenBannerView.h" +#import "XPRoomGraffitiGiftAnimationView.h" + static const CGFloat kTipViewStayDuration = 3.0; static const CGFloat kTipViewMoveDuration = 0.5; @@ -53,9 +75,15 @@ PAGViewListener, SVGAPlayerDelegate, HWDMP4PlayDelegate, GiftAnimationDelegate, -NIMBroadcastManagerDelegate - +NIMBroadcastManagerDelegate, +PIUniversalBannerViewDelegate, +XPRoomGiftBroadcastViewDelegate, +XPRoomLuckyBigPrizeViewDelegate, +PIRoomGiftBroadcastWindowDelegate, +XPRoomAnchorRankBannerViewDelegate, +XPRoomStarKitchenBannerViewDelegate, +XPRoomGraffitiGiftAnimationViewDelegate > @property (nonatomic, weak) idhostDelegate; @@ -82,7 +110,7 @@ NIMBroadcastManagerDelegate @property(nonatomic, assign) BOOL isPlayingGiftEffect; @property(nonatomic, strong) NSMutableArray *svgaQueue; @property(nonatomic, strong) VAPView *vapGiftEffectView; -@property(nonatomic,strong) SVGAImageView *vggGiftEffectView; +@property(nonatomic, strong) SVGAImageView *vggGiftEffectView; @property(nonatomic, strong) NSMutableArray *mp4AvatarLoaders; @property(nonatomic, copy) NSString *GiftDynamicEffectListPath; @property(nonatomic, strong) dispatch_source_t giftEffectTimer; @@ -103,6 +131,20 @@ NIMBroadcastManagerDelegate @property(nonatomic, strong) SVGAImageView *carSVGAEffectView; @property(nonatomic, strong) NSMutableArray *carEffectQueue; +/// --- 旧逻辑,有需要再重构 +@property(nonatomic, assign) BOOL isPlayOfB; +@property(nonatomic, strong) NSMutableArray *animationListB; // 玩法 +@property(nonatomic, assign) CGFloat broadCastHieght; +@property(nonatomic, assign) BOOL isLuckyGiftAnimation; +@property (nonatomic, strong) NetImageView *imageLoader; +@property (nonatomic, strong) SVGAImageView *datingEffectView; +@property (nonatomic, strong) NSMutableArray *sailingQueue; +@property (nonatomic, strong) NSMutableArray *datingEffectQueue; +@property (nonatomic, strong) NSMutableArray *graffitiGiftQueue; +@property (nonatomic, strong) NSMutableArray *acrossRoomPKQueue; +@property (nonatomic,strong) SVGAImageView *luckyGiftEffectView; ///福袋礼物送礼物的特效 +@property (nonatomic, strong) VAPView *luckyVapGiftEffectView; ///福袋礼物VAP特效 + @end @implementation RoomAnimationView @@ -150,6 +192,7 @@ NIMBroadcastManagerDelegate [self setupGiftEffects]; [self setupBanner]; [self setupCar]; + [self setupOldMethods]; } - (void)setupUI { @@ -170,7 +213,8 @@ NIMBroadcastManagerDelegate [self.bannerContainer mas_makeConstraints:^(MASConstraintMaker *make) { make.top.mas_equalTo(self).offset(kNavigationHeight); make.leading.trailing.mas_equalTo(self); - make.bottom.mas_equalTo(self.mas_centerY); +// make.bottom.mas_equalTo(self.mas_centerY); + make.height.mas_equalTo(180); }]; } @@ -196,6 +240,15 @@ NIMBroadcastManagerDelegate _carEffectQueue = [NSMutableArray array]; } +- (void)setupOldMethods { + _broadCastHieght = 190 - 150 + kGetScaleWidth(69); + _sailingQueue = @[].mutableCopy; + _datingEffectQueue = @[].mutableCopy; + _graffitiGiftQueue = @[].mutableCopy; + _acrossRoomPKQueue = @[].mutableCopy; + _animationListB = @[].mutableCopy; +} + #pragma mark - Method: Enter Roooooom - (void)enterRoom:(NIMMessage *)message content:(NIMChatroomNotificationContent *)content { NIMMessageChatroomExtension *messageExt = (NIMMessageChatroomExtension *)message.messageExt; @@ -505,10 +558,10 @@ NIMBroadcastManagerDelegate attachment.second == Custom_Message_Sub_General_Floating_Screen_All_Room)) { [self receiveGameBanner:attachment]; } else { -// if(self.animationListB.count == 0 && self.isPlayOfB == NO){ -// [self createGeneralFloatingScreenAnimation:roomGraffiti bannerModel:model]; -// } -// [self.animationListB addObject:roomGraffiti]; + if(self.animationListB.count == 0 && self.isPlayOfB == NO){ + [self createGeneralFloatingScreenAnimation:roomGraffiti bannerModel:model]; + } + [self.animationListB addObject:roomGraffiti]; } } @@ -666,7 +719,10 @@ NIMBroadcastManagerDelegate receiveInfo.vggUrl = giftInfo.vggUrl; } - [self.giftAnimationManager enqueueGift:receiveInfo]; + if (attachment.second != Custom_Message_Sub_Gift_EmbeddedStyle) { + // Custom_Message_Sub_Gift_EmbeddedStyle 只需播放特效 + [self.giftAnimationManager enqueueGift:receiveInfo]; + } } - (void)receiveGift:(GiftReceiveInfoModel *)receiveInfo { @@ -674,13 +730,14 @@ NIMBroadcastManagerDelegate return; } - // 单独处理 combo + // 处理 combo [[GiftComboManager sharedManager] receiveGiftInfoForDisplayComboFlags:receiveInfo container:self]; - RoomInfoModel * roomInfo = [self.hostDelegate getRoomInfo]; if (receiveInfo.isLuckyBagGift) { - + if (receiveInfo.isShowAnimation) { + [self handleLuckyBagGifts:receiveInfo]; + } } else { if (![NSString isEmpty:receiveInfo.mp4Url] || ![NSString isEmpty:receiveInfo.vggUrl]) { [self.svgaQueue addObject:receiveInfo]; @@ -693,6 +750,41 @@ NIMBroadcastManagerDelegate } } +- (void)handleLuckyBagGifts:(GiftReceiveInfoModel *)receiveInfo { + //如果是福袋礼物的话 就不用看他的价值了 只要有SVGA的话 就播放 + // MARK: 此代码从 XPRoomAnimationView copy 而来,暂时无法确认其正确性 + RoomInfoModel * roomInfo = [self.hostDelegate getRoomInfo]; + if (receiveInfo.displayGift.count > 0) { + [receiveInfo.displayGift enumerateObjectsUsingBlock:^(GiftInfoModel * _Nonnull obj, NSUInteger idx, BOOL * _Nonnull stop) { + if ((obj.otherViewType == GiftOtherViewTypeMp4 || obj.otherViewType == GiftOtherViewTypePag) && obj.viewUrl && obj.viewUrl.length > 0 && roomInfo.hasAnimationEffect) { + GiftReceiveInfoModel * model = [[GiftReceiveInfoModel alloc] init]; + model.mp4Url = obj.viewUrl; + model.avatar = receiveInfo.sendUserAvatar; + model.gift = obj; + model.giftNum = [obj.giftNum integerValue];; + model.nick = receiveInfo.nick; + model.targetUids = receiveInfo.targetUids; + model.isBatch = receiveInfo.isBatch; + model.targetAvatar = receiveInfo.targetAvatar; + model.targetNick = receiveInfo.targetNick; + [self.svgaQueue addObject:model]; + } else if (obj.hasVggPic && roomInfo.hasAnimationEffect) { + GiftReceiveInfoModel * model = [[GiftReceiveInfoModel alloc] init]; + model.mp4Url = obj.viewUrl; + model.avatar = receiveInfo.sendUserAvatar; + model.gift = obj; + model.giftNum = [obj.giftNum integerValue];; + model.nick = receiveInfo.nick; + model.targetUids = receiveInfo.targetUids; + model.isBatch = receiveInfo.isBatch; + model.targetAvatar = receiveInfo.targetAvatar; + model.targetNick = receiveInfo.targetNick; + [self.svgaQueue addObject:model]; + } + }]; + } +} + - (void)startHandleGiftEffectTimer { NSTimeInterval period = 2.0; dispatch_queue_t queue = dispatch_get_global_queue(0, 0); @@ -741,7 +833,7 @@ NIMBroadcastManagerDelegate if (![NSString isEmpty:receiveInfo.mp4Url]) { [self stopCarEffect:giftInfo.goldPrice]; targetURL = receiveInfo.mp4Url; - [self playGiftEffectWithPagUrl:giftInfo.viewUrl]; + [self playLuckyGiftEffectWithVapUrl:receiveInfo.mp4Url]; } else if (![NSString isEmpty:receiveInfo.luckyGiftSvgaUrl]) { [self stopCarEffect:giftInfo.goldPrice]; targetURL = receiveInfo.luckyGiftSvgaUrl; @@ -961,11 +1053,10 @@ NIMBroadcastManagerDelegate else if (container == self.vapGiftEffectView) { [self playVAGEnd]; } -// else -// if(container == self.luckyVapGiftEffectView) { -// [self.luckyVapGiftEffectView removeFromSuperview]; -// self.luckyVapGiftEffectView = nil; -// } + else if(container == self.luckyVapGiftEffectView) { + [self.luckyVapGiftEffectView removeFromSuperview]; + self.luckyVapGiftEffectView = nil; + } }); } @@ -979,13 +1070,10 @@ NIMBroadcastManagerDelegate else if (container == self.vapGiftEffectView) { [self playVAGEnd]; } -// else if(container == self.luckyVapGiftEffectView) { -// [self.luckyVapGiftEffectView removeFromSuperview]; -// self.luckyVapGiftEffectView = nil; -// } else if(container == self.wishGiftEffectView) { -// [self.wishGiftEffectView removeFromSuperview]; -// self.wishGiftEffectView = nil; -// } + else if(container == self.luckyVapGiftEffectView) { + [self.luckyVapGiftEffectView removeFromSuperview]; + self.luckyVapGiftEffectView = nil; + } }); } @@ -1099,46 +1187,47 @@ NIMBroadcastManagerDelegate [self _handleCommonBanner:attachment]; break; case CustomMessageType_LuckyBag: - // TODO: 福袋 + [self handleLuckyBag:attachment]; break; case CustomMessageType_Look_Love: - // TODO: 寻爱 / 砸蛋 + [self handle98:attachment]; break; case CustomMessageType_RoomPlay_Dating: - // TODO: 相亲 + [self handleDating:attachment]; break; case CustomMessageType_Across_Room_PK: - // TODO: 跨房/个播 PK + [self handleAcrossRoomPK:attachment]; break; case CustomMessageType_Anchor_FansTeam: - // TODO: 个播粉丝团 + [self handleAnchorFansTeam:attachment]; break; case CustomMessageType_Anchor_Hour_Rank: - // TODO: 个播小时榜 + [self handleAnchorHourRank:attachment]; break; case CustomMessageType_License_Hour_Rank: - // TODO: 牌照房小时榜 + [self handleLicenseHourRank:attachment]; break; case CustomMessageType_Gift_Compound: - // TODO: 魔法小屋合成礼物 + [self handle93:attachment]; break; case CustomMessageType_Room_Sailing: - // TODO: 航海 + [self handle81:attachment]; break; - case CustomMessageType_Graffiti_Gift: - // TODO: 涂鸦礼物 + case CustomMessageType_Graffiti_Gift: { + [self receiveRoomGraffitiGift:attachment]; + } break; case CustomMessageType_Graffiti_Star_Kitchen: - // TODO: 星级厨房飘屏 + [self handle104:attachment]; break; case CustomMessageType_Treasure_Fairy: - // TODO: 夺宝精灵 + [self handleFairy:attachment]; break; case CustomMessageType_Tarot: - // TODO: 夺宝精灵 + [self handleTarot:attachment]; break; case CustomMessageType_Common_H5: - // TODO: 通用 H5 页面 + [self handleCommonH5:attachment]; break; default: break; @@ -1166,17 +1255,10 @@ NIMBroadcastManagerDelegate [self _handleGift:receiveInfo attachment:attachment]; break; case Custom_Message_Sub_Gift_ChannelNotify: -#if DEBUG -// [self playLuckyWinningBanner:attachment]; -// return; -#endif //处理原广播通用飘屏 banner 逻辑 [self receiveRoomGiftBanner:attachment]; return; break; - case Custom_Message_Sub_Gift_LuckySend: - // TODO: 福袋礼物 - break; case Custom_Message_Sub_Gift_EmbeddedStyle: [self _handleGiftEmbeddedStyle:receiveInfo attachment:attachment]; break; @@ -1288,6 +1370,216 @@ NIMBroadcastManagerDelegate } } +- (void)handleCommonH5:(AttachmentModel *)attachment { + if (!attachment) { + return; + } + + switch (attachment.second) { + case Custom_Message_Sub_Common_H5_Novice: + case Custom_Message_Sub_Common_H5_Advanced: + [self receiveCommonH5Banner:attachment]; + break; + + default: + break; + } +} + +- (void)handleTarot:(AttachmentModel *)attachment { + if (!attachment) { + return; + } + switch (attachment.second) { + case Custom_Message_Sub_Tarot_Advanced: + case Custom_Message_Sub_Tarot_Intermediate: + [self receiveTarotBanner:attachment]; + break; + + default: + break; + } +} + +- (void)handleFairy:(AttachmentModel *)attachment { + if (!attachment) { + return; + } + switch (attachment.second) { + case Custom_Message_Sub_Treasure_Fairy_Draw_Gift_L4: + case Custom_Message_Sub_Treasure_Fairy_Draw_Gift_L5: + case Custom_Message_Sub_Treasure_Fairy_Convert_L1: + case Custom_Message_Sub_Treasure_Fairy_Convert_L2: + case Custom_Message_Sub_Treasure_Fairy_Convert_L3: + [self receiveTreasureFairyGiftHighLevel:attachment]; + break; + + default: + break; + } +} + +- (void)handle98:(AttachmentModel *)attachment { + if (!attachment) { + return; + } + switch (attachment.second) { + case Custom_Message_Sub_Look_Love_InRoom_NeedAllMicSend: + [self receiveCandyTreeGiftHighLevle:attachment]; + break; + + default: + break; + } +} + +- (void)handle104:(AttachmentModel *)attachment { + if (!attachment) { + return; + } + switch (attachment.second) { + case Custom_Message_Sub_Star_Kitchen_FullScreen: + [self receiveRoomGraffitiStarKitchen:attachment]; + break; + + default: + break; + } +} + +- (void)handleLuckyBag:(AttachmentModel *)attachment { + if (!attachment) { + return; + } + switch (attachment.second) { + case Custom_Message_Sub_Room_Gift_LuckBag_FullScree: + [self receiveLuckyGiftBigPrize:attachment]; + break; + + default: + break; + } +} + +- (void)handleVIPLevelUp:(AttachmentModel *)attachment { + if (!attachment) { + return; + } + switch (attachment.second) { + case Custom_Message_Sub_Room_Noble_LevelUp_Suspend: + [self receiveNobleLevelUp:attachment]; + break; + + default: + break; + } +} + +- (void)handleDating:(AttachmentModel *)attachment { + if (!attachment) { + return; + } + switch (attachment.second) { + case Custom_Message_Sub_Room_Play_Dating_Public_Result: + [self roomDatingPublicResult:attachment]; + break; + + default: + break; + } +} + +- (void)handleAcrossRoomPK:(AttachmentModel *)attachment { + if (!attachment) { + return; + } + switch (attachment.second) { + case Custom_Message_Sub_AcrossRoomPK_Result: + [self acrossRoomPKBannerAnimation:attachment]; + break; + + default: + break; + } +} + +- (void)handleAnchorFansTeam:(AttachmentModel *)attachment { + if (!attachment) { + return; + } + switch (attachment.second) { + case Custom_Message_Sub_FansTeam_Join_Success: { + GiftReceiveInfoModel *receiveInfo = [[GiftReceiveInfoModel alloc] init]; + GiftInfoModel *giftInfo = [GiftInfoModel modelWithJSON:attachment.data[@"giftVo"]]; + receiveInfo.gift = giftInfo; + receiveInfo.giftInfo = giftInfo; + [self receiveFansTeamGiftHandleSendGiftAnimation:attachment]; + [self receiveGift:receiveInfo]; + } + break; + + default: + break; + } +} + +- (void)handleAnchorHourRank:(AttachmentModel *)attachment { + if (!attachment) { + return; + } + switch (attachment.second) { + case Custom_Message_Sub_Anchor_Hour_Rank: + [self receiveAnchorHourRank:attachment]; + break; + + default: + break; + } +} + +- (void)handleLicenseHourRank:(AttachmentModel *)attachment { + if (!attachment) { + return; + } + switch (attachment.second) { + case Custom_Message_Sub_License_Hour_Rank: + [self receiveAnchorHourRank:attachment]; + break; + + default: + break; + } +} + +- (void)handle93:(AttachmentModel *)attachment { + if (!attachment) { + return; + } + switch (attachment.second) { + case Custom_Message_Sub_Gift_Compound: + [self receiveGiftCompound:attachment]; + break; + + default: + break; + } +} + +- (void)handle81:(AttachmentModel *)attachment { + if (!attachment) { + return; + } + switch (attachment.second) { + case Custom_Message_Sub_Sailing_AllRoom_Notify: + case Custom_Message_Sub_Sailing_InRoom_NeedAllMicSend: + [self receiveRoomSailing:attachment]; + break; + + default: + break; + } +} + #pragma mark - RoomGuestDelegate: NIMNotificationMessageDelegate - (void)handleNIMNotificationMessage:(NIMMessage *)message { NIMNotificationObject *notiMsg = (NIMNotificationObject *)message.messageObject; @@ -1320,6 +1612,27 @@ NIMBroadcastManagerDelegate case CustomMessageType_General_Floating_Screen: [self _handleCommonBanner:attachment]; break; + case CustomMessageType_Noble_VIP: + [self handleVIPLevelUp:attachment]; + break; + case CustomMessageType_LuckyBag: + [self handleLuckyBag:attachment]; + break; + case CustomMessageType_Graffiti_Star_Kitchen: + [self handle104:attachment]; + break; + case CustomMessageType_Look_Love: + [self handle98:attachment]; + break; + case CustomMessageType_Treasure_Fairy: + [self handleFairy:attachment]; + break; + case CustomMessageType_Tarot: + [self handleTarot:attachment]; + break; + case CustomMessageType_Common_H5: + [self handleCommonH5:attachment]; + break; default: break; @@ -1453,25 +1766,6 @@ NIMBroadcastManagerDelegate return @""; } -- (void)_handleLuckyBagGift:(GiftReceiveInfoModel *)receiveInfo attachment:(AttachmentModel *)attachment { -// [self receiveGiftHandleSendGiftAnimation:attachment]; -// if (!self.delegate.getRoomInfo.hasAnimationEffect) { -// return; -// } -// if (receiveInfo.viewUrl.length > 0) { -// [self playLuckyGiftEffectWithVapUrl:receiveInfo.viewUrl]; -// } else { -// NSString *svgaString = receiveInfo.luckyGiftSvgaUrl.length > 0 ? receiveInfo.luckyGiftSvgaUrl : receiveInfo.gift.luckyGiftSvgaUrl; -// NSURL * luckyGiftSvgaUrl = [NSURL URLWithString:svgaString]; -// if (luckyGiftSvgaUrl.absoluteString.length > 0) { -// [self playLuckyGiftEffect:luckyGiftSvgaUrl]; -// } -// } -// dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.5 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{ -// [self receiveGift:receiveInfo]; -// }); -} - - (BOOL)_isInSudGame { BOOL isGamePlaying = NO; if (self.hostDelegate.getRoomInfo.type == RoomType_MiniGame) { @@ -1529,9 +1823,9 @@ NIMBroadcastManagerDelegate - (XPRoomAnimationHitView *)bannerContainer { if (!_bannerContainer) { _bannerContainer = [[XPRoomAnimationHitView alloc] init]; -#if DEBUG - _bannerContainer.backgroundColor = [UIColor colorWithWhite:1 alpha:0.4]; -#endif +//#if DEBUG +// _bannerContainer.backgroundColor = [UIColor colorWithWhite:1 alpha:0.4]; +//#endif } return _bannerContainer; } @@ -1643,4 +1937,970 @@ NIMBroadcastManagerDelegate return _carPagEffectView; } +#pragma mark - OLD METHODs + +-(void)receiveCommonH5Banner:(AttachmentModel *)attachment{ + if ([self _isInSudGame]) {return;} + 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); + CGFloat top = (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; + [self.middleContainer 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]; + } + [self playAnimationWithModel]; + } + }]; + [tarrowVeiw pop_addAnimation:moveAnimation forKey:@"moveOutAnimation"]; + } + }]; + [tarrowVeiw pop_addAnimation:springAnimation forKey:@"candyTreespingOutAnimation"]; +} + +- (void)receiveLuckyGiftBigPrize:(AttachmentModel *)attachment { + if ([self _isInSudGame]) {return;} + + PIBaseAnimationViewModel * prizeModel = [PIBaseAnimationViewModel modelWithDictionary:attachment.data]; + prizeModel.type = GiftBannerType_Lucky; + prizeModel.isInRoomVisable = 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 = (kNavigationHeight + 15); + self.isLuckyGiftAnimation = YES; + XPRoomLuckyBigPrizeView * luckyGiftEffectView = [[XPRoomLuckyBigPrizeView alloc] initWithFrame:CGRectMake(KScreenWidth, top, 375, 71)]; + luckyGiftEffectView.delegate = self; + [self.topContainer 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; + [self playAnimationWithModel]; + } + }]; + [luckyGiftEffectView pop_addAnimation:moveAnimation forKey:@"moveOutAnimation"]; + }); + [luckyGiftEffectView pop_addAnimation:springAnimation forKey:@"nobleLevelUpspingOutAnimation"]; +} + +- (void)receiveCandyTreeGiftHighLevle:(AttachmentModel *)attatchment { + if ([self _isInSudGame]) {return;} + 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 = (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; + [self.middleContainer 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)]; + @kWeakify(self); + [springAnimation setCompletionBlock:^(POPAnimation *anim, BOOL finished) { + @kStrongify(self); + 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]; + } + [self playAnimationWithModel]; + } + }]; + [candyTreeView pop_addAnimation:moveAnimation forKey:@"moveOutAnimation"]; + } + }]; + [candyTreeView pop_addAnimation:springAnimation forKey:@"candyTreespingOutAnimation"]; +} + +- (void)receiveNobleLevelUp:(AttachmentModel *)attachment { + @kWeakify(self); + [[NetImageView new]loadImageWithUrl:attachment.data[@"avatar"] completion:^(UIImage * _Nonnull image, NSURL * _Nonnull url) { + @kStrongify(self); + 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 = (kNavigationHeight + 15); + XPRoomNobleLevelUpView *nobleLevelUpView = [[XPRoomNobleLevelUpView alloc] initWithFrame:CGRectMake(KScreenWidth, top, KScreenWidth, 90)]; + nobleLevelUpView.nobleInfo = model.data; + [self.topContainer 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]; + } + [self playAnimationWithModel]; + } + }]; + [nobleLevelUpView pop_addAnimation:moveAnimation forKey:@"moveOutAnimation"]; + }); + [nobleLevelUpView pop_addAnimation:springAnimation forKey:@"nobleLevelUpspingOutAnimation"]; + }; +} + +-(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 = (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; + [self.topContainer 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]; + } + [self playAnimationWithModel]; + } + }]; + [starKitchenView pop_addAnimation:moveAnimation forKey:@"moveOutAnimation"]; + } + }]; + [starKitchenView pop_addAnimation:springAnimation forKey:@"starKitchenOutAnimation"]; +} + +- (void)createAnchorHourRankAnimation:(PIBaseAnimationViewModel *)attachment { + self.isPlayOfB = YES; + CGFloat top = (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]; + [self.topContainer 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]; + [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) { + [self.hostDelegate exitRoom]; + dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(1 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{ + [XPRoomViewController openRoom:view.anchorRankInfo.uid viewController:[XCCurrentVCStackManager shareManager].getCurrentVC]; + }); + } +} + +- (void)receiveTreasureFairyGiftHighLevel:(AttachmentModel *)attatchment { + if ([self _isInSudGame]) {return;} + 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 { + self.isPlayOfB = YES; + CGFloat kscale = (CGFloat)60 / (CGFloat)375; + CGFloat top = (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; + [self.middleContainer 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]; + } + [self playAnimationWithModel]; + } + }]; + [treasureView pop_addAnimation:moveAnimation forKey:@"moveOutAnimation"]; + } + }]; + [treasureView pop_addAnimation:springAnimation forKey:@"candyTreespingOutAnimation"]; +} + +-(void)receiveTarotBanner:(AttachmentModel *)attachment{ + if ([self _isInSudGame]) {return;} + 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 = (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; + [self.middleContainer 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]; + } + [self playAnimationWithModel]; + } + }]; + [tarrowVeiw pop_addAnimation:moveAnimation forKey:@"moveOutAnimation"]; + } + }]; + [tarrowVeiw pop_addAnimation:springAnimation forKey:@"candyTreespingOutAnimation"]; +} + +- (void)createGiftCompoundBannerAnimation:(PIBaseAnimationViewModel *)attachment { + self.isPlayOfB = YES; + XPRoomGiftCompoundView *compoundGiftView = [[XPRoomGiftCompoundView alloc] initWithFrame:CGRectMake(KScreenWidth, kNavigationHeight + 15, KScreenWidth, 45)]; + compoundGiftView.compoundGiftInfo = attachment.data; + [self.middleContainer addSubview:compoundGiftView]; + POPSpringAnimation *springAnimation = [POPSpringAnimation animationWithPropertyNamed:kPOPViewCenter]; + springAnimation.springSpeed = 12; + springAnimation.springBounciness = 10.f; + springAnimation.fromValue = [NSValue valueWithCGPoint:compoundGiftView.center]; + springAnimation.toValue = [NSValue valueWithCGPoint:CGPointMake(compoundGiftView.frame.size.width / 2, compoundGiftView.center.y)]; + [springAnimation setCompletionBlock:^(POPAnimation *anim, BOOL finished) { + if (finished) { + POPBasicAnimation *moveAnimation = [POPBasicAnimation animationWithPropertyNamed:kPOPViewCenter]; + moveAnimation.fromValue = [NSValue valueWithCGPoint:CGPointMake(0, compoundGiftView.center.y)]; + moveAnimation.toValue = [NSValue valueWithCGPoint:CGPointMake(-KScreenWidth/2, compoundGiftView.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) { + [compoundGiftView removeFromSuperview]; + self.isPlayOfB = NO; + if(self.animationListB.count > 0){ + [self.animationListB removeObjectAtIndex:0]; + } + [self playAnimationWithModel]; + } + }]; + [compoundGiftView pop_addAnimation:moveAnimation forKey:@"moveOutAnimation"]; + } + }]; + [compoundGiftView pop_addAnimation:springAnimation forKey:@"compoundGiftSpingOutAnimation"]; +} + +- (void)createGeneralFloatingScreenAnimation:(PIBaseAnimationViewModel *)attachment bannerModel:(PIUniversalBannerModel *)model { + self.isPlayOfB = YES; + CGFloat top = (kNavigationHeight + 15); + + if (!model) { + model = [PIUniversalBannerModel modelWithDictionary:attachment.data]; + } + + BOOL isSvga = [model.resourceType.uppercaseString isEqualToString:@"SVGA"]; + __block PIUniversalBannerView *bannerView; + @kWeakify(self); + if (isSvga == YES) { + SVGAParser *parser = [SVGAParser new]; + [parser parseWithURL:[NSURL URLWithString:model.resourceContent] completionBlock:^(SVGAVideoEntity * _Nonnull videoItem) { + @kStrongify(self); + model.videoItem = videoItem; + CGFloat height = kGetScaleWidth(60); + if(videoItem.videoSize.width > 0){ + height = KScreenWidth * videoItem.videoSize.height / videoItem.videoSize.width; + } + + bannerView = [[PIUniversalBannerView alloc]initWithFrame:CGRectMake(KScreenWidth, top, KScreenWidth, height)]; + [self showGeneralFloatingScreenView:bannerView model:model]; + } failureBlock:^(NSError * _Nonnull error) { + @kStrongify(self); + [bannerView removeFromSuperview]; + self.isPlayOfB = NO; + if(self.animationListB.count > 0){ + [self.animationListB removeObjectAtIndex:0]; + } + [self playAnimationWithModel]; + }]; + }else{ + if (!_imageLoader) { + _imageLoader = [[NetImageView alloc] init]; + } + [self.imageLoader loadImageWithUrl:model.resourceContent + completion:^(UIImage * _Nonnull image, NSURL * _Nonnull url) { + @kStrongify(self); + model.image = image; + CGFloat width = image.size.width <= 0 ? kGetScaleWidth(60) : image.size.width; + CGFloat height = image.size.height ; + CGFloat getHeight = KScreenWidth * height / width; + if (getHeight > 100) { + getHeight = 100; + } + bannerView = [[PIUniversalBannerView alloc]initWithFrame:CGRectMake(KScreenWidth, top, KScreenWidth, getHeight) ]; + [self showGeneralFloatingScreenView:bannerView model:model]; + + } + fail:^(NSError * _Nonnull error) { + @kStrongify(self); + [bannerView removeFromSuperview]; + 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; + [self.topContainer 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)]; + @kWeakify(self); + [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() + 5; + moveAnimation.duration = 0.5; + moveAnimation.repeatCount = 1; + moveAnimation.removedOnCompletion = YES; + + [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"]; +} + +- (void)roomDatingPublicResult:(AttachmentModel *)attachment { + self.datingEffectQueue = [NSMutableArray array]; + ///心动结果公布的话 结果是一个数组 + NSArray * results = [DatingInfoModel modelsWithArray:attachment.data[@"list"]]; + [self.datingEffectQueue addObjectsFromArray:results]; + if (self.datingEffectQueue.count > 0) { + [self startDatingAnimation:self.datingEffectQueue.firstObject]; + } +} + +- (void)startDatingAnimation:(DatingInfoModel *)datingModel { + [[NSNotificationCenter defaultCenter] postNotificationName:@"message" object:[self createRoomDatingResultMessage:datingModel]]; + NSString * targetUid= [NSString stringWithFormat:@"%ld", datingModel.targetUid]; + NSString * uid= [NSString stringWithFormat:@"%ld", datingModel.uid]; + if (datingModel.hasHeart || datingModel.hasSelectUser) { + datingModel.originPoint = [self.hostDelegate animationPointAtStageViewByUid:uid]; + datingModel.targetPoint = [self.hostDelegate animationPointAtStageViewByUid:targetUid]; + } + XPRoomDatingAnimationView *datingView = [[XPRoomDatingAnimationView alloc] init]; + [self.topContainer addSubview:datingView]; + [datingView startAnimationWithModel:datingModel finishBlock:^(BOOL finish) { + [datingView removeFromSuperview]; + [self.datingEffectQueue removeObject:datingModel]; + if (self.datingEffectQueue.count > 0) { + DatingInfoModel * datingModel = [self.datingEffectQueue firstObject]; + [self startDatingAnimation:datingModel]; + } + }]; +} + +- (NIMMessage *)createRoomDatingResultMessage:(DatingInfoModel *)datingModel { + NIMMessage * message = [[NIMMessage alloc] init]; + NIMSession * session = [NIMSession session:[NSString stringWithFormat:@"%ld", self.hostDelegate.getRoomInfo.roomId] type:NIMSessionTypeChatroom]; + [message setValue:session forKey:@"session"]; + AttachmentModel * attach = [[AttachmentModel alloc] init]; + attach.first = CustomMessageType_RoomPlay_Dating; + if (datingModel.hasHeart) {///如果是互选的话 + attach.second = Custom_Message_Sub_Room_Play_Dating_Result_Mutual; + } else { + attach.second = Custom_Message_Sub_Room_Play_Dating_Result_Not_Mutual; + } + attach.data = [datingModel model2dictionary]; + NIMCustomObject * object = [[NIMCustomObject alloc] init]; + object.attachment = attach; + message.messageObject = object; + return message; +} + +- (void)acrossRoomPKBannerAnimation:(AttachmentModel *)attacment { + AcrossRoomPKPrizeModel * prizeModel = [AcrossRoomPKPrizeModel modelWithJSON:attacment.data]; + if (attacment.second == Custom_Message_Sub_AnchorPK_Result) { + prizeModel.pkType = 1; + } else { + prizeModel.pkType = 0; + } + [self.acrossRoomPKQueue addObject:prizeModel]; + if (self.acrossRoomPKQueue.count == 1 ) {//判断为1个时开始播放,防止多条消息回来后重叠播放 + [self startAcrossRoomPKAnimation:self.acrossRoomPKQueue.firstObject]; + } +} + +- (void)startAcrossRoomPKAnimation:(AcrossRoomPKPrizeModel *)model { + XPAcrossRoomPKPrizeView *wishEffectView = [[XPAcrossRoomPKPrizeView alloc] initWithFrame:CGRectMake(KScreenWidth, kNavigationHeight+40, KScreenWidth, 87)]; + wishEffectView.data = model; + UITapGestureRecognizer *tap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(gotoPkWinRoom:)]; + [wishEffectView addGestureRecognizer:tap]; + [self.topContainer addSubview:wishEffectView]; + [UIView animateWithDuration:0.5 animations:^{ + wishEffectView.frame = CGRectMake(0, kNavigationHeight+40, KScreenWidth, 87); + } completion:^(BOOL finished) { + dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(3.0 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{ + [UIView animateWithDuration:0.5 animations:^{ + wishEffectView.hidden = YES; + } completion:^(BOOL finished) { + [wishEffectView removeFromSuperview]; + [self.acrossRoomPKQueue removeObject:model]; + if (self.acrossRoomPKQueue.count > 0) { + [self startAcrossRoomPKAnimation:self.acrossRoomPKQueue.firstObject]; + } + }]; + }); + }]; +} + +- (void)gotoPkWinRoom:(UITapGestureRecognizer *)tap { + XPAcrossRoomPKPrizeView * view = (XPAcrossRoomPKPrizeView *)tap.view; + if (view.data.winUid.length > 0) { + [self.hostDelegate exitRoom]; + dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(1 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{ + [XPRoomViewController openRoom:view.data.winUid viewController:[XCCurrentVCStackManager shareManager].getCurrentVC]; + }); + } +} + +- (void)receiveFansTeamGiftHandleSendGiftAnimation:(AttachmentModel *)attachment { + if ([self _isInSudGame]) {return;} + if (!self.hostDelegate.getRoomInfo.hasAnimationEffect) {return;} + GiftReceiveInfoModel *receiveInfo = [[GiftReceiveInfoModel alloc] init]; + GiftInfoModel *gift = [GiftInfoModel modelWithJSON:attachment.data[@"giftVo"]]; + receiveInfo.gift = gift; + receiveInfo.giftInfo = gift; + receiveInfo.targetUid = [NSString stringWithFormat:@"%ld", self.hostDelegate.getRoomInfo.uid]; + GiftInfoModel * giftInfo = receiveInfo.gift ? receiveInfo.gift : receiveInfo.giftInfo; + if (attachment.second == Custom_Message_Sub_AllMicroLuckySend || attachment.second == Custom_Message_Sub_AllBatchMicroLuckySend || attachment.second == Custom_Message_Sub_Gift_LuckySend) { + NSString * giftId = [NSString stringWithFormat:@"%ld", receiveInfo.luckyGiftList.giftList.firstObject.giftId]; + giftInfo = [[XPGiftStorage shareStorage] findGiftInfo:giftId]; + } + if (giftInfo == nil) { + giftInfo = [[XPGiftStorage shareStorage] findGiftInfo:receiveInfo.giftId]; + } + + ///在最外面判断是否可以拿到那个礼物 后面使用就不用判断了 + receiveInfo.gift = giftInfo; + receiveInfo.isLuckyBagGift = (attachment.second == Custom_Message_Sub_AllMicroLuckySend || attachment.second == Custom_Message_Sub_AllBatchMicroLuckySend || attachment.second == Custom_Message_Sub_Gift_LuckySend); + [self.giftAnimationManager enqueueGift:receiveInfo]; +} + +- (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)receiveGiftCompound:(AttachmentModel *)attachment { + if ([self _isInSudGame]) {return;} + PIBaseAnimationViewModel *magicModel =[PIBaseAnimationViewModel new]; + magicModel.data = attachment.data; + magicModel.type = GiftBannerType_Magic_House; + if(self.animationListB.count == 0 && self.isPlayOfB == NO){ + [self createGiftCompoundBannerAnimation:magicModel]; + } + [self.animationListB addObject:magicModel]; +} + +- (void)receiveRoomSailing:(AttachmentModel *)attachment { + if ([self _isInSudGame]) {return;} + if (self.sailingQueue.count == 0) { + [self createSailingBannerAnimation:attachment]; + } + [self.sailingQueue addObject:attachment]; +} + +- (void)createSailingBannerAnimation:(AttachmentModel *)attatchment { + CGFloat kscale = (CGFloat)60 / (CGFloat)375; + XPSailingAnimationView *sailingView = [[XPSailingAnimationView alloc] initWithFrame:CGRectMake(KScreenWidth, kNavigationHeight + 15, KScreenWidth, KScreenWidth * kscale)]; + sailingView.prizeInfo = attatchment.data; + [self.middleContainer addSubview:sailingView]; + POPSpringAnimation *springAnimation = [POPSpringAnimation animationWithPropertyNamed:kPOPViewCenter]; + springAnimation.springSpeed = 12; + springAnimation.springBounciness = 10.f; + springAnimation.fromValue = [NSValue valueWithCGPoint:sailingView.center]; + springAnimation.toValue = [NSValue valueWithCGPoint:CGPointMake(sailingView.frame.size.width / 2, sailingView.center.y)]; + [springAnimation setCompletionBlock:^(POPAnimation *anim, BOOL finished) { + if (finished) { + POPBasicAnimation *moveAnimation = [POPBasicAnimation animationWithPropertyNamed:kPOPViewCenter]; + moveAnimation.fromValue = [NSValue valueWithCGPoint:CGPointMake(0, sailingView.center.y)]; + moveAnimation.toValue = [NSValue valueWithCGPoint:CGPointMake(-KScreenWidth/2, sailingView.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) { + [sailingView removeFromSuperview]; + if (self.sailingQueue.count > 0) { + [self.sailingQueue removeObjectAtIndex:0]; + } + if (self.sailingQueue.count > 0) { + [self createSailingBannerAnimation:self.sailingQueue.firstObject]; + } + } + }]; + [sailingView pop_addAnimation:moveAnimation forKey:@"moveOutAnimation"]; + } + }]; + [sailingView pop_addAnimation:springAnimation forKey:@"candyTreespingOutAnimation"]; +} + +- (void)receiveRoomGraffitiGift:(AttachmentModel *)attachment { + if (self.graffitiGiftQueue.count == 0) { + [self startGraffitiGiftAnimation:attachment]; + } + [self.graffitiGiftQueue addObject:attachment]; +} + +- (void)startGraffitiGiftAnimation:(AttachmentModel *)model { + NSDictionary * dic = model.data; + NSNumber * giftId = dic[@"giftId"]; + GiftInfoModel * giftInfo = [[XPGiftStorage shareStorage] findGiftInfo:giftId.stringValue]; + NSArray * array = dic[@"drawFixedArray"]; + if (giftInfo.giftUrl.length > 0 && array.count > 0) { + [[SDWebImageManager sharedManager] loadImageWithURL:[NSURL URLWithString:giftInfo.giftUrl] options:SDWebImageProgressiveLoad progress:nil completed:^(UIImage * _Nullable image, NSData * _Nullable data, NSError * _Nullable error, SDImageCacheType cacheType, BOOL finished, NSURL * _Nullable imageURL) { + if (error == nil && image) { + XPRoomGraffitiGiftAnimationView *graffitiView = [[XPRoomGraffitiGiftAnimationView alloc] initWithFrame:CGRectMake(0, 0, KScreenWidth, KScreenHeight)]; + graffitiView.giftImage = image; + graffitiView.delegate = self; + graffitiView.model = model; + graffitiView.pointArray = array; + [graffitiView beginDrawAnimation]; + [self.topContainer addSubview:graffitiView]; + } else { + [self.graffitiGiftQueue removeObject:model]; + if (self.graffitiGiftQueue.count > 0) { + [self startGraffitiGiftAnimation:self.graffitiGiftQueue.firstObject]; + } + } + }]; + } else { + [self.graffitiGiftQueue removeObject:model]; + if (self.graffitiGiftQueue.count > 0) { + [self startGraffitiGiftAnimation:self.graffitiGiftQueue.firstObject]; + } + } +} + +- (void)playLuckyGiftEffectWithVapUrl:(NSString *)vapUrl { + NSString *encodingUrl = [vapUrl pureURLString]; + encodingUrl = [encodingUrl stringByAddingPercentEncodingWithAllowedCharacters:[NSCharacterSet URLQueryAllowedCharacterSet]]; + NSString *fileName = [[encodingUrl componentsSeparatedByString:@"/"] lastObject]; + NSString *fullPath = [self.GiftDynamicEffectListPath stringByAppendingPathComponent:fileName]; + + if ([[NSFileManager defaultManager] fileExistsAtPath:fullPath]){ + vapUrl = fullPath; + [self _addSubviewToMiddleContainer:self.luckyVapGiftEffectView]; + [self.luckyVapGiftEffectView setMute:NO]; + [self.luckyVapGiftEffectView playHWDMP4:vapUrl repeatCount:1 delegate:self]; + } else { + @kWeakify(self); + [self.vapParser parseWithURL:encodingUrl completionBlock:^(NSString * _Nullable videoUrl) { + @kStrongify(self); + if (videoUrl.length) { + [self _addSubviewToMiddleContainer:self.luckyVapGiftEffectView]; + [self.luckyVapGiftEffectView setMute:NO]; + [self.luckyVapGiftEffectView playHWDMP4:videoUrl repeatCount:1 delegate:self]; + } + } failureBlock:^(NSError * _Nullable error) { + self.luckyVapGiftEffectView.hidden = YES; + }]; + } +} + +-(void)playAnimationWithModel{ + if(self.animationListB.count <= 0){ + 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 createTarotBannerAnimation:model]; + }else if(model.type == GiftBannerType_Common_H5){ + [self createCommonH5BannerAnimation:model]; + }else if(model.type == GiftBannerType_Magic_House){ + [self createGiftCompoundBannerAnimation:model]; + }else if (model.type == GiftBannerType_General_Floating_Screen){ + [self createGeneralFloatingScreenAnimation:model bannerModel:nil]; + } +} + +- (SVGAImageView *)luckyGiftEffectView { + if (!_luckyGiftEffectView) { + _luckyGiftEffectView = [[SVGAImageView alloc]init]; + _luckyGiftEffectView.backgroundColor = [UIColor colorWithWhite:0 alpha:0.5]; + _luckyGiftEffectView.userInteractionEnabled = NO; + _luckyGiftEffectView.delegate = self; + _luckyGiftEffectView.hidden = YES; + } + return _luckyGiftEffectView; +} + +- (VAPView *)luckyVapGiftEffectView { + if (!_luckyVapGiftEffectView) { + _luckyVapGiftEffectView = [[VAPView alloc] initWithFrame:CGRectMake(0, 0, KScreenWidth, KScreenHeight)]; + _luckyVapGiftEffectView.backgroundColor = [UIColor colorWithWhite:0 alpha:0.5]; + _luckyVapGiftEffectView.contentMode = UIViewContentModeScaleAspectFill; + _luckyVapGiftEffectView.hidden = YES; + } + return _luckyVapGiftEffectView; +} + +#pragma mark - Old Methods Delegate: XPRoomGiftBroadcastViewDelegate +- (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 && self.hostDelegate.getRoomInfo.uid != roomUid.integerValue) { + [self.hostDelegate exitRoom]; + 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)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.isInRoomVisable && giftInfo.roomUid.length > 0 && giftInfo.roomUid.integerValue != self.hostDelegate.getRoomInfo.uid) { + [self.hostDelegate exitRoom]; + dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(1 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{ + [XPRoomViewController openRoom:giftInfo.roomUid viewController:[XCCurrentVCStackManager shareManager].getCurrentVC]; + }); + } +} + +- (void)xPRoomStarKitchenBannerView:(XPRoomStarKitchenBannerView *)view didClick:(XPRoomStarKitchenModel *)starModel{ + if(starModel.skipUrl == nil || starModel.skipUrl.length == 0)return; + XPWebViewController * webVC = [[XPWebViewController alloc] initWithRoomUID:starModel.roomUid]; + webVC.isPush = YES; + webVC.url = starModel.skipUrl; + [self.hostDelegate.getCurrentNav pushViewController:webVC animated:YES]; +} + +- (void)xPRoomAnchorRankBannerView:(XPRoomAnchorRankBannerView *)view rankInfo:(RoomHalfHourRankModel *)rankInfo{ + if (rankInfo.uid.integerValue > 0 && self.hostDelegate.getRoomInfo.uid != rankInfo.uid.integerValue) { + [self.hostDelegate exitRoom]; + dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(1 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{ + [XPRoomViewController openRoom:rankInfo.uid viewController:[XCCurrentVCStackManager shareManager].getCurrentVC]; + }); + } +} + +-(void)confirmLeaveForTheRoom:(NSString *_Nonnull)roomUid{ + if (roomUid.length > 0 && self.hostDelegate.getRoomInfo.uid != roomUid.integerValue) { + [self.hostDelegate exitRoom]; + 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)pIUniversalBannerView:(PIUniversalBannerView *)view didClick:(PIUniversalBannerModel *)model{ + if (model.skipType == 2){ + [self.hostDelegate exitRoom]; + dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(1 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{ + [XPRoomViewController openRoom:model.skipContent viewController:[XCCurrentVCStackManager shareManager].getCurrentVC]; + }); + }else if (model.skipType == 3){ + XPWebViewController * webVC = [[XPWebViewController alloc] initWithRoomUID:nil]; + webVC.isPush = YES; + webVC.url = model.skipContent; + [self.hostDelegate.getCurrentNav pushViewController:webVC animated:YES]; + } +} + +- (void)xPRoomGraffitiGiftAnimationViewCompletion:(XPRoomGraffitiGiftAnimationView *)view attachment:(nonnull AttachmentModel *)attachment{ + [view removeFromSuperview]; + if ([self.graffitiGiftQueue containsObject:attachment]) { + [self.graffitiGiftQueue removeObject:attachment]; + } + if (self.graffitiGiftQueue.count > 0) { + [self startGraffitiGiftAnimation:self.graffitiGiftQueue.firstObject]; + } +} + @end diff --git a/YuMi/Modules/YMRoom/View/AnimationView/XPRoomAnimationView.m b/YuMi/Modules/YMRoom/View/AnimationView/XPRoomAnimationView.m index 9a43b9f0..86e2505a 100644 --- a/YuMi/Modules/YMRoom/View/AnimationView/XPRoomAnimationView.m +++ b/YuMi/Modules/YMRoom/View/AnimationView/XPRoomAnimationView.m @@ -269,8 +269,9 @@ GiftAnimationDelegate> return; } if (attachment.first == CustomMessageType_Gift && attachment.second == Custom_Message_Sub_Gift_ChannelNotify){///广播 全服礼物飘屏 + /// // [self receiveBroadcastGift:attachment]; - [self receiveRoomGiftBanner:attachment]; +// [self receiveRoomGiftBanner:attachment]; } else if (attachment.first == CustomMessageType_Noble_VIP && attachment.second == Custom_Message_Sub_Room_Noble_LevelUp_Suspend) {///VIP升级全服飘屏 [self receiveNobleLevelUp:attachment]; }else if(attachment.first == CustomMessageType_LuckyBag && attachment.second == Custom_Message_Sub_Room_Gift_LuckBag_FullScree){ @@ -892,7 +893,6 @@ GiftAnimationDelegate> [self createTreasureFairyBannerAnimation:giftModel]; } [self.animationListB addObject:giftModel]; - } - (void)createTreasureFairyBannerAnimation:(PIBaseAnimationViewModel *)attatchment { self.isPlayOfB = YES;