Files
peko-ios/YuMi/Modules/YMRoom/View/AnimationView/XPRoomAnimationView.m

2958 lines
139 KiB
Mathematica
Raw Normal View History

2023-07-14 18:50:55 +08:00
//
// YMRoomAnimationView.m
// YUMI
//
// Created by YUMI on 2021/12/6.
//
#import "XPRoomAnimationView.h"
///Third
#import <Masonry/Masonry.h>
#import <SVGA.h>
#import <NIMSDK/NIMSDK.h>
#import <POP.h>
#import "QGVAPConfigModel.h"
#import "UIView+VAP.h"
2023-10-28 04:46:10 +08:00
2023-07-14 18:50:55 +08:00
#import <UIImageView+WebCache.h>
2024-04-03 17:18:44 +08:00
#import <libpag/libpag.h>
2023-07-14 18:50:55 +08:00
///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 "XPMessageRemoteExtModel.h"
#import "DatingInfoModel.h"
#import "AcrossRoomPKPrizeModel.h"
#import "RoomHalfHourRankModel.h"
#import "ClientConfig.h"
2024-10-15 20:56:25 +08:00
#import "ActivityInfoModel.h"
2023-07-14 18:50:55 +08:00
///View
2024-03-25 14:39:36 +08:00
2023-07-14 18:50:55 +08:00
#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"
2023-08-10 10:12:19 +08:00
#import "XPTreasureFairyGiftView.h"
2023-09-14 11:16:47 +08:00
#import "XPRoomTarrowBannerView.h"
2023-10-24 12:27:53 +08:00
#import "PIRoomGiftBroadcastWindow.h"
2024-03-20 19:55:26 +08:00
#import "PIUniversalBannerModel.h"
#import "PIUniversalBannerView.h"
2023-10-24 12:27:53 +08:00
#import "GiftComboManager.h"
2024-09-12 14:01:12 +08:00
#import "LuckyGiftWinningFlagView.h"
#import "LuckyGiftWinningBannerView.h"
2023-10-24 12:27:53 +08:00
2024-09-23 18:01:54 +08:00
#import "CPGiftBanner.h"
#import "CPLevelUpAnimation.h"
#import "CPBindingAnimation.h"
2024-10-15 20:56:25 +08:00
#import "MSRoomGameWebVC.h"
#import "GameUniversalBannerView.h"
#import "RoomHighValueGiftBannerAnimation.h"
2024-10-15 20:56:25 +08:00
#import "GiftAnimationManager.h"
2024-09-20 21:19:08 +08:00
@interface XPRoomAnimationView ()<
SVGAPlayerDelegate,
NIMBroadcastManagerDelegate,
XPRoomGiftBroadcastViewDelegate,
HWDMP4PlayDelegate,
XPRoomLuckyBigPrizeViewDelegate,
XPRoomGraffitiGiftAnimationViewDelegate,
XPRoomStarKitchenBannerViewDelegate,
PAGViewListener,
XPRoomAnchorRankBannerViewDelegate,
PIRoomGiftBroadcastWindowDelegate,
PIUniversalBannerViewDelegate,
GiftAnimationDelegate>
2023-07-14 18:50:55 +08:00
///
///
@property (nonatomic,strong) XPRoomAnimationHitView * lowLevelView;
///
@property (nonatomic,strong) XPRoomAnimationHitView * middleLevelView;
///
@property (nonatomic,strong) XPRoomAnimationHitView * highLevleView;
2023-07-21 14:07:04 +08:00
@property(nonatomic,strong) UIStackView *highSTackView;
2023-07-14 18:50:55 +08:00
///
@property (strong, nonatomic) SVGAParser *parser;
///VAP
@property (nonatomic, strong) XPRoomGiftAnimationParser *vapParser;
///
@property (nonatomic,strong) SVGAImageView *giftEffectView;
///pag
@property(nonatomic,strong) PAGView *giftPagView;
2023-07-14 18:50:55 +08:00
///VAP
@property (nonatomic, strong) VAPView *vapGiftEffectView;
///
@property (nonatomic,strong) SVGAImageView *luckyGiftEffectView;
///VAP
@property (nonatomic, strong) VAPView *luckyVapGiftEffectView;
///
@property (nonatomic,weak) id<RoomHostDelegate>delegate;
2023-08-30 17:35:45 +08:00
/// 6s
@property (nonatomic,strong)dispatch_source_t giftEffectTimer;
2023-07-14 18:50:55 +08:00
#pragma mark -
@property(nonatomic, strong) GiftAnimationManager *giftAnimationManager;
2023-07-14 18:50:55 +08:00
///
@property (nonatomic,assign) BOOL isLargeGiftAnimating;
#pragma mark -
@property (nonatomic, strong) NSMutableArray<NSDictionary *> *carEffectQueue;
@property (nonatomic,strong) SVGAImageView *carEffectView;
///VAP
@property (nonatomic, strong) VAPView *carVapEffectView;
2023-09-21 17:44:59 +08:00
///pag
@property(nonatomic,strong) PAGView *carPagView;
2023-07-14 18:50:55 +08:00
#pragma mark -
@property (nonatomic, strong) NSMutableArray<NSDictionary *> *enterEffectQueue;
@property (nonatomic,strong) SVGAImageView *enterEffectView;
#pragma mark -
@property (nonatomic, strong) NSMutableArray<DatingInfoModel *> *datingEffectQueue;
@property (nonatomic,strong) SVGAImageView *datingEffectView;
#pragma mark - PK
@property (nonatomic, strong) NSMutableArray<AcrossRoomPKPrizeModel *> *acrossRoomPKQueue;
#pragma mark -
@property (nonatomic, strong) NSMutableArray<AttachmentModel *> *sailingQueue;
#pragma mark -
@property (nonatomic, strong) NSMutableArray<AttachmentModel *> *graffitiGiftQueue;
///
@property (nonatomic,assign) BOOL isLuckyGiftAnimation;
#pragma mark -
@property (nonatomic,strong) SVGAImageView *wishGiftEffectView;
/// PresentAchieveAbstractMatrix
@property(nonatomic,strong) NSMutableArray<GiftReceiveInfoModel *> *animationListA;
/// YUMIPresentBigCaptureMatrix
@property(nonatomic,strong) NSMutableArray<PIBaseAnimationViewModel *> *animationListB;
///
@property(nonatomic,assign) BOOL isPlayOfA;
///
@property(nonatomic,assign) BOOL isPlayOfB;
///animationListAanimationListBanimationListAanimationListB
2023-07-21 18:53:10 +08:00
//@property(nonatomic,assign) BOOL isAnimationListAFinish;
2023-07-21 14:07:04 +08:00
@property(nonatomic,strong) NSMutableArray *svgaQueue;
2023-10-24 12:27:53 +08:00
@property(nonatomic,assign) CGFloat broadCastHieght;
@property (nonatomic, strong) NetImageView *imageLoader;
@property (nonatomic, copy) NSString *GiftDynamicEffectListPath;
2024-09-23 18:01:54 +08:00
/// banner CP banner CP
2024-10-15 21:06:19 +08:00
/// 1.0.28 banner
2024-09-23 18:01:54 +08:00
@property (nonatomic, strong) NSMutableArray *roomEffectModelsQueueV2;
@property (nonatomic, assign) BOOL isRoomEffectV2Displaying;
2024-09-12 14:01:12 +08:00
2024-09-20 21:19:08 +08:00
///CP
@property (nonatomic, strong) AttachmentModel *cpAttachment;
@property(nonatomic, strong) GiftReceiveInfoModel *mp4TempReceiveInfoModel;
2024-12-06 14:38:45 +08:00
//@property(nonatomic, strong) NetImageView *mp4AvatarLoader_1;
//@property(nonatomic, strong) NetImageView *mp4AvatarLoader_2;
@property(nonatomic, strong) NSMutableArray *avatarLoaders;
2023-07-14 18:50:55 +08:00
@end
@implementation XPRoomAnimationView
- (void)dealloc {
[NSObject cancelPreviousPerformRequestsWithTarget:self];
[[NIMSDK sharedSDK].broadcastManager removeDelegate:self];
2023-08-30 17:35:45 +08:00
2023-07-14 18:50:55 +08:00
}
-(void)resumeTimer{
if(self.giftEffectTimer != nil){
2023-10-07 09:57:48 +08:00
dispatch_source_cancel(self.giftEffectTimer);
self.giftEffectTimer = nil;
}
// if(self.giftTimer != nil){
// dispatch_source_cancel(self.giftTimer);
// self.giftTimer = nil;
// }
2023-09-21 17:44:59 +08:00
[self.giftPagView removeListener:self];
}
2023-07-14 18:50:55 +08:00
- (instancetype)initWithDelegate:(id<RoomHostDelegate>)delegate {
self = [super init];
if (self) {
[[NIMSDK sharedSDK].broadcastManager addDelegate:self];
self.delegate = delegate;
2023-07-14 18:50:55 +08:00
[self initSubViews];
[self initSubViewConstraints];
2024-01-03 16:58:16 +08:00
self.giftAnimationManager = [[GiftAnimationManager alloc] initWithContainerView:self.lowLevelView];
self.giftAnimationManager.delegate = self;
2024-09-23 18:01:54 +08:00
_roomEffectModelsQueueV2 = [NSMutableArray array];
_GiftDynamicEffectListPath = [[NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES) xpSafeObjectAtIndex:0] stringByAppendingPathComponent:@"GiftDynamicEffectList"];
2023-07-14 18:50:55 +08:00
}
return self;
}
#pragma mark - Private Method
- (void)initSubViews {
[self addSubview:self.lowLevelView];
[self addSubview:self.middleLevelView];
[self addSubview:self.highLevleView];
}
- (void)initSubViewConstraints {
[self.lowLevelView mas_makeConstraints:^(MASConstraintMaker *make) {
make.edges.mas_equalTo(self);
}];
[self.middleLevelView mas_makeConstraints:^(MASConstraintMaker *make) {
make.edges.mas_equalTo(self);
}];
[self.highLevleView mas_makeConstraints:^(MASConstraintMaker *make) {
make.edges.mas_equalTo(self);
}];
}
//
- (BOOL)isInSudGame {
BOOL isGamePlaying = NO;
if (self.delegate.getRoomInfo.type == RoomType_MiniGame) {
for (int i = -1; i<5; i++) {
NSMutableDictionary * micQueue = self.delegate.getMicroQueue;
MicroQueueModel *micSequence = [micQueue objectForKey:[NSString stringWithFormat:@"%d", i]];
if (micSequence == nil || micSequence.userInfo == nil) {
continue;
}
if (micSequence.userInfo.uid == [AccountInfoStorage instance].getUid.integerValue && micSequence.userInfo.gameStatus == LittleGamePlayStatus_Plying) {
isGamePlaying = YES;
break;
}
}
}
return isGamePlaying;
}
#pragma mark - NIMBroadcastDelegate
// 广
- (void)onReceiveBroadcastMessage:(NIMBroadcastMessage *)broadcastMessage{
if (broadcastMessage.content) {
NSDictionary *msgDictionary = [broadcastMessage.content toJSONObject];
AttachmentModel *attachment = [AttachmentModel modelWithJSON:msgDictionary[@"body"]];
2024-04-24 20:08:24 +08:00
NSString *partitionId = [NSString stringWithFormat:@"%@",attachment.data[@"partitionId"]];
if(![partitionId isEqualToString:self.delegate.getUserInfo.partitionId]){
return;
}
2023-07-14 18:50:55 +08:00
if (attachment.first == CustomMessageType_Gift && attachment.second == Custom_Message_Sub_Gift_ChannelNotify){///广
// [self receiveBroadcastGift:attachment];
[self receiveRoomGiftBanner:attachment];
2024-04-11 15:47:44 +08:00
} else if (attachment.first == CustomMessageType_Noble_VIP && attachment.second == Custom_Message_Sub_Room_Noble_LevelUp_Suspend) {///VIP
2023-07-14 18:50:55 +08:00
[self receiveNobleLevelUp:attachment];
}else if(attachment.first == CustomMessageType_LuckyBag && attachment.second == Custom_Message_Sub_Room_Gift_LuckBag_FullScree){
[self receiveLuckyGiftBigPrize:attachment];
}else if(attachment.first == CustomMessageType_Graffiti_Star_Kitchen && attachment.second == Custom_Message_Sub_Star_Kitchen_FullScreen){
[self receiveRoomGraffitiStarKitchen:attachment];
}else if(attachment.first == CustomMessageType_Look_Love && attachment.second == Custom_Message_Sub_Look_Love_InRoom_NeedAllMicSend){
[self receiveCandyTreeGiftHighLevle:attachment];
2023-08-10 10:12:19 +08:00
}else if (attachment.first == CustomMessageType_Treasure_Fairy && (attachment.second == Custom_Message_Sub_Treasure_Fairy_Draw_Gift_L4 || attachment.second == Custom_Message_Sub_Treasure_Fairy_Draw_Gift_L5 || attachment.second == Custom_Message_Sub_Treasure_Fairy_Convert_L1 || attachment.second == Custom_Message_Sub_Treasure_Fairy_Convert_L2 || attachment.second == Custom_Message_Sub_Treasure_Fairy_Convert_L3)) { //
[self receiveTreasureFairyGiftHighLevel:attachment];
2023-09-14 11:16:47 +08:00
}else if (attachment.first == CustomMessageType_Tarot && (attachment.second == Custom_Message_Sub_Tarot_Advanced || attachment.second == Custom_Message_Sub_Tarot_Intermediate)){
[self receiveTarotBanner:attachment];
2023-09-27 21:41:03 +08:00
}else if (attachment.first == CustomMessageType_Common_H5 &&(attachment.second == Custom_Message_Sub_Common_H5_Novice || attachment.second == Custom_Message_Sub_Common_H5_Advanced)){
2023-09-14 11:16:47 +08:00
[self receiveCommonH5Banner:attachment];
2024-10-15 20:56:25 +08:00
}else if (attachment.first == CustomMessageType_General_Floating_Screen &&
(attachment.second == Custom_Message_Sub_General_Floating_Screen_One_Room || attachment.second == Custom_Message_Sub_General_Floating_Screen_All_Room)){
2024-03-20 19:55:26 +08:00
[self receiveRoomGeneralFloatingScreen:attachment];
2023-07-14 18:50:55 +08:00
}
}
}
#pragma mark - RoomGuestDelegate
- (void)handleNIMCustomMessage:(NIMMessage *)message {
NIMCustomObject *obj = (NIMCustomObject *)message.messageObject;
if (obj.attachment != nil && [obj.attachment isKindOfClass:[AttachmentModel class]]) {
AttachmentModel *attachment = (AttachmentModel *)obj.attachment;
if (attachment.first == CustomMessageType_Gift) {
GiftReceiveInfoModel * receiveInfo = [GiftReceiveInfoModel modelWithJSON:attachment.data];
2024-12-11 10:48:01 +08:00
[receiveInfo giftDataAlignment];
if (attachment.second == Custom_Message_Sub_Gift_EmbeddedStyle) {
2024-12-06 14:38:45 +08:00
if (receiveInfo.giftVo) {
receiveInfo.gift = receiveInfo.giftVo;
}
receiveInfo.targetUid = [[attachment.data objectForKey:@"recvUserUid"] stringValue];
receiveInfo.targetNick = [attachment.data objectForKey:@"recvUserNick"];
receiveInfo.targetAvatar = [attachment.data objectForKey:@"recvUserAvatar"];
receiveInfo.avatar = [attachment.data objectForKey:@"sendUserAvatar"];
receiveInfo.nick = [attachment.data objectForKey:@"sendUserNick"];
receiveInfo.uid = [[attachment.data objectForKey:@"sendUserUid"] stringValue];
} else if (attachment.second == Custom_Message_Sub_Gift_Send) {
2024-12-02 19:33:20 +08:00
if (receiveInfo.targetUsers.count == 0) {
GiftReceiveUserInfoModel *model = [[GiftReceiveUserInfoModel alloc] init];
model.nick = receiveInfo.targetNick;
model.avatar = receiveInfo.targetAvatar;
model.uid = receiveInfo.uid.integerValue;
receiveInfo.targetUsers = @[model];
}
if (receiveInfo.targetUids.count == 0) {
receiveInfo.targetUids = @[@(receiveInfo.uid.integerValue)];
}
}
2024-12-06 14:38:45 +08:00
2023-07-14 18:50:55 +08:00
receiveInfo.isLuckyBagGift = attachment.second == Custom_Message_Sub_Gift_LuckySend;
receiveInfo.isBatch = (attachment.second == Custom_Message_Sub_AllBatchSend || attachment.second == Custom_Message_Sub_AllBatchMicroLuckySend);
2024-09-12 18:49:42 +08:00
receiveInfo.isComboBatch = attachment.second == Custom_Message_Sub_AllMicroSend;
2024-12-11 10:48:01 +08:00
2023-07-14 18:50:55 +08:00
if (receiveInfo.isLuckyBagGift) {
2024-12-11 10:48:01 +08:00
[self receiveGiftHandleSendGiftAnimation:attachment];
2023-07-14 18:50:55 +08:00
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];
2023-11-01 10:36:21 +08:00
if (luckyGiftSvgaUrl.absoluteString.length > 0) {
[self playLuckyGiftEffect:luckyGiftSvgaUrl];
2023-07-14 18:50:55 +08:00
}
}
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.5 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
[self receiveGift:receiveInfo];
});
} else {
2024-12-11 10:48:01 +08:00
if (receiveInfo.gift.notifyFull == 1 && attachment.second == Custom_Message_Sub_Gift_Send) {
return;
}
2024-12-11 10:48:01 +08:00
[self receiveGiftHandleSendGiftAnimation:attachment];
2023-07-14 18:50:55 +08:00
[self receiveGift:receiveInfo];
}
} else if (attachment.first == CustomMessageType_AllMicroSend) { //
GiftReceiveInfoModel * receiveInfo = [GiftReceiveInfoModel modelWithJSON:attachment.data];
2024-12-11 10:48:01 +08:00
[receiveInfo giftDataAlignment];
2023-07-14 18:50:55 +08:00
receiveInfo.isLuckyBagGift = (attachment.second == Custom_Message_Sub_AllMicroLuckySend || attachment.second == Custom_Message_Sub_AllBatchMicroLuckySend);
2024-09-12 18:49:42 +08:00
receiveInfo.isComboBatch = attachment.second == Custom_Message_Sub_AllMicroSend;
2023-07-14 18:50:55 +08:00
receiveInfo.isBatch = (attachment.second == Custom_Message_Sub_AllBatchSend || attachment.second == Custom_Message_Sub_AllBatchMicroLuckySend);
2024-12-04 21:22:38 +08:00
2023-07-14 18:50:55 +08:00
if (receiveInfo.isLuckyBagGift) {
2024-12-11 10:48:01 +08:00
[self receiveGiftHandleSendGiftAnimation:attachment];
2023-07-14 18:50:55 +08:00
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];
2023-11-01 10:36:21 +08:00
if (luckyGiftSvgaUrl.absoluteString.length > 0) {
[self playLuckyGiftEffect:luckyGiftSvgaUrl];
2023-07-14 18:50:55 +08:00
}
}
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.5 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
[self receiveGift:receiveInfo];
});
} else {
2024-12-11 10:48:01 +08:00
[self receiveGiftHandleSendGiftAnimation:attachment];
2023-07-14 18:50:55 +08:00
[self receiveGift:receiveInfo];
}
2023-07-21 14:07:04 +08:00
} else if (attachment.first == CustomMessageType_LuckyBag ) {//
2023-07-14 18:50:55 +08:00
[self receiveLuckyGiftBigPrize:attachment];
2023-07-21 14:07:04 +08:00
} else if (attachment.first == CustomMessageType_Look_Love && (attachment.second == Custom_Message_Sub_Look_Love_AllRoom_Notify) ) {//
2023-07-14 18:50:55 +08:00
[self receiveCandyTreeGiftHighLevle:attachment];
} else if (attachment.first == CustomMessageType_Car_Notify && attachment.second == Custom_Message_Sub_Car_EnterRoom ) {//
[self receiveDriveCarEnterRoom:attachment];
} else if(attachment.first == CustomMessageType_RoomPlay_Dating && attachment.second == Custom_Message_Sub_Room_Play_Dating_Public_Result) {
[self roomDatingPublicResult:attachment];
} else if(attachment.first == CustomMessageType_Across_Room_PK && attachment.second == Custom_Message_Sub_AcrossRoomPK_Result) {
[self acrossRoomPKBannerAnimation:attachment];
} else if (attachment.first == CustomMessageType_Anchor_FansTeam && attachment.second == 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];
} else if (attachment.first == CustomMessageType_Across_Room_PK && attachment.second == Custom_Message_Sub_AnchorPK_Result) {//PK
[self acrossRoomPKBannerAnimation:attachment];
} else if (attachment.first == CustomMessageType_Anchor_Hour_Rank && attachment.second == Custom_Message_Sub_Anchor_Hour_Rank) {///
[self receiveAnchorHourRank:attachment];
} else if (attachment.first == CustomMessageType_License_Hour_Rank && attachment.second == Custom_Message_Sub_License_Hour_Rank) {///
2023-09-25 16:02:57 +08:00
[self receiveAnchorHourRank:attachment];
2023-07-14 18:50:55 +08:00
} else if (attachment.first == CustomMessageType_Gift_Compound && attachment.second == Custom_Message_Sub_Gift_Compound) {///
[self receiveGiftCompound:attachment];
} else if(attachment.first == CustomMessageType_Room_Sailing && (attachment.second == Custom_Message_Sub_Sailing_AllRoom_Notify || attachment.second == Custom_Message_Sub_Sailing_InRoom_NeedAllMicSend)) {
[self receiveRoomSailing:attachment];
} else if(attachment.first == CustomMessageType_Graffiti_Gift) {///
[self receiveRoomGraffitiGift:attachment];
} else if(attachment.first == CustomMessageType_Graffiti_Star_Kitchen){///
[self receiveRoomGraffitiStarKitchen:attachment];
2023-10-25 10:42:11 +08:00
}else if (attachment.first == CustomMessageType_Treasure_Fairy && (attachment.second == Custom_Message_Sub_Treasure_Fairy_Draw_Gift_L4 || attachment.second == Custom_Message_Sub_Treasure_Fairy_Convert_L1 || attachment.second == Custom_Message_Sub_Treasure_Fairy_Convert_L2 || attachment.second == Custom_Message_Sub_Treasure_Fairy_Convert_L3)) { //
2023-09-26 17:57:39 +08:00
[self receiveTreasureFairyGiftHighLevel:attachment];
}else if (attachment.first == CustomMessageType_Tarot && (attachment.second == Custom_Message_Sub_Tarot_Advanced || attachment.second == Custom_Message_Sub_Tarot_Intermediate)){
2023-09-27 12:35:29 +08:00
PIBaseAnimationViewModel *giftNotifyInfo = [PIBaseAnimationViewModel modelWithJSON:attachment.data];
2023-09-27 16:06:18 +08:00
if(attachment.second == Custom_Message_Sub_Tarot_Intermediate && self.delegate.getRoomInfo.uid != giftNotifyInfo.roomUid.integerValue){
2023-09-27 12:35:29 +08:00
return;
}
2023-09-26 17:57:39 +08:00
[self receiveTarotBanner:attachment];
2023-09-27 21:41:03 +08:00
}else if (attachment.first == CustomMessageType_Common_H5 &&(attachment.second == Custom_Message_Sub_Common_H5_Novice || attachment.second == Custom_Message_Sub_Common_H5_Advanced)){
2023-09-26 17:57:39 +08:00
[self receiveCommonH5Banner:attachment];
2024-03-20 19:55:26 +08:00
}else if (attachment.first == CustomMessageType_General_Floating_Screen && attachment.second == Custom_Message_Sub_General_Floating_Screen_One_Room){
[self receiveRoomGeneralFloatingScreen:attachment];
2024-09-12 14:01:12 +08:00
} else if (attachment.first == CustomMessageType_Super_Gift &&
attachment.second == Custom_Message_Sub_Super_Gift_Winning_Coins) {
[self receiveLuckGiftWinning:attachment];
} else if (attachment.first == CustomMessageType_Super_Gift &&
attachment.second == Custom_Message_Sub_Super_Gift_Winning_Coins_ALL_Room) {
[self receiveLuckGiftBanner:attachment];
2024-09-20 21:19:08 +08:00
} else if (attachment.first == CustomMessageType_CP) {
2024-09-23 18:01:54 +08:00
[self receiveCPEvent: attachment];
2023-07-14 18:50:55 +08:00
}
}
}
- (void)handleNIMNotificationMessage:(NIMMessage *)message {
NIMNotificationObject *notiMsg = (NIMNotificationObject *)message.messageObject;
NIMChatroomNotificationContent *content = (NIMChatroomNotificationContent *)notiMsg.content;
if (content.eventType == NIMChatroomEventTypeEnter) {
NIMMessageChatroomExtension * messageExt = (NIMMessageChatroomExtension *)message.messageExt;
NSDictionary * dic = [(NSDictionary *)messageExt.roomExt.toJSONObject objectForKey:message.from];
XPMessageRemoteExtModel * extModel = [XPMessageRemoteExtModel modelWithJSON:dic];
if (extModel.enterHide) {//
if ([message.from isEqualToString:[AccountInfoStorage instance].getUid]) {
[self createEnterHideAnimation:dic];
}
return;
}
[self userEnterRoom:content ext:extModel];
}
}
2024-09-12 14:01:12 +08:00
2024-10-15 20:56:25 +08:00
#pragma mark -
- (void)receiveGameBanner:(AttachmentModel *)attachment {
[self.roomEffectModelsQueueV2 addObject:attachment];
if (!self.isRoomEffectV2Displaying) {
[self processNextRoomEffectAttachment];
}
}
- (void)playGameBanner:(AttachmentModel *)attachment {
@kWeakify(self);
[GameUniversalBannerView display:self with:attachment complete:^{
@kStrongify(self);
[self processNextRoomEffectAttachment];
} goToGame:^(NSInteger gameID) {
@kStrongify(self);
NSArray *baishunList = [self.delegate getPlayList];
for (ActivityInfoModel *model in baishunList) {
if (model.id == gameID) {
if ([self.delegate isKindOfClass:[XPRoomViewController class]]){
MSRoomGameWebVC *vc = [[MSRoomGameWebVC alloc]initWithDelegate:self.delegate gameModel:model];
vc.view.frame = CGRectMake(0, 0, KScreenWidth, KScreenHeight);
XPRoomViewController *roomVC = (XPRoomViewController *)self.delegate;
[roomVC addChildViewController:vc];
XPRoomAnimationView *animationView;
for (id obj in self.delegate.getSuperView.subviews) {
if ([obj isKindOfClass:[XPRoomAnimationView class]]){
animationView = obj;
break;
}
}
[self.delegate.getSuperView addSubview:vc.view];
vc.view.tag = 913;
}
return;
}
}
}];
}
2024-09-12 14:01:12 +08:00
#pragma mark -
- (void)receiveLuckGiftWinning:(AttachmentModel *)attachment {
RoomInfoModel *roomInfo = self.delegate.getRoomInfo;
[LuckyGiftWinningFlagView display:self
with:attachment
roomID:roomInfo.roomId
uID:[AccountInfoStorage instance].getUid];
}
- (void)receiveLuckGiftBanner:(AttachmentModel *)attachment {
2024-09-23 18:01:54 +08:00
[self.roomEffectModelsQueueV2 addObject:attachment];
if (!self.isRoomEffectV2Displaying) {
[self processNextRoomEffectAttachment];
2024-09-12 14:01:12 +08:00
}
}
2024-09-23 18:01:54 +08:00
- (void)processNextRoomEffectAttachment {
2024-09-12 14:01:12 +08:00
//
2024-09-23 18:01:54 +08:00
if (self.roomEffectModelsQueueV2.count == 0) {
2024-09-12 14:01:12 +08:00
//
2024-09-23 18:01:54 +08:00
self.isRoomEffectV2Displaying = NO;
2024-09-12 14:01:12 +08:00
return;
}
//
2024-09-23 18:01:54 +08:00
AttachmentModel *nextAttachment = [self.roomEffectModelsQueueV2 firstObject];
[self.roomEffectModelsQueueV2 removeObjectAtIndex:0];
2024-09-12 14:01:12 +08:00
//
2024-09-23 18:01:54 +08:00
self.isRoomEffectV2Displaying = YES;
switch (nextAttachment.second) {
2024-10-15 20:56:25 +08:00
case Custom_Message_Sub_General_Floating_Screen_One_Room:
case Custom_Message_Sub_General_Floating_Screen_All_Room:
[self playGameBanner:nextAttachment];
break;
2024-09-23 18:01:54 +08:00
case Custom_Message_Sub_Super_Gift_Winning_Coins_ALL_Room:
[self playLuckyWinningBanner:nextAttachment];
break;
case Custom_Message_Sub_CP_Gift:
[self playCPGiftBanner:nextAttachment];
break;
case Custom_Message_Sub_CP_Upgrade:
[self playCPLevelUp:nextAttachment];
break;
case Custom_Message_Sub_CP_Binding:
[self playCPBinding:nextAttachment];
break;
case Custom_Message_Sub_Gift_ChannelNotify:
[self playRoomGiftBanner:nextAttachment];
break;
2024-09-23 18:01:54 +08:00
default:
break;
}
}
- (void)playLuckyWinningBanner:(AttachmentModel *)nextAttachment {
2024-10-12 19:30:41 +08:00
// [self receiveRoomGeneralFloatingScreen]
2024-09-12 14:01:12 +08:00
RoomInfoModel *roomInfo = self.delegate.getRoomInfo;
// display
@kWeakify(self);
2024-09-23 18:01:54 +08:00
[LuckyGiftWinningBannerView display:self
inRoomUid:roomInfo.uid
with:nextAttachment
complete:^{
2024-09-12 14:01:12 +08:00
@kStrongify(self);
// Display
2024-09-23 18:01:54 +08:00
[self processNextRoomEffectAttachment];
2024-09-12 14:01:12 +08:00
} exitCurrentRoom:^{
@kStrongify(self);
[self.delegate exitRoom];
}];
}
2024-03-20 19:55:26 +08:00
#pragma mark -
2024-09-12 14:01:12 +08:00
-(void)receiveRoomGeneralFloatingScreen:(AttachmentModel *)attachment{
2024-03-20 19:55:26 +08:00
PIBaseAnimationViewModel *roomGraffiti = [PIBaseAnimationViewModel new];
2024-09-12 14:01:12 +08:00
roomGraffiti.data = attachment.data;
2024-03-20 19:55:26 +08:00
roomGraffiti.type = GiftBannerType_General_Floating_Screen;
2024-09-12 14:01:12 +08:00
roomGraffiti.first = attachment.first;
roomGraffiti.second = attachment.second;
2024-10-15 20:56:25 +08:00
PIUniversalBannerModel *model = [PIUniversalBannerModel modelWithDictionary:attachment.data];
if (model.skipType == 7 &&
(attachment.second == Custom_Message_Sub_General_Floating_Screen_One_Room ||
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];
2024-03-20 19:55:26 +08:00
}
}
2024-10-15 20:56:25 +08:00
- (void)createGeneralFloatingScreenAnimation:(PIBaseAnimationViewModel *)attachment bannerModel:(PIUniversalBannerModel *)model {
2024-03-20 19:55:26 +08:00
self.isPlayOfB = YES;
CGFloat top = self.isPlayOfA == YES ? (self.broadCastHieght + statusbarHeight) : (kNavigationHeight + 15);
2024-10-15 20:56:25 +08:00
if (!model) {
model = [PIUniversalBannerModel modelWithDictionary:attachment.data];
}
BOOL isSvga = [model.resourceType.uppercaseString isEqualToString:@"SVGA"];
__block PIUniversalBannerView *bannerView;
@kWeakify(self);
2024-03-20 19:55:26 +08:00
if (isSvga == YES) {
SVGAParser *parser = [SVGAParser new];
[parser parseWithURL:[NSURL URLWithString:model.resourceContent] completionBlock:^(SVGAVideoEntity * _Nonnull videoItem) {
@kStrongify(self);
2024-03-20 19:55:26 +08:00
model.videoItem = videoItem;
2024-04-24 20:08:24 +08:00
CGFloat height = kGetScaleWidth(60);
if(videoItem.videoSize.width > 0){
height = KScreenWidth * videoItem.videoSize.height / videoItem.videoSize.width;
}
2024-10-15 20:56:25 +08:00
2024-04-24 20:08:24 +08:00
bannerView = [[PIUniversalBannerView alloc]initWithFrame:CGRectMake(KScreenWidth, top, KScreenWidth, height)];
2024-03-20 19:55:26 +08:00
[self showGeneralFloatingScreenView:bannerView model:model];
} failureBlock:^(NSError * _Nonnull error) {
@kStrongify(self);
2024-03-25 14:54:27 +08:00
[bannerView removeFromSuperview];
self.isPlayOfB = NO;
if(self.animationListB.count > 0){
[self.animationListB removeObjectAtIndex:0];
}
[self playAnimationWithModel];
2024-03-20 19:55:26 +08:00
}];
}else{
if (!_imageLoader) {
_imageLoader = [[NetImageView alloc] init];
}
[self.imageLoader loadImageWithUrl:model.resourceContent
completion:^(UIImage * _Nonnull image, NSURL * _Nonnull url) {
@kStrongify(self);
2024-03-20 19:55:26 +08:00
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) ];
2024-03-20 19:55:26 +08:00
[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];
2024-03-20 19:55:26 +08:00
}];
}
}
-(void)showGeneralFloatingScreenView:(PIUniversalBannerView *)bannerView model:(PIUniversalBannerModel *)model{
BOOL isSvga = [model.resourceType isEqualToString:@"SVGA"];
bannerView.isSvga = isSvga;
bannerView.model = model;
bannerView.delegate = self;
[self.highLevleView 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);
2024-03-20 19:55:26 +08:00
[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)];
2024-04-24 20:08:24 +08:00
moveAnimation.beginTime = CACurrentMediaTime() + 5;
2024-03-20 19:55:26 +08:00
moveAnimation.duration = 0.5;
moveAnimation.repeatCount = 1;
moveAnimation.removedOnCompletion = YES;
2024-03-20 19:55:26 +08:00
[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){
[self.delegate 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];
2024-03-20 19:55:26 +08:00
webVC.isPush = YES;
webVC.url = model.skipContent;
[self.delegate.getCurrentNav pushViewController:webVC animated:YES];
}
}
#pragma mark -
2023-07-14 18:50:55 +08:00
-(void)receiveRoomGraffitiStarKitchen:(AttachmentModel *)attacment{
PIBaseAnimationViewModel *roomGraffiti = [PIBaseAnimationViewModel new];
roomGraffiti.data = attacment.data;
roomGraffiti.type = GiftBannerType_kitchen;
2024-03-12 18:17:33 +08:00
roomGraffiti.first = attacment.first;
roomGraffiti.second = attacment.second;
2023-07-14 18:50:55 +08:00
if(self.animationListB.count == 0 && self.isPlayOfB == NO){
[self createStarKitchenBannerAnimation:roomGraffiti];
}
[self.animationListB addObject:roomGraffiti];
}
- (void)createStarKitchenBannerAnimation:(PIBaseAnimationViewModel *)attacment{
self.isPlayOfB = YES;
2023-10-24 12:27:53 +08:00
CGFloat top = self.isPlayOfA == YES ? (self.broadCastHieght + statusbarHeight) : (kNavigationHeight + 15);
2023-07-14 18:50:55 +08:00
XPRoomStarKitchenBannerView *starKitchenView = [[XPRoomStarKitchenBannerView alloc]initWithFrame:CGRectMake(0, top, KScreenWidth, kGetScaleWidth(60))];
2024-03-12 18:17:33 +08:00
starKitchenView.isSvga = attacment.second == Custom_Message_Sub_Star_Kitchen_FullScreen;
2023-07-14 18:50:55 +08:00
XPRoomStarKitchenModel *starModel = [XPRoomStarKitchenModel modelWithDictionary:attacment.data];
starKitchenView.delegate = self;
starKitchenView.starModel = starModel;
[self.highLevleView 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"];
}
#pragma mark - XPRoomStarKitchenBannerViewDelegate
- (void)xPRoomStarKitchenBannerView:(XPRoomStarKitchenBannerView *)view didClick:(XPRoomStarKitchenModel *)starModel{
if(starModel.skipUrl == nil || starModel.skipUrl.length == 0)return;
XPWebViewController * webVC = [[XPWebViewController alloc] initWithRoomUID:starModel.roomUid];
2023-07-14 18:50:55 +08:00
webVC.isPush = YES;
webVC.url = starModel.skipUrl;
[self.delegate.getCurrentNav pushViewController:webVC animated:YES];
2023-09-14 11:16:47 +08:00
}
#pragma mark - h5
-(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 {
2023-09-21 17:44:59 +08:00
2023-09-14 11:16:47 +08:00
CGFloat kscale = (CGFloat)55 / (CGFloat)375;
self.isPlayOfB = YES;
2023-10-24 12:27:53 +08:00
CGFloat top = self.isPlayOfA == YES ? (self.broadCastHieght + statusbarHeight) : (kNavigationHeight + 15);
2023-09-14 11:16:47 +08:00
XPRoomTarrowBannerView *tarrowVeiw = [[XPRoomTarrowBannerView alloc]initWithFrame:CGRectMake(KScreenWidth, top, KScreenWidth , KScreenWidth * kscale)isH5:YES];
tarrowVeiw.isBig = attatchment.second == Custom_Message_Sub_Common_H5_Advanced;
2023-09-15 16:08:43 +08:00
tarrowVeiw.giftH5Info = attatchment;
2023-09-14 11:16:47 +08:00
[self.middleLevelView 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"];
2023-09-21 17:44:59 +08:00
2023-09-14 11:16:47 +08:00
}
#pragma mark -
-(void)receiveTarotBanner:(AttachmentModel *)attachment{
if ([self isInSudGame]) {return;}
PIBaseAnimationViewModel *giftNotifyInfo = [PIBaseAnimationViewModel modelWithJSON:attachment.data];
2023-09-27 12:35:29 +08:00
2023-09-14 11:16:47 +08:00
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 {
2023-09-21 17:44:59 +08:00
2023-09-14 11:16:47 +08:00
CGFloat kscale = (CGFloat)55 / (CGFloat)375;
self.isPlayOfB = YES;
2023-10-24 12:27:53 +08:00
CGFloat top = self.isPlayOfA == YES ? (self.broadCastHieght + statusbarHeight) : (kNavigationHeight + 15);
2023-09-14 11:16:47 +08:00
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.middleLevelView 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];
}
2023-09-21 17:44:59 +08:00
// if(self. isAnimationListAFinish == YES){
//
// [self playAnimationWithModel];
// self.isAnimationListAFinish = NO;
// return;
// }
2023-09-14 11:16:47 +08:00
[self playAnimationWithModel];
}
}];
[tarrowVeiw pop_addAnimation:moveAnimation forKey:@"moveOutAnimation"];
}
}];
[tarrowVeiw pop_addAnimation:springAnimation forKey:@"candyTreespingOutAnimation"];
2023-09-21 17:44:59 +08:00
2023-07-14 18:50:55 +08:00
}
2023-08-10 10:12:19 +08:00
#pragma mark -
- (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];
2023-09-21 17:44:59 +08:00
2023-08-10 10:12:19 +08:00
}
- (void)createTreasureFairyBannerAnimation:(PIBaseAnimationViewModel *)attatchment {
2023-08-16 14:21:58 +08:00
self.isPlayOfB = YES;
2023-08-10 10:12:19 +08:00
CGFloat kscale = (CGFloat)60 / (CGFloat)375;
2023-10-24 12:27:53 +08:00
CGFloat top = self.isPlayOfA == YES ? (self.broadCastHieght + statusbarHeight) : (kNavigationHeight + 15);
2023-08-10 10:12:19 +08:00
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.middleLevelView 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];
}
2023-09-21 17:44:59 +08:00
// if(self. isAnimationListAFinish == YES){
//
// [self playAnimationWithModel];
// self.isAnimationListAFinish = NO;
// return;
// }
2023-08-10 10:12:19 +08:00
[self playAnimationWithModel];
}
}];
[treasureView pop_addAnimation:moveAnimation forKey:@"moveOutAnimation"];
}
}];
[treasureView pop_addAnimation:springAnimation forKey:@"candyTreespingOutAnimation"];
}
2023-07-14 18:50:55 +08:00
#pragma mark -
- (void)receiveRoomGraffitiGift:(AttachmentModel *)attacment {
if (self.graffitiGiftQueue.count == 0) {
[self startGraffitiGiftAnimation:attacment];
}
[self.graffitiGiftQueue addObject:attacment];
}
- (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.highLevleView 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)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];
}
}
#pragma mark - PK
- (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.highLevleView 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.delegate 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];
});
}
}
#pragma mark -
- (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.delegate animationPointAtStageViewByUid:uid];
datingModel.targetPoint = [self.delegate animationPointAtStageViewByUid:targetUid];
}
XPRoomDatingAnimationView * datingView = [[XPRoomDatingAnimationView alloc] init];
[self.highLevleView 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.delegate.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;
}
#pragma mark - XXX
- (void)userEnterRoom:(NIMChatroomNotificationContent *)content ext:(XPMessageRemoteExtModel *)extModel {
2024-12-16 19:41:23 +08:00
NSString *userName = [NSString isEmpty:extModel.nick] ? content.source.nick : extModel.nick;
2024-12-06 14:38:45 +08:00
if ([NSString isEmpty:userName] && content.source.userId.intValue == self.delegate.getUserInfo.uid) {
userName = self.delegate.getUserInfo.nick;
} else if ([NSString isEmpty:userName]) {
userName = extModel.nick;
} else if ([NSString isEmpty:userName]) {
userName = @"";
}
2024-05-11 10:21:48 +08:00
if(extModel.enterRoomEffects.length > 0){
2024-12-06 14:38:45 +08:00
NSString * title = [NSString stringWithFormat:YMLocalizedString(@"XPRoomAnimationView0"), userName];
2024-05-11 10:21:48 +08:00
if (self.enterEffectQueue.count ==0) {
[self playUserEnterRoomAnimation:title experLevelSeq:extModel.experLevelSeq effectPath:extModel.enterRoomEffects];
}
NSDictionary * dic= @{@"title":title, @"experLevelSeq":[NSString stringWithFormat:@"%ld", extModel.experLevelSeq], @"effectPath" : extModel.enterRoomEffects.length ? extModel.enterRoomEffects : @""};
[self.enterEffectQueue addObject:dic];
return;
2024-12-06 14:38:45 +08:00
} else if (extModel.experLevelSeq < 30) {
return;
2024-05-11 10:21:48 +08:00
}
2024-12-06 14:38:45 +08:00
NSString * title = [NSString stringWithFormat:YMLocalizedString(@"XPRoomAnimationView0"), userName];
2023-07-14 18:50:55 +08:00
if (self.enterEffectQueue.count ==0) {
[self playUserEnterRoomAnimation:title experLevelSeq:extModel.experLevelSeq effectPath:extModel.enterRoomEffects];
}
NSDictionary * dic= @{@"title":title, @"experLevelSeq":[NSString stringWithFormat:@"%ld", extModel.experLevelSeq], @"effectPath" : extModel.enterRoomEffects.length ? extModel.enterRoomEffects : @""};
[self.enterEffectQueue addObject:dic];
}
- (void)playUserEnterRoomAnimation:(NSString *)title experLevelSeq:(NSInteger)experLevelSeq effectPath:(NSString *)effectPath {
if (self.enterEffectView.superview == nil) {
self.enterEffectView.frame = CGRectMake(KScreenWidth, 339 + kSafeAreaTopHeight, KScreenWidth, effectPath.length ? 75 : 40);
[self.lowLevelView addSubview:self.enterEffectView];
}
NSMutableAttributedString * attribute = [[NSMutableAttributedString alloc] initWithString:title attributes:@{NSFontAttributeName:[UIFont systemFontOfSize:26], NSForegroundColorAttributeName:[UIColor whiteColor]}];
[attribute setYy_alignment:NSTextAlignmentLeft];
2024-12-06 14:38:45 +08:00
BOOL needRemoveHandly = NO;
2024-11-28 10:40:21 +08:00
2023-07-14 18:50:55 +08:00
if (effectPath.length > 0) {
2024-12-06 14:38:45 +08:00
needRemoveHandly = YES;
2023-07-14 18:50:55 +08:00
@kWeakify(self);
[self.parser parseWithURL:[NSURL URLWithString:effectPath] completionBlock:^(SVGAVideoEntity * _Nonnull videoItem) {
@kStrongify(self);
2024-12-06 14:38:45 +08:00
self.enterEffectView.loops = 0;
2023-07-14 18:50:55 +08:00
self.enterEffectView.hidden = NO;
2024-12-06 14:38:45 +08:00
self.enterEffectView.clearsAfterStop = YES;
2023-07-14 18:50:55 +08:00
self.enterEffectView.alpha = 1;
self.enterEffectView.videoItem = videoItem;
[self.enterEffectView setAttributedText:attribute forKey:@"room_text"];
[self.enterEffectView startAnimation];
} failureBlock:^(NSError * _Nonnull error) {
NSLog(@"%@", error);
2023-07-14 18:50:55 +08:00
}];
} else {
NSString * path;
if (experLevelSeq >= 30 && experLevelSeq <= 39) {
2024-11-28 10:40:21 +08:00
path = @"experience_entre_effect_30";
} else if (experLevelSeq >= 40 && experLevelSeq <= 49) {
2024-11-28 10:40:21 +08:00
path = @"experience_entre_effect_40";
} else if (experLevelSeq >= 50 && experLevelSeq <= 59) {
2024-11-28 10:40:21 +08:00
path = @"experience_entre_effect_50";
} else if (experLevelSeq >= 60 && experLevelSeq <= 69) {
2024-11-28 10:40:21 +08:00
path = @"experience_entre_effect_60";
} else if (experLevelSeq >= 70 && experLevelSeq <= 79) {
2024-11-28 10:40:21 +08:00
path = @"experience_entre_effect_70";
} else if (experLevelSeq >= 80 && experLevelSeq <= 89) {
2024-11-28 10:40:21 +08:00
path = @"experience_entre_effect_80";
} else if (experLevelSeq > 89) {
path = @"experience_entre_effect_90";
}
2024-11-28 10:40:21 +08:00
if ([NSString isEmpty:path]) {
return;
}
NSString * anatomiser1Name = [NSString stringWithFormat:@"%@/%@.svga", @"https://image.molistar.xyz/", path];
2023-07-14 18:50:55 +08:00
@kWeakify(self);
[self.parser parseWithURL:[NSURL URLWithString:anatomiser1Name] completionBlock:^(SVGAVideoEntity * _Nonnull videoItem) {
@kStrongify(self);
self.enterEffectView.loops = 1;
self.enterEffectView.hidden = NO;
self.enterEffectView.clearsAfterStop = NO;
self.enterEffectView.alpha = 1;
self.enterEffectView.videoItem = videoItem;
[self.enterEffectView setAttributedText:attribute forKey:@"room_text"];
[self.enterEffectView startAnimation];
} failureBlock:^(NSError * _Nonnull error) {
NSLog(@"%@", error);
2023-07-14 18:50:55 +08:00
}];
}
2024-12-06 14:38:45 +08:00
2023-07-14 18:50:55 +08:00
[UIView animateWithDuration:0.5 animations:^{
self.enterEffectView.frame = CGRectMake(0, 339 + kSafeAreaTopHeight, KScreenWidth, effectPath.length ? 75 : 40);
} completion:^(BOOL finished) {
2024-12-06 14:38:45 +08:00
if (needRemoveHandly) {
// dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(1 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
// [self.enterEffectView stopAnimation];
// });
[UIView animateWithDuration:0.5 delay:1 options:UIViewAnimationOptionCurveEaseInOut animations:^{
self.enterEffectView.frame = CGRectMake(-KScreenWidth, 339 + kSafeAreaTopHeight, KScreenWidth, effectPath.length ? 75 : 40);
} completion:^(BOOL finished) {
[self.enterEffectView stopAnimation];
[self svgaPlayerDidFinishedAnimation:self.enterEffectView];
}];
}
2023-07-14 18:50:55 +08:00
}];
}
///
- (void)createEnterHideAnimation:(NSDictionary *)dic {
XPRoomEnterHideTipView *enterHideTipView = [[XPRoomEnterHideTipView alloc] initWithFrame:CGRectMake(KScreenWidth, (KScreenHeight - 48) * 0.5, KScreenWidth, 48)];
[self.highLevleView addSubview:enterHideTipView];
POPSpringAnimation *springAnimation = [POPSpringAnimation animationWithPropertyNamed:kPOPViewCenter];
springAnimation.springSpeed = 12;
springAnimation.springBounciness = 10.f;
springAnimation.fromValue = [NSValue valueWithCGPoint:enterHideTipView.center];
springAnimation.toValue = [NSValue valueWithCGPoint:CGPointMake(enterHideTipView.frame.size.width / 2, enterHideTipView.center.y)];
[springAnimation setCompletionBlock:^(POPAnimation *anim, BOOL finished) {
if (finished) {
POPBasicAnimation *moveAnimation = [POPBasicAnimation animationWithPropertyNamed:kPOPViewCenter];
moveAnimation.fromValue = [NSValue valueWithCGPoint:CGPointMake(0, enterHideTipView.center.y)];
moveAnimation.toValue = [NSValue valueWithCGPoint:CGPointMake(-KScreenWidth/2, enterHideTipView.center.y)];
moveAnimation.beginTime = CACurrentMediaTime() + 3;
moveAnimation.duration = 0.5;
moveAnimation.repeatCount = 1;
moveAnimation.removedOnCompletion = YES;
[moveAnimation setCompletionBlock:^(POPAnimation *anim, BOOL finished) {
if (finished) {
[enterHideTipView removeFromSuperview];
}
}];
[enterHideTipView pop_addAnimation:moveAnimation forKey:@"moveOutAnimation"];
}
}];
[enterHideTipView pop_addAnimation:springAnimation forKey:@"roomEnterTipUpspingOutAnimation"];
}
#pragma mark -
- (void)receiveDriveCarEnterRoom:(AttachmentModel *)attatchment {
if (self.isLargeGiftAnimating) {return;}
if ([self isInSudGame]) {return;}
if (!self.delegate.getRoomInfo.hasAnimationEffect) {return;}
NSInteger otherViewType = [attatchment.data[@"otherViewType"] integerValue];
NSString *viewUrl = attatchment.data[@"viewUrl"];
NSString * effect = attatchment.data[@"effect"];
if (viewUrl.length) {
NSDictionary * dic = @{@"otherViewType":@(otherViewType), @"viewUrl":viewUrl};
if (self.carEffectQueue.count == 0) {
[self playCarEffect:dic];
}
[self.carEffectQueue addObject:dic];
} else if(effect.length) {
NSDictionary * dic = @{@"effect":effect};
if (self.carEffectQueue.count == 0) {
[self playCarEffect:dic];
}
[self.carEffectQueue addObject:dic];
}
}
- (void)playCarEffect:(NSDictionary *)effectDict {
NSString *viewUrl = [effectDict objectForKey:@"viewUrl"];
NSString *carEffect = [effectDict objectForKey:@"effect"];
2024-11-28 10:40:21 +08:00
@kWeakify(self);
2023-07-14 18:50:55 +08:00
if (viewUrl.length) {
[self.vapParser parseWithURL:viewUrl completionBlock:^(NSString * _Nullable videoUrl) {
2024-11-28 10:40:21 +08:00
@kStrongify(self);
2023-07-14 18:50:55 +08:00
if (videoUrl.length) {
2023-09-21 17:44:59 +08:00
if([videoUrl containsString:@".pag"]){
self.carPagView.hidden = NO;
if(self.carPagView.superview == nil){
[self.middleLevelView addSubview:self.carPagView];
[self.carPagView mas_makeConstraints:^(MASConstraintMaker *make) {
make.center.mas_equalTo(self.middleLevelView);
make.width.mas_equalTo(KScreenWidth);
make.height.mas_equalTo(KScreenHeight);
}];
[self.carPagView setPath:videoUrl];
self.carPagView.userInteractionEnabled = NO;
self.carPagView.repeatCount = 1;
self.carPagView.scaleMode = PAGScaleModeStretch;
[self.carPagView play];
}
2024-11-28 10:40:21 +08:00
} else {
self.carVapEffectView.hidden = NO;
if (self.carVapEffectView.superview == nil) {
[self.middleLevelView addSubview:self.carVapEffectView];
[self.carVapEffectView mas_makeConstraints:^(MASConstraintMaker *make) {
make.center.mas_equalTo(self.middleLevelView);
make.width.mas_equalTo(KScreenWidth);
make.height.mas_equalTo(KScreenHeight);
}];
}
[self.carVapEffectView setMute:NO];
[self.carVapEffectView playHWDMP4:videoUrl repeatCount:1 delegate:self];
2023-08-14 19:03:26 +08:00
}
2023-07-14 18:50:55 +08:00
}
} failureBlock:^(NSError * _Nullable error) {
}];
} else if (carEffect.length) {
[self.parser parseWithURL:[NSURL URLWithString:carEffect] completionBlock:^(SVGAVideoEntity * _Nullable videoItem) {
2024-11-28 10:40:21 +08:00
@kStrongify(self);
2023-07-14 18:50:55 +08:00
if (videoItem != nil) {
2023-08-14 19:03:26 +08:00
if (self.carEffectView.superview == nil) {
[self.middleLevelView addSubview:self.carEffectView];
[self.carEffectView mas_makeConstraints:^(MASConstraintMaker *make) {
make.center.mas_equalTo(self.middleLevelView);
make.width.mas_equalTo(KScreenWidth);
make.height.mas_equalTo(KScreenHeight);
}];
}
2023-07-14 18:50:55 +08:00
CGFloat width = videoItem.videoSize.width;
CGFloat height = videoItem.videoSize.height;
if (width > height) {
self.carEffectView.contentMode = UIViewContentModeScaleAspectFit;
} else {//
CGFloat resizeH = KScreenWidth * height / width;//
if (resizeH > KScreenHeight) {//
self.carEffectView.contentMode = UIViewContentModeScaleAspectFill;
} else {//
self.carEffectView.contentMode = UIViewContentModeScaleAspectFit;
}
}
self.carEffectView.hidden = NO;
self.carEffectView.alpha = 1;
self.carEffectView.loops = 1;
self.carEffectView.clearsAfterStop = YES;
self.carEffectView.videoItem = videoItem;
[self.carEffectView startAnimation];
}
} failureBlock:^(NSError * _Nullable error) {
}];
}
}
#pragma mark -
- (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;
2023-10-24 12:27:53 +08:00
CGFloat top = self.isPlayOfA == YES ? (self.broadCastHieght + statusbarHeight) : (kNavigationHeight + 15);
2023-07-14 18:50:55 +08:00
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.middleLevelView 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)];
2024-11-28 10:40:21 +08:00
@kWeakify(self);
2023-07-14 18:50:55 +08:00
[springAnimation setCompletionBlock:^(POPAnimation *anim, BOOL finished) {
2024-11-28 10:40:21 +08:00
@kStrongify(self);
2023-07-14 18:50:55 +08:00
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];
}
2023-09-21 17:44:59 +08:00
// if(self. isAnimationListAFinish == YES){
//
// [self playAnimationWithModel];
// self.isAnimationListAFinish = NO;
// return;
// }
2023-07-14 18:50:55 +08:00
[self playAnimationWithModel];
}
}];
[candyTreeView pop_addAnimation:moveAnimation forKey:@"moveOutAnimation"];
}
}];
[candyTreeView pop_addAnimation:springAnimation forKey:@"candyTreespingOutAnimation"];
}
#pragma mark -
- (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.middleLevelView 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"];
}
2024-04-11 15:47:44 +08:00
#pragma mark - VIP
2023-07-14 18:50:55 +08:00
- (void)receiveNobleLevelUp:(AttachmentModel *)attachment {
2024-07-22 21:09:29 +08:00
@kWeakify(self);
2023-11-15 14:16:01 +08:00
[[NetImageView new]loadImageWithUrl:attachment.data[@"avatar"] completion:^(UIImage * _Nonnull image, NSURL * _Nonnull url) {
2024-07-22 21:09:29 +08:00
@kStrongify(self);
2023-11-15 14:16:01 +08:00
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];
}];
2023-07-14 18:50:55 +08:00
}
- (void)createNobleLevelUpBannerAnimation:(PIBaseAnimationViewModel *)model {
self.isPlayOfB = YES;
2023-10-24 12:27:53 +08:00
CGFloat top = self.isPlayOfA == YES ? (self.broadCastHieght + statusbarHeight) : (kNavigationHeight + 15);
2023-07-14 18:50:55 +08:00
XPRoomNobleLevelUpView *nobleLevelUpView = [[XPRoomNobleLevelUpView alloc] initWithFrame:CGRectMake(KScreenWidth, top, KScreenWidth, 90)];
nobleLevelUpView.nobleInfo = model.data;
[self.highLevleView addSubview:nobleLevelUpView];
2023-11-20 14:25:47 +08:00
@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];
2023-07-14 18:50:55 +08:00
}
2023-11-20 14:25:47 +08:00
}];
[nobleLevelUpView pop_addAnimation:moveAnimation forKey:@"moveOutAnimation"];
});
[nobleLevelUpView pop_addAnimation:springAnimation forKey:@"nobleLevelUpspingOutAnimation"];
};
2023-07-14 18:50:55 +08:00
}
#pragma mark -
- (void)receiveGiftCompound:(AttachmentModel *)attachment {
if ([self isInSudGame]) {return;}
2024-01-03 16:58:16 +08:00
PIBaseAnimationViewModel *magicModel =[PIBaseAnimationViewModel new];
magicModel.data = attachment.data;
magicModel.type = GiftBannerType_Magic_House;
if(self.animationListB.count == 0 && self.isPlayOfB == NO){
[self createGiftCompoundBannerAnimation:magicModel];
2023-07-14 18:50:55 +08:00
}
2024-01-03 16:58:16 +08:00
[self.animationListB addObject:magicModel];
2023-07-14 18:50:55 +08:00
}
2024-01-03 16:58:16 +08:00
- (void)createGiftCompoundBannerAnimation:(PIBaseAnimationViewModel *)attachment {
self.isPlayOfB = YES;
2023-07-14 18:50:55 +08:00
XPRoomGiftCompoundView *compoundGiftView = [[XPRoomGiftCompoundView alloc] initWithFrame:CGRectMake(KScreenWidth, kNavigationHeight + 15, KScreenWidth, 45)];
compoundGiftView.compoundGiftInfo = attachment.data;
[self.middleLevelView 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];
2024-01-03 16:58:16 +08:00
self.isPlayOfB = NO;
if(self.animationListB.count > 0){
[self.animationListB removeObjectAtIndex:0];
2023-07-14 18:50:55 +08:00
}
2024-01-03 16:58:16 +08:00
// if(self.isAnimationListAFinish == YES){
// self.isAnimationListAFinish = NO;
// [self playAnimationWithModel];
// return;
// }
[self playAnimationWithModel];
2023-07-14 18:50:55 +08:00
}
}];
[compoundGiftView pop_addAnimation:moveAnimation forKey:@"moveOutAnimation"];
}
}];
[compoundGiftView pop_addAnimation:springAnimation forKey:@"compoundGiftSpingOutAnimation"];
}
2023-09-25 16:02:57 +08:00
#pragma mark - XPRoomAnchorRankBannerViewDelegate
- (void)xPRoomAnchorRankBannerView:(XPRoomAnchorRankBannerView *)view rankInfo:(RoomHalfHourRankModel *)rankInfo{
2023-07-14 18:50:55 +08:00
if (rankInfo.uid.integerValue > 0 && self.delegate.getRoomInfo.uid != rankInfo.uid.integerValue) {
[self.delegate 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];
});
}
}
2023-09-25 16:02:57 +08:00
#pragma mark -
2023-07-14 18:50:55 +08:00
- (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;
2023-10-24 12:27:53 +08:00
CGFloat top = self.isPlayOfA == YES ? (self.broadCastHieght + statusbarHeight) : (kNavigationHeight + 15);
2023-09-25 16:02:57 +08:00
XPRoomAnchorRankBannerView *anchorRankView = [[XPRoomAnchorRankBannerView alloc] initWithFrame:CGRectMake(KScreenWidth,top, KScreenWidth, kGetScaleWidth(55))];
2023-07-14 18:50:55 +08:00
anchorRankView.anchorRankInfo = [RoomHalfHourRankModel modelWithDictionary:attachment.data];
2023-09-25 16:02:57 +08:00
anchorRankView.delegate = self;
2023-07-14 18:50:55 +08:00
UITapGestureRecognizer *tap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(gotoTopRankAnchorRoom:)];
[anchorRankView addGestureRecognizer:tap];
[self.highLevleView 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];
}
2023-09-21 17:44:59 +08:00
// if(self.isAnimationListAFinish == YES){
// self.isAnimationListAFinish = NO;
// [self playAnimationWithModel];
// return;
// }
2023-07-14 18:50:55 +08:00
[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.delegate 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];
});
}
}
#pragma mark -
- (void)receiveFansTeamGiftHandleSendGiftAnimation:(AttachmentModel *)attachment {
if ([self isInSudGame]) {return;}
if (!self.delegate.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.delegate.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];
2024-12-11 10:48:01 +08:00
2023-07-14 18:50:55 +08:00
}
#pragma mark -
- (void)receiveGiftHandleSendGiftAnimation:(AttachmentModel *)attachment {
if ([self isInSudGame]) {return;}
if (!self.delegate.getRoomInfo.hasAnimationEffect) {return;}
GiftReceiveInfoModel * receiveInfo = [GiftReceiveInfoModel modelWithJSON:attachment.data];
if (attachment.second == Custom_Message_Sub_Gift_EmbeddedStyle) {
receiveInfo.targetUid = [[attachment.data objectForKey:@"recvUserUid"] stringValue];
receiveInfo.targetNick = [attachment.data objectForKey:@"recvUserNick"];
receiveInfo.targetAvatar = [attachment.data objectForKey:@"recvUserAvatar"];
receiveInfo.avatar = [attachment.data objectForKey:@"sendUserAvatar"];
receiveInfo.nick = [attachment.data objectForKey:@"sendUserNick"];
receiveInfo.uid = [[attachment.data objectForKey:@"sendUserUid"] stringValue];
}
2023-07-14 18:50:55 +08:00
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];
2023-07-14 18:50:55 +08:00
2024-12-11 10:48:01 +08:00
}
#pragma mark - GiftAnimationManagerDelegate
- (CGPoint)animationPointAtStageViewByUid:(NSString *)uid {
return [self.delegate animationPointAtStageViewByUid:uid];
2023-07-14 18:50:55 +08:00
}
#pragma mark -
- (void)createGiftBroadcastViewAnimation:(GiftReceiveInfoModel *)giftModel {
self.isPlayOfA = YES;
XPRoomGiftBroadcastView * view = [[XPRoomGiftBroadcastView alloc] init];
view.delegate = self;
2023-10-24 12:27:53 +08:00
view.frame = CGRectMake(KScreenWidth, 35 + statusbarHeight, KScreenWidth, kGetScaleWidth(69));
2023-07-14 18:50:55 +08:00
view.broadcastModel = giftModel;
[self.highLevleView 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.animationListA.count > 0 && self.isPlayOfB == NO && self.isPlayOfA == NO) {
[self createGiftBroadcastViewAnimation:self.animationListA.firstObject];
}
}
}];
[view pop_addAnimation:moveAnimation forKey:@"moveOutAnimation"];
}
#pragma mark - XPRoomGiftBroadcastViewDelegate
2023-10-24 12:27:53 +08:00
- (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;
}
2023-07-14 18:50:55 +08:00
if (roomUid.length > 0 && self.delegate.getRoomInfo.uid != roomUid.integerValue) {
[self.delegate 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];
});
}
}
2023-10-24 12:27:53 +08:00
#pragma mark - PIRoomGiftBroadcastWindowDelegate
-(void)confirmLeaveForTheRoom:(NSString *_Nonnull)roomUid{
if (roomUid.length > 0 && self.delegate.getRoomInfo.uid != roomUid.integerValue) {
[self.delegate 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];
});
2023-07-14 18:50:55 +08:00
}
}
#pragma mark -
- (void)receiveLuckyGiftBigPrize:(AttachmentModel *)attachment {
if ([self isInSudGame]) {return;}
2023-09-21 17:44:59 +08:00
PIBaseAnimationViewModel * prizeModel = [PIBaseAnimationViewModel modelWithDictionary:attachment.data];
prizeModel.type = GiftBannerType_Lucky;
prizeModel.isInRoomVisable = attachment.second == Custom_Message_Sub_Room_Gift_LuckBag;
2023-09-21 17:44:59 +08:00
if(self.animationListB.count == 0 && self.isPlayOfB == NO){
[self createBigPrizeAnimation:prizeModel];
}
[self.animationListB addObject:prizeModel];
2023-07-14 18:50:55 +08:00
}
- (void)createBigPrizeAnimation:(PIBaseAnimationViewModel *)prizeModel {
self.isPlayOfB = YES;
2023-10-24 12:27:53 +08:00
CGFloat top = self.isPlayOfA == YES ? (self.broadCastHieght + statusbarHeight) : (kNavigationHeight + 15);
2023-07-14 18:50:55 +08:00
self.isLuckyGiftAnimation = YES;
2024-01-03 16:58:16 +08:00
XPRoomLuckyBigPrizeView * luckyGiftEffectView = [[XPRoomLuckyBigPrizeView alloc] initWithFrame:CGRectMake(KScreenWidth, top, 375, 71)];
2023-07-14 18:50:55 +08:00
luckyGiftEffectView.delegate = self;
[self.highLevleView 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)];
2024-01-03 16:58:16 +08:00
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"];
2023-09-21 17:44:59 +08:00
2023-07-21 18:53:10 +08:00
});
2023-07-14 18:50:55 +08:00
[luckyGiftEffectView pop_addAnimation:springAnimation forKey:@"nobleLevelUpspingOutAnimation"];
}
-(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){
2023-09-25 16:02:57 +08:00
[self createAnchorHourRankAnimation:model];
2023-08-16 14:21:58 +08:00
}else if(model.type == GiftBannerType_Fairy){
[self createTreasureFairyBannerAnimation:model];
2023-09-14 11:16:47 +08:00
}else if(model.type == GiftBannerType_Tarrow){
[self createTarotBannerAnimation:model];
}else if(model.type == GiftBannerType_Common_H5){
[self createCommonH5BannerAnimation:model];
2024-01-03 16:58:16 +08:00
}else if(model.type == GiftBannerType_Magic_House){
[self createGiftCompoundBannerAnimation:model];
2023-07-14 18:50:55 +08:00
}
}
-(void)playAnimationWithModel{
2023-09-21 17:44:59 +08:00
// if(self.isAnimationListAFinish == YES)return;
2023-07-14 18:50:55 +08:00
if(self.animationListB.count <= 0){
if(self.animationListA.count > 0 && self.isPlayOfB == NO && self.isPlayOfA == NO){
2023-07-21 14:07:04 +08:00
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.5 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
[self createGiftBannerViewAnimation:self.animationListA.firstObject];
});
2023-07-14 18:50:55 +08:00
}
return;
}
2023-07-14 18:50:55 +08:00
if(self.isPlayOfB == YES)return;
2023-07-14 18:50:55 +08:00
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){
2023-09-25 16:02:57 +08:00
[self createAnchorHourRankAnimation:model];
2023-08-10 10:12:19 +08:00
}else if(model.type == GiftBannerType_Fairy){
[self createTreasureFairyBannerAnimation:model];
2023-09-14 11:16:47 +08:00
}else if(model.type == GiftBannerType_Tarrow){
[self createTarotBannerAnimation:model];
}else if(model.type == GiftBannerType_Common_H5){
[self createCommonH5BannerAnimation:model];
2024-01-03 16:58:16 +08:00
}else if(model.type == GiftBannerType_Magic_House){
[self createGiftCompoundBannerAnimation:model];
2024-03-20 19:55:26 +08:00
}else if (model.type == GiftBannerType_General_Floating_Screen){
2024-10-15 20:56:25 +08:00
[self createGeneralFloatingScreenAnimation:model bannerModel:nil];
2023-07-14 18:50:55 +08:00
}
}
#pragma mark - XPRoomLuckyBigPrizeViewDelegate
- (void)xPRoomLuckyBigPrizeView:(XPRoomLuckyBigPrizeView *)view luckyGiftInfo:(PIBaseAnimationViewModel *)giftInfo {
2024-01-03 16:58:16 +08:00
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.delegate.getRoomInfo.uid) {
[self.delegate 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];
});
}
2023-07-14 18:50:55 +08:00
}
#pragma mark -
- (void)receiveCombo:(GiftReceiveInfoModel *)receiveInfo {
[[GiftComboManager sharedManager] receiveGiftInfoForDisplayComboFlags:receiveInfo
container:self];
}
- (void)startAnimation:(UIView *)animatedView {
//
CGFloat leftPosition = -animatedView.frame.size.width;
// 1
[UIView animateWithDuration:0.25
delay:0
options:UIViewAnimationOptionCurveEaseInOut
animations:^{
//
animatedView.center = CGPointMake(self.bounds.size.width / 2, self.bounds.size.height / 2);
} completion:^(BOOL finished) {
// 2
[self continueAnimationToLeft:leftPosition view:animatedView];
}];
}
// 2
- (void)continueAnimationToLeft:(CGFloat)leftPosition view:(UIView *)animatedView {
// 2
[UIView animateWithDuration:0.25
delay:500.0
options:UIViewAnimationOptionCurveEaseInOut
animations:^{
//
animatedView.center = CGPointMake(leftPosition, self.bounds.size.height / 2);
} completion:^(BOOL finished) {
//
[animatedView removeFromSuperview];
}];
}
2023-07-14 18:50:55 +08:00
#pragma mark -
///
- (void)receiveGift:(GiftReceiveInfoModel *)receiveInfo {
if ([self isInSudGame] || receiveInfo.isHomeShow == YES) {
return;
}
[self receiveCombo:receiveInfo];
2023-07-14 18:50:55 +08:00
///CPU
RoomInfoModel * roomInfo = [self.delegate getRoomInfo];
2023-07-14 18:50:55 +08:00
if (receiveInfo.isLuckyBagGift) {
if (receiveInfo.isShowAnimation) {
// SVGA
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) {
2023-07-14 18:50:55 +08:00
GiftReceiveInfoModel * model = [[GiftReceiveInfoModel alloc] init];
model.viewUrl = obj.viewUrl;
2023-07-21 14:07:04 +08:00
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) {
2023-07-14 18:50:55 +08:00
GiftReceiveInfoModel * model = [[GiftReceiveInfoModel alloc] init];
2023-07-21 14:07:04 +08:00
model.viewUrl = 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];
2023-07-14 18:50:55 +08:00
}
}];
}
}
} else {
GiftInfoModel *giftInfo = receiveInfo.gift != nil ? receiveInfo.gift : receiveInfo.giftInfo;
if (!giftInfo) {
giftInfo = [[XPGiftStorage shareStorage] findGiftInfo: receiveInfo.giftId];
}
///
if (giftInfo) {
receiveInfo.gift = giftInfo;
}
if (receiveInfo.targetUsers.count > 0 && receiveInfo.targetUids.count <= 0) {
receiveInfo.targetUids = [receiveInfo.targetUsers valueForKeyPath:@"uid"];
2023-09-21 17:44:59 +08:00
}
2023-07-14 18:50:55 +08:00
NSInteger giftTotal = 0;
if (receiveInfo.targetUids.count > 0) {
giftTotal = receiveInfo.giftNum * giftInfo.goldPrice * receiveInfo.targetUids.count;
} else {
giftTotal = receiveInfo.giftNum * giftInfo.goldPrice;
}
if ((giftInfo.otherViewType == GiftOtherViewTypeMp4 || giftInfo.otherViewType == GiftOtherViewTypePag) && giftInfo.viewUrl.length > 0 && roomInfo.hasAnimationEffect) {
2023-07-14 18:50:55 +08:00
receiveInfo.viewUrl = giftInfo.viewUrl;
2023-09-21 17:44:59 +08:00
// [self.animationListA addObject:receiveInfo];
2023-07-21 14:07:04 +08:00
[self.svgaQueue addObject:receiveInfo];
} else if (giftInfo.hasVggPic && giftInfo.vggUrl.length > 0 && roomInfo.hasAnimationEffect) {///SVGA
2023-07-14 18:50:55 +08:00
receiveInfo.vggUrl = giftInfo.vggUrl;
2023-09-21 17:44:59 +08:00
// [self.animationListA addObject:receiveInfo];
2023-07-21 14:07:04 +08:00
[self.svgaQueue addObject:receiveInfo];
2023-07-14 18:50:55 +08:00
}
}
2023-08-30 17:35:45 +08:00
if (self.giftEffectTimer == nil && self.svgaQueue.count > 0) {
[self startHandleGiftEffectTimer];
2023-07-21 14:07:04 +08:00
}
2023-07-14 18:50:55 +08:00
}
2023-08-30 17:35:45 +08:00
///
- (void)startHandleGiftEffectTimer {
2023-08-31 15:34:07 +08:00
NSTimeInterval period = 1.0; // 6 1svga 2.svga 3
2023-08-30 17:35:45 +08:00
dispatch_queue_t queue = dispatch_get_global_queue(0, 0);
dispatch_source_t _timer = dispatch_source_create(DISPATCH_SOURCE_TYPE_TIMER, 0, 0, queue);
dispatch_source_set_timer(_timer, dispatch_walltime(NULL, 0), period * NSEC_PER_SEC, 0); //
@kWeakify(self);
dispatch_source_set_event_handler(_timer, ^{
@kStrongify(self)
2024-12-06 14:38:45 +08:00
NSLog(@"******************* 当前队列个数: %@image loader 个数: %@", @(self.svgaQueue.count), @(self.avatarLoaders.count));
2023-08-30 17:35:45 +08:00
if (self.svgaQueue.count > 0) {
dispatch_sync(dispatch_get_main_queue(), ^{
2023-08-31 15:34:07 +08:00
if(self.isLargeGiftAnimating == NO){
GiftReceiveInfoModel * receiveModel = [self.svgaQueue xpSafeObjectAtIndex:0];
if (receiveModel) {
[self createGiftSvgaAnimation:receiveModel];
[self.svgaQueue removeObjectAtIndex:0];
NSLog(@"******************* 执行播放 %@, self.svgaQueue num: %@", receiveModel.targetAvatar, @(self.svgaQueue.count));
}
2023-08-31 15:34:07 +08:00
}
2023-08-30 17:35:45 +08:00
});
}else {
dispatch_source_cancel(_timer);
self.giftEffectTimer = nil;
}
});
dispatch_resume(_timer);
self.giftEffectTimer = _timer;
}
2023-07-21 14:07:04 +08:00
-(void)createGiftSvgaAnimation:(GiftReceiveInfoModel *)receiveInfo{
GiftInfoModel *giftInfo = receiveInfo.gift != nil ? receiveInfo.gift : receiveInfo.giftInfo;
if (!giftInfo) {
giftInfo = [[XPGiftStorage shareStorage] findGiftInfo: receiveInfo.giftId];
}
2023-09-21 17:44:59 +08:00
if ((giftInfo.otherViewType == GiftOtherViewTypeMp4 || giftInfo.otherViewType == GiftOtherViewTypePag) && giftInfo.viewUrl.length > 0 && [self.delegate getRoomInfo].hasAnimationEffect) {
if(giftInfo.otherViewType == GiftOtherViewTypePag){
[self largeGiftStopCarEffect:giftInfo.goldPrice];
[self playGiftEffectWithPagUrl:giftInfo.viewUrl];
}else{
[self largeGiftStopCarEffect:giftInfo.goldPrice];
self.mp4TempReceiveInfoModel = receiveInfo;
2023-09-21 17:44:59 +08:00
[self playGiftEffectWithVapUrl:giftInfo.viewUrl];
}
2023-07-21 14:07:04 +08:00
}
if (giftInfo.hasVggPic && giftInfo.vggUrl.length > 0 && [self.delegate getRoomInfo].hasAnimationEffect) {
[self largeGiftStopCarEffect:giftInfo.goldPrice];
[self playGiftEffect:giftInfo.vggUrl];
}
[[NSNotificationCenter defaultCenter] postNotificationName:@"kExchangeRoomAnimationViewAndGameViewIndex"
object:nil];
2023-07-21 14:07:04 +08:00
}
2023-07-14 18:50:55 +08:00
- (void)createGiftBannerViewAnimation:(GiftReceiveInfoModel *)receiveInfo {
2023-08-08 16:37:36 +08:00
[self createGiftBroadcastViewAnimation:receiveInfo];
2023-07-14 18:50:55 +08:00
}
- (void)largeGiftStopCarEffect:(double)goldPrice {
if ([ClientConfig shareConfig].configInfo.hideCarEffectGiftPrice <= goldPrice) {
2023-08-31 15:34:07 +08:00
self.isLargeGiftAnimating = YES;
2023-07-14 18:50:55 +08:00
[self.carEffectView stopAnimation];
[self.carVapEffectView stopHWDMP4];
2023-09-21 17:44:59 +08:00
[self.carPagView stop];
2023-07-14 18:50:55 +08:00
[self.carEffectQueue removeAllObjects];
}
}
- (NSArray<XPGiftBannerUserInfoModel *> *)makeBannerUsers {
NSArray<MicroQueueModel *> * microArray = [self.delegate getMicroQueue].allValues;
NSMutableArray * array = [NSMutableArray array];
[microArray enumerateObjectsUsingBlock:^(MicroQueueModel * _Nonnull obj, NSUInteger idx, BOOL * _Nonnull stop) {
XPGiftBannerUserInfoModel * bannserUser = [[XPGiftBannerUserInfoModel alloc] init];
bannserUser.position = obj.microState.position;
bannserUser.uid = obj.userInfo.uid;
[array addObject:bannserUser];
}];
return array;
}
/// SVGA
- (void)playGiftEffect:(NSString *)vggUrl {
if ([self isInSudGame]) {return;}
2024-11-22 21:05:47 +08:00
NSString *encodingUrl = [vggUrl pureURLString];
2024-05-16 14:30:21 +08:00
NSString *fileName = [[encodingUrl componentsSeparatedByString:@"/"] lastObject];
NSString *fullPath = [self.GiftDynamicEffectListPath stringByAppendingPathComponent:fileName];
2024-05-15 17:35:51 +08:00
if ([[NSFileManager defaultManager] fileExistsAtPath:fullPath]){
2024-05-16 14:30:21 +08:00
NSData *data = [NSData dataWithContentsOfFile:fullPath options:0 error:NULL];
@kWeakify(self);
[self.parser parseWithData:data cacheKey:fileName completionBlock:^(SVGAVideoEntity * _Nonnull videoItem) {
@kStrongify(self);
2023-08-08 16:37:36 +08:00
if (videoItem != nil) {
2023-08-14 19:03:26 +08:00
self.giftEffectView.hidden = NO;
if (self.giftEffectView.superview == nil) {
[self.middleLevelView addSubview:self.giftEffectView];
[self.giftEffectView mas_makeConstraints:^(MASConstraintMaker *make) {
make.center.mas_equalTo(self.middleLevelView);
make.width.mas_equalTo(KScreenWidth);
make.height.mas_equalTo(KScreenHeight);
}];
}
2023-08-08 16:37:36 +08:00
CGFloat width = videoItem.videoSize.width;
CGFloat height = videoItem.videoSize.height;
if (width > height) {
self.giftEffectView.contentMode = UIViewContentModeScaleAspectFit;
} else {//
CGFloat resizeH = KScreenWidth * height / width;//
if (resizeH > KScreenHeight) {//
self.giftEffectView.contentMode = UIViewContentModeScaleAspectFill;
} else {//
self.giftEffectView.contentMode = UIViewContentModeScaleAspectFit;
}
}
self.giftEffectView.alpha = 1;
self.giftEffectView.loops = 1;
self.giftEffectView.clearsAfterStop = YES;
self.giftEffectView.videoItem = videoItem;
[self.giftEffectView startAnimation];
} else {
self.isLargeGiftAnimating = NO;
2023-08-08 16:37:36 +08:00
}
2023-09-21 17:44:59 +08:00
} failureBlock:^(NSError * _Nonnull error) {
@kStrongify(self);
2023-09-21 17:44:59 +08:00
self.giftEffectView.hidden = YES;
2024-04-19 11:57:52 +08:00
self.isLargeGiftAnimating = NO;
2023-09-21 17:44:59 +08:00
}];
} else {
@kWeakify(self);
[self.parser parseWithURL:[NSURL URLWithString:encodingUrl] completionBlock:^(SVGAVideoEntity * _Nullable videoItem) {
@kStrongify(self);
if (videoItem != nil) {
self.giftEffectView.hidden = NO;
if (self.giftEffectView.superview == nil) {
[self.middleLevelView addSubview:self.giftEffectView];
[self.giftEffectView mas_makeConstraints:^(MASConstraintMaker *make) {
make.center.mas_equalTo(self.middleLevelView);
make.width.mas_equalTo(KScreenWidth);
make.height.mas_equalTo(KScreenHeight);
}];
}
CGFloat width = videoItem.videoSize.width;
CGFloat height = videoItem.videoSize.height;
if (width > height) {
2023-07-14 18:50:55 +08:00
self.giftEffectView.contentMode = UIViewContentModeScaleAspectFit;
} else {//
CGFloat resizeH = KScreenWidth * height / width;//
if (resizeH > KScreenHeight) {//
self.giftEffectView.contentMode = UIViewContentModeScaleAspectFill;
} else {//
self.giftEffectView.contentMode = UIViewContentModeScaleAspectFit;
}
2023-07-14 18:50:55 +08:00
}
self.giftEffectView.alpha = 1;
self.giftEffectView.loops = 1;
self.giftEffectView.clearsAfterStop = YES;
self.giftEffectView.videoItem = videoItem;
[self.giftEffectView startAnimation];
return;
2023-07-14 18:50:55 +08:00
}
self.isLargeGiftAnimating = NO;
} failureBlock:^(NSError * _Nullable error) {
@kStrongify(self);
self.giftEffectView.hidden = YES;
self.isLargeGiftAnimating = NO;
}];
}
2023-07-14 18:50:55 +08:00
}
2023-09-21 17:44:59 +08:00
/// pag
- (void)playGiftEffectWithPagUrl:(NSString *)pagUrl {
if ([self isInSudGame]) {return;}
[self.vapParser parseWithURL:pagUrl completionBlock:^(NSString * _Nullable videoUrl) {
self.giftPagView.hidden = NO;
if(self.giftPagView.superview == nil){
[self.middleLevelView addSubview:self.giftPagView];
[self.giftPagView mas_makeConstraints:^(MASConstraintMaker *make) {
make.center.mas_equalTo(self.middleLevelView);
make.width.mas_equalTo(KScreenWidth);
make.height.mas_equalTo(KScreenHeight);
}];
[self.giftPagView setPath:videoUrl];
self.giftPagView.userInteractionEnabled = NO;
self.giftPagView.repeatCount = 1;
self.giftPagView.scaleMode = PAGScaleModeStretch;
[self.giftPagView play];
}
} failureBlock:^(NSError * _Nullable error) {
self.giftPagView.hidden = YES;
}];
}
2023-07-14 18:50:55 +08:00
/// vap
- (void)playGiftEffectWithVapUrl:(NSString *)vapUrl {
2024-11-22 21:05:47 +08:00
NSString *encodingUrl = [vapUrl pureURLString];
2024-05-16 14:30:21 +08:00
NSString *fileName = [[encodingUrl componentsSeparatedByString:@"/"] lastObject];
NSString *fullPath = [self.GiftDynamicEffectListPath stringByAppendingPathComponent:fileName];
2024-12-06 14:38:45 +08:00
self.avatarLoaders = @[].mutableCopy;
2024-05-15 17:35:51 +08:00
if ([[NSFileManager defaultManager] fileExistsAtPath:fullPath]){
vapUrl = fullPath;
2023-08-31 15:34:07 +08:00
2023-08-14 19:03:26 +08:00
self.vapGiftEffectView.hidden = NO;
if (self.vapGiftEffectView.superview == nil) {
[self.middleLevelView addSubview:self.vapGiftEffectView];
[self.vapGiftEffectView mas_makeConstraints:^(MASConstraintMaker *make) {
make.center.mas_equalTo(self.middleLevelView);
make.width.mas_equalTo(KScreenWidth);
make.height.mas_equalTo(KScreenHeight);
}];
}
2024-05-21 16:19:10 +08:00
[self.vapGiftEffectView setMute:NO];
2023-08-14 19:03:26 +08:00
[self.vapGiftEffectView playHWDMP4:vapUrl repeatCount:1 delegate:self];
}else {
@kWeakify(self);
[self.vapParser parseWithURL:encodingUrl completionBlock:^(NSString * _Nullable videoUrl) {
@kStrongify(self);
if (videoUrl.length) {
self.vapGiftEffectView.hidden = NO;
if (self.vapGiftEffectView.superview == nil) {
[self.middleLevelView addSubview:self.vapGiftEffectView];
[self.vapGiftEffectView mas_makeConstraints:^(MASConstraintMaker *make) {
make.center.mas_equalTo(self.middleLevelView);
make.width.mas_equalTo(KScreenWidth);
make.height.mas_equalTo(KScreenHeight);
}];
}
[self.vapGiftEffectView setMute:NO];
[self.vapGiftEffectView playHWDMP4:videoUrl repeatCount:1 delegate:self];
2023-08-14 19:03:26 +08:00
}
} failureBlock:^(NSError * _Nullable error) {
self.vapGiftEffectView.hidden = YES;
}];
}
2023-07-14 18:50:55 +08:00
}
/// SVGA
- (void)playLuckyGiftEffect:(NSURL *)vggUrl {
if ([self isInSudGame]) {return;}
2023-08-14 19:03:26 +08:00
2024-11-22 21:05:47 +08:00
NSString *encodingUrl = [vggUrl.absoluteString pureURLString];
2024-05-16 14:30:21 +08:00
NSString *fileName = [[encodingUrl componentsSeparatedByString:@"/"] lastObject];
NSString *fullPath = [self.GiftDynamicEffectListPath stringByAppendingPathComponent:fileName];
2024-05-15 17:35:51 +08:00
if ([[NSFileManager defaultManager] fileExistsAtPath:fullPath]){
NSData *data=[NSData dataWithContentsOfFile:fullPath options:0 error:NULL];
2023-08-08 16:37:36 +08:00
[self.parser parseWithData:data cacheKey:@"" completionBlock:^(SVGAVideoEntity * _Nonnull videoItem) {
if (videoItem != nil) {
2023-08-14 19:03:26 +08:00
self.luckyGiftEffectView.hidden = NO;
if (self.luckyGiftEffectView.superview == nil) {
[self.middleLevelView addSubview:self.luckyGiftEffectView];
[self.luckyGiftEffectView mas_makeConstraints:^(MASConstraintMaker *make) {
make.center.mas_equalTo(self.middleLevelView);
make.width.mas_equalTo(KScreenWidth);
make.height.mas_equalTo(KScreenHeight);
}];
}
2023-08-08 16:37:36 +08:00
CGFloat width = videoItem.videoSize.width;
CGFloat height = videoItem.videoSize.height;
if (width > height) {
self.luckyGiftEffectView.contentMode = UIViewContentModeScaleAspectFit;
} else {//
CGFloat resizeH = KScreenWidth * height / width;//
if (resizeH > KScreenHeight) {//
self.luckyGiftEffectView.contentMode = UIViewContentModeScaleAspectFill;
} else {//
self.luckyGiftEffectView.contentMode = UIViewContentModeScaleAspectFit;
}
}
self.luckyGiftEffectView.alpha = 1;
self.luckyGiftEffectView.loops = 1;
self.luckyGiftEffectView.clearsAfterStop = YES;
self.luckyGiftEffectView.videoItem = videoItem;
[self.luckyGiftEffectView startAnimation];
}
} failureBlock:^(NSError * _Nonnull error) {
self.luckyGiftEffectView.hidden = YES;
}];
return;
};
2023-07-18 18:26:10 +08:00
2024-05-17 16:57:28 +08:00
[self.parser parseWithURL:[NSURL URLWithString:encodingUrl] completionBlock:^(SVGAVideoEntity * _Nullable videoItem) {
2023-07-14 18:50:55 +08:00
if (videoItem != nil) {
2023-08-14 19:03:26 +08:00
self.luckyGiftEffectView.hidden = NO;
if (self.luckyGiftEffectView.superview == nil) {
[self.middleLevelView addSubview:self.luckyGiftEffectView];
[self.luckyGiftEffectView mas_makeConstraints:^(MASConstraintMaker *make) {
make.center.mas_equalTo(self.middleLevelView);
make.width.mas_equalTo(KScreenWidth);
make.height.mas_equalTo(KScreenHeight);
}];
}
2023-07-14 18:50:55 +08:00
CGFloat width = videoItem.videoSize.width;
CGFloat height = videoItem.videoSize.height;
if (width > height) {
self.luckyGiftEffectView.contentMode = UIViewContentModeScaleAspectFit;
} else {//
CGFloat resizeH = KScreenWidth * height / width;//
if (resizeH > KScreenHeight) {//
self.luckyGiftEffectView.contentMode = UIViewContentModeScaleAspectFill;
} else {//
self.luckyGiftEffectView.contentMode = UIViewContentModeScaleAspectFit;
}
}
self.luckyGiftEffectView.alpha = 1;
self.luckyGiftEffectView.loops = 1;
self.luckyGiftEffectView.clearsAfterStop = YES;
self.luckyGiftEffectView.videoItem = videoItem;
[self.luckyGiftEffectView startAnimation];
}
} failureBlock:^(NSError * _Nullable error) {
self.luckyGiftEffectView.hidden = YES;
}];
}
/// vap
- (void)playLuckyGiftEffectWithVapUrl:(NSString *)vapUrl {
2024-11-22 21:05:47 +08:00
NSString *encodingUrl = [vapUrl pureURLString];
2024-11-07 16:16:09 +08:00
encodingUrl = [encodingUrl stringByAddingPercentEncodingWithAllowedCharacters:[NSCharacterSet URLQueryAllowedCharacterSet]];
2024-05-16 14:30:21 +08:00
NSString *fileName = [[encodingUrl componentsSeparatedByString:@"/"] lastObject];
NSString *fullPath = [self.GiftDynamicEffectListPath stringByAppendingPathComponent:fileName];
2024-05-15 17:35:51 +08:00
if ([[NSFileManager defaultManager] fileExistsAtPath:fullPath]){
vapUrl = fullPath;
2023-08-14 19:03:26 +08:00
self.luckyVapGiftEffectView.hidden = NO;
if (self.luckyVapGiftEffectView.superview == nil) {
[self.middleLevelView addSubview:self.luckyVapGiftEffectView];
[self.luckyVapGiftEffectView mas_makeConstraints:^(MASConstraintMaker *make) {
make.center.mas_equalTo(self.middleLevelView);
make.width.mas_equalTo(KScreenWidth);
make.height.mas_equalTo(KScreenHeight);
}];
}
2024-05-21 16:19:10 +08:00
[self.luckyVapGiftEffectView setMute:NO];
2023-08-14 19:03:26 +08:00
[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.luckyVapGiftEffectView.hidden = NO;
if (self.luckyVapGiftEffectView.superview == nil) {
[self.middleLevelView addSubview:self.luckyVapGiftEffectView];
[self.luckyVapGiftEffectView mas_makeConstraints:^(MASConstraintMaker *make) {
make.center.mas_equalTo(self.middleLevelView);
make.width.mas_equalTo(KScreenWidth);
make.height.mas_equalTo(KScreenHeight);
}];
}
[self.luckyVapGiftEffectView setMute:NO];
[self.luckyVapGiftEffectView playHWDMP4:videoUrl repeatCount:1 delegate:self];
2023-08-14 19:03:26 +08:00
}
} failureBlock:^(NSError * _Nullable error) {
self.luckyVapGiftEffectView.hidden = YES;
}];
}
2023-07-14 18:50:55 +08:00
}
#pragma mark -
- (void)svgaPlayerDidFinishedAnimation:(SVGAPlayer *)player {
if (player == self.giftEffectView) {
self.giftEffectView.hidden = YES;
2023-08-30 16:50:10 +08:00
if (self.isLargeGiftAnimating == YES) {
self.isLargeGiftAnimating = NO;
}
2023-07-14 18:50:55 +08:00
} else if (player == self.luckyGiftEffectView) {
self.luckyGiftEffectView.hidden = YES;
} else if(player == self.carEffectView) {
self.carEffectView.hidden = YES;
[self.carEffectView removeFromSuperview];
if (self.carEffectQueue.count > 0) {
[self.carEffectQueue removeObjectAtIndex:0];
}
if (self.carEffectQueue.count > 0) {
[self playCarEffect:self.carEffectQueue.firstObject];
}
} else if(player == self.enterEffectView) {
self.enterEffectView.hidden = YES;
[self.enterEffectView removeFromSuperview];
if (self.enterEffectQueue.count > 0) {
[self.enterEffectQueue removeObjectAtIndex:0];
}
if (self.enterEffectQueue.count > 0) {
NSString * title = [self.enterEffectQueue.firstObject objectForKey:@"title"];
NSInteger experLevelSeq = [(NSString *)[self.enterEffectQueue.firstObject objectForKey:@"experLevelSeq"] integerValue];
NSString *effectPath = [self.enterEffectQueue.firstObject objectForKey:@"effectPath"];
[self playUserEnterRoomAnimation:title experLevelSeq:experLevelSeq effectPath:effectPath];
}
}
}
2024-09-20 21:19:08 +08:00
#pragma mark - CP
2024-09-23 18:01:54 +08:00
- (void)receiveCPEvent:(AttachmentModel *)attachment {
[self.roomEffectModelsQueueV2 addObject:attachment];
if (!self.isRoomEffectV2Displaying) {
[self processNextRoomEffectAttachment];
}
}
2024-09-20 21:19:08 +08:00
2024-09-23 18:01:54 +08:00
- (void)playCPBinding:(AttachmentModel *)attachment {
@kWeakify(self);
[CPBindingAnimation display:self
with:attachment
complete:^{
@kStrongify(self);
[self processNextRoomEffectAttachment];
}];
2024-09-20 21:19:08 +08:00
}
2024-09-23 18:01:54 +08:00
- (void)playCPGiftBanner:(AttachmentModel *)attachMent {
@kWeakify(self);
[CPGiftBanner display:self
with:attachMent
complete:^{
@kStrongify(self);
[self processNextRoomEffectAttachment];
}];
2024-09-20 21:19:08 +08:00
}
2024-09-23 18:01:54 +08:00
- (void)playCPLevelUp:(AttachmentModel *)attachMent {
@kWeakify(self);
[CPLevelUpAnimation display:self
with:attachMent
complete:^{
@kStrongify(self);
[self processNextRoomEffectAttachment];
}];
}
#pragma mark -
- (void)receiveRoomGiftBanner:(AttachmentModel *)obj {
[self.roomEffectModelsQueueV2 addObject:obj];
if (!self.isRoomEffectV2Displaying) {
[self processNextRoomEffectAttachment];
}
}
- (void)playRoomGiftBanner:(AttachmentModel *)obj {
@kWeakify(self);
[RoomHighValueGiftBannerAnimation display:self
with:obj
complete:^{
2024-09-23 18:01:54 +08:00
@kStrongify(self);
[self processNextRoomEffectAttachment];
}];
2024-09-20 21:19:08 +08:00
}
2023-07-14 18:50:55 +08:00
#pragma mark -
- (void)receiveRoomWishGiftCelebrate:(AttachmentModel *)attachment {
CGFloat x = random() % (int)(KScreenWidth - 200);
CGFloat y= random() % 40 + kNavigationHeight;
if (self.wishGiftEffectView.superview == nil) {
[self.lowLevelView addSubview:self.wishGiftEffectView];
[self.wishGiftEffectView mas_makeConstraints:^(MASConstraintMaker *make) {
2024-04-11 17:05:27 +08:00
make.leading.mas_equalTo(x);
2023-07-14 18:50:55 +08:00
make.top.mas_equalTo(y);
make.width.mas_equalTo(200);
make.height.mas_equalTo(167);
}];
}
[self.wishGiftEffectView mas_updateConstraints:^(MASConstraintMaker *make) {
2024-04-11 17:05:27 +08:00
make.leading.mas_equalTo(x);
2023-07-14 18:50:55 +08:00
make.top.mas_equalTo(y);
}];
NSString * anatomiser1Name = [NSString stringWithFormat:@"%@/room_wish_gift_sendCelebrate.svga", API_Image_URL];
[self.parser parseWithURL:[NSURL URLWithString:anatomiser1Name] completionBlock:^(SVGAVideoEntity * _Nonnull videoItem) {
self.wishGiftEffectView.alpha = 1;
self.wishGiftEffectView.loops = 1;
self.wishGiftEffectView.clearsAfterStop = YES;
self.wishGiftEffectView.videoItem = videoItem;
[self.wishGiftEffectView startAnimation];
} failureBlock:^(NSError * _Nonnull error) {
}];
}
#pragma mark - HWDMP4PlayDelegate
//truefalse
- (BOOL)shouldStartPlayMP4:(VAPView *)container config:(QGVAPConfigModel *)config {
CGFloat width = config.info.size.width;
CGFloat height = config.info.size.height;
container.center = self.center;
[container mas_updateConstraints:^(MASConstraintMaker *make) {
make.width.mas_equalTo(KScreenWidth);
make.height.mas_equalTo(KScreenWidth * height / width);
}];
return YES;
}
- (void)viewDidFinishPlayMP4:(NSInteger)totalFrameCount view:(VAPView *)container {
dispatch_async(dispatch_get_main_queue(), ^{
container.hidden = YES;
if (container == self.carVapEffectView) {
[self.carVapEffectView removeFromSuperview];
self.carVapEffectView = nil;
if (self.carEffectQueue.count > 0) {
[self.carEffectQueue removeObjectAtIndex:0];
}
if (self.carEffectQueue.count > 0) {
[self playCarEffect:self.carEffectQueue.firstObject];
}
} else if (container == self.vapGiftEffectView) {
[self.vapGiftEffectView removeFromSuperview];
self.vapGiftEffectView = nil;
self.mp4TempReceiveInfoModel = nil;
2023-08-30 16:50:10 +08:00
if (self.isLargeGiftAnimating == YES) {
self.isLargeGiftAnimating = NO;
}
2023-07-14 18:50:55 +08:00
} else if(container == self.luckyVapGiftEffectView) {
[self.luckyVapGiftEffectView removeFromSuperview];
self.luckyVapGiftEffectView = nil;
}
});
}
- (void)viewDidStopPlayMP4:(NSInteger)lastFrameIndex view:(VAPView *)container {
dispatch_async(dispatch_get_main_queue(), ^{
container.hidden = YES;
if (container == self.carVapEffectView) {
[self.carVapEffectView removeFromSuperview];
self.carVapEffectView = nil;
if (self.carEffectQueue.count > 0) {
[self.carEffectQueue removeObjectAtIndex:0];
}
if (self.carEffectQueue.count > 0) {
[self playCarEffect:self.carEffectQueue.firstObject];
}
} else if (container == self.vapGiftEffectView) {
[self.vapGiftEffectView removeFromSuperview];
self.vapGiftEffectView = nil;
self.mp4TempReceiveInfoModel = nil;
2023-08-30 16:50:10 +08:00
if (self.isLargeGiftAnimating == YES) {
self.isLargeGiftAnimating = NO;
}
2023-07-14 18:50:55 +08:00
} else if(container == self.luckyVapGiftEffectView) {
[self.luckyVapGiftEffectView removeFromSuperview];
self.luckyVapGiftEffectView = nil;
} else if(container == self.wishGiftEffectView) {
[self.wishGiftEffectView removeFromSuperview];
self.wishGiftEffectView = nil;
}
});
}
2024-04-19 11:57:52 +08:00
- (void)viewDidFailPlayMP4:(NSError *)error{
if (self.isLargeGiftAnimating == YES) {
self.isLargeGiftAnimating = NO;
}
self.mp4TempReceiveInfoModel = nil;
2024-04-19 11:57:52 +08:00
}
- (void)loadVapImageWithURL:(NSString *)urlStr context:(NSDictionary *)context completion:(VAPImageCompletionBlock)completionBlock {
if (self.mp4TempReceiveInfoModel) {
dispatch_async(dispatch_get_main_queue(), ^{
QGVAPSourceInfo *info = (QGVAPSourceInfo *)context[@"resource"];
2024-12-06 14:38:45 +08:00
NSLog(@" MP4 的 key - info.contentTag : %@", info.contentTag);
if ([info.contentTag isEqualToString:@"avatar1"]) {
if ([NSString isEmpty:self.mp4TempReceiveInfoModel.avatar]) {
completionBlock(kImage(@"common_avatar"), nil, @"dafeult image");
} else {
NSString *path = @"";
switch (self.mp4TempReceiveInfoModel.gift.showAvatarType) {
case 1: // 使 avatar
case 3:
path = self.mp4TempReceiveInfoModel.avatar;
break;
case 2: // 使 target avatar
path = self.mp4TempReceiveInfoModel.targetAvatar;
break;
default:
completionBlock(kImage(@"common_avatar"), nil, @"dafeult image");
return;
break;
}
2024-12-06 14:38:45 +08:00
NetImageView *avatar_1_Loader = [[NetImageView alloc] init];
[avatar_1_Loader loadImageWithUrl:path completion:^(UIImage * _Nullable image, NSURL * _Nonnull url) {
completionBlock(image, nil, urlStr);
}];
2024-12-06 14:38:45 +08:00
[self.avatarLoaders addObject:avatar_1_Loader];
}
}
else if ([info.contentTag isEqualToString:@"avatar2"] ) {
GiftReceiveInfoModel *infoModel = self.mp4TempReceiveInfoModel;// [self.embeddedTargetDatas lastObject];
2024-12-06 14:38:45 +08:00
if (!infoModel || [NSString isEmpty:infoModel.targetAvatar]) {
completionBlock(kImage(@"common_avatar"), nil, @"dafeult image");
} else {
2024-12-06 14:38:45 +08:00
NetImageView *avatar_2_Loader = [[NetImageView alloc] init];
[avatar_2_Loader loadImageWithUrl:infoModel.targetAvatar completion:^(UIImage * _Nullable image, NSURL * _Nonnull url) {
completionBlock(image, nil, urlStr);
}];
2024-12-06 14:38:45 +08:00
[self.avatarLoaders addObject:avatar_2_Loader];
}
} else {
2024-12-06 14:38:45 +08:00
completionBlock(kImage(@"common_avatar"), nil, @"completionBlock");
}
});
}
}
- (NSString *)contentForVapTag:(NSString *)tag resource:(QGVAPSourceInfo *)info {
NSString *name1 = @"";
switch (self.mp4TempReceiveInfoModel.gift.showAvatarType) {
2024-12-06 14:38:45 +08:00
case 1:
case 3:
name1 = self.mp4TempReceiveInfoModel.nick;
break;
2024-12-06 14:38:45 +08:00
case 2:
name1 = self.mp4TempReceiveInfoModel.targetNick;
break;
default:
break;
}
NSDictionary *extraInfo = @{@"name1" : [NSString isEmpty:name1] ? @"" : name1,
@"name2" : [NSString isEmpty:self.mp4TempReceiveInfoModel.targetNick] ? @"" : self.mp4TempReceiveInfoModel.targetNick,
// @"id1" : [NSString isEmpty:self.mp4TempReceiveInfoModel.uid] ? @"" : self.mp4TempReceiveInfoModel.uid ,
// @"id2" : [NSString isEmpty:infoModel.targetUid] ? @"" : infoModel.targetUid
};
return [NSString isEmpty:extraInfo[tag]] ? @" " : extraInfo[tag];
}
2023-09-21 17:44:59 +08:00
#pragma mark - PAGViewListener
/**
* Notifies the beginning of the animation. It can be called from either the UI thread or the thread
* that calls the play method.
*/
- (void)onAnimationStart:(PAGView*)pagView{
}
/**
* Notifies the end of the animation. It can only be called from the UI thread.
*/
- (void)onAnimationEnd:(PAGView*)pagView{
dispatch_async(dispatch_get_main_queue(), ^{
pagView.hidden = YES;
if (pagView == self.giftPagView) {
[self.giftPagView removeFromSuperview];
self.giftPagView = nil;
if (self.isLargeGiftAnimating == YES) {
self.isLargeGiftAnimating = NO;
}
}else if(pagView == self.carPagView){
[self.carPagView removeFromSuperview];
self.carPagView = nil;
if (self.carEffectQueue.count > 0) {
[self.carEffectQueue removeObjectAtIndex:0];
}
if (self.carEffectQueue.count > 0) {
[self playCarEffect:self.carEffectQueue.firstObject];
}
}
});
}
2023-07-14 18:50:55 +08:00
2023-09-21 17:44:59 +08:00
/**
* Notifies the cancellation of the animation. It can be called from either the UI thread or the
* thread that calls the stop method.
*/
- (void)onAnimationCancel:(PAGView*)pagView{
dispatch_async(dispatch_get_main_queue(), ^{
pagView.hidden = YES;
if (pagView == self.giftPagView) {
[self.giftPagView removeFromSuperview];
self.giftPagView = nil;
if (self.isLargeGiftAnimating == YES) {
self.isLargeGiftAnimating = NO;
}
}
});
}
/**
* Notifies the repetition of the animation. It can only be called from the UI thread.
*/
- (void)onAnimationRepeat:(PAGView*)pagView{
}
/**
* Notifies another frame of the animation has occurred. It may be called from an arbitrary
* thread if the animation is running asynchronously.
*/
- (void)onAnimationUpdate:(PAGView*)pagView{
}
2023-07-14 18:50:55 +08:00
#pragma mark - Getters And Setters
- (SVGAImageView *)giftEffectView {
if (!_giftEffectView) {
_giftEffectView = [[SVGAImageView alloc]init];
_giftEffectView.backgroundColor = [UIColor colorWithWhite:0 alpha:0.5];
_giftEffectView.userInteractionEnabled = NO;
_giftEffectView.delegate = self;
_giftEffectView.hidden = YES;
}
return _giftEffectView;
}
- (VAPView *)vapGiftEffectView {
if (!_vapGiftEffectView) {
_vapGiftEffectView = [[VAPView alloc] initWithFrame:CGRectMake(0, 0, KScreenWidth, KScreenHeight)];
_vapGiftEffectView.backgroundColor = [UIColor colorWithWhite:0 alpha:0.5];
_vapGiftEffectView.contentMode = UIViewContentModeScaleAspectFill;
_vapGiftEffectView.hidden = YES;
}
return _vapGiftEffectView;
}
- (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;
}
- (VAPView *)carVapEffectView {
if (!_carVapEffectView) {
_carVapEffectView = [[VAPView alloc] initWithFrame:CGRectMake(0, 0, KScreenWidth, KScreenHeight)];
_carVapEffectView.backgroundColor = [UIColor colorWithWhite:0 alpha:0.3];
_carVapEffectView.contentMode = UIViewContentModeScaleAspectFill;
_carVapEffectView.hidden = YES;
}
return _carVapEffectView;
}
- (XPRoomGiftAnimationParser *)vapParser {
if (!_vapParser) {
_vapParser = [[XPRoomGiftAnimationParser alloc] init];
}
return _vapParser;
}
- (SVGAParser *)parser {
if (!_parser) {
_parser = [[SVGAParser alloc]init];
}
return _parser;
}
- (XPRoomAnimationHitView *)lowLevelView {
if (!_lowLevelView) {
_lowLevelView = [[XPRoomAnimationHitView alloc] init];
_lowLevelView.backgroundColor = [UIColor clearColor];
_lowLevelView.userInteractionEnabled = YES;
}
return _lowLevelView;
}
- (XPRoomAnimationHitView *)middleLevelView {
if (!_middleLevelView) {
_middleLevelView = [[XPRoomAnimationHitView alloc] init];
_middleLevelView.backgroundColor = [UIColor clearColor];
_middleLevelView.userInteractionEnabled = YES;
}
return _middleLevelView;
}
- (XPRoomAnimationHitView *)highLevleView {
if (!_highLevleView) {
_highLevleView = [[XPRoomAnimationHitView alloc] init];
_highLevleView.backgroundColor = [UIColor clearColor];
_highLevleView.userInteractionEnabled = YES;
}
return _highLevleView;
}
- (NSMutableArray<NSDictionary *> *)carEffectQueue {
if (_carEffectQueue == nil) {
_carEffectQueue = [NSMutableArray array];
}
return _carEffectQueue;
}
- (SVGAImageView *)carEffectView {
if (_carEffectView == nil) {
_carEffectView = [[SVGAImageView alloc]init];
_carEffectView.delegate = self;
_carEffectView.contentMode = UIViewContentModeScaleAspectFit;
_carEffectView.frame = CGRectMake(0, 0, KScreenWidth, KScreenHeight);
_carEffectView.backgroundColor = [UIColor colorWithRed:0 green:0 blue:0 alpha:0.3];
_carEffectView.alpha = 0;
_carEffectView.userInteractionEnabled = NO;
}
return _carEffectView;
}
- (NSMutableArray<NSDictionary *> *)enterEffectQueue {
if (_enterEffectQueue == nil) {
_enterEffectQueue = [NSMutableArray array];
}
return _enterEffectQueue;
}
- (SVGAImageView *)enterEffectView {
if (_enterEffectView == nil) {
_enterEffectView = [[SVGAImageView alloc]init];
_enterEffectView.delegate = self;
_enterEffectView.contentMode = UIViewContentModeScaleAspectFit;
_enterEffectView.frame = CGRectMake(0, 0, KScreenWidth, 40);
_enterEffectView.backgroundColor = [UIColor clearColor];
_enterEffectView.alpha = 0;
_enterEffectView.userInteractionEnabled = NO;
}
return _enterEffectView;
}
- (SVGAImageView *)datingEffectView {
if (_datingEffectView == nil) {
_datingEffectView = [[SVGAImageView alloc]init];
_datingEffectView.delegate = self;
_datingEffectView.contentMode = UIViewContentModeScaleAspectFit;
_datingEffectView.frame = CGRectMake(0, 0, KScreenWidth, KScreenHeight);
_datingEffectView.backgroundColor = [UIColor clearColor];
_datingEffectView.alpha = 0;
_datingEffectView.userInteractionEnabled = NO;
}
return _datingEffectView;
}
- (NSMutableArray<AcrossRoomPKPrizeModel *> *)acrossRoomPKQueue {
if (!_acrossRoomPKQueue) {
_acrossRoomPKQueue = [NSMutableArray array];
}
return _acrossRoomPKQueue;
}
- (NSMutableArray<AttachmentModel *> *)sailingQueue {
if (!_sailingQueue) {
_sailingQueue = [NSMutableArray array];
}
return _sailingQueue;
}
- (NSMutableArray<AttachmentModel *> *)graffitiGiftQueue {
if (!_graffitiGiftQueue) {
_graffitiGiftQueue = [NSMutableArray array];
}
return _graffitiGiftQueue;
}
- (SVGAImageView *)wishGiftEffectView {
if (_wishGiftEffectView == nil) {
_wishGiftEffectView = [[SVGAImageView alloc]init];
_wishGiftEffectView.delegate = self;
_wishGiftEffectView.contentMode = UIViewContentModeScaleAspectFit;
_wishGiftEffectView.frame = CGRectMake(0, 0, 210, 183);
_wishGiftEffectView.backgroundColor = [UIColor clearColor];
_wishGiftEffectView.alpha = 1;
_wishGiftEffectView.userInteractionEnabled = NO;
}
return _wishGiftEffectView;
}
- (NSMutableArray *)animationListA{
if(!_animationListA){
_animationListA = [NSMutableArray array];
}
return _animationListA;
}
- (NSMutableArray *)animationListB{
if(!_animationListB){
_animationListB = [NSMutableArray array];
}
return _animationListB;
}
2023-07-21 14:07:04 +08:00
- (NSMutableArray *)svgaQueue{
if(!_svgaQueue){
_svgaQueue = [NSMutableArray array];
}
return _svgaQueue;
}
- (PAGView *)giftPagView{
if(!_giftPagView){
_giftPagView = [[PAGView alloc]init];
2023-09-21 17:44:59 +08:00
[_giftPagView addListener:self];
_giftPagView.backgroundColor = [UIColor clearColor];
}
return _giftPagView;
}
2023-09-21 17:44:59 +08:00
- (PAGView *)carPagView{
if(!_carPagView){
_carPagView = [[PAGView alloc]init];
[_carPagView addListener:self];
_carPagView.backgroundColor = [UIColor clearColor];
}
return _carPagView;
}
2023-10-24 12:27:53 +08:00
- (CGFloat)broadCastHieght{
if(_broadCastHieght == 0){
_broadCastHieght = 190 - 150 + kGetScaleWidth(69);
}
return _broadCastHieght;
}
2024-09-20 21:19:08 +08:00
2023-07-14 18:50:55 +08:00
@end