diff --git a/pennapps-2020.xcodeproj/project.pbxproj b/pennapps-2020.xcodeproj/project.pbxproj index 7eb6f8c..9d4d79f 100644 --- a/pennapps-2020.xcodeproj/project.pbxproj +++ b/pennapps-2020.xcodeproj/project.pbxproj @@ -19,7 +19,6 @@ 13AC1041250CC122003512FA /* LobbyPlayerTableViewCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = 13AC1040250CC122003512FA /* LobbyPlayerTableViewCell.swift */; }; 76346068250C883900A24D75 /* LobbyVC.swift in Sources */ = {isa = PBXBuildFile; fileRef = 76346067250C883900A24D75 /* LobbyVC.swift */; }; 7634606E250D1DAE00A24D75 /* GameVC.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7634606D250D1DAE00A24D75 /* GameVC.swift */; }; - 76989E07250D6557000F5948 /* GamePlayer.swift in Sources */ = {isa = PBXBuildFile; fileRef = 76989E06250D6557000F5948 /* GamePlayer.swift */; }; 76989E0A250D65B7000F5948 /* Flargio.scnassets in Resources */ = {isa = PBXBuildFile; fileRef = 76989E09250D65B7000F5948 /* Flargio.scnassets */; }; E810E093250C9A6B00942D72 /* LobbyViewModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = E810E091250C9A6B00942D72 /* LobbyViewModel.swift */; }; E810E094250C9A6B00942D72 /* LobbyPlayer.swift in Sources */ = {isa = PBXBuildFile; fileRef = E810E092250C9A6B00942D72 /* LobbyPlayer.swift */; }; @@ -46,12 +45,8 @@ 54C428A97DB3A55B6DE43E7F /* Pods-pennapps-2020.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-pennapps-2020.debug.xcconfig"; path = "Target Support Files/Pods-pennapps-2020/Pods-pennapps-2020.debug.xcconfig"; sourceTree = ""; }; 76346067250C883900A24D75 /* LobbyVC.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = LobbyVC.swift; sourceTree = ""; }; 7634606D250D1DAE00A24D75 /* GameVC.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = GameVC.swift; sourceTree = ""; }; - 76989E06250D6557000F5948 /* GamePlayer.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = GamePlayer.swift; sourceTree = ""; }; 76989E09250D65B7000F5948 /* Flargio.scnassets */ = {isa = PBXFileReference; lastKnownFileType = wrapper.scnassets; path = Flargio.scnassets; sourceTree = ""; }; - 844C4D806B4F875F9ECA09A8 /* Pods_pennapps_2020.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Pods_pennapps_2020.framework; sourceTree = BUILT_PRODUCTS_DIR; }; - DAC17A8D30BF73C28BB1FAD7 /* Pods-pennapps-2020.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-pennapps-2020.release.xcconfig"; path = "Target Support Files/Pods-pennapps-2020/Pods-pennapps-2020.release.xcconfig"; sourceTree = ""; }; - E810E091250C9A6B00942D72 /* LobbyViewModel.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = LobbyViewModel.swift; sourceTree = ""; }; E810E092250C9A6B00942D72 /* LobbyPlayer.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = LobbyPlayer.swift; sourceTree = ""; }; FA4F6298250D5F3600653A62 /* GameViewModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = GameViewModel.swift; sourceTree = ""; }; @@ -77,6 +72,8 @@ 137A5E70250C3CD4003EAD14 /* Products */, 9C7443281B792A62262A04E8 /* Pods */, 7058A40AFAA52444D88DF6C3 /* Frameworks */, + FA4F629D250D74CB00653A62 /* Recovered References */, + ); sourceTree = ""; }; @@ -138,10 +135,8 @@ isa = PBXGroup; children = ( 7634606D250D1DAE00A24D75 /* GameVC.swift */, - FA4F6298250D5F3600653A62 /* GameViewModel.swift */, FA4F629A250D646600653A62 /* GamePlayer.swift */, - ); path = Game; sourceTree = ""; @@ -164,6 +159,14 @@ path = Pods; sourceTree = ""; }; + FA4F629D250D74CB00653A62 /* Recovered References */ = { + isa = PBXGroup; + children = ( + 76989E06250D6557000F5948 /* GamePlayer.swift */, + ); + name = "Recovered References"; + sourceTree = ""; + }; /* End PBXGroup section */ /* Begin PBXNativeTarget section */ @@ -291,7 +294,6 @@ 13052713250C6AF300529A64 /* HomeScreenViewModel.swift in Sources */, E810E094250C9A6B00942D72 /* LobbyPlayer.swift in Sources */, 13AC1041250CC122003512FA /* LobbyPlayerTableViewCell.swift in Sources */, - 76989E07250D6557000F5948 /* GamePlayer.swift in Sources */, 7634606E250D1DAE00A24D75 /* GameVC.swift in Sources */, 76346068250C883900A24D75 /* LobbyVC.swift in Sources */, ); @@ -369,7 +371,7 @@ GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; GCC_WARN_UNUSED_FUNCTION = YES; GCC_WARN_UNUSED_VARIABLE = YES; - IPHONEOS_DEPLOYMENT_TARGET = 13.4; + IPHONEOS_DEPLOYMENT_TARGET = 13.1; MTL_ENABLE_DEBUG_INFO = INCLUDE_SOURCE; MTL_FAST_MATH = YES; ONLY_ACTIVE_ARCH = YES; @@ -423,7 +425,8 @@ GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; GCC_WARN_UNUSED_FUNCTION = YES; GCC_WARN_UNUSED_VARIABLE = YES; - IPHONEOS_DEPLOYMENT_TARGET = 13.4; + IPHONEOS_DEPLOYMENT_TARGET = 13.1; + MTL_ENABLE_DEBUG_INFO = NO; MTL_FAST_MATH = YES; SDKROOT = iphoneos; @@ -440,8 +443,9 @@ ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; CODE_SIGN_IDENTITY = "Apple Development"; CODE_SIGN_STYLE = Automatic; - DEVELOPMENT_TEAM = 3456953M9M; + DEVELOPMENT_TEAM = LFFFF46AX3; INFOPLIST_FILE = "pennapps-2020/Info.plist"; + IPHONEOS_DEPLOYMENT_TARGET = 13.0; LD_RUNPATH_SEARCH_PATHS = ( "$(inherited)", "@executable_path/Frameworks", @@ -462,6 +466,7 @@ CODE_SIGN_STYLE = Automatic; DEVELOPMENT_TEAM = LFFFF46AX3; INFOPLIST_FILE = "pennapps-2020/Info.plist"; + IPHONEOS_DEPLOYMENT_TARGET = 13.0; LD_RUNPATH_SEARCH_PATHS = ( "$(inherited)", "@executable_path/Frameworks", diff --git a/pennapps-2020/Base.lproj/Main.storyboard b/pennapps-2020/Base.lproj/Main.storyboard index 3193f0a..601df1a 100644 --- a/pennapps-2020/Base.lproj/Main.storyboard +++ b/pennapps-2020/Base.lproj/Main.storyboard @@ -1,5 +1,5 @@ - + @@ -15,8 +15,8 @@ - - - - + + - - + + - - @@ -316,7 +316,7 @@ - + diff --git a/pennapps-2020/Game/GameVC.swift b/pennapps-2020/Game/GameVC.swift index 97a7f19..24815fc 100644 --- a/pennapps-2020/Game/GameVC.swift +++ b/pennapps-2020/Game/GameVC.swift @@ -43,13 +43,19 @@ extension GameVC: ARSessionDelegate { self.xPos.text = "\(pos.x)" self.yPos.text = "\(pos.y)" self.zPos.text = "\(pos.z)" - print(viewModel.userId) +// print(viewModel.userId) viewModel.updatePosition(userId: viewModel.userId, x: Double(pos.x), z: Double(pos.z)) { (error) in if error != nil { print(error) } } - + print("updated pos func done") + viewModel.observeGamePlayers { (error) in + if error != nil { + print(error) + } + } + print("updated game players func done") } } diff --git a/pennapps-2020/Game/GameViewModel.swift b/pennapps-2020/Game/GameViewModel.swift index e36c296..4b67766 100644 --- a/pennapps-2020/Game/GameViewModel.swift +++ b/pennapps-2020/Game/GameViewModel.swift @@ -16,9 +16,9 @@ class GameViewModel { var ROOM_ID: String var userId: String! var hostId: String! - var gamePlayers: [GamePlayer]! + var gamePlayers: [String:GamePlayer]! - init(roomId: String, ref: DatabaseReference!, userId: String, hostId: String, gamePlayers: [GamePlayer]) { + init(roomId: String, ref: DatabaseReference!, userId: String, hostId: String, gamePlayers: [String:GamePlayer]) { self.ROOM_ID = roomId self.ref = ref self.userId = userId @@ -32,4 +32,22 @@ class GameViewModel { ref.child("\(self.PLAY_ROOMS_DB)/\(self.ROOM_ID)/players/\(userId)/x").setValue(x) ref.child("\(self.PLAY_ROOMS_DB)/\(self.ROOM_ID)/players/\(userId)/z").setValue(z) } + + func observeGamePlayers(handler: @escaping (String?) -> Void) { + print("Observer Game Playersss-------------") + print(hostId) + ref.child("\(self.PLAY_ROOMS_DB)/\(self.ROOM_ID)/players/").observe(.childChanged) {(snapshot) in + guard var data = snapshot.value as? [String: GamePlayer] else { + handler("player was invalid") + return + } + print("observeGamePlayers") + let newPos = data["nickname"] + self.gamePlayers[snapshot.key] = newPos + print(snapshot.key) + print(data["nickname"]) + print(data["x"]) + print(data["z"]) + } + } } diff --git a/pennapps-2020/HomeScreen/HomeScreenVC.swift b/pennapps-2020/HomeScreen/HomeScreenVC.swift index 393ffe3..5ede09f 100644 --- a/pennapps-2020/HomeScreen/HomeScreenVC.swift +++ b/pennapps-2020/HomeScreen/HomeScreenVC.swift @@ -35,7 +35,9 @@ class HomeScreenVC: UIViewController, UITextFieldDelegate { super.viewDidLoad() // Do any additional setup after loading the view. self.viewModel = HomeScreenViewModel(ref: Database.database().reference()) - + + joinButton.layer.cornerRadius = 8.0 + createButton.layer.cornerRadius = 8.0 roomLabel.isHidden = true nicknameLabel.isHidden = true nicknameTextField.delegate = self diff --git a/pennapps-2020/Lobby/LobbyVC.swift b/pennapps-2020/Lobby/LobbyVC.swift index a88b05b..c9dd6c0 100644 --- a/pennapps-2020/Lobby/LobbyVC.swift +++ b/pennapps-2020/Lobby/LobbyVC.swift @@ -141,7 +141,11 @@ class LobbyVC: UIViewController, UITableViewDelegate, UITableViewDataSource { let vc = segue.destination as! GameVC vc.delegate = self - vc.viewModel = GameViewModel(roomId: viewModel.ROOM_ID, ref: viewModel.ref, userId: viewModel.userId, hostId: viewModel.hostId, gamePlayers: viewModel.getGamePlayers()) + var gpMap:[String:GamePlayer] = [:] + for player in viewModel.getGamePlayers() { + gpMap[player.userId] = player + } + vc.viewModel = GameViewModel(roomId: viewModel.ROOM_ID, ref: viewModel.ref, userId: viewModel.userId, hostId: viewModel.hostId, gamePlayers: gpMap) } }