修正 combo 金币显示问题

This commit is contained in:
AI Health Developer
2025-04-11 10:45:49 +08:00
parent 0275decc7e
commit faa6a2c4dc
4 changed files with 31 additions and 9 deletions

View File

@@ -690,7 +690,7 @@ XPRoomGraffitiGiftAnimationViewDelegate
[self loadBroveSVGAVideoItem:level.integerValue];
}
if (coins) {
[[NSNotificationCenter defaultCenter] postNotificationName:@"receiveLuckGiftWinning" object:[NSString stringByRemovingRedundantZeros:coins.stringValue]];
// [[NSNotificationCenter defaultCenter] postNotificationName:@"receiveLuckGiftWinning" object:[NSString stringByRemovingRedundantZeros:coins.stringValue]];
}
}
}

View File

@@ -13,9 +13,10 @@ NS_ASSUME_NONNULL_BEGIN
@interface GiftComboView : UIView
- (void)setupCurrentGold:(double)gold;
- (void)updateCurrentGold:(double)gold giftPrice:(double)price isFromWinning:(BOOL)isFromWinning;
- (void)updateCurrentGold:(double)gold giftPrice:(double)price isFromWinning:(BOOL)isFromWinning isBrove:(BOOL)isBrove;
- (void)updateCount;
- (void)stopTimer;
- (void)endCombo;
@end
NS_ASSUME_NONNULL_END

View File

@@ -50,7 +50,7 @@
if (self = [super init]) {
self.feedbackGenerator = [[UIImpactFeedbackGenerator alloc] initWithStyle:UIImpactFeedbackStyleHeavy];
self.updateGoldQueue = @[].mutableCopy;
[self setupNotification];
UIButton *b = [UIButton buttonWithType:UIButtonTypeCustom];
[b addTarget:self action:@selector(handleTapSpace) forControlEvents:UIControlEventTouchUpInside];
@@ -64,6 +64,7 @@
[self setupTimer];
[self updateCount];
[self setupSVGAParser];
[self setupNotification];
}
return self;
}
@@ -90,10 +91,13 @@
}
- (void)setupNotification {
@kWeakify(self);
[[NSNotificationCenter defaultCenter] removeObserver:self name:@"receiveLuckGiftWinning" object:nil];
[[NSNotificationCenter defaultCenter] addObserverForName:@"receiveLuckGiftWinning"
object:nil
queue:[NSOperationQueue mainQueue]
usingBlock:^(NSNotification * _Nonnull notification) {
@kStrongify(self);
if ([notification.object isKindOfClass:[NSString class]]) {
[self handleStringNotification:notification.object];
} else if ([notification.object isKindOfClass:[NSDictionary class]]) {
@@ -104,7 +108,7 @@
- (void)handleStringNotification:(NSString *)coin {
if (![NSString isEmpty:coin]) {
[self updateCurrentGold:coin.doubleValue giftPrice:0 isFromWinning:YES];
[self updateCurrentGold:coin.doubleValue giftPrice:0 isFromWinning:YES isBrove:YES];
}
}
@@ -112,7 +116,7 @@
double coin = [[dic objectForKey:@"CurrentGold"] doubleValue];
double price = [[dic objectForKey:@"Price"] doubleValue];
BOOL isFromWinning = [[dic objectForKey:@"isFromWinning"] boolValue];
[self updateCurrentGold:coin giftPrice:price isFromWinning:isFromWinning];
[self updateCurrentGold:coin giftPrice:price isFromWinning:isFromWinning isBrove:YES];
}
- (void)updateCount {
@@ -132,6 +136,16 @@
[self.countdownRingView stopCountdown];
}
- (void)endCombo {
// [[NSNotificationCenter defaultCenter] removeObserver:self];
// [self.countdownRingView stopCountdown];
// [self.countdownRingView removeFromSuperview];
// self.countdownRingView = nil;
// [self.playImageView stopAnimation];
// [self.playImageView clear];
// self.playImageView.delegate = nil;
}
- (void)setupUI {
[self addSubview:self.container];
[self.container mas_makeConstraints:^(MASConstraintMaker *make) {
@@ -239,6 +253,8 @@
#pragma mark -
- (void)setupCurrentGold:(double)gold {
NSLog(@" --- --- --- 更新总数:%f", gold);
self.comboGoldNum = gold;
self.comboGoldLabel.text = @(gold).stringValue;
}
@@ -266,11 +282,13 @@
}
}
- (void)updateCurrentGold:(double)gold giftPrice:(double)price isFromWinning:(BOOL)isFromWinning {
- (void)updateCurrentGold:(double)gold giftPrice:(double)price isFromWinning:(BOOL)isFromWinning isBrove:(BOOL)isBrove {
NSString *goldString = isFromWinning ? [NSString stringWithFormat:@"+ %@", @(gold)] : @(-price).stringValue;
if (isFromWinning) {
double updateGold = self.comboGoldNum + gold;
[self setupCurrentGold:updateGold];
// if (!isBrove) {
double updateGold = self.comboGoldNum + gold;
[self setupCurrentGold:updateGold];
// }
} else {
// double updateGold = self.comboGoldNum + gold;
[self setupCurrentGold:gold];

View File

@@ -177,10 +177,13 @@ UIKIT_EXTERN NSString * kShowFirstRechargeView;
if (self->_luckyBroadcastView) {
self.luckyBroadcastView.hidden = NO;
}
[self.presenter getUserWalletInfo];
[self.comboView stopTimer];
[self.comboView endCombo];
[self.comboView removeFromSuperview];
self.comboView = nil;
[self.presenter getUserWalletInfo];
}
break;
case ComboAction_Combo_Count_Update: {