feat: 完成礼物连击功能 | 更换金币资源图片

This commit is contained in:
eggmanQQQ
2024-09-10 15:27:47 +08:00
parent e45176485d
commit f668f43a42
93 changed files with 1059 additions and 288 deletions

View File

@@ -65,7 +65,9 @@
#import "PIRoomGiftBroadcastWindow.h"
#import "PIUniversalBannerModel.h"
#import "PIUniversalBannerView.h"
#import "GiftComboFlagView.h"
#import "GiftComboManager.h"
@interface XPRoomAnimationView ()<SVGAPlayerDelegate,NIMBroadcastManagerDelegate, XPRoomGiftBroadcastViewDelegate, HWDMP4PlayDelegate, XPRoomLuckyBigPrizeViewDelegate, XPRoomGraffitiGiftAnimationViewDelegate, XPRoomStarKitchenBannerViewDelegate,PAGViewListener,XPRoomAnchorRankBannerViewDelegate,PIRoomGiftBroadcastWindowDelegate,PIUniversalBannerViewDelegate>
///
@@ -268,7 +270,7 @@
if (attachment.first == CustomMessageType_Gift) {
GiftReceiveInfoModel * receiveInfo = [GiftReceiveInfoModel modelWithJSON:attachment.data];
receiveInfo.isLuckyBagGift = attachment.second == Custom_Message_Sub_Gift_LuckySend;
receiveInfo.isBatch = YES;
receiveInfo.isBatch = (attachment.second == Custom_Message_Sub_AllBatchSend || attachment.second == Custom_Message_Sub_AllBatchMicroLuckySend);
[self receiveGiftHandleSendGiftAnimation:attachment];
if (receiveInfo.isLuckyBagGift) {
if (!self.delegate.getRoomInfo.hasAnimationEffect) {return;}
@@ -292,7 +294,7 @@
GiftReceiveInfoModel * receiveInfo = [GiftReceiveInfoModel modelWithJSON:attachment.data];
receiveInfo.isLuckyBagGift = (attachment.second == Custom_Message_Sub_AllMicroLuckySend || attachment.second == Custom_Message_Sub_AllBatchMicroLuckySend);
receiveInfo.isBatch = (attachment.second == Custom_Message_Sub_AllBatchSend || attachment.second == Custom_Message_Sub_AllBatchMicroLuckySend);
[self receiveGiftHandleSendGiftAnimation:attachment];
[self receiveGiftHandleSendGiftAnimation:attachment];
if (receiveInfo.isLuckyBagGift) {
if (!self.delegate.getRoomInfo.hasAnimationEffect) {return;}
if (receiveInfo.viewUrl.length > 0) {
@@ -303,7 +305,6 @@
if (luckyGiftSvgaUrl.absoluteString.length > 0) {
[self playLuckyGiftEffect:luckyGiftSvgaUrl];
}
}
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.5 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
[self receiveGift:receiveInfo];
@@ -1500,8 +1501,18 @@
}
endPoint = [self getGiftAnimationPoint:userId isEnd:YES];
dispatch_time_t timer = dispatch_time(DISPATCH_TIME_NOW, 0.5 * NSEC_PER_SEC);
BOOL isCombing = [[GiftComboManager sharedManager] isGiftCombing] &&
[sendUid isEqualToString:[AccountInfoStorage instance].getUid];
if (isCombing) {
timer = dispatch_time(DISPATCH_TIME_NOW, 0.25 * NSEC_PER_SEC);
}
dispatch_after(timer, dispatch_get_main_queue(), ^{
[self beginGiftAnimation:giftInfo.giftUrl startPoint:starPoint endPoint:endPoint];
[self beginGiftAnimation:giftInfo.giftUrl
startPoint:starPoint
endPoint:endPoint
isGiftCombing:isCombing];
});
}
}
@@ -1517,10 +1528,20 @@
point = CGPointMake([UIScreen mainScreen].bounds.size.width / 2, 44 + kSafeAreaTopHeight);
}
}
if ([[GiftComboManager sharedManager] isGiftCombing] &&
[uid isEqualToString:[AccountInfoStorage instance].getUid] &&
isEnd == false) {
point = CGPointMake([UIScreen mainScreen].bounds.size.width - 60, [UIScreen mainScreen].bounds.size.height - kSafeAreaTopHeight - 60);
}
return point;
}
- (void)beginGiftAnimation:(NSString *)giftUrl startPoint:(CGPoint)startPoint endPoint:(CGPoint)endPoint {
- (void)beginGiftAnimation:(NSString *)giftUrl
startPoint:(CGPoint)startPoint
endPoint:(CGPoint)endPoint
isGiftCombing:(BOOL)isGiftCombing {
NetImageView * giftImageView = [self.giftReuseArray anyObject];
if (giftImageView == nil) {
giftImageView = [[NetImageView alloc]initWithFrame:CGRectMake(0, 0 , 55, 55)];
@@ -1536,14 +1557,61 @@
giftImageView.imageUrl = giftUrl;
[self.lowLevelView addSubview:giftImageView];
CAAnimationGroup *group = [self createGiftAnimationStartPoint:startPoint endPoint:endPoint];
if (isGiftCombing) {
group = [self createGiftComboAnimationStartPoint:startPoint endPoint:endPoint];
}
// startPoint
giftImageView.layer.position = startPoint;
[giftImageView.layer addAnimation:group forKey:@"giftDisplayViewAnimation"];
[self performSelector:@selector(aniationDidFinish:) withObject:giftImageView afterDelay:(3.2+0.25)];
}
- (CAAnimationGroup *)createGiftComboAnimationStartPoint:(CGPoint)startPoint
endPoint:(CGPoint)endPoint {
// 1: 0.4
CAKeyframeAnimation *scaleAnimation1 = [CAKeyframeAnimation animationWithKeyPath:@"transform.scale"];
scaleAnimation1.duration = 0.1;
scaleAnimation1.values = @[@1.0, @0.4];
scaleAnimation1.repeatCount = 1;
scaleAnimation1.calculationMode = kCAAnimationCubic;
scaleAnimation1.removedOnCompletion = NO;
scaleAnimation1.fillMode = kCAFillModeForwards;
// : 0.5
CAKeyframeAnimation *positionAnimation = [CAKeyframeAnimation animationWithKeyPath:@"position"];
positionAnimation.duration = 0.5;
positionAnimation.beginTime = 0.1; //
positionAnimation.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseInEaseOut];
positionAnimation.values = @[[NSValue valueWithCGPoint:startPoint], [NSValue valueWithCGPoint:endPoint]];
positionAnimation.repeatCount = 1;
positionAnimation.removedOnCompletion = NO;
positionAnimation.fillMode = kCAFillModeForwards;
// 2: 1.2
CAKeyframeAnimation *scaleAnimation2 = [CAKeyframeAnimation animationWithKeyPath:@"transform.scale"];
scaleAnimation2.duration = 0.5;
scaleAnimation2.beginTime = 0.1; //
scaleAnimation2.values = @[@0.4, @2];
scaleAnimation2.repeatCount = 1;
scaleAnimation2.calculationMode = kCAAnimationCubic;
scaleAnimation2.removedOnCompletion = NO;
scaleAnimation2.fillMode = kCAFillModeForwards;
//
CAAnimationGroup *group = [CAAnimationGroup animation];
group.duration = 0.6; // 0.1 () + 0.5 ()
group.animations = @[scaleAnimation1, positionAnimation, scaleAnimation2];
group.repeatCount = 1;
group.removedOnCompletion = NO;
group.fillMode = kCAFillModeForwards;
return group;
}
///
/// @param startPoint
/// @param endPoint
- (CAAnimationGroup *)createGiftAnimationStartPoint:(CGPoint)startPoint endPoint:(CGPoint)endPoint{
- (CAAnimationGroup *)createGiftAnimationStartPoint:(CGPoint)startPoint endPoint:(CGPoint)endPoint {
CGPoint centerPoint = CGPointMake(KScreenWidth / 2, KScreenHeight / 2);
CAKeyframeAnimation *animation0 = [CAKeyframeAnimation animation];
animation0.duration = 0.8;
@@ -1563,8 +1631,7 @@
animation1.calculationMode = kCAAnimationCubic;
animation1.removedOnCompletion = NO;
animation1.fillMode = kCAFillModeForwards;
CAKeyframeAnimation *animation2 = [CAKeyframeAnimation animation];
animation2.duration = 0.8;
animation2.beginTime = 0.8;
@@ -1853,11 +1920,53 @@
}
}
#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];
}];
}
#pragma mark -
///
- (void)receiveGift:(GiftReceiveInfoModel *)receiveInfo {
if ([self isInSudGame]) {return;}
if(receiveInfo.isHomeShow == YES)return;
if ([self isInSudGame] || receiveInfo.isHomeShow == YES) {
return;
}
[self receiveCombo:receiveInfo];
///CPU
RoomInfoModel * roomInfo = [self.delegate getRoomInfo];
if (receiveInfo.isLuckyBagGift) {