From 028282f7847e1c8d8599733d59eaa7ef760c23e9 Mon Sep 17 00:00:00 2001 From: 127-Z3R0 <81heti1bif@hft-stuttgart.de> Date: Tue, 2 Jun 2020 20:52:11 +0200 Subject: [PATCH] implement RoundIncrement feature --- GoldWars/GoldWars/Entities/HUD.swift | 4 ++-- GoldWars/GoldWars/GameCenterManager.swift | 2 ++ GoldWars/GoldWars/RoundCalculatorService.swift | 4 ++++ 3 files changed, 8 insertions(+), 2 deletions(-) diff --git a/GoldWars/GoldWars/Entities/HUD.swift b/GoldWars/GoldWars/Entities/HUD.swift index ab72ece..a05168c 100644 --- a/GoldWars/GoldWars/Entities/HUD.swift +++ b/GoldWars/GoldWars/Entities/HUD.swift @@ -150,7 +150,7 @@ class HUD: GKEntity { backgroundRoundCounter.zPosition = 2 backgroundRoundCounter.position = CGPoint(x: Double(size.width) * 0.06, y: Double(size.height) * 0.08) - currentRoundLabel.text = "\(RoundCalculatorService.sharedInstance.roundcount)" + currentRoundLabel.text = "\(RoundCalculatorService.sharedInstance.currentRound)" currentRoundLabel.fontSize = 50 currentRoundLabel.fontColor = SKColor.black currentRoundLabel.verticalAlignmentMode = .center @@ -158,7 +158,7 @@ class HUD: GKEntity { currentRoundLabel.zPosition = backgroundRoundCounter.zPosition + 1 roundsLabel.zPosition = backgroundRoundCounter.zPosition + 1 - roundsLabel.text = "of \(RoundCalculatorService.sharedInstance.rounds)" + roundsLabel.text = "of \(RoundCalculatorService.sharedInstance.MAX_ROUNDS)" roundsLabel.fontColor = SKColor.black roundsLabel.verticalAlignmentMode = .center roundsLabel.fontSize = 12 diff --git a/GoldWars/GoldWars/GameCenterManager.swift b/GoldWars/GoldWars/GameCenterManager.swift index 64bfd7a..b5314a3 100644 --- a/GoldWars/GoldWars/GameCenterManager.swift +++ b/GoldWars/GoldWars/GameCenterManager.swift @@ -159,6 +159,8 @@ final class GameCenterManager: NSObject, GKMatchmakerViewControllerDelegate, GKG } if let snapshotModel = try? jsonDecoder.decode(SnapshotModel.self, from: data) { DataService.sharedInstance.snapshotModel = snapshotModel + RoundCalculatorService.sharedInstance.currentRound += 1 + entityManager.getHUD()?.setCurrentRound(round: RoundCalculatorService.sharedInstance.currentRound) entityManager.updateSnapshotModel(snapshotModel: snapshotModel) entityManager.getHUD()?.startWithDuration() } diff --git a/GoldWars/GoldWars/RoundCalculatorService.swift b/GoldWars/GoldWars/RoundCalculatorService.swift index a70efdd..00fbf43 100644 --- a/GoldWars/GoldWars/RoundCalculatorService.swift +++ b/GoldWars/GoldWars/RoundCalculatorService.swift @@ -147,6 +147,10 @@ class RoundCalculatorService { DataService.sharedInstance.localRoundData.localPlayerMoves.removeAll() DataService.sharedInstance.localRoundData.hasAttackBoost = false DataService.sharedInstance.localRoundData.hasDefenceBoost = false + + currentRound += 1 + entityManager.getHUD()?.setCurrentRound(round: currentRound) + MultiplayerNetwork.sharedInstance.sendSnapshotModelToPlayers() DataService.sharedInstance.snapshotModel = currentSnapshotModel entityManager.updateSnapshotModel(snapshotModel: currentSnapshotModel!)