156 lines
5.9 KiB
Objective-C
156 lines
5.9 KiB
Objective-C
//
|
|
// MSRoomMenuGameVC.m
|
|
// YuMi
|
|
//
|
|
// Created by duoban on 2024/4/29.
|
|
//
|
|
#import "Api+Room.h"
|
|
#import "MSRoomMenuGameVC.h"
|
|
#import "MSRoomMenuGameView.h"
|
|
#import "XPTreasureFairyViewController.h"
|
|
#import "XPRoomHalfWebView.h"
|
|
#import "XPWebViewController.h"
|
|
#import "XPCandyTreeViewController.h"
|
|
#import "XPSailingViewController.h"
|
|
#import "XPRoomViewController.h"
|
|
#import "MSRoomGameWebVC.h"
|
|
@interface MSRoomMenuGameVC ()<MSRoomMenuGameViewDelegate>
|
|
@property(nonatomic,strong) MSRoomMenuGameView *gameView;
|
|
///host 代理
|
|
@property (nonatomic,weak) id<RoomHostDelegate>hostDelegate;
|
|
@end
|
|
|
|
@implementation MSRoomMenuGameVC
|
|
-(void)dealloc{
|
|
|
|
}
|
|
- (instancetype)initWithDelegate:(id<RoomHostDelegate>)delegate{
|
|
self = [super init];
|
|
if(self){
|
|
self.hostDelegate = delegate;
|
|
}
|
|
return self;
|
|
}
|
|
- (BOOL)isHiddenNavBar {
|
|
return YES;
|
|
}
|
|
- (void)viewDidLoad {
|
|
[super viewDidLoad];
|
|
[self installUI];
|
|
[self installConstraints];
|
|
[self getGameData];
|
|
}
|
|
-(void)getGameData{
|
|
NSMutableArray *playList = [self.hostDelegate getPlayList];
|
|
if(playList.count > 0){
|
|
_gameView.playList = playList;
|
|
return;
|
|
}
|
|
NSString * roomId = [NSString stringWithFormat:@"%ld", self.hostDelegate.getRoomInfo.roomId];
|
|
[Api getPlayList:^(BaseModel * _Nullable data, NSInteger code, NSString * _Nullable msg) {
|
|
if (code == 200) {
|
|
NSArray <ActivityInfoModel *>* array = [ActivityInfoModel modelsWithArray:data.data];
|
|
self.gameView.playList = [[NSMutableArray alloc]initWithArray:array];
|
|
|
|
}
|
|
} roomId:roomId];
|
|
}
|
|
-(void)installUI{
|
|
self.view.backgroundColor = [UIColor clearColor];
|
|
[self.view addSubview:self.gameView];
|
|
}
|
|
-(void)installConstraints{
|
|
[self.gameView mas_makeConstraints:^(MASConstraintMaker *make) {
|
|
make.edges.equalTo(self.view);
|
|
}];
|
|
}
|
|
|
|
#pragma mark- MSRoomMenuGameViewDelegate
|
|
- (void)didClickBackBtnAction{
|
|
[self dismissViewControllerAnimated:YES completion:nil];
|
|
}
|
|
-(void)ms_didSelectItemAtIndexPath:(ActivityInfoModel *)model{
|
|
self.gameView.hidden = YES;
|
|
if ([model.code isEqualToString:@"FIND_LOVE"]) {
|
|
[self lookLoveTapRecognizer];
|
|
} else if([model.code isEqualToString:@"NAUTICAL_ADVENTURE"]) {
|
|
[self sailTapRecognizer];
|
|
}else if([model.code isEqualToString:@"BAISHUN"]){
|
|
[self clickGameVC:model];
|
|
}else if([model.code isEqualToString:@"SEIZE_TREASURE"]){
|
|
if ([self.hostDelegate isKindOfClass:[XPRoomViewController class]]){
|
|
XPRoomViewController *vc = (XPRoomViewController *)self.hostDelegate;
|
|
XPTreasureFairyViewController * fairyVC = [[XPTreasureFairyViewController alloc] initWithdelegate:self.hostDelegate];
|
|
fairyVC.roomUid =[NSString stringWithFormat:@"%ld", self.hostDelegate.getRoomInfo.uid];
|
|
fairyVC.view.frame = CGRectMake(0, KScreenHeight, KScreenWidth, KScreenHeight);
|
|
[vc addChildViewController:fairyVC];
|
|
[fairyVC.navigationController setNavigationBarHidden:YES animated:NO];
|
|
[vc.view addSubview:fairyVC.view];
|
|
[UIView animateWithDuration:0.2 animations:^{
|
|
|
|
fairyVC.view.frame = CGRectMake(0, 0, KScreenWidth, KScreenHeight);
|
|
|
|
}completion:^(BOOL finished) {
|
|
|
|
}];
|
|
}
|
|
} else if(model.skipType == ActivitySkipType_Web) {
|
|
if(model.showType == ActivityShowType_Half){
|
|
XPRoomHalfWebView * webView = [[XPRoomHalfWebView alloc] init];
|
|
webView.isPlayView = YES;
|
|
webView.roomUid = [NSString stringWithFormat:@"%ld", self.hostDelegate.getRoomInfo.uid];
|
|
webView.url = model.skipContent;
|
|
[TTPopup popupView:webView style:TTPopupStyleActionSheet];
|
|
return;
|
|
}
|
|
|
|
XPWebViewController * webVC = [[XPWebViewController alloc] init];
|
|
webVC.roomUid = [NSString stringWithFormat:@"%ld", self.hostDelegate.getRoomInfo.uid];
|
|
webVC.url = model.skipContent;
|
|
[self.hostDelegate.getCurrentNav pushViewController:webVC animated:YES];
|
|
}
|
|
[self dismissViewControllerAnimated:YES completion:nil];
|
|
}
|
|
-(void)clickGameVC:(ActivityInfoModel *)model{
|
|
if ([self.hostDelegate isKindOfClass:[XPRoomViewController class]]){
|
|
MSRoomGameWebVC *vc = [[MSRoomGameWebVC alloc]initWithDelegate:self.hostDelegate gameModel:model];
|
|
vc.view.frame = CGRectMake(0, 0, KScreenWidth, KScreenHeight);
|
|
XPRoomViewController *roomVC = (XPRoomViewController *)self.hostDelegate;
|
|
[roomVC addChildViewController:vc];
|
|
[self.hostDelegate.getSuperView addSubview:vc.view];
|
|
}
|
|
|
|
}
|
|
- (void)lookLoveTapRecognizer {
|
|
|
|
if ([self.hostDelegate isKindOfClass:[XPRoomViewController class]]){
|
|
XPCandyTreeViewController * candyTreeVC = [[XPCandyTreeViewController alloc] initWithDelegate:self.hostDelegate];
|
|
candyTreeVC.view.frame = CGRectMake(0, KScreenHeight, KScreenWidth, KScreenHeight);
|
|
[self.hostDelegate.getSuperView addSubview:candyTreeVC.view];
|
|
XPRoomViewController *vc = (XPRoomViewController *)self.hostDelegate;
|
|
[vc addChildViewController:candyTreeVC];
|
|
[candyTreeVC.navigationController setNavigationBarHidden:YES animated:NO];
|
|
[UIView animateWithDuration:0.1 animations:^{
|
|
candyTreeVC.view.frame = CGRectMake(0, 0, KScreenWidth, KScreenHeight);
|
|
}completion:^(BOOL finished) {
|
|
|
|
}];
|
|
}
|
|
|
|
|
|
}
|
|
- (void)sailTapRecognizer {
|
|
NSString * roomUid = [NSString stringWithFormat:@"%ld", self.hostDelegate.getRoomInfo.uid];
|
|
XPSailingViewController * sailingVC = [[XPSailingViewController alloc] initWithRoomUid:roomUid];
|
|
[self.hostDelegate.getCurrentNav presentViewController:sailingVC animated:YES completion:nil];
|
|
}
|
|
#pragma mark - 懒加载
|
|
- (MSRoomMenuGameView *)gameView{
|
|
if(!_gameView){
|
|
_gameView = [[MSRoomMenuGameView alloc]initWithFrame:CGRectZero];
|
|
_gameView.delegate = self;
|
|
}
|
|
return _gameView;
|
|
}
|
|
@end
|