新增夺宝精灵
This commit is contained in:
@@ -13,6 +13,7 @@ typedef enum : NSUInteger {
|
||||
GiftBannerType_kitchen,///厨房
|
||||
GiftBannerType_AnchorHour,///个播小时榜
|
||||
GiftBannerType_LicneseHour,///牌照房小时榜
|
||||
GiftBannerType_Fairy,///夺宝精灵
|
||||
} GiftBannerType;
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
|
@@ -60,6 +60,7 @@
|
||||
#import "XPWebViewController.h"
|
||||
#import "PIBaseAnimationViewModel.h"
|
||||
#import "PIFullScreenBannerAnimation.h"
|
||||
#import "XPTreasureFairyGiftView.h"
|
||||
@interface XPRoomAnimationView ()<SVGAPlayerDelegate,NIMBroadcastManagerDelegate, XPRoomGiftBroadcastViewDelegate, HWDMP4PlayDelegate, XPRoomLuckyBigPrizeViewDelegate,XPRoomLicneseHourRankViewDelegate, XPRoomGraffitiGiftAnimationViewDelegate, XPRoomStarKitchenBannerViewDelegate>
|
||||
///展示的不同层级
|
||||
///最底层的
|
||||
@@ -222,6 +223,8 @@
|
||||
[self receiveRoomGraffitiStarKitchen:attachment];
|
||||
}else if(attachment.first == CustomMessageType_Look_Love && attachment.second == Custom_Message_Sub_Look_Love_InRoom_NeedAllMicSend){
|
||||
[self receiveCandyTreeGiftHighLevle:attachment];
|
||||
}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];
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -414,6 +417,76 @@
|
||||
[self.delegate.getCurrentNav pushViewController:webVC animated:YES];
|
||||
|
||||
}
|
||||
#pragma mark - 夺宝精灵横幅
|
||||
- (void)receiveTreasureFairyGiftHighLevel:(AttachmentModel *)attatchment {
|
||||
if ([self isInSudGame]) {return;}
|
||||
|
||||
if ([self isInSudGame]) {return;}
|
||||
PIBaseAnimationViewModel *giftModel = [PIBaseAnimationViewModel new];
|
||||
giftModel.data = attatchment.data;
|
||||
giftModel.second = attatchment.second;
|
||||
giftModel.first = attatchment.first;
|
||||
giftModel.type = GiftBannerType_Fairy;
|
||||
if (self.animationListB.count == 0 && self.isPlayOfB == NO) {
|
||||
[self createTreasureFairyBannerAnimation:giftModel];
|
||||
}
|
||||
[self.animationListB addObject:giftModel];
|
||||
|
||||
}
|
||||
- (void)createTreasureFairyBannerAnimation:(PIBaseAnimationViewModel *)attatchment {
|
||||
CGFloat kscale = (CGFloat)60 / (CGFloat)375;
|
||||
CGFloat top = self.isPlayOfA == YES ? (190 + statusbarHeight) : (kNavigationHeight + 15);
|
||||
XPTreasureFairyGiftView *treasureView = [[XPTreasureFairyGiftView alloc] initWithFrame:CGRectMake(KScreenWidth, top, KScreenWidth , KScreenWidth * kscale)];
|
||||
//最大礼物
|
||||
if ((attatchment.second == Custom_Message_Sub_Treasure_Fairy_Draw_Gift_L5) || (attatchment.second == Custom_Message_Sub_Treasure_Fairy_Convert_L3)) {
|
||||
treasureView.isMaxLargeGift = YES;
|
||||
}else{
|
||||
treasureView.isMaxLargeGift = NO;
|
||||
}
|
||||
if ((attatchment.second == Custom_Message_Sub_Treasure_Fairy_Draw_Gift_L4) || (attatchment.second == Custom_Message_Sub_Treasure_Fairy_Draw_Gift_L5)) {
|
||||
treasureView.isDrawGift = YES; //抽奖
|
||||
}else{
|
||||
treasureView.isDrawGift = NO; //召唤
|
||||
}
|
||||
treasureView.treasureInfo = attatchment.data;
|
||||
[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];
|
||||
}
|
||||
// if(self. isAnimationListAFinish == YES){
|
||||
//
|
||||
// [self playAnimationWithModel];
|
||||
// self.isAnimationListAFinish = NO;
|
||||
// return;
|
||||
// }
|
||||
[self playAnimationWithModel];
|
||||
}
|
||||
}];
|
||||
[treasureView pop_addAnimation:moveAnimation forKey:@"moveOutAnimation"];
|
||||
}
|
||||
}];
|
||||
[treasureView pop_addAnimation:springAnimation forKey:@"candyTreespingOutAnimation"];
|
||||
}
|
||||
#pragma mark - 涂鸦礼物动画
|
||||
- (void)receiveRoomGraffitiGift:(AttachmentModel *)attacment {
|
||||
if (self.graffitiGiftQueue.count == 0) {
|
||||
@@ -1457,6 +1530,8 @@
|
||||
[self createAnchorHourRankAnimation:model];
|
||||
}else if(model.type == GiftBannerType_LicneseHour){
|
||||
[self createLicneseHourRankAnimation:model];
|
||||
}else if(model.type == GiftBannerType_Fairy){
|
||||
[self createTreasureFairyBannerAnimation:model];
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -0,0 +1,23 @@
|
||||
//
|
||||
// XPTreasureFairyGiftView.h
|
||||
// xplan-ios
|
||||
//
|
||||
// Created by XY on 2023/3/1.
|
||||
//
|
||||
|
||||
#import <UIKit/UIKit.h>
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
@interface XPTreasureFairyGiftView : UIView
|
||||
|
||||
///是否是动态飘屏
|
||||
@property (nonatomic,assign) BOOL isMaxLargeGift;
|
||||
/// 是否是抽奖(抽奖、召唤)
|
||||
@property (nonatomic,assign) BOOL isDrawGift;
|
||||
///夺宝信息
|
||||
@property (nonatomic,copy) NSDictionary *treasureInfo;
|
||||
|
||||
@end
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
193
YuMi/Modules/YMRoom/View/AnimationView/XPTreasureFairyGiftView.m
Normal file
193
YuMi/Modules/YMRoom/View/AnimationView/XPTreasureFairyGiftView.m
Normal file
@@ -0,0 +1,193 @@
|
||||
//
|
||||
// XPTreasureFairyGiftView.m
|
||||
// xplan-ios
|
||||
//
|
||||
// Created by XY on 2023/3/1.
|
||||
//
|
||||
|
||||
#import "XPTreasureFairyGiftView.h"
|
||||
///Third
|
||||
#import <Masonry/Masonry.h>
|
||||
#import <SVGA.h>
|
||||
#import "XPSVGAPlayer.h"
|
||||
#import "ThemeColor+Room.h"
|
||||
#import "TreasureFailryMessageModel.h"
|
||||
#import "NSObject+MJExtension.h"
|
||||
|
||||
@interface XPTreasureFairyGiftView()
|
||||
|
||||
///动画管理类
|
||||
@property (strong, nonatomic) SVGAParser *parser;
|
||||
///夺宝特效
|
||||
@property (nonatomic,strong) XPSVGAPlayer *treasureView;
|
||||
///背景图
|
||||
@property (nonatomic,strong) UIImageView *backImageView;
|
||||
///容器
|
||||
@property (nonatomic,strong) UIView *titleView;
|
||||
///显示文本内容
|
||||
@property (nonatomic,strong) UILabel *titleLabel;
|
||||
|
||||
@end
|
||||
|
||||
@implementation XPTreasureFairyGiftView
|
||||
|
||||
- (instancetype)initWithFrame:(CGRect)frame {
|
||||
self = [super initWithFrame:frame];
|
||||
if (self) {
|
||||
[self initSubViews];
|
||||
[self initSubViewConstraints];
|
||||
}
|
||||
return self;
|
||||
}
|
||||
#pragma mark - Private Method
|
||||
- (void)initSubViews {
|
||||
[self addSubview:self.treasureView];
|
||||
[self addSubview:self.backImageView];
|
||||
[self.backImageView addSubview:self.titleView];
|
||||
|
||||
[self.titleView addSubview:self.titleLabel];
|
||||
}
|
||||
|
||||
- (void)initSubViewConstraints {
|
||||
[self.treasureView mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
make.edges.equalTo(self);
|
||||
}];
|
||||
|
||||
[self.backImageView mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
make.edges.equalTo(self);
|
||||
}];
|
||||
|
||||
[self.titleView mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
make.left.right.mas_equalTo(self.backImageView).inset(20);
|
||||
make.height.mas_equalTo(28);
|
||||
make.top.mas_equalTo(self.backImageView).offset(23);
|
||||
}];
|
||||
|
||||
[self.titleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
make.left.right.mas_equalTo(self.titleView);
|
||||
make.centerY.mas_equalTo(self.titleView);
|
||||
}];
|
||||
}
|
||||
|
||||
- (NSAttributedString *)createAttribute:(NSString * )text color:(UIColor *)color fontSize:(CGFloat)fonSize {
|
||||
NSDictionary * attribute = @{NSFontAttributeName:[UIFont systemFontOfSize:fonSize], NSForegroundColorAttributeName:color};
|
||||
NSMutableAttributedString *attr = [[NSMutableAttributedString alloc] initWithString:text attributes:attribute];
|
||||
return attr;
|
||||
}
|
||||
|
||||
#pragma mark - Getters And Setters
|
||||
- (void)setTreasureInfo:(NSDictionary *)treasureInfo {
|
||||
if (treasureInfo) {
|
||||
TreasureFailryMessageModel * giftInfo = [TreasureFailryMessageModel modelWithDictionary:treasureInfo];
|
||||
NSMutableAttributedString * attribute = [[NSMutableAttributedString alloc] init];
|
||||
CGFloat fontSize = self.isMaxLargeGift ? 22 : 13;
|
||||
// CGFloat fontSize = 13;
|
||||
if (self.isDrawGift) {
|
||||
[attribute appendAttributedString:[self createAttribute:YMLocalizedString(@"XPTreasureFairyGiftView0") color:[DJDKMIMOMColor colorWithHexString:@"#8C4700"] fontSize:fontSize]];
|
||||
NSString * nick = giftInfo.nick;
|
||||
if (nick.length > 6) {
|
||||
nick = [nick substringToIndex:6];
|
||||
}
|
||||
[attribute appendAttributedString:[self createAttribute:nick color:[DJDKMIMOMColor colorWithHexString:@"#EC4613"] fontSize:fontSize]];
|
||||
[attribute appendAttributedString:[self createAttribute:YMLocalizedString(@"XPTreasureFairyGiftView1") color:[DJDKMIMOMColor colorWithHexString:@"#8C4700"] fontSize:fontSize]];
|
||||
[attribute appendAttributedString:[self createAttribute:giftInfo.rewardName color:[DJDKMIMOMColor colorWithHexString:@"#EC4613"] fontSize:fontSize]];
|
||||
if (giftInfo.rewardNum > 1) {
|
||||
[attribute appendAttributedString:[self createAttribute:[NSString stringWithFormat:@" X%ld", giftInfo.rewardNum] color:[DJDKMIMOMColor colorWithHexString:@"#EC4613"] fontSize:fontSize]];
|
||||
}
|
||||
}else{
|
||||
[attribute appendAttributedString:[self createAttribute:YMLocalizedString(@"XPTreasureFairyGiftView2") color:[DJDKMIMOMColor colorWithHexString:@"#8C4700"] fontSize:fontSize]];
|
||||
[attribute appendAttributedString:[self createAttribute:giftInfo.nick color:[DJDKMIMOMColor colorWithHexString:@"#EC4613"] fontSize:fontSize]];
|
||||
[attribute appendAttributedString:[self createAttribute:YMLocalizedString(@"XPTreasureFairyGiftView3") color:[DJDKMIMOMColor colorWithHexString:@"#8C4700"] fontSize:fontSize]];
|
||||
NSString *level = @"";
|
||||
if (giftInfo.rewardLevel == 1) {
|
||||
level = YMLocalizedString(@"XPTreasureFairyGiftView4");
|
||||
}else if (giftInfo.rewardLevel == 2) {
|
||||
level = YMLocalizedString(@"XPTreasureFairyGiftView5");
|
||||
}else if (giftInfo.rewardLevel == 3) {
|
||||
level = YMLocalizedString(@"XPTreasureFairyGiftView6");
|
||||
}
|
||||
[attribute appendAttributedString:[self createAttribute:level color:[DJDKMIMOMColor colorWithHexString:@"#8C4700"] fontSize:fontSize]];
|
||||
[attribute appendAttributedString:[self createAttribute:YMLocalizedString(@"XPTreasureFairyGiftView7") color:[DJDKMIMOMColor colorWithHexString:@"#8C4700"] fontSize:fontSize]];
|
||||
[attribute appendAttributedString:[self createAttribute:[NSString stringWithFormat:@"%ld",giftInfo.rewardShowValue] color:[DJDKMIMOMColor colorWithHexString:@"#F1390A"] fontSize:fontSize]];
|
||||
|
||||
if ([giftInfo.rewardType isEqualToString:@"gift"]) {
|
||||
[attribute appendAttributedString:[self createAttribute:YMLocalizedString(@"XPTreasureFairyGiftView8") color:[DJDKMIMOMColor colorWithHexString:@"#F1390A"] fontSize:fontSize]];
|
||||
}else{
|
||||
[attribute appendAttributedString:[self createAttribute:giftInfo.rewardUnit color:[DJDKMIMOMColor colorWithHexString:@"#F1390A"] fontSize:fontSize]];
|
||||
}
|
||||
|
||||
[attribute appendAttributedString:[self createAttribute:giftInfo.rewardName color:[DJDKMIMOMColor colorWithHexString:@"#F1390A"] fontSize:fontSize]];
|
||||
}
|
||||
|
||||
NSMutableParagraphStyle *paragraphStyle = [NSMutableParagraphStyle new];
|
||||
paragraphStyle.lineBreakMode = NSLineBreakByCharWrapping;
|
||||
paragraphStyle.lineSpacing = 0.0f;//行间距
|
||||
paragraphStyle.alignment = NSTextAlignmentCenter;
|
||||
paragraphStyle.baseWritingDirection = NSWritingDirectionLeftToRight;
|
||||
[attribute addAttribute:NSParagraphStyleAttributeName value:paragraphStyle range:NSMakeRange(0, attribute.length)];
|
||||
[self.treasureView setAttributedText:attribute forKey:@"touming_text_name"];
|
||||
if (self.isMaxLargeGift) {
|
||||
self.backImageView.hidden = YES;
|
||||
self.treasureView.hidden = NO;
|
||||
@kWeakify(self);
|
||||
[self.parser parseWithNamed:@"treasure_fairy_gift_bg" inBundle:[NSBundle mainBundle] completionBlock:^(SVGAVideoEntity * _Nonnull videoItem) {
|
||||
@kStrongify(self);
|
||||
self.treasureView.loops = 1;
|
||||
self.treasureView.clearsAfterStop = NO;
|
||||
self.treasureView.videoItem = videoItem;
|
||||
|
||||
[self.treasureView startAnimation];
|
||||
} failureBlock:^(NSError * _Nonnull error) {
|
||||
|
||||
}];
|
||||
} else {
|
||||
self.backImageView.hidden = NO;
|
||||
self.treasureView.hidden = YES;
|
||||
self.titleLabel.attributedText = attribute;
|
||||
self.titleLabel.textAlignment = NSTextAlignmentCenter;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
- (XPSVGAPlayer *)treasureView {
|
||||
if (!_treasureView) {
|
||||
_treasureView = [[XPSVGAPlayer alloc]init];
|
||||
_treasureView.backgroundColor = [UIColor clearColor];
|
||||
_treasureView.userInteractionEnabled = NO;
|
||||
}
|
||||
return _treasureView;
|
||||
}
|
||||
|
||||
- (SVGAParser *)parser {
|
||||
if (!_parser) {
|
||||
_parser = [[SVGAParser alloc]init];
|
||||
}
|
||||
return _parser;
|
||||
}
|
||||
|
||||
- (UIView *)titleView {
|
||||
if (!_titleView) {
|
||||
_titleView = [[UIView alloc] init];
|
||||
_titleView.backgroundColor = [UIColor clearColor];
|
||||
}
|
||||
return _titleView;
|
||||
}
|
||||
|
||||
- (UIImageView *)backImageView {
|
||||
if (!_backImageView) {
|
||||
_backImageView = [[UIImageView alloc] init];
|
||||
_backImageView.userInteractionEnabled = YES;
|
||||
_backImageView.image = [UIImage imageNamed:@"room_treaseure_fairy_normal_gift_bg"];
|
||||
}
|
||||
return _backImageView;
|
||||
}
|
||||
|
||||
- (UILabel *)titleLabel {
|
||||
if (!_titleLabel) {
|
||||
_titleLabel = [[UILabel alloc] init];
|
||||
_titleLabel.numberOfLines = 2;
|
||||
}
|
||||
return _titleLabel;
|
||||
}
|
||||
|
||||
@end
|
Reference in New Issue
Block a user