From 41d5fc8a5c19c657266a14d1b6693d4e04ebce09 Mon Sep 17 00:00:00 2001 From: Jakob Haag Date: Mon, 11 May 2020 19:18:19 +0200 Subject: [PATCH] test --- GoldWars/GoldWars/Entities/Modal.swift | 2 +- .../GoldWars/Map/TwoPlayerDefaultTestMap.swift | 5 +++-- GoldWars/GoldWars/MatchmakingHelper.swift | 15 +++++++++++---- 3 files changed, 15 insertions(+), 7 deletions(-) diff --git a/GoldWars/GoldWars/Entities/Modal.swift b/GoldWars/GoldWars/Entities/Modal.swift index a8f638f..0c87e03 100644 --- a/GoldWars/GoldWars/Entities/Modal.swift +++ b/GoldWars/GoldWars/Entities/Modal.swift @@ -20,7 +20,7 @@ class Modal: GKEntity{ addComponent(ModalBackgroundComponent(anchorPoint: anchorPoint)) addComponent(ModalContentComponent( header: "Basis Information", - body: "Diese Basis enthält \(base.unitCount) Einheiten", + body: "Diese Basis enthält \(base.unitCount) Einheiten und gehört Spieler \(base.ownerShipPlayer?.displayName ?? "null")", footer: "", anchorPoint: anchorPoint ) diff --git a/GoldWars/GoldWars/Map/TwoPlayerDefaultTestMap.swift b/GoldWars/GoldWars/Map/TwoPlayerDefaultTestMap.swift index a45af1f..c8b3c50 100644 --- a/GoldWars/GoldWars/Map/TwoPlayerDefaultTestMap.swift +++ b/GoldWars/GoldWars/Map/TwoPlayerDefaultTestMap.swift @@ -22,10 +22,11 @@ class TwoPlayerDefaultTestMap: MapProtocol { func load() { + // Create Bases let basePlayerOne = Base( position: CGPoint(x: self.size.width * 0.1, y: self.size.height / 2), - player: MatchmakingHelper.sharedInstance.mpMatch?.players[0], + player: (MatchmakingHelper.sharedInstance.isServer) ? GKLocalPlayer.local : MatchmakingHelper.sharedInstance.mpMatch?.players[0], team: .team1 ) @@ -48,7 +49,7 @@ class TwoPlayerDefaultTestMap: MapProtocol { let basePlayerTwo = Base( position: CGPoint(x: self.size.width * 0.9, y: self.size.height / 2), - player: MatchmakingHelper.sharedInstance.mpMatch?.players[1], + player: (!MatchmakingHelper.sharedInstance.isServer) ? GKLocalPlayer.local : MatchmakingHelper.sharedInstance.mpMatch?.players[0], team: .team2 ) diff --git a/GoldWars/GoldWars/MatchmakingHelper.swift b/GoldWars/GoldWars/MatchmakingHelper.swift index 72e3c25..5545d25 100644 --- a/GoldWars/GoldWars/MatchmakingHelper.swift +++ b/GoldWars/GoldWars/MatchmakingHelper.swift @@ -33,7 +33,6 @@ class MatchmakingHelper: NSObject, GKMatchmakerViewControllerDelegate, GKMatchDe var viewController: UIViewController? var mpMatchStarted: Bool var isServer: Bool - var spieler1: GKPlayer? var nameSpieler1 = "" var menusc: MenuScene? let localPlayer: GKLocalPlayer = GKLocalPlayer.local @@ -154,13 +153,21 @@ class MatchmakingHelper: NSObject, GKMatchmakerViewControllerDelegate, GKMatchDe if player == GKLocalPlayer.local { self.isServer = true - self.spieler1 = player - self.nameSpieler1 = self.spieler1!.displayName - } else { self.isServer = false } + print("====================================") + print(GKLocalPlayer.local) + for player in MatchmakingHelper.sharedInstance.mpMatch!.players { + print(player) + } + print("====================================") + + print(MatchmakingHelper.sharedInstance.mpMatch) + + print("====================================") + self.delegate?.matchStarted() self.menusc!.loadScene(scene: GameScene(size: self.menusc!.size)) })