房间内PK选择Pk的人
This commit is contained in:
@@ -300,6 +300,7 @@
|
||||
E80B0734280D740600A79F63 /* MessageContentGuildView.m in Sources */ = {isa = PBXBuildFile; fileRef = E80B0733280D740600A79F63 /* MessageContentGuildView.m */; };
|
||||
E80B0737280D790400A79F63 /* GuildMessageModel.m in Sources */ = {isa = PBXBuildFile; fileRef = E80B0736280D790400A79F63 /* GuildMessageModel.m */; };
|
||||
E80A086227F2AC190027B30C /* RoomPKDetailInfoModel.m in Sources */ = {isa = PBXBuildFile; fileRef = E80A086127F2AC190027B30C /* RoomPKDetailInfoModel.m */; };
|
||||
E80A086527F318620027B30C /* XPRoomPKPlayingView.m in Sources */ = {isa = PBXBuildFile; fileRef = E80A086427F318620027B30C /* XPRoomPKPlayingView.m */; };
|
||||
E80CBDE627D0C1CF001E1EC2 /* HomeMenuSourceModel.m in Sources */ = {isa = PBXBuildFile; fileRef = E80CBDE527D0C1CF001E1EC2 /* HomeMenuSourceModel.m */; };
|
||||
E80CBDEA27D0C53F001E1EC2 /* XPWeakTimer.m in Sources */ = {isa = PBXBuildFile; fileRef = E80CBDE927D0C53F001E1EC2 /* XPWeakTimer.m */; };
|
||||
E80CBDED27D0D899001E1EC2 /* XPHomeLikeEmptyTableViewCell.m in Sources */ = {isa = PBXBuildFile; fileRef = E80CBDEC27D0D899001E1EC2 /* XPHomeLikeEmptyTableViewCell.m */; };
|
||||
@@ -1416,6 +1417,8 @@
|
||||
E80B0736280D790400A79F63 /* GuildMessageModel.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = GuildMessageModel.m; sourceTree = "<group>"; };
|
||||
E80A086027F2AC190027B30C /* RoomPKDetailInfoModel.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = RoomPKDetailInfoModel.h; sourceTree = "<group>"; };
|
||||
E80A086127F2AC190027B30C /* RoomPKDetailInfoModel.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = RoomPKDetailInfoModel.m; sourceTree = "<group>"; };
|
||||
E80A086327F318620027B30C /* XPRoomPKPlayingView.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = XPRoomPKPlayingView.h; sourceTree = "<group>"; };
|
||||
E80A086427F318620027B30C /* XPRoomPKPlayingView.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = XPRoomPKPlayingView.m; sourceTree = "<group>"; };
|
||||
E80CBDE427D0C1CF001E1EC2 /* HomeMenuSourceModel.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = HomeMenuSourceModel.h; sourceTree = "<group>"; };
|
||||
E80CBDE527D0C1CF001E1EC2 /* HomeMenuSourceModel.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = HomeMenuSourceModel.m; sourceTree = "<group>"; };
|
||||
E80CBDE827D0C53F001E1EC2 /* XPWeakTimer.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = XPWeakTimer.h; sourceTree = "<group>"; };
|
||||
@@ -4025,6 +4028,8 @@
|
||||
E8664ED527E434D5000171BA /* XPRoomPKRecordViewController.m */,
|
||||
E81AF32327F1D5B8003B9E43 /* XPRoomPKProgressView.h */,
|
||||
E81AF32427F1D5B8003B9E43 /* XPRoomPKProgressView.m */,
|
||||
E80A086327F318620027B30C /* XPRoomPKPlayingView.h */,
|
||||
E80A086427F318620027B30C /* XPRoomPKPlayingView.m */,
|
||||
);
|
||||
path = View;
|
||||
sourceTree = "<group>";
|
||||
@@ -7053,6 +7058,7 @@
|
||||
9BA8A48327C726E8000365A3 /* ThemeColor+SkillCard.m in Sources */,
|
||||
E8AEAED6271412EC0017FCE0 /* XPRoomViewController.m in Sources */,
|
||||
E8E5E1A327C3730B00F457D8 /* XPHomeSectionView.m in Sources */,
|
||||
E80A086527F318620027B30C /* XPRoomPKPlayingView.m in Sources */,
|
||||
E8E70D9226F2F60C00F03460 /* XPMineItemModel.m in Sources */,
|
||||
189DD74A26E21D8400AB55B1 /* SSKeychain.m in Sources */,
|
||||
E8DACCFE27673F870052092C /* GiftValueInfoModel.m in Sources */,
|
||||
|
22
xplan-ios/Assets.xcassets/Room/RoomPK/room_pk_playing_bg.imageset/Contents.json
vendored
Normal file
22
xplan-ios/Assets.xcassets/Room/RoomPK/room_pk_playing_bg.imageset/Contents.json
vendored
Normal file
@@ -0,0 +1,22 @@
|
||||
{
|
||||
"images" : [
|
||||
{
|
||||
"idiom" : "universal",
|
||||
"scale" : "1x"
|
||||
},
|
||||
{
|
||||
"filename" : "room_pk_playing_bg@2x.png",
|
||||
"idiom" : "universal",
|
||||
"scale" : "2x"
|
||||
},
|
||||
{
|
||||
"filename" : "room_pk_playing_bg@3x.png",
|
||||
"idiom" : "universal",
|
||||
"scale" : "3x"
|
||||
}
|
||||
],
|
||||
"info" : {
|
||||
"author" : "xcode",
|
||||
"version" : 1
|
||||
}
|
||||
}
|
BIN
xplan-ios/Assets.xcassets/Room/RoomPK/room_pk_playing_bg.imageset/room_pk_playing_bg@2x.png
vendored
Normal file
BIN
xplan-ios/Assets.xcassets/Room/RoomPK/room_pk_playing_bg.imageset/room_pk_playing_bg@2x.png
vendored
Normal file
Binary file not shown.
After Width: | Height: | Size: 129 KiB |
BIN
xplan-ios/Assets.xcassets/Room/RoomPK/room_pk_playing_bg.imageset/room_pk_playing_bg@3x.png
vendored
Normal file
BIN
xplan-ios/Assets.xcassets/Room/RoomPK/room_pk_playing_bg.imageset/room_pk_playing_bg@3x.png
vendored
Normal file
Binary file not shown.
After Width: | Height: | Size: 204 KiB |
22
xplan-ios/Assets.xcassets/Room/RoomPK/room_pk_playing_fold.imageset/Contents.json
vendored
Normal file
22
xplan-ios/Assets.xcassets/Room/RoomPK/room_pk_playing_fold.imageset/Contents.json
vendored
Normal file
@@ -0,0 +1,22 @@
|
||||
{
|
||||
"images" : [
|
||||
{
|
||||
"idiom" : "universal",
|
||||
"scale" : "1x"
|
||||
},
|
||||
{
|
||||
"filename" : "room_pk_playing_fold@2x.png",
|
||||
"idiom" : "universal",
|
||||
"scale" : "2x"
|
||||
},
|
||||
{
|
||||
"filename" : "room_pk_playing_fold@3x.png",
|
||||
"idiom" : "universal",
|
||||
"scale" : "3x"
|
||||
}
|
||||
],
|
||||
"info" : {
|
||||
"author" : "xcode",
|
||||
"version" : 1
|
||||
}
|
||||
}
|
BIN
xplan-ios/Assets.xcassets/Room/RoomPK/room_pk_playing_fold.imageset/room_pk_playing_fold@2x.png
vendored
Normal file
BIN
xplan-ios/Assets.xcassets/Room/RoomPK/room_pk_playing_fold.imageset/room_pk_playing_fold@2x.png
vendored
Normal file
Binary file not shown.
After Width: | Height: | Size: 1.4 KiB |
BIN
xplan-ios/Assets.xcassets/Room/RoomPK/room_pk_playing_fold.imageset/room_pk_playing_fold@3x.png
vendored
Normal file
BIN
xplan-ios/Assets.xcassets/Room/RoomPK/room_pk_playing_fold.imageset/room_pk_playing_fold@3x.png
vendored
Normal file
Binary file not shown.
After Width: | Height: | Size: 4.7 KiB |
@@ -41,6 +41,7 @@
|
||||
#import "XPAnchorFansTaskModel.h"
|
||||
#import "AcrossRoomPKPanelModel.h"
|
||||
#import "RoomPKDetailInfoModel.h"
|
||||
#import "RoomPKChooseUserModel.h"
|
||||
///View
|
||||
#import "XPRoomHalfWebView.h"
|
||||
#import "XPAnchorAudienceUpMicView.h"
|
||||
@@ -339,14 +340,24 @@
|
||||
if (micModel.userInfo && micModel.userInfo.uid > 0) {
|
||||
UserInfoModel * userInfo = micModel.userInfo;
|
||||
if (userInfo.groupType == GroupTyp_Red) {
|
||||
[redArray addObject:userInfo];
|
||||
RoomPKChooseUserModel * redInfo = [[RoomPKChooseUserModel alloc] init];
|
||||
redInfo.userUrl = userInfo.avatar;
|
||||
redInfo.uid = [NSString stringWithFormat:@"%ld", userInfo.uid];
|
||||
redInfo.groupType = userInfo.groupType;
|
||||
redInfo.position = micModel.microState.position;
|
||||
[redArray addObject:redInfo];
|
||||
} else if(userInfo.groupType == GroupType_Blue) {
|
||||
[blueArray addObject:userInfo];
|
||||
RoomPKChooseUserModel * blueInfo = [[RoomPKChooseUserModel alloc] init];
|
||||
blueInfo.userUrl = userInfo.avatar;
|
||||
blueInfo.uid = [NSString stringWithFormat:@"%ld", userInfo.uid];
|
||||
blueInfo.groupType = userInfo.groupType;
|
||||
blueInfo.position = micModel.microState.position;
|
||||
[blueArray addObject:blueInfo];
|
||||
}
|
||||
}
|
||||
}
|
||||
self.roompkPanelView.redUserArray = redArray;
|
||||
self.roompkPanelView.blueUserArray = blueArray;
|
||||
self.roompkPanelView.redChooseArray = redArray.copy;
|
||||
self.roompkPanelView.blueChooseArray = blueArray.copy;
|
||||
}
|
||||
} else {
|
||||
[XCHUDTool showErrorWithMessage:msg];
|
||||
@@ -503,6 +514,38 @@
|
||||
AttachmentModel *attachment = (AttachmentModel *)obj.attachment;
|
||||
if (attachment.first == CustomMessageType_AnchorRoom_AudienceUpMic) {
|
||||
[self showAskForUpMic:attachment.data];
|
||||
} else if(attachment.first == CustomMessageType_Room_PK) {
|
||||
if (attachment.second == Custom_Message_Sub_Room_PK_Start) {
|
||||
RoomPKInfoModel * pkInfo = [RoomPKInfoModel modelWithDictionary:attachment.data];
|
||||
self.pkDetailInfo.roomPK = pkInfo;
|
||||
[self.roompkPanelView startRoomPKCountDown:pkInfo.duration];
|
||||
if (pkInfo.pkStatus == RoomPKStatusType_Playing) {
|
||||
//TODO: 弹框显示Pk
|
||||
}
|
||||
}else if (attachment.second == Custom_Message_Sub_Room_PK_Mode_Open){
|
||||
RoomPKInfoModel * pkInfo = [RoomPKInfoModel modelWithDictionary:attachment.data];
|
||||
self.pkDetailInfo.roomPK = pkInfo;
|
||||
} else if(attachment.second == Custom_Message_Sub_Room_PK_Re_Start) {
|
||||
RoomPKInfoModel * pkInfo = [RoomPKInfoModel modelWithDictionary:attachment.data];
|
||||
self.pkDetailInfo.roomPK = pkInfo;
|
||||
} else if(attachment.second == Custom_Message_Sub_Room_PK_Result) {
|
||||
RoomPKInfoModel * pkInfo = [RoomPKInfoModel modelWithDictionary:attachment.data];
|
||||
self.roompkPanelView.isReceivePKResult = YES;
|
||||
[self.roompkPanelView stopRoomPKCountDown];
|
||||
if (pkInfo.pkStatus == RoomPKStatusType_ReStart) {///重新开始了 需要重新赋值
|
||||
self.pkDetailInfo.roomPK = pkInfo;
|
||||
} else {
|
||||
if (pkInfo.pkId == self.pkDetailInfo.roomPK.pkId) {
|
||||
self.pkDetailInfo.roomPK = pkInfo;
|
||||
//TODO: 更新自己的麦序结果
|
||||
}
|
||||
}
|
||||
} else if(attachment.second == Custom_Message_Sub_Room_PK_Mode_Close) {
|
||||
[self.roompkPanelView stopRoomPKCountDown];
|
||||
[self.roompkPanelView clearRoomPKTeamData];
|
||||
[self.roompkPanelView removeFromSuperview];
|
||||
//TODO: 更新自己的麦序
|
||||
}
|
||||
} else if (attachment.first == CustomMessageType_Across_Room_PK) {
|
||||
///自己是公会超管
|
||||
BOOL meIsSuperAdmin = NO;
|
||||
@@ -789,14 +832,24 @@
|
||||
if (micModel.userInfo && micModel.userInfo.uid > 0) {
|
||||
UserInfoModel * userInfo = micModel.userInfo;
|
||||
if (userInfo.groupType == GroupTyp_Red) {
|
||||
[redArray addObject:userInfo];
|
||||
RoomPKChooseUserModel * redInfo = [[RoomPKChooseUserModel alloc] init];
|
||||
redInfo.userUrl = userInfo.avatar;
|
||||
redInfo.uid = [NSString stringWithFormat:@"%ld", userInfo.uid];
|
||||
redInfo.groupType = userInfo.groupType;
|
||||
redInfo.position = micModel.microState.position;
|
||||
[redArray addObject:redInfo];
|
||||
} else if(userInfo.groupType == GroupType_Blue) {
|
||||
[blueArray addObject:userInfo];
|
||||
RoomPKChooseUserModel * blueInfo = [[RoomPKChooseUserModel alloc] init];
|
||||
blueInfo.userUrl = userInfo.avatar;
|
||||
blueInfo.uid = [NSString stringWithFormat:@"%ld", userInfo.uid];
|
||||
blueInfo.groupType = userInfo.groupType;
|
||||
blueInfo.position = micModel.microState.position;
|
||||
[blueArray addObject:blueInfo];
|
||||
}
|
||||
}
|
||||
}
|
||||
self.roompkPanelView.redUserArray = redArray;
|
||||
self.roompkPanelView.blueUserArray = blueArray;
|
||||
self.roompkPanelView.redChooseArray = redArray.copy;
|
||||
self.roompkPanelView.blueChooseArray = blueArray.copy;
|
||||
}
|
||||
} else {
|
||||
[self getRoomPKDetailInfo];
|
||||
|
@@ -55,6 +55,16 @@ NS_ASSUME_NONNULL_BEGIN
|
||||
duration:(NSString *)duration
|
||||
roomUid:(NSString *)roomUid
|
||||
operUid:(NSString *)operUid;
|
||||
|
||||
/// 查询房间PK结果
|
||||
/// @param completion 完成
|
||||
/// @param roomUid 房主的uid
|
||||
/// @param operUid 操作者的uid
|
||||
/// @param pkId Pk的id
|
||||
+ (void)checkRoomPKResult:(HttpRequestHelperCompletion)completion
|
||||
roomUid:(NSString *)roomUid
|
||||
operUid:(NSString *)operUid
|
||||
pkId:(NSString *)pkId;
|
||||
@end
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
||||
|
@@ -53,6 +53,14 @@
|
||||
[self makeRequest:@"room/pk/create" method:HttpRequestHelperMethodPOST completion:completion,__FUNCTION__, pkMode, voteMode, duration, roomUid, operUid, nil];
|
||||
}
|
||||
|
||||
/// 查询房间PK结果
|
||||
/// @param completion 完成
|
||||
/// @param roomUid 房主的uid
|
||||
/// @param operUid 操作者的uid
|
||||
/// @param pkId Pk的id
|
||||
+ (void)checkRoomPKResult:(HttpRequestHelperCompletion)completion roomUid:(NSString *)roomUid operUid:(NSString *)operUid pkId:(NSString *)pkId {
|
||||
[self makeRequest:@"room/pk/query" method:HttpRequestHelperMethodGET completion:completion, __FUNCTION__, roomUid, operUid, pkId, nil];
|
||||
}
|
||||
|
||||
|
||||
@end
|
||||
|
@@ -44,6 +44,20 @@ typedef NS_ENUM(NSInteger,RoomPKStatusType){
|
||||
@property (nonatomic, copy) NSDictionary<NSString *, NSDictionary<NSString *, NSArray<NSString *> *> *> *sendGiftUids;
|
||||
///参与PK的队伍
|
||||
@property (nonatomic, strong) NSArray<RoomPKTeamModel *> * teams;
|
||||
///本地字段
|
||||
///红队的人员
|
||||
@property (nonatomic,strong) NSArray *redUserArray;
|
||||
///蓝队的人员
|
||||
@property (nonatomic,strong) NSArray *blueUserArray;
|
||||
///红队按礼物价值计算的话分数
|
||||
@property (nonatomic,assign) CGFloat redTeamValueScore;
|
||||
///蓝队总的分数按礼物价值计算的话分数
|
||||
@property (nonatomic,assign) CGFloat blueTeamValueScore;
|
||||
///红队收到礼物个数(按照收礼个数)
|
||||
@property (nonatomic, strong) NSMutableSet * redTeamGiftPersonDic;
|
||||
///蓝队收到礼物个数(按照收礼个数)
|
||||
@property (nonatomic, strong) NSMutableSet * blueTeamGiftPersonDic;
|
||||
|
||||
@end
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
||||
|
@@ -8,15 +8,17 @@
|
||||
#import <UIKit/UIKit.h>
|
||||
#import "XPEnum.h"
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
@class XPRoomPKPanelUserView, UserInfoModel;
|
||||
@class XPRoomPKPanelUserView, RoomPKChooseUserModel;
|
||||
@protocol XPRoomPKPanelUserViewDelegate <NSObject>
|
||||
///选择红队还是蓝队的添加人
|
||||
- (void)xPRoomPKPanelUserView:(XPRoomPKPanelUserView *)view didClickAddButton:(GroupType)type;
|
||||
|
||||
@end
|
||||
@interface XPRoomPKPanelUserView : UIView
|
||||
///高度
|
||||
@property (nonatomic,assign) CGFloat itemHeight;
|
||||
@property (nonatomic,assign) GroupType type;
|
||||
@property (nonatomic,strong) NSArray<UserInfoModel *> *userArray;
|
||||
@property (nonatomic,strong, nullable) NSArray<RoomPKChooseUserModel *> *userArray;
|
||||
///代理
|
||||
@property (nonatomic,weak) id<XPRoomPKPanelUserViewDelegate> delegate;
|
||||
@end
|
||||
|
@@ -12,7 +12,7 @@
|
||||
#import "NetImageView.h"
|
||||
#import "ThemeColor.h"
|
||||
///Model
|
||||
#import "UserInfoModel.h"
|
||||
#import "RoomPKChooseUserModel.h"
|
||||
|
||||
@interface XPRoomPKPanelUserView ()
|
||||
///容器
|
||||
@@ -49,6 +49,7 @@
|
||||
|
||||
#pragma mark - Private Method
|
||||
- (void)initSubViews {
|
||||
self.itemHeight = 25;
|
||||
[self addSubview:self.stackView];
|
||||
[self.stackView addArrangedSubview:self.addButton];
|
||||
[self.stackView addArrangedSubview:self.userView];
|
||||
@@ -100,14 +101,14 @@
|
||||
for (int i = 0 ; i< self.viewArray.count; i++) {
|
||||
NetImageView * view = [self.viewArray objectAtIndex:i];
|
||||
if (i < self.userArray.count) {
|
||||
UserInfoModel * userInfo = [self.userArray objectAtIndex:i];
|
||||
RoomPKChooseUserModel * userInfo = [self.userArray objectAtIndex:i];
|
||||
view.hidden = NO;
|
||||
view.imageUrl = userInfo.avatar;
|
||||
view.imageUrl = userInfo.userUrl;
|
||||
} else {
|
||||
view.hidden = YES;
|
||||
}
|
||||
}
|
||||
CGFloat userViewWidth = (_userArray.count - 1) * 15 + 25;
|
||||
CGFloat userViewWidth = (_userArray.count - 1) * 15 + self.itemHeight;
|
||||
[self.userView mas_updateConstraints:^(MASConstraintMaker *make) {
|
||||
make.width.mas_equalTo(userViewWidth);
|
||||
}];
|
||||
@@ -128,7 +129,7 @@
|
||||
self.fifthUserView.layer.borderColor = color;
|
||||
[self.addButton setImage:[UIImage imageNamed:@"room_pk_progrss_red_add"] forState:UIControlStateNormal];
|
||||
[self.firstUserView mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
make.size.mas_equalTo(CGSizeMake(25, 25));
|
||||
make.size.mas_equalTo(CGSizeMake(self.itemHeight, self.itemHeight));
|
||||
make.right.centerY.mas_equalTo(self.userView);
|
||||
}];
|
||||
|
||||
@@ -161,7 +162,7 @@
|
||||
self.fifthUserView.layer.borderColor = color;
|
||||
[self.addButton setImage:[UIImage imageNamed:@"room_pk_progrss_blue_add"] forState:UIControlStateNormal];
|
||||
[self.fifthUserView mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
make.size.mas_equalTo(CGSizeMake(25, 25));
|
||||
make.size.mas_equalTo(CGSizeMake(self.itemHeight, self.itemHeight));
|
||||
make.left.centerY.mas_equalTo(self.userView);
|
||||
}];
|
||||
|
||||
@@ -189,6 +190,13 @@
|
||||
}
|
||||
}
|
||||
|
||||
- (void)setItemHeight:(CGFloat)itemHeight {
|
||||
_itemHeight = itemHeight;
|
||||
[self mas_updateConstraints:^(MASConstraintMaker *make) {
|
||||
make.height.mas_equalTo(self.itemHeight);
|
||||
}];
|
||||
}
|
||||
|
||||
- (UIStackView *)stackView {
|
||||
if (!_stackView) {
|
||||
_stackView = [[UIStackView alloc] init];
|
||||
|
@@ -139,10 +139,11 @@
|
||||
*stop = YES;
|
||||
}
|
||||
}];
|
||||
if (selectModel) {
|
||||
[self.chooseArray removeObject:selectModel];
|
||||
if (selectModel && !model.isSelect) {
|
||||
selectModel.groupType = GroupType_default;
|
||||
}
|
||||
if (model.isSelect) {
|
||||
|
||||
if (model.isSelect && selectModel == nil) {
|
||||
[self.chooseArray addObject:model];
|
||||
}
|
||||
}
|
||||
|
19
xplan-ios/Main/Room/View/RoomPK/View/XPRoomPKPlayingView.h
Normal file
19
xplan-ios/Main/Room/View/RoomPK/View/XPRoomPKPlayingView.h
Normal file
@@ -0,0 +1,19 @@
|
||||
//
|
||||
// XPRoomPKPlayingView.h
|
||||
// xplan-ios
|
||||
//
|
||||
// Created by 冯硕 on 2022/3/29.
|
||||
//
|
||||
|
||||
#import <UIKit/UIKit.h>
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
@class RoomPKDetailInfoModel;
|
||||
@interface XPRoomPKPlayingView : UIView
|
||||
///是否是管理员
|
||||
@property (nonatomic,assign) BOOL isManager;
|
||||
///PK详情
|
||||
@property (nonatomic,strong) RoomPKDetailInfoModel *pkDetailInfo;
|
||||
@end
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
338
xplan-ios/Main/Room/View/RoomPK/View/XPRoomPKPlayingView.m
Normal file
338
xplan-ios/Main/Room/View/RoomPK/View/XPRoomPKPlayingView.m
Normal file
@@ -0,0 +1,338 @@
|
||||
//
|
||||
// XPRoomPKPlayingView.m
|
||||
// xplan-ios
|
||||
//
|
||||
// Created by 冯硕 on 2022/3/29.
|
||||
//
|
||||
|
||||
#import "XPRoomPKPlayingView.h"
|
||||
///Third
|
||||
#import <Masonry/Masonry.h>
|
||||
///Tool
|
||||
#import "ThemeColor.h"
|
||||
#import "XPMacro.h"
|
||||
#import "TTPopup.h"
|
||||
#import "UIImage+Utils.h"
|
||||
///Model
|
||||
#import "RoomPKDetailInfoModel.h"
|
||||
///View
|
||||
#import "XPRoomPKPanelUserView.h"
|
||||
|
||||
@interface XPRoomPKPlayingView ()
|
||||
///背景
|
||||
@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 (nonatomic,strong) UIButton *foldButton;
|
||||
///显示Pk模式
|
||||
@property (nonatomic,strong) UILabel *voteModeLabel;
|
||||
///显示pk
|
||||
@property (nonatomic,strong) UILabel *pkLabel;
|
||||
@end
|
||||
|
||||
|
||||
@implementation XPRoomPKPlayingView
|
||||
- (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.backImageView];
|
||||
|
||||
[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.backImageView addSubview:self.beginButton];
|
||||
[self.backImageView addSubview:self.voteModeLabel];
|
||||
[self.backImageView addSubview:self.pkLabel];
|
||||
|
||||
[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.height.mas_equalTo(153);
|
||||
}];
|
||||
|
||||
[self.backImageView mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
make.edges.mas_equalTo(self);
|
||||
}];
|
||||
|
||||
[self.timeLabel mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
make.centerX.mas_equalTo(self.backImageView);
|
||||
make.top.mas_equalTo(self.backImageView);
|
||||
}];
|
||||
|
||||
[self.redTeamView mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
make.right.mas_equalTo(self.backImageView.mas_centerX).offset(-56);
|
||||
make.centerY.mas_equalTo(self.backImageView).offset(25);
|
||||
}];
|
||||
|
||||
[self.voteModeLabel mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
make.centerX.mas_equalTo(self.backImageView);
|
||||
make.top.mas_equalTo(self.backImageView).offset(36);
|
||||
}];
|
||||
|
||||
[self.pkLabel mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
make.centerX.mas_equalTo(self.backImageView);
|
||||
make.top.mas_equalTo(self.voteModeLabel.mas_bottom).offset(6);
|
||||
}];
|
||||
|
||||
[self.blueTeamView mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
make.left.mas_equalTo(self.backImageView.mas_centerX).offset(56);
|
||||
make.centerY.mas_equalTo(self.redTeamView);
|
||||
}];
|
||||
|
||||
[self.progressView mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
make.width.mas_equalTo(56 * 2 + 45 * 2);
|
||||
make.height.mas_equalTo(7);
|
||||
make.centerX.mas_equalTo(self.backImageView);
|
||||
make.top.mas_equalTo(self.redTeamView.mas_bottom).offset(13);
|
||||
}];
|
||||
|
||||
[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.left.mas_equalTo(self.progressView);
|
||||
make.top.mas_equalTo(self.progressView.mas_bottom).offset(3);
|
||||
}];
|
||||
|
||||
[self.blueScoreLabel mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
make.centerY.mas_equalTo(self.redScoreLabel);
|
||||
make.right.mas_equalTo(self.progressView);
|
||||
}];
|
||||
|
||||
[self.beginButton mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
make.size.mas_equalTo(CGSizeMake(90, 24));
|
||||
make.centerX.mas_equalTo(self.backImageView);
|
||||
make.bottom.mas_equalTo(self.backImageView.mas_bottom).offset(-15);
|
||||
}];
|
||||
}
|
||||
|
||||
|
||||
|
||||
#pragma mark - Event Response
|
||||
- (void)beginButtonAction:(UIButton *)sender {
|
||||
//TODO: 重新开始
|
||||
}
|
||||
|
||||
- (void)foldButtonAction:(UIButton *)sender {
|
||||
[TTPopup dismiss];
|
||||
}
|
||||
|
||||
#pragma mark - Getters And Setters
|
||||
- (void)setIsManager:(BOOL)isManager {
|
||||
_isManager = isManager;
|
||||
if (_isManager) {
|
||||
self.beginButton.hidden = !_isManager;
|
||||
}
|
||||
}
|
||||
|
||||
- (void)setPkDetailInfo:(RoomPKDetailInfoModel *)pkDetailInfo {
|
||||
_pkDetailInfo = pkDetailInfo;
|
||||
if (_pkDetailInfo) {
|
||||
RoomPKInfoModel * infoModel = pkDetailInfo.roomPK;
|
||||
if (infoModel.teams.count > 0) {
|
||||
NSMutableArray * redArray = [NSMutableArray array];
|
||||
NSMutableArray * blueArray = [NSMutableArray array];
|
||||
for (int i = 0; i < infoModel.teams.count; i++) {
|
||||
RoomPKTeamModel * teamInfo = [infoModel.teams objectAtIndex:i];
|
||||
if (infoModel.pkStatus == RoomPKStatusType_End || infoModel.pkStatus == RoomPKStatusType_NonStart) {
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
- (UIImageView *)backImageView {
|
||||
if (!_backImageView) {
|
||||
_backImageView = [[UIImageView alloc] init];
|
||||
_backImageView.userInteractionEnabled = YES;
|
||||
_backImageView.image = [UIImage imageNamed:@"room_pk_playing_bg"];
|
||||
}
|
||||
return _backImageView;
|
||||
}
|
||||
|
||||
- (UILabel *)timeLabel {
|
||||
if (!_timeLabel) {
|
||||
_timeLabel = [[UILabel alloc] init];
|
||||
_timeLabel.font = [UIFont systemFontOfSize:10];
|
||||
_timeLabel.textColor = UIColorFromRGB(0x602A06);
|
||||
_timeLabel.textAlignment = NSTextAlignmentCenter;
|
||||
_timeLabel.text= @"00:00";
|
||||
}
|
||||
return _timeLabel;
|
||||
}
|
||||
|
||||
- (UILabel *)voteModeLabel {
|
||||
if (!_voteModeLabel) {
|
||||
_voteModeLabel = [[UILabel alloc] init];
|
||||
_voteModeLabel.font = [UIFont systemFontOfSize:10 weight:UIFontWeightMedium];
|
||||
_voteModeLabel.textColor = UIColorFromRGB(0x79674E);
|
||||
_voteModeLabel.textAlignment = NSTextAlignmentCenter;
|
||||
}
|
||||
return _voteModeLabel;
|
||||
}
|
||||
|
||||
- (UILabel *)pkLabel {
|
||||
if (!_pkLabel) {
|
||||
_pkLabel = [[UILabel alloc] init];
|
||||
_pkLabel.text= @"PK";
|
||||
_pkLabel.textAlignment = NSTextAlignmentCenter;
|
||||
_pkLabel.font = [UIFont systemFontOfSize:10 weight:UIFontWeightMedium];;
|
||||
_pkLabel.textColor = UIColorFromRGB(0x79674E);
|
||||
}
|
||||
return _pkLabel;
|
||||
}
|
||||
|
||||
|
||||
- (XPRoomPKPanelUserView *)redTeamView {
|
||||
if (!_redTeamView) {
|
||||
_redTeamView = [[XPRoomPKPanelUserView alloc] init];
|
||||
_redTeamView.type = GroupTyp_Red;
|
||||
_redTeamView.itemHeight = 45;
|
||||
}
|
||||
return _redTeamView;
|
||||
}
|
||||
|
||||
- (XPRoomPKPanelUserView *)blueTeamView {
|
||||
if (!_blueTeamView) {
|
||||
_blueTeamView = [[XPRoomPKPanelUserView alloc] init];
|
||||
_blueTeamView.type = GroupType_Blue;
|
||||
_blueTeamView.itemHeight = 45;
|
||||
}
|
||||
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:@"重新开始" 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 addTarget:self action:@selector(beginButtonAction:) forControlEvents:UIControlEventTouchUpInside];
|
||||
}
|
||||
return _beginButton;
|
||||
}
|
||||
|
||||
- (UIButton *)foldButton {
|
||||
if (!_foldButton) {
|
||||
_foldButton = [UIButton buttonWithType:UIButtonTypeCustom];
|
||||
[_foldButton setImage:[UIImage imageNamed:@"room_pk_playing_fold"] forState:UIControlStateNormal];
|
||||
[_foldButton setImage:[UIImage imageNamed:@"room_pk_playing_fold"] forState:UIControlStateSelected];
|
||||
[_foldButton addTarget:self action:@selector(foldButtonAction:) forControlEvents:UIControlEventTouchUpInside];
|
||||
}
|
||||
return _foldButton;
|
||||
}
|
||||
|
||||
@end
|
@@ -8,18 +8,28 @@
|
||||
#import <UIKit/UIKit.h>
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
@class RoomPKDetailInfoModel, MicroQueueModel, UserInfoModel;
|
||||
@class RoomPKDetailInfoModel, MicroQueueModel, RoomPKChooseUserModel;
|
||||
@interface XPRoomPKProgressView : UIView
|
||||
///房主的uid
|
||||
@property (nonatomic,copy) NSString *roomUid;
|
||||
///群聊的id
|
||||
@property (nonatomic,copy) NSString *roomId;
|
||||
@property (nonatomic, strong) NSMutableDictionary<NSString *, MicroQueueModel *> *micQueue;
|
||||
@property (nonatomic,strong) RoomPKDetailInfoModel *pkDetailInfo;
|
||||
///是否是管理员
|
||||
@property (nonatomic,assign) BOOL isManager;
|
||||
///红队
|
||||
@property (nonatomic,strong) NSArray<UserInfoModel *> *redUserArray;
|
||||
///蓝队
|
||||
@property (nonatomic,strong) NSArray<UserInfoModel *> *blueUserArray;
|
||||
///红色的
|
||||
@property (nonatomic,strong) NSArray<RoomPKChooseUserModel *> *redChooseArray;
|
||||
///蓝色的
|
||||
@property (nonatomic,strong) NSArray<RoomPKChooseUserModel *> *blueChooseArray;
|
||||
///是否收到了Pk的结果
|
||||
@property (nonatomic,assign) BOOL isReceivePKResult;
|
||||
///清理数据
|
||||
- (void)clearRoomPKTeamData;
|
||||
///开始倒计时
|
||||
- (void)startRoomPKCountDown:(CGFloat)time;
|
||||
///结束倒计时
|
||||
- (void)stopRoomPKCountDown;
|
||||
@end
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
||||
|
@@ -13,6 +13,9 @@
|
||||
#import "XPMacro.h"
|
||||
#import "TTPopup.h"
|
||||
#import "UIImage+Utils.h"
|
||||
#import "Api+RoomPK.h"
|
||||
#import "AccountInfoStorage.h"
|
||||
#import "XCHUDTool.h"
|
||||
///Model
|
||||
#import "RoomPKDetailInfoModel.h"
|
||||
#import "MicroQueueModel.h"
|
||||
@@ -46,16 +49,22 @@
|
||||
@property (nonatomic,strong) UIImageView * blueProgressView;
|
||||
///进度的分割线
|
||||
@property (nonatomic,strong) UIImageView *progressLineView;
|
||||
///红色的
|
||||
@property (nonatomic,strong) NSArray *redChooseArray;
|
||||
///蓝色的
|
||||
@property (nonatomic,strong) NSArray *blueChooseArray;
|
||||
///倒计时
|
||||
@property (strong, nonatomic) dispatch_source_t timer;
|
||||
///当前的时间
|
||||
@property (nonatomic,assign) CGFloat currentTime;
|
||||
///检查失败的次数
|
||||
@property (nonatomic,assign) int checkResultNum;
|
||||
@end
|
||||
|
||||
|
||||
@implementation XPRoomPKProgressView
|
||||
- (instancetype)initWithFrame:(CGRect)frame
|
||||
{
|
||||
|
||||
- (void)dealloc {
|
||||
[self stopRoomPKCountDown];
|
||||
}
|
||||
|
||||
- (instancetype)initWithFrame:(CGRect)frame {
|
||||
self = [super initWithFrame:frame];
|
||||
if (self) {
|
||||
[self initSubViews];
|
||||
@@ -64,6 +73,88 @@
|
||||
return self;
|
||||
}
|
||||
|
||||
#pragma mark - Public Method
|
||||
- (void)startRoomPKCountDown:(CGFloat)time {
|
||||
__block long tempTime = time - 1; //倒计时时间
|
||||
__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(), ^{
|
||||
//TODO: 如果依旧没有结果就在拉一次 第二次啦的时候 还没有结果的话 就结束掉这个pk
|
||||
|
||||
});
|
||||
} 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;
|
||||
});
|
||||
tempTime--;
|
||||
self.currentTime = tempTime;
|
||||
}
|
||||
});
|
||||
dispatch_resume(self.timer);
|
||||
}
|
||||
|
||||
- (void)stopRoomPKCountDown {
|
||||
if (self.timer) {
|
||||
dispatch_source_cancel(_timer);
|
||||
_timer = nil;
|
||||
}
|
||||
}
|
||||
|
||||
- (void)clearRoomPKTeamData {
|
||||
self.redScoreLabel.text = @"0";
|
||||
self.blueScoreLabel.text = @"0";
|
||||
self.redTeamView.userArray = nil;
|
||||
self.blueTeamView.userArray = nil;
|
||||
}
|
||||
|
||||
#pragma mark - 查询pk结果的
|
||||
- (void)checkRoomPKResult{
|
||||
if (self.checkResultNum > 2) {
|
||||
//pk请求已经不行了 只能结束了
|
||||
[self clearRoomPKTeamData];
|
||||
//TODO: 更新麦序
|
||||
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;
|
||||
if (self.pkDetailInfo.roomPK.pkId > 0) {
|
||||
NSString * pkId = [NSString stringWithFormat:@"%ld", self.pkDetailInfo.roomPK.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:self.roomUid operUid:uid pkId:pkId];
|
||||
}
|
||||
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
- (void)resetRoomPKQueueDefaultGroupType {
|
||||
|
||||
}
|
||||
|
||||
|
||||
#pragma mark - Private Method
|
||||
- (void)initSubViews {
|
||||
[self addSubview:self.backImageView];
|
||||
@@ -163,31 +254,10 @@
|
||||
#pragma mark - XPRoomPKPanelUserViewDelegate
|
||||
- (void)xPRoomPKPanelUserView:(XPRoomPKPanelUserView *)view didClickAddButton:(GroupType)type {
|
||||
if (self.isManager) {
|
||||
NSMutableArray<RoomPKChooseUserModel *> * redArrar= [NSMutableArray array];
|
||||
for (int i = 0; i < self.redUserArray.count; i++) {
|
||||
UserInfoModel * userInfo = [self.redUserArray objectAtIndex:i];
|
||||
RoomPKChooseUserModel * model = [[RoomPKChooseUserModel alloc] init];
|
||||
model.uid = [NSString stringWithFormat:@"%ld", userInfo.uid];
|
||||
model.groupType = GroupTyp_Red;
|
||||
model.nick = userInfo.nick;
|
||||
[redArrar addObject:model];
|
||||
}
|
||||
self.redChooseArray = redArrar.copy;
|
||||
NSMutableArray<RoomPKChooseUserModel *> * blueArrar= [NSMutableArray array];
|
||||
for (int i = 0; i < self.blueUserArray.count; i++) {
|
||||
UserInfoModel * userInfo = [self.blueUserArray objectAtIndex:i];
|
||||
RoomPKChooseUserModel * model = [[RoomPKChooseUserModel alloc] init];
|
||||
model.uid = [NSString stringWithFormat:@"%ld", userInfo.uid];
|
||||
model.groupType = GroupType_Blue;
|
||||
model.nick = userInfo.nick;
|
||||
[blueArrar addObject:model];
|
||||
}
|
||||
self.blueChooseArray = blueArrar.copy;
|
||||
|
||||
XPRoomPKSelectUserView * chooseUserView = [[XPRoomPKSelectUserView alloc] init];
|
||||
chooseUserView.delegate = self;
|
||||
chooseUserView.redUserArray = redArrar;
|
||||
chooseUserView.blueUserArray = blueArrar;
|
||||
chooseUserView.redUserArray = self.redChooseArray;
|
||||
chooseUserView.blueUserArray = self.blueChooseArray;
|
||||
chooseUserView.groupType = type;
|
||||
chooseUserView.microQueueArray = self.micQueue.allValues;
|
||||
[TTPopup popupView:chooseUserView style:TTPopupStyleAlert];
|
||||
@@ -252,7 +322,25 @@
|
||||
|
||||
#pragma mark - Event Response
|
||||
- (void)beginButtonAction:(UIButton *)sender {
|
||||
if (self.redChooseArray.count > 0 && self.blueChooseArray.count > 0) {
|
||||
if (self.pkDetailInfo.roomPK.pkStatus == RoomPKStatusType_End || self.pkDetailInfo.roomPK.pkStatus == RoomPKStatusType_ReStart) {
|
||||
[TTPopup alertWithMessage:@"当前正在准备阶段,是否确认准备开始PK?" confirmHandler:^{
|
||||
//TODO: 开始Pk
|
||||
} cancelHandler:^{
|
||||
|
||||
}];
|
||||
} else if(self.pkDetailInfo.roomPK.pkStatus == RoomPKStatusType_Playing) {
|
||||
//TODO: 展示PK中的面板
|
||||
} else if(self.pkDetailInfo.roomPK.pkStatus == RoomPKStatusType_NonStart) {
|
||||
[TTPopup alertWithMessage:@"当前正在准备阶段,是否确认准备开始PK?" confirmHandler:^{
|
||||
///开始PK
|
||||
} cancelHandler:^{
|
||||
|
||||
}];
|
||||
}
|
||||
} else {
|
||||
[XCHUDTool showErrorWithMessage:@"每队至少有一个人"];
|
||||
}
|
||||
}
|
||||
|
||||
#pragma mark - Getters And Setters
|
||||
@@ -263,31 +351,14 @@
|
||||
}
|
||||
}
|
||||
|
||||
- (void)setPkDetailInfo:(RoomPKDetailInfoModel *)pkDetailInfo {
|
||||
_pkDetailInfo = pkDetailInfo;
|
||||
if (_pkDetailInfo) {
|
||||
RoomPKInfoModel * infoModel = pkDetailInfo.roomPK;
|
||||
if (infoModel.teams.count > 0) {
|
||||
NSMutableArray * redArray = [NSMutableArray array];
|
||||
NSMutableArray * blueArray = [NSMutableArray array];
|
||||
for (int i = 0; i < infoModel.teams.count; i++) {
|
||||
RoomPKTeamModel * teamInfo = [infoModel.teams objectAtIndex:i];
|
||||
if (infoModel.pkStatus == RoomPKStatusType_End || infoModel.pkStatus == RoomPKStatusType_NonStart) {
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
- (void)setRedChooseArray:(NSArray<RoomPKChooseUserModel *> *)redChooseArray {
|
||||
_redChooseArray = redChooseArray;
|
||||
self.redTeamView.userArray = _redChooseArray;
|
||||
}
|
||||
|
||||
- (void)setRedUserArray:(NSArray *)redUserArray {
|
||||
_redUserArray = redUserArray;
|
||||
self.redTeamView.userArray = _redUserArray;
|
||||
}
|
||||
|
||||
- (void)setBlueUserArray:(NSArray *)blueUserArray {
|
||||
_blueUserArray = blueUserArray;
|
||||
self.blueTeamView.userArray = _blueUserArray;
|
||||
- (void)setBlueChooseArray:(NSArray<RoomPKChooseUserModel *> *)blueChooseArray {
|
||||
_blueChooseArray = blueChooseArray;
|
||||
self.blueTeamView.userArray = _blueChooseArray;
|
||||
}
|
||||
|
||||
- (UIImageView *)backImageView {
|
||||
|
@@ -56,9 +56,9 @@
|
||||
///时间
|
||||
@property (nonatomic,assign) int duraTime;
|
||||
///红队的成员
|
||||
@property (nonatomic,copy) NSArray *redUserArray;
|
||||
@property (nonatomic,strong) NSMutableArray *redUserArray;
|
||||
///蓝队的成员
|
||||
@property (nonatomic,copy) NSArray *blueUserArray;
|
||||
@property (nonatomic,strong) NSMutableArray *blueUserArray;
|
||||
@end
|
||||
|
||||
@implementation XPRoomPKViewController
|
||||
@@ -238,9 +238,9 @@
|
||||
- (void)xPRoomPKSelectUserView:(XPRoomPKSelectUserView *)view groupType:(GroupType)groupType didChooseUserInfos:(NSArray<RoomPKChooseUserModel *> *)userInfos {
|
||||
[TTPopup dismiss];
|
||||
if (groupType == GroupTyp_Red) {
|
||||
self.redUserArray = userInfos;
|
||||
self.redUserArray = [NSMutableArray arrayWithArray:userInfos];;
|
||||
} else {
|
||||
self.blueUserArray = userInfos;
|
||||
self.blueUserArray = [NSMutableArray arrayWithArray:userInfos];
|
||||
}
|
||||
|
||||
if (self.redUserArray.count > 0) {
|
||||
@@ -262,14 +262,24 @@
|
||||
RoomPKChooseUserModel * userInfo = [self.redUserArray objectAtIndex:i];
|
||||
if (i < self.redTeamViews.count) {
|
||||
XPRoomPKUserView * userView = [self.redTeamViews objectAtIndex:i];
|
||||
if (userInfo.groupType == GroupTyp_Red) {
|
||||
userView.userInfo = userInfo;
|
||||
} else {
|
||||
userView.userInfo = nil;
|
||||
[self.redUserArray removeObject:userInfo];
|
||||
}
|
||||
}
|
||||
}
|
||||
for (int i = 0; i < self.blueUserArray.count; i++) {
|
||||
RoomPKChooseUserModel * userInfo = [self.blueUserArray objectAtIndex:i];
|
||||
if (i < self.blueTeamViews.count) {
|
||||
XPRoomPKUserView * userView = [self.blueTeamViews objectAtIndex:i];
|
||||
if (userInfo.groupType == GroupType_Blue) {
|
||||
userView.userInfo = userInfo;
|
||||
} else {
|
||||
userView.userInfo = nil;
|
||||
[self.blueUserArray removeObject:userInfo];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -470,5 +480,4 @@
|
||||
|
||||
|
||||
|
||||
|
||||
@end
|
||||
|
Reference in New Issue
Block a user