Files
peko-ios/YuMi/Modules/YMRoom/View/RoomPK/View/XPRoomPKProgressView.m
2024-03-25 23:18:36 +08:00

1121 lines
42 KiB
Objective-C

//
// YMRoomPKProgressView.m
// YUMI
//
// Created by YUMI on 2022/3/28.
//
#import "XPRoomPKProgressView.h"
///Third
#import <Masonry/Masonry.h>
///Tool
#import "DJDKMIMOMColor.h"
#import "YUMIMacroUitls.h"
#import "TTPopup.h"
#import "UIImage+Utils.h"
#import "Api+RoomPK.h"
#import "AccountInfoStorage.h"
#import "XNDJTDDLoadingTool.h"
#import "XPGiftStorage.h"
#import "GiftReceiveInfoModel.h"
#import "GiftInfoModel.h"
#import "XCCurrentVCStackManager.h"
#import "NSArray+Safe.h"
///Model
#import "RoomPKDetailInfoModel.h"
#import "MicroQueueModel.h"
#import "UserInfoModel.h"
#import "RoomPKChooseUserModel.h"
#import "AttachmentModel.h"
#import "MicroExtModel.h"
#import "XPArrangeMicInfoModel.h"
#import "RoomInfoModel.h"
///View
#import "XPRoomPKPanelUserView.h"
#import "XPRoomPKSelectUserView.h"
#import "XPRoomPKPlayingView.h"
#import "XPRoomPKPlayingView.h"
#import "XPRoomPKResultView.h"
#import "XPArrangeMicViewController.h"
@interface XPRoomPKProgressView ()<XPRoomPKPanelUserViewDelegate, XPRoomPKSelectUserViewDelegate, XPRoomPKPlayingViewDelegate>
///背景
@property (nonatomic,strong) UIImageView *backImageView;
///开始
@property (nonatomic,strong) UIButton *beginButton;
///时间
@property (nonatomic,strong) UILabel *timeLabel;
///红队的容器
@property (nonatomic,strong) XPRoomPKPanelUserView * redTeamView;
///红队的分数
@property (nonatomic,strong) UILabel *redScoreLabel;
///蓝队的容器
@property (nonatomic,strong) XPRoomPKPanelUserView * blueTeamView;
///蓝队的分数
@property (nonatomic,strong) UILabel *blueScoreLabel;
///进度的容器
@property (nonatomic,strong) UIView * progressView;
///红队的进度
@property (nonatomic,strong) UIImageView * redProgressView;
///蓝队的进度
@property (nonatomic,strong) UIImageView * blueProgressView;
///进度的分割线
@property (nonatomic,strong) UIImageView *progressLineView;
///倒计时
@property (strong, nonatomic) dispatch_source_t timer;
///当前的时间
@property (nonatomic,assign) CGFloat currentTime;
///检查失败的次数
@property (nonatomic,assign) int checkResultNum;
///正在pk中的面板
@property (nonatomic,strong) XPRoomPKPlayingView *roomPKPlayingView;
///红队的分数
@property (nonatomic,assign) long redTeamScore;
///蓝的分数
@property (nonatomic,assign) long blueTeamScore;
///红队收到礼物个数(按照收礼个数)
@property (nonatomic, strong) NSMutableDictionary * redTeamGiftPersonDic;
///蓝队收到礼物个数(按照收礼个数)
@property (nonatomic, strong) NSMutableDictionary * blueTeamGiftPersonDic;
///红色的
@property (nonatomic,strong) NSArray<RoomPKChooseUserModel *> *redChooseArray;
///蓝色的
@property (nonatomic,strong) NSArray<RoomPKChooseUserModel *> *blueChooseArray;
///是否收到了Pk的结果
@property (nonatomic,assign) BOOL isReceivePKResult;
///pk详情
@property (nonatomic,strong) RoomPKInfoModel *roomPKInfo;
///是否正在进行中
@property (nonatomic,assign) BOOL isPlaying;
@end
@implementation XPRoomPKProgressView
- (void)dealloc {
[self stopRoomPKCountDown];
}
- (instancetype)initWithFrame:(CGRect)frame {
self = [super initWithFrame:frame];
if (self) {
[self initSubViews];
[self initSubViewConstraints];
}
return self;
}
#pragma mark - Public Method
- (void)handleRoomPKCustomMessage:(AttachmentModel *)attachment {
if (attachment.second == Custom_Message_Sub_Room_PK_Start) {
[XNDJTDDLoadingTool showSuccessWithMessage:YMLocalizedString(@"XPRoomPKProgressView0")];
RoomPKInfoModel * pkInfo = [RoomPKInfoModel modelWithDictionary:attachment.data];
self.roomPKInfo = pkInfo;
[self startRoomPKCountDown:pkInfo.duration];
[self handleRoomPKInfoChangeState];
}else if (attachment.second == Custom_Message_Sub_Room_PK_Mode_Open){
RoomPKInfoModel * pkInfo = [RoomPKInfoModel modelWithDictionary:attachment.data];
self.roomPKInfo = pkInfo;
[self handleRoomPKInfoChangeState];
} else if(attachment.second == Custom_Message_Sub_Room_PK_Re_Start) {
RoomPKInfoModel * pkInfo = [RoomPKInfoModel modelWithDictionary:attachment.data];
self.roomPKInfo = pkInfo;
[self handleRoomPKInfoChangeState];
} else if(attachment.second == Custom_Message_Sub_Room_PK_Result) {
[TTPopup dismiss];
RoomPKInfoModel * pkInfo = [RoomPKInfoModel modelWithDictionary:attachment.data];
self.isReceivePKResult = YES;
[self stopRoomPKCountDown];
[self clearRoomPKTeamData];
self.checkResultNum = 1;
if (pkInfo.pkStatus == RoomPKStatusType_ReStart) {///重新开始了 需要重新赋值
self.roomPKInfo = pkInfo;
} else {
if ([pkInfo.pkId isEqualToString:self.roomPKInfo.pkId]) {
[self clearRoomPKTeamData];
self.roomPKInfo = pkInfo;
[self resetRoomPKGroupType];
}
}
if (pkInfo.pkStatus == RoomPKStatusType_End) {
XPRoomPKResultView * result = [[XPRoomPKResultView alloc] init];
result.roomPKResultInfoModel = pkInfo;
[TTPopup popupView:result style:TTPopupStyleAlert];
}
[self handleRoomPKInfoChangeState];
} else if(attachment.second == Custom_Message_Sub_Room_PK_Mode_Close) {
[XNDJTDDLoadingTool showSuccessWithMessage:YMLocalizedString(@"XPRoomPKProgressView1")];
[self stopRoomPKCountDown];
[self clearRoomPKTeamData];
[self removeFromSuperview];
[self resetRoomPKGroupType];
}
}
- (void)roomPKReceiveGift:(AttachmentModel *)attachment {
if (self.roomPKInfo.pkStatus == RoomPKStatusType_Playing) {
GiftReceiveInfoModel *giftReceiveInfo = [GiftReceiveInfoModel modelWithJSON:attachment.data];
GiftInfoModel *giftInfo = giftReceiveInfo.gift == nil ? giftReceiveInfo.giftInfo : giftReceiveInfo.gift;
if (giftInfo == nil) {
giftInfo = [[XPGiftStorage shareStorage] findGiftInfo:giftReceiveInfo.giftId];
}
if (attachment.first == CustomMessageType_AllMicroSend) {
if (attachment.second == Custom_Message_Sub_AllBatchSend || attachment.second == Custom_Message_Sub_AllMicroSend) {///普通礼物
NSArray *targetUids = giftReceiveInfo.targetUids;
if (giftReceiveInfo.targetUids.count <=0) {
if (giftReceiveInfo.targetUsers.count > 0) {
targetUids = [giftReceiveInfo.targetUsers valueForKeyPath:@"uid"];
} else {
targetUids = giftReceiveInfo.targetUid.integerValue > 0? @[giftReceiveInfo.targetUid] : @[];
}
}
if (self.roomPKInfo.voteMode == RoomPKVoteModeType_NumberPerson) { // 按送礼人数计算
[self canculeRoomPKSendGiftNumPerson:targetUids sendUid:giftReceiveInfo.uid];
} else {
[self canculeRoomGiftValueReceiveInfo:targetUids giftPrice:giftInfo.goldPrice * giftReceiveInfo.giftNum];
}
} else if(attachment.second == Custom_Message_Sub_AllMicroLuckySend || attachment.second == Custom_Message_Sub_AllBatchMicroLuckySend) {///福袋礼物
if (giftReceiveInfo.luckyGiftList) {
__block NSInteger goldPrice = 0;
[giftReceiveInfo.luckyGiftList.giftList enumerateObjectsUsingBlock:^(GiftListsInfo * _Nonnull giftListInfo, NSUInteger idx, BOOL * _Nonnull stop) {
GiftInfoModel *giftInfo = [[XPGiftStorage shareStorage] findGiftInfo:[NSString stringWithFormat:@"%ld", giftListInfo.giftId]];
goldPrice += giftInfo.goldPrice * giftListInfo.giftNum;
}];
NSArray *targetUids;
if (giftReceiveInfo.luckyGiftList.user.uid > 0) {
targetUids = @[[NSString stringWithFormat:@"%ld", giftReceiveInfo.luckyGiftList.user.uid]];
}
if (self.roomPKInfo.voteMode == RoomPKVoteModeType_NumberPerson) { // 按送礼人数计算
[self canculeRoomPKSendGiftNumPerson:targetUids sendUid:giftReceiveInfo.uid];
} else {
[self canculeRoomGiftValueReceiveInfo:targetUids giftPrice:goldPrice];
}
}
}
} else if(attachment.first == CustomMessageType_Gift) {
if (attachment.second == Custom_Message_Sub_Gift_LuckySend) {
__block NSInteger goldPrice = 0;
[giftReceiveInfo.luckyGiftList.giftList enumerateObjectsUsingBlock:^(GiftListsInfo * _Nonnull giftListInfo, NSUInteger idx, BOOL * _Nonnull stop) {
GiftInfoModel *giftInfo = [[XPGiftStorage shareStorage] findGiftInfo:[NSString stringWithFormat:@"%ld", giftListInfo.giftId]];
goldPrice += giftInfo.goldPrice * giftListInfo.giftNum;
}];
NSArray *targetUids;
if (giftReceiveInfo.luckyGiftList.user.uid > 0) {
targetUids = @[[NSString stringWithFormat:@"%ld", giftReceiveInfo.luckyGiftList.user.uid]];
}
if (self.roomPKInfo.voteMode == RoomPKVoteModeType_NumberPerson) { // 按送礼人数计算
[self canculeRoomPKSendGiftNumPerson:targetUids sendUid:giftReceiveInfo.uid];
} else {
[self canculeRoomGiftValueReceiveInfo:targetUids giftPrice:goldPrice];
}
} else {
NSArray *targetUids = giftReceiveInfo.targetUids;
if (giftReceiveInfo.targetUids.count <=0) {
if (giftReceiveInfo.targetUsers.count > 0) {
targetUids = [giftReceiveInfo.targetUsers valueForKeyPath:@"uid"];
} else {
targetUids = giftReceiveInfo.targetUid.integerValue > 0? @[giftReceiveInfo.targetUid] : @[];
}
}
if (self.roomPKInfo.voteMode == RoomPKVoteModeType_NumberPerson) { // 按送礼人数计算
if (giftInfo.giftType != GiftType_super){
[self canculeRoomPKSendGiftNumPerson:targetUids sendUid:giftReceiveInfo.uid];
}
} else {
if (giftInfo.giftType != GiftType_super){
[self canculeRoomGiftValueReceiveInfo:targetUids giftPrice:giftInfo.goldPrice * giftReceiveInfo.giftNum];
}
}
}
}
}
}
- (void)enterRoomGetRoomPKDetailInfo {
NSString * roomUid = [NSString stringWithFormat:@"%ld", self.roomInfo.uid];
[Api getRoomPKDetail:^(BaseModel * _Nullable data, NSInteger code, NSString * _Nullable msg) {
if (code == 200) {
RoomPKDetailInfoModel * pkDetailInfo = [RoomPKDetailInfoModel modelWithDictionary:data.data];
self.roomPKInfo = pkDetailInfo.roomPK;
[self handleRoomPKInfoChangeState];
if (self.roomPKInfo.pkStatus == RoomPKStatusType_Playing) {
[self startRoomPKCountDown:(self.roomPKInfo.endTime - pkDetailInfo.now) / 1000];
}
NSMutableDictionary * queue = self.micQueue;
///配置一下麦序的信息
NSMutableArray * redArray = [NSMutableArray array];
NSMutableArray * blueArray = [NSMutableArray array];
if (self.roomPKInfo.pkStatus == RoomPKStatusType_Playing) {
for (int i = 0; i < self.roomPKInfo.teams.count; i++) {
RoomPKTeamModel * teamInfo = [self.roomPKInfo.teams safeObjectAtIndex1:i];
if (teamInfo.team == GroupType_Red) {
self.redTeamScore = teamInfo.score;
for (int i = 0; i < teamInfo.teamMembers.count; i++) {
RoomPKTeamUserModel * teamUserModel = [teamInfo.teamMembers safeObjectAtIndex1:i];
RoomPKChooseUserModel * redInfo = [[RoomPKChooseUserModel alloc] init];
redInfo.avatar = teamUserModel.avatar;
redInfo.uid = teamUserModel.uid;
redInfo.groupType = GroupType_Red;
redInfo.position = [self findMicroInfoByUid:teamUserModel.uid].microState.position;
redInfo.nick = teamUserModel.nick;
[redArray addObject:redInfo];
}
} else if(teamInfo.team == GroupType_Blue) {
self.blueTeamScore = teamInfo.score;
for (int i = 0; i < teamInfo.teamMembers.count; i++) {
RoomPKTeamUserModel * teamUserModel = [teamInfo.teamMembers safeObjectAtIndex1:i];
RoomPKChooseUserModel * blueInfo = [[RoomPKChooseUserModel alloc] init];
blueInfo.avatar = teamUserModel.avatar;
blueInfo.uid = teamUserModel.uid;
blueInfo.groupType = GroupType_Blue;
blueInfo.position = [self findMicroInfoByUid:teamUserModel.uid].microState.position;
blueInfo.nick = teamUserModel.nick;
[blueArray addObject:blueInfo];
}
}
}
[self configRedTeamScore:self.redTeamScore blueTeamScore:self.blueTeamScore];
} else {
for (int i = 0 ; i < queue.allValues.count; i++) {
MicroQueueModel * micModel = [queue.allValues safeObjectAtIndex1:i];
if (micModel.userInfo && micModel.userInfo.uid > 0) {
UserInfoModel * userInfo = micModel.userInfo;
if (userInfo.groupType == GroupType_Red) {
RoomPKChooseUserModel * redInfo = [[RoomPKChooseUserModel alloc] init];
redInfo.avatar = userInfo.avatar;
redInfo.uid = [NSString stringWithFormat:@"%ld", userInfo.uid];
redInfo.groupType = userInfo.groupType;
redInfo.position = micModel.microState.position;
redInfo.nick = userInfo.nick;
[redArray addObject:redInfo];
} else if(userInfo.groupType == GroupType_Blue) {
RoomPKChooseUserModel * blueInfo = [[RoomPKChooseUserModel alloc] init];
blueInfo.avatar = userInfo.avatar;
blueInfo.uid = [NSString stringWithFormat:@"%ld", userInfo.uid];
blueInfo.groupType = userInfo.groupType;
blueInfo.position = micModel.microState.position;
blueInfo.nick = userInfo.nick;
[blueArray addObject:blueInfo];
}
}
}
}
self.redChooseArray = redArray.copy;
self.blueChooseArray = blueArray.copy;
} else {
[XNDJTDDLoadingTool showErrorWithMessage:msg];
}
} roomUid:roomUid];
}
- (BOOL)isRoomPKPlaying {
return self.isPlaying;
}
#pragma mark - 查询pk结果的
- (void)checkRoomPKResult{
if (self.checkResultNum > 2) {
//pk请求已经不行了 只能结束了
[self clearRoomPKTeamData];
[self resetRoomPKGroupType];
return;
}
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(5 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
if (!self.isReceivePKResult) {
NSString * uid = [AccountInfoStorage instance].getUid;
NSString * roomUid = [NSString stringWithFormat:@"%ld", self.roomInfo.uid];
if (self.roomPKInfo.pkId.length > 0) {
NSString * pkId = self.roomPKInfo.pkId;
[Api checkRoomPKResult:^(BaseModel * _Nullable data, NSInteger code, NSString * _Nullable msg) {
if (code == 200) {
self.checkResultNum = 1;
self.isReceivePKResult = YES;
} else {
self.checkResultNum++;
[self checkRoomPKResult];
}
} roomUid:roomUid operUid:uid pkId:pkId];
}
}
});
}
#pragma mark - Private Method
- (void)initSubViews {
[self addSubview:self.backImageView];
[self addSubview:self.beginButton];
[self.backImageView addSubview:self.timeLabel];
[self.backImageView addSubview:self.redTeamView];
[self.backImageView addSubview:self.redScoreLabel];
[self.backImageView addSubview:self.blueTeamView];
[self.backImageView addSubview:self.blueScoreLabel];
[self.backImageView addSubview:self.progressView];
[self.progressView addSubview:self.redProgressView];
[self.progressView addSubview:self.blueProgressView];
[self.progressView addSubview:self.progressLineView];
}
- (void)initSubViewConstraints {
[self mas_makeConstraints:^(MASConstraintMaker *make) {
make.width.mas_equalTo(260);
make.bottom.mas_equalTo(self.beginButton.mas_bottom);
}];
[self.backImageView mas_makeConstraints:^(MASConstraintMaker *make) {
make.size.mas_equalTo(CGSizeMake(260, 60));
make.top.left.mas_equalTo(self);
}];
[self.beginButton mas_makeConstraints:^(MASConstraintMaker *make) {
make.size.mas_equalTo(CGSizeMake(90, 24));
make.centerX.mas_equalTo(self.backImageView);
make.centerY.mas_equalTo(self.backImageView.mas_bottom);
}];
[self.timeLabel mas_makeConstraints:^(MASConstraintMaker *make) {
make.centerX.mas_equalTo(self.backImageView);
make.top.mas_equalTo(self.backImageView);
}];
[self.progressView mas_makeConstraints:^(MASConstraintMaker *make) {
make.width.mas_equalTo(85 * 2);
make.height.mas_equalTo(7);
make.centerX.mas_equalTo(self.backImageView);
make.top.mas_equalTo(self.backImageView).offset(23);
}];
[self.redTeamView mas_makeConstraints:^(MASConstraintMaker *make) {
make.right.mas_equalTo(self.progressView.mas_left);
make.centerY.mas_equalTo(self.progressView);
make.height.mas_equalTo(25);
make.left.mas_greaterThanOrEqualTo(15);
}];
[self.blueTeamView mas_makeConstraints:^(MASConstraintMaker *make) {
make.left.mas_equalTo(self.progressView.mas_right);
make.centerY.mas_equalTo(self.progressView);
make.height.mas_equalTo(25);
make.right.mas_lessThanOrEqualTo(-15);
}];
[self.redProgressView mas_makeConstraints:^(MASConstraintMaker *make) {
make.left.top.bottom.mas_equalTo(self.progressView);
make.width.mas_equalTo(85);
}];
[self.blueProgressView mas_makeConstraints:^(MASConstraintMaker *make) {
make.right.top.bottom.mas_equalTo(self.progressView);
make.left.mas_equalTo(self.redProgressView.mas_right);
}];
[self.progressLineView mas_makeConstraints:^(MASConstraintMaker *make) {
make.size.mas_equalTo(CGSizeMake(2.5, 12.5));
make.centerX.mas_equalTo(self.blueProgressView.mas_left).offset(-1.2);
make.centerY.mas_equalTo(self.progressView);
}];
[self.redScoreLabel mas_makeConstraints:^(MASConstraintMaker *make) {
make.centerX.mas_equalTo(self.redTeamView);
make.top.mas_equalTo(self.redTeamView.mas_bottom).offset(5);
make.left.mas_lessThanOrEqualTo(self.backImageView);
}];
[self.blueScoreLabel mas_makeConstraints:^(MASConstraintMaker *make) {
make.centerX.mas_equalTo(self.blueTeamView);
make.centerY.mas_equalTo(self.redScoreLabel);
make.right.mas_lessThanOrEqualTo(self.backImageView);
}];
}
- (BOOL)isOnMicro:(NSString *)uid {
for (int i = 0; i < self.micQueue.allValues.count; i++) {
MicroQueueModel * micModel = [self.micQueue.allValues safeObjectAtIndex1:i];
if (micModel.userInfo && micModel.userInfo.uid > 0 && micModel.userInfo.uid == uid.integerValue) {
return YES;
}
}
return NO;
}
- (MicroQueueModel *)findMicroInfoByUid:(NSString *)uid {
for (MicroQueueModel *model in self.micQueue.allValues) {
if (model.userInfo && model.userInfo.uid == uid.intValue) {
return model;
}
}
return nil;
}
- (void)canculeRoomGiftValueReceiveInfo:(NSArray *)targetUids giftPrice:(NSInteger)giftPrice{
for (RoomPKChooseUserModel * userInfo in self.redChooseArray) {
for (NSString * uid in targetUids) {
NSString * userId = uid;
if ([userId isKindOfClass:[NSNumber class]]) {
userId = ((NSNumber *)userId).stringValue;
}
if (userId.integerValue == userInfo.uid.integerValue) {
self.redTeamScore += giftPrice;
break;
}
}
}
for (RoomPKChooseUserModel * userInfo in self.blueChooseArray) {
for (NSString * uid in targetUids) {
NSString * userId = uid;
if ([userId isKindOfClass:[NSNumber class]]) {
userId = ((NSNumber *)userId).stringValue;
}
if (userId.integerValue == userInfo.uid.integerValue) {
self.blueTeamScore += giftPrice;
break;
}
}
}
[self configRedTeamScore:self.redTeamScore blueTeamScore:self.blueTeamScore];
}
- (void)canculeRoomPKSendGiftNumPerson:(NSArray *)sendGiftUses sendUid:(NSString *)sendUid{
/**
1.先取出红队队员 -> 判断这个队员是否是接收礼物者 -> 是接收礼物则先判断送礼uid中是否存在送礼人 -> 存在不变, 不存在则+1
2.蓝队同理
**/
if (!self.redTeamGiftPersonDic) {
self.redTeamGiftPersonDic = [NSMutableDictionary dictionary];
// 取出红队
NSDictionary *redDict = self.roomPKInfo.sendGiftUids[@"2"];
// 先创建好 {队员uid : Set}
for (RoomPKTeamUserModel *info in self.redChooseArray) {
[self.redTeamGiftPersonDic setObject:[NSMutableSet set] forKey:info.uid];
}
for (NSString *key in redDict) {
// key为队员uid 值为数组
NSArray *sendGiftUids = [redDict objectForKey:key];
NSMutableSet *set = [NSMutableSet set];
[set addObjectsFromArray:sendGiftUids];
[self.redTeamGiftPersonDic setObject:set forKey:key];
}
}
if (!self.blueTeamGiftPersonDic) {
self.blueTeamGiftPersonDic = [NSMutableDictionary dictionary];
// 取出蓝队
NSDictionary *blueDict = self.roomPKInfo.sendGiftUids[@"1"];
// 先创建好 {队员uid : Set}
for (RoomPKTeamUserModel *info in self.blueChooseArray) {
[self.blueTeamGiftPersonDic setObject:[NSMutableSet set] forKey:info.uid];
}
for (NSString *key in blueDict) {
// key为队员uid 值为数组
NSArray *sendGiftUids = [blueDict objectForKey:key];
NSMutableSet *set = [NSMutableSet set];
[set addObjectsFromArray:sendGiftUids];
[self.blueTeamGiftPersonDic setObject:set forKey:key];
}
}
for (RoomPKTeamUserModel *infor in self.redChooseArray) {
for (NSString *uid in sendGiftUses) {
NSString * userId = uid;
if ([userId isKindOfClass:[NSNumber class]]) {
userId = ((NSNumber *)userId).stringValue;
}
if (userId.integerValue == infor.uid.integerValue) {
NSMutableSet *set = [self.redTeamGiftPersonDic objectForKey:infor.uid];
if ([set containsObject:sendUid]) {
continue;
} else {
[set addObject:sendUid];
}
}
}
}
for (RoomPKTeamUserModel *infor in self.blueChooseArray) {
for (NSString *uid in sendGiftUses) {
NSString * userId = uid;
if ([userId isKindOfClass:[NSNumber class]]) {
userId = ((NSNumber *)userId).stringValue;
}
if (userId.integerValue == infor.uid.integerValue) {
NSMutableSet *set = [self.blueTeamGiftPersonDic objectForKey:infor.uid];
if ([set containsObject:sendUid]) {
continue;
} else {
[set addObject:sendUid];
}
}
}
}
long blueTeamtotal = 0;
long redTeamtotal = 0;
for (NSString *key in self.redTeamGiftPersonDic) {
NSMutableSet *set = [self.redTeamGiftPersonDic objectForKey:key];
redTeamtotal = redTeamtotal + set.count;
}
for (NSString *key in self.blueTeamGiftPersonDic) {
NSMutableSet *set = [self.blueTeamGiftPersonDic objectForKey:key];
blueTeamtotal = blueTeamtotal + set.count;
}
[self configRedTeamScore:redTeamtotal blueTeamScore:blueTeamtotal];
}
- (void)handleRoomPKInfoChangeState {
self.isPlaying = NO;
if (self.roomPKInfo) {
switch (_roomPKInfo.pkStatus) {
case RoomPKStatusType_End:
[self handleBeginButtonState];
break;
case RoomPKStatusType_Playing:
{
[TTPopup dismiss];
[self handleBeginButtonState];
self.isPlaying = YES;
self.roomPKPlayingView.pkDetailInfo = self.roomPKInfo;
self.roomPKPlayingView.redChooseArray = self.redChooseArray;
self.roomPKPlayingView.blueChooseArray = self.blueChooseArray;
[self.roomPKPlayingView configRedTeamScore:self.redTeamScore blueTeamScore:self.blueTeamScore];
[TTPopup popupView:self.roomPKPlayingView style:TTPopupStyleAlert];
}
break;
case RoomPKStatusType_ReStart:
case RoomPKStatusType_NonStart:
{
[self handleBeginButtonState];
[self clearRoomPKTeamData];
[self stopRoomPKCountDown];
}
break;
default:
break;
}
}
}
- (void)resetRoomPKGroupType {
NSString * uid = [AccountInfoStorage instance].getUid;
if ([self isOnMicro:uid]) {
MicroQueueModel * micModel = [self findMicroInfoByUid:uid];
if (micModel.userInfo && micModel.userInfo.uid > 0 && micModel.userInfo.groupType != GroupType_default) {
micModel.userInfo.groupType = GroupType_default;
NIMChatroomQueueUpdateRequest *request = [[NIMChatroomQueueUpdateRequest alloc]init];
request.key = [NSString stringWithFormat:@"%d", micModel.microState.position];
NSMutableDictionary *curUserInfo = [[NSMutableDictionary alloc]initWithDictionary:[self userInfoToQueueExt:micModel.userInfo]];
[curUserInfo setValue:@(YES) forKey:@"isNoProhibitMic"];
request.value = [curUserInfo toJSONString];
NSString * roomId = [NSString stringWithFormat:@"%ld", self.roomInfo.roomId];
request.roomId = roomId;
request.transient = YES;
[[NIMSDK sharedSDK].chatroomManager updateChatroomQueueObject:request completion:^(NSError * _Nullable error) {
}];
}
}
}
- (NSDictionary *)userInfoToQueueExt:(UserInfoModel *)userInfo {
MicroExtModel * extModel = [[MicroExtModel alloc] init];
extModel.gender = userInfo.gender;
extModel.avatar = userInfo.avatar;
extModel.uid = userInfo.uid;
extModel.nick = userInfo.nick;
extModel.headWearUrl = userInfo.headwearEffect.length > 0 ? userInfo.headwearEffect : userInfo.headwearPic;
extModel.micCircle = userInfo.micCircle;
extModel.micNickColor = userInfo.micNickColor;
extModel.groupType = userInfo.groupType;
return [extModel model2dictionary];
}
- (NSString *)roomPKTeamJsonString {
NSMutableArray * teamArray = [NSMutableArray array];
for (int i = 0; i < self.redChooseArray.count; i++) {
RoomPKChooseUserModel * userInfo = [self.redChooseArray safeObjectAtIndex1:i];
NSMutableDictionary * redDic = [NSMutableDictionary dictionary];
[redDic setObject:userInfo.uid forKey:@"uid"];
[redDic setObject:@(userInfo.groupType) forKey:@"type"];
[teamArray addObject:redDic];
}
for (int i = 0; i < self.blueChooseArray.count; i++) {
RoomPKChooseUserModel * userInfo = [self.blueChooseArray safeObjectAtIndex1:i];
NSMutableDictionary * blueDic = [NSMutableDictionary dictionary];
[blueDic setObject:userInfo.uid forKey:@"uid"];
[blueDic setObject:@(userInfo.groupType) forKey:@"type"];
[teamArray addObject:blueDic];
}
if (teamArray.count > 0) {
return [teamArray toJSONString];
}
return @"";
}
- (void)startRoomPKCountDown:(CGFloat)time {
__block long tempTime = time; //倒计时时间
__weak typeof(self) weakSelf = self;
self.currentTime = tempTime;
if (self.timer != nil) {
dispatch_source_cancel(self.timer);
}
dispatch_queue_t queue = dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0);
self.timer = dispatch_source_create(DISPATCH_SOURCE_TYPE_TIMER, 0, 0, queue);
dispatch_source_set_timer(self.timer,dispatch_walltime(NULL, 0),1.0*NSEC_PER_SEC, 0); //每秒执行
dispatch_source_set_event_handler(self.timer, ^{
typeof(weakSelf) self = weakSelf;
if(tempTime <= 0){ //倒计时结束,关闭
self.currentTime = 0;
dispatch_source_cancel(self.timer);
dispatch_async(dispatch_get_main_queue(), ^{
[self checkRoomPKResult];
});
} else {
dispatch_async(dispatch_get_main_queue(), ^{
//设置按钮显示读秒效果
NSInteger minute = tempTime / 60;
NSInteger second = (tempTime % 60);
NSString *timeStr = [NSString stringWithFormat:@"%02zd:%02zd", minute, second];
self.timeLabel.text= timeStr;
self.roomPKPlayingView.currentTime = timeStr;
});
tempTime--;
self.currentTime = tempTime;
}
});
dispatch_resume(self.timer);
}
- (void)stopRoomPKCountDown {
if (self.timer) {
dispatch_source_cancel(_timer);
_timer = nil;
}
}
- (void)clearRoomPKTeamData {
[self.roomPKPlayingView clearRoomPKData];
self.redScoreLabel.text = @"0";
self.blueScoreLabel.text = @"0";
self.redTeamScore = 0;
self.blueTeamScore = 0;
self.redTeamGiftPersonDic = nil;
self.blueTeamGiftPersonDic = nil;
self.timeLabel.text = YMLocalizedString(@"XPRoomPKProgressView2");
[self.redProgressView mas_updateConstraints:^(MASConstraintMaker *make) {
make.width.mas_equalTo(85);
}];
}
- (void)configRedTeamScore:(long)redTeamScore blueTeamScore:(long)blueTeamScore {
self.redTeamScore = redTeamScore;
self.blueTeamScore = blueTeamScore;
self.redScoreLabel.text = [NSString stringWithFormat:@"%ld", redTeamScore];
self.blueScoreLabel.text = [NSString stringWithFormat:@"%ld", blueTeamScore];
if (redTeamScore > 0 || blueTeamScore > 0) {
CGFloat redScale = (CGFloat)redTeamScore / (CGFloat)(redTeamScore + blueTeamScore);
if (redScale == 1) {
redScale = 0.99;
}
[self.redProgressView mas_updateConstraints:^(MASConstraintMaker *make) {
make.width.mas_equalTo(85 * 2 * redScale);
}];
}
[self.roomPKPlayingView configRedTeamScore:redTeamScore blueTeamScore:blueTeamScore];
}
- (void)handleBeginButtonState {
if (self.roomPKInfo) {
if (self.roomPKInfo.pkStatus == RoomPKStatusType_Playing) {
self.beginButton.hidden = YES;
} else {
self.beginButton.hidden = !self.isManager;
}
} else {
self.beginButton.hidden = !self.isManager;
}
}
#pragma mark - XPRoomPKPanelUserViewDelegate
- (void)xPRoomPKPanelUserView:(XPRoomPKPanelUserView *)view didClickAddButton:(GroupType)type {
[TTPopup dismiss];
if (self.roomPKInfo.pkStatus == RoomPKStatusType_Playing) {
self.roomPKPlayingView.pkDetailInfo = self.roomPKInfo;
self.roomPKPlayingView.redChooseArray = self.redChooseArray;
self.roomPKPlayingView.blueChooseArray = self.blueChooseArray;
[self.roomPKPlayingView configRedTeamScore:self.redTeamScore blueTeamScore:self.blueTeamScore];
[TTPopup popupView:self.roomPKPlayingView style:TTPopupStyleAlert];
return;
}
if (self.isManager) {
XPRoomPKSelectUserView * chooseUserView = [[XPRoomPKSelectUserView alloc] init];
chooseUserView.delegate = self;
chooseUserView.redUserArray = self.redChooseArray;
chooseUserView.blueUserArray = self.blueChooseArray;
chooseUserView.groupType = type;
chooseUserView.microQueueArray = self.micQueue.allValues;
[TTPopup popupView:chooseUserView style:TTPopupStyleAlert];
} else {
XPArrangeMicInfoModel * info = [[XPArrangeMicInfoModel alloc] init];
info.roomUid = [NSString stringWithFormat:@"%ld", self.roomInfo.uid];
info.roomId = [NSString stringWithFormat:@"%ld", self.roomInfo.roomId];
info.nick = self.roomInfo.nick;
info.roomAvatar = self.roomInfo.avatar;
info.roomTitle = self.roomInfo.title;
info.micQueue = self.micQueue;
info.isManager = self.isManager;
info.type = ArrangeMicType_Room_PK;
XPArrangeMicViewController * arrangeMicVC = [[XPArrangeMicViewController alloc] initWithInfo:info];
[[XCCurrentVCStackManager shareManager].getCurrentVC.navigationController presentViewController:arrangeMicVC animated:YES completion:nil];
}
}
#pragma mark - XPRoomPKSelectUserViewDelegate
- (void)xPRoomPKSelectUserView:(XPRoomPKSelectUserView *)view groupType:(GroupType)groupType didChooseUserInfos:(NSArray<RoomPKChooseUserModel *> *)userInfos {
[TTPopup dismiss];
if (groupType == GroupType_Red) {
self.redChooseArray = userInfos;
} else {
self.blueChooseArray = userInfos;
}
if (self.redChooseArray.count > 0 || self.blueChooseArray.count > 0) {
NSMutableDictionary * dic = [NSMutableDictionary dictionary];
for (int i = 0 ; i< self.redChooseArray.count; i++) {
RoomPKChooseUserModel * model = [self.redChooseArray safeObjectAtIndex1:i];
if (model.uid.integerValue <= 0) {
continue;
}
NSMutableDictionary * data =[[model model2dictionary] mutableCopy];
[data removeObjectForKey:@"title"];
[data removeObjectForKey:@"imageName"];
[data removeObjectForKey:@"userUrl"];
[data removeObjectForKey:@"isSelect"];
[data removeObjectForKey:@"isEnableChoose"];
[data setValue:@(YES) forKey:@"isNoProhibitMic"];
[dic setValue:data forKey:model.uid];
}
for (int i = 0 ; i< self.blueChooseArray.count; i++) {
RoomPKChooseUserModel * model = [self.blueChooseArray safeObjectAtIndex1:i];
if (model.uid.integerValue <= 0 ) {
continue;
}
NSMutableDictionary * data =[[model model2dictionary] mutableCopy];
[data removeObjectForKey:@"title"];
[data removeObjectForKey:@"imageName"];
[data removeObjectForKey:@"userUrl"];
[data removeObjectForKey:@"isSelect"];
[data removeObjectForKey:@"isEnableChoose"];
[data setValue:@(YES) forKey:@"isNoProhibitMic"];
[dic setValue:data forKey:model.uid];
}
if (dic.allKeys.count > 0) {
AttachmentModel * attachment = [[AttachmentModel alloc] init];
attachment.first = CustomMessageType_Room_PK;
attachment.second = Custom_Message_Sub_Room_PK_Manager_Up_Mic;
attachment.data = dic;
NSString * roomId = [NSString stringWithFormat:@"%ld", self.roomInfo.roomId];
NSString *sessionID = roomId;
NIMMessage *message = [[NIMMessage alloc]init];
NIMCustomObject *object = [[NIMCustomObject alloc] init];
object.attachment = attachment;
message.messageObject = object;
//构造会话
NIMSession *session = [NIMSession session:sessionID type:NIMSessionTypeChatroom];
[[NIMSDK sharedSDK].chatManager sendMessage:message toSession:session error:nil];
}
}
}
#pragma mark - XPRoomPKPlayingViewDelegate
- (void)xPRoomPKPlayingView:(XPRoomPKPlayingView *)view didClickResetBegin:(UIButton *)sender {
[TTPopup dismiss];
[TTPopup alertWithMessage:YMLocalizedString(@"XPRoomPKProgressView3") confirmHandler:^{
RoomPKInfoModel * roompkInfo = self.roomPKInfo;
NSString * roomUid = [NSString stringWithFormat:@"%ld", self.roomInfo.uid];
[Api createRoomPK:^(BaseModel * _Nullable data, NSInteger code, NSString * _Nullable msg) {
if (code == 200) {
RoomPKInfoModel * newRoomPKInfo = [RoomPKInfoModel modelWithDictionary:data.data];
self.roomPKInfo = newRoomPKInfo;
} else {
[XNDJTDDLoadingTool showErrorWithMessage:msg];
}
} pkMode:[NSString stringWithFormat:@"%ld", roompkInfo.pkMode] voteMode:[NSString stringWithFormat:@"%ld", roompkInfo.voteMode] duration:[NSString stringWithFormat:@"%0.f", roompkInfo.duration] roomUid:roomUid operUid:[AccountInfoStorage instance].getUid];
} cancelHandler:^{
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.5 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
if (self.roomPKInfo.pkStatus == RoomPKStatusType_Playing) {
self.roomPKPlayingView.pkDetailInfo = self.roomPKInfo;
self.roomPKPlayingView.redChooseArray = self.redChooseArray;
self.roomPKPlayingView.blueChooseArray = self.blueChooseArray;
[self.roomPKPlayingView configRedTeamScore:self.redTeamScore blueTeamScore:self.blueTeamScore];
[TTPopup popupView:self.roomPKPlayingView style:TTPopupStyleAlert];
}
});
}];
}
#pragma mark - Event Response
- (void)beginButtonAction:(UIButton *)sender {
if (self.roomPKInfo != nil) {
RoomPKInfoModel * roompkInfo = self.roomPKInfo;
NSString * roomUid = [NSString stringWithFormat:@"%ld", self.roomInfo.uid];
if (self.redChooseArray.count > 0 && self.blueChooseArray.count > 0) {
if (self.roomPKInfo.pkStatus == RoomPKStatusType_End || self.roomPKInfo.pkStatus == RoomPKStatusType_ReStart) {
[TTPopup alertWithMessage:YMLocalizedString(@"XPRoomPKProgressView10") confirmHandler:^{
[Api createRoomPK:^(BaseModel * _Nullable data, NSInteger code, NSString * _Nullable msg) {
if (code == 200) {
RoomPKInfoModel * newRoomPKInfo = [RoomPKInfoModel modelWithDictionary:data.data];
self.roomPKInfo = newRoomPKInfo;
NSString * teamJsonStr = [self roomPKTeamJsonString];
///开始PK
[Api begainRoomPK:^(BaseModel * _Nullable data, NSInteger code, NSString * _Nullable msg) {
if (code == 200) {
RoomPKInfoModel * roomPKInfo = [RoomPKInfoModel modelWithDictionary:data.data];
self.roomPKInfo = roomPKInfo;
} else {
[XNDJTDDLoadingTool showErrorWithMessage:msg];
}
} roomUid:roomUid pkId:newRoomPKInfo.pkId joinUsers:teamJsonStr];
} else {
[XNDJTDDLoadingTool showErrorWithMessage:msg];
}
} pkMode:[NSString stringWithFormat:@"%ld", roompkInfo.pkMode] voteMode:[NSString stringWithFormat:@"%ld", roompkInfo.voteMode] duration:[NSString stringWithFormat:@"%0.f", roompkInfo.duration] roomUid:roomUid operUid:[AccountInfoStorage instance].getUid];
} cancelHandler:^{
}];
} else if(self.roomPKInfo.pkStatus == RoomPKStatusType_Playing) {
[self didTapBackImageRecognizer];
} else if(self.roomPKInfo.pkStatus == RoomPKStatusType_NonStart) {
[TTPopup alertWithMessage:YMLocalizedString(@"XPRoomPKProgressView5" ) confirmHandler:^{
NSString * teamJsonStr = [self roomPKTeamJsonString];
///开始PK
[Api begainRoomPK:^(BaseModel * _Nullable data, NSInteger code, NSString * _Nullable msg) {
if (code == 200) {
RoomPKInfoModel * roomPKInfo = [RoomPKInfoModel modelWithDictionary:data.data];
self.roomPKInfo = roomPKInfo;
} else {
[XNDJTDDLoadingTool showErrorWithMessage:msg];
}
} roomUid:roomUid pkId:self.roomPKInfo.pkId joinUsers:teamJsonStr];
} cancelHandler:^{
}];
}
} else {
[XNDJTDDLoadingTool showErrorWithMessage:YMLocalizedString(@"XPRoomPKProgressView6")];
}
}else {
[XNDJTDDLoadingTool showErrorWithMessage:YMLocalizedString(@"XPRoomPKProgressView7")];
[self enterRoomGetRoomPKDetailInfo];
}
}
- (void)didTapBackImageRecognizer {
if (self.roomPKInfo.pkStatus == RoomPKStatusType_Playing) {
[TTPopup dismiss];
self.roomPKPlayingView.pkDetailInfo = self.roomPKInfo;
self.roomPKPlayingView.redChooseArray = self.redChooseArray;
self.roomPKPlayingView.blueChooseArray = self.blueChooseArray;
[self.roomPKPlayingView configRedTeamScore:self.redTeamScore blueTeamScore:self.blueTeamScore];
[TTPopup popupView:self.roomPKPlayingView style:TTPopupStyleAlert];
}
}
#pragma mark - Getters And Setters
- (void)setMicQueue:(NSMutableDictionary<NSString *,MicroQueueModel *> *)micQueue {
_micQueue = micQueue;
if (self.roomPKInfo.pkStatus != RoomPKStatusType_Playing) {
NSMutableArray * redArray = [NSMutableArray array];
NSMutableArray * blueArray = [NSMutableArray array];
for (int i = 0 ; i < _micQueue.allValues.count; i++) {
MicroQueueModel * micModel = [_micQueue.allValues safeObjectAtIndex1:i];
if (micModel.userInfo && micModel.userInfo.uid > 0) {
UserInfoModel * userInfo = micModel.userInfo;
if (userInfo.groupType == GroupType_Red) {
RoomPKChooseUserModel * redInfo = [[RoomPKChooseUserModel alloc] init];
redInfo.avatar = userInfo.avatar;
redInfo.uid = [NSString stringWithFormat:@"%ld", userInfo.uid];
redInfo.nick = userInfo.nick;
redInfo.groupType = userInfo.groupType;
redInfo.position = micModel.microState.position;
[redArray addObject:redInfo];
} else if(userInfo.groupType == GroupType_Blue) {
RoomPKChooseUserModel * blueInfo = [[RoomPKChooseUserModel alloc] init];
blueInfo.avatar = userInfo.avatar;
blueInfo.nick = userInfo.nick;
blueInfo.uid = [NSString stringWithFormat:@"%ld", userInfo.uid];
blueInfo.groupType = userInfo.groupType;
blueInfo.position = micModel.microState.position;
[blueArray addObject:blueInfo];
}
}
}
self.redChooseArray = redArray.copy;
self.blueChooseArray = blueArray.copy;
}
}
- (void)setIsManager:(BOOL)isManager {
_isManager = isManager;
[self handleBeginButtonState];
self.roomPKPlayingView.isManager = _isManager;
}
- (void)setRedChooseArray:(NSArray<RoomPKChooseUserModel *> *)redChooseArray {
_redChooseArray = redChooseArray;
self.redTeamView.userArray = _redChooseArray;
self.roomPKPlayingView.redChooseArray = _redChooseArray;
}
- (void)setBlueChooseArray:(NSArray<RoomPKChooseUserModel *> *)blueChooseArray {
_blueChooseArray = blueChooseArray;
self.blueTeamView.userArray = _blueChooseArray;
self.roomPKPlayingView.blueChooseArray = _blueChooseArray;
}
- (UIImageView *)backImageView {
if (!_backImageView) {
_backImageView = [[UIImageView alloc] init];
_backImageView.userInteractionEnabled = YES;
_backImageView.image = [UIImage imageNamed:@"room_pk_progrss_bg"];
UITapGestureRecognizer * tap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(didTapBackImageRecognizer)];
[_backImageView addGestureRecognizer:tap];
}
return _backImageView;
}
- (UILabel *)timeLabel {
if (!_timeLabel) {
_timeLabel = [[UILabel alloc] init];
_timeLabel.font = [UIFont systemFontOfSize:10];
_timeLabel.textColor = UIColorFromRGB(0x602A06);
_timeLabel.textAlignment = NSTextAlignmentCenter;
_timeLabel.text= YMLocalizedString(@"XPRoomPKProgressView8");
}
return _timeLabel;
}
- (XPRoomPKPanelUserView *)redTeamView {
if (!_redTeamView) {
_redTeamView = [[XPRoomPKPanelUserView alloc] init];
_redTeamView.itemHeight = 25;
_redTeamView.type = GroupType_Red;
_redTeamView.delegate = self;
}
return _redTeamView;
}
- (XPRoomPKPanelUserView *)blueTeamView {
if (!_blueTeamView) {
_blueTeamView = [[XPRoomPKPanelUserView alloc] init];
_blueTeamView.itemHeight = 25;
_blueTeamView.type = GroupType_Blue;
_blueTeamView.delegate = self;
}
return _blueTeamView;
}
- (UIView *)progressView {
if (!_progressView) {
_progressView = [[UIView alloc] init];
_progressView.backgroundColor = [UIColor clearColor];
}
return _progressView;
}
- (UIImageView *)redProgressView {
if (!_redProgressView) {
_redProgressView = [[UIImageView alloc] init];
_redProgressView.userInteractionEnabled = YES;
_redProgressView.image = [UIImage gradientColorImageFromColors:@[UIColorFromRGB(0xFA96AE), UIColorFromRGB(0xE943F8)] gradientType:GradientTypeLeftToRight imgSize:CGSizeMake(10, 10)];
_redProgressView.contentMode = UIViewContentModeScaleAspectFill;
_redProgressView.layer.masksToBounds = YES;
}
return _redProgressView;
}
- (UIImageView *)blueProgressView {
if (!_blueProgressView) {
_blueProgressView = [[UIImageView alloc] init];
_blueProgressView.userInteractionEnabled = YES;
_blueProgressView.image = [UIImage gradientColorImageFromColors:@[UIColorFromRGB(0x4F7AFF), UIColorFromRGB(0x44C0FE)] gradientType:GradientTypeLeftToRight imgSize:CGSizeMake(10, 10)];
_blueProgressView.contentMode = UIViewContentModeScaleAspectFill;
_blueProgressView.layer.masksToBounds = YES;
}
return _blueProgressView;
}
- (UIImageView *)progressLineView {
if (!_progressLineView) {
_progressLineView = [[UIImageView alloc] init];
_progressLineView.userInteractionEnabled = YES;
_progressLineView.image = [UIImage imageNamed:@"room_pk_progrss_line_bg"];
}
return _progressLineView;
}
- (UILabel *)redScoreLabel {
if (!_redScoreLabel) {
_redScoreLabel = [[UILabel alloc] init];
_redScoreLabel.text = @"0";
_redScoreLabel.font = [UIFont systemFontOfSize:12 weight:UIFontWeightMedium];
_redScoreLabel.textColor = UIColor.whiteColor;
_redScoreLabel.textAlignment = NSTextAlignmentCenter;
}
return _redScoreLabel;
}
- (UILabel *)blueScoreLabel {
if (!_blueScoreLabel) {
_blueScoreLabel = [[UILabel alloc] init];
_blueScoreLabel.text = @"0";
_blueScoreLabel.font = [UIFont systemFontOfSize:12 weight:UIFontWeightMedium];
_blueScoreLabel.textColor = UIColor.whiteColor;
_blueScoreLabel.textAlignment = NSTextAlignmentCenter;
}
return _blueScoreLabel;
}
- (UIButton *)beginButton {
if (!_beginButton) {
_beginButton = [UIButton buttonWithType:UIButtonTypeCustom];
[_beginButton setTitle:YMLocalizedString(@"XPRoomPKProgressView9") forState:UIControlStateNormal];
[_beginButton setTitleColor:UIColorFromRGB(0x602A06) forState:UIControlStateNormal];
_beginButton.titleLabel.font = [UIFont systemFontOfSize:15];
[_beginButton setBackgroundImage:[UIImage gradientColorImageFromColors:@[UIColorFromRGB(0xFFDAA8), UIColorFromRGB(0xFFBD64)] gradientType:GradientTypeUpleftToLowright imgSize:CGSizeMake(10, 10)] forState:UIControlStateNormal];
_beginButton.layer.masksToBounds = YES;
_beginButton.layer.cornerRadius = 12;
_beginButton.hidden = YES;
[_beginButton addTarget:self action:@selector(beginButtonAction:) forControlEvents:UIControlEventTouchUpInside];
}
return _beginButton;
}
- (XPRoomPKPlayingView *)roomPKPlayingView {
if (!_roomPKPlayingView) {
_roomPKPlayingView = [[XPRoomPKPlayingView alloc] init];
_roomPKPlayingView.delegate = self;
}
return _roomPKPlayingView;
}
@end