setLabel Names

This commit is contained in:
Niko Jochim 2020-06-18 12:55:37 +02:00
parent f363d30f15
commit 8df133f896
3 changed files with 11 additions and 5 deletions

View File

@ -35,8 +35,10 @@ class HUD: GKEntity {
init(size: CGSize) {
hostLabel = SKLabelNode(text: GameCenterManager.sharedInstance.hostingPlayer?.displayName)
hostLabel.name = "hostLabel"
hostUnitsLabel = SKLabelNode(text: "500" )
peerLabel = SKLabelNode(text: GameCenterManager.sharedInstance.peerPlayer?.displayName)
peerLabel.name = "peerLabel"
peerUnitsLabel = SKLabelNode(text: "500")
roundTimerLabel = SKLabelNode(text: "")

View File

@ -47,7 +47,7 @@ class RoundTimer: Timer {
@objc func onTimerFires()
{
timeLeft -= 1
EntityManager.gameEMInstance.updateTime(time: (timeLeft > 0 ? String(timeLeft) : roundEnded))
if timeLeft == 0 {
@ -56,6 +56,7 @@ class RoundTimer: Timer {
if !MultiplayerNetwork.sharedInstance.isSending {
MultiplayerNetwork.sharedInstance.sendPlayerMoves(localRoundData: DataService.sharedInstance.localRoundData)
}
calculate = true
if timeLeft <= 0 {
if calculate
&& !RoundCalculatorService.sharedInstance.isCalculating

View File

@ -29,6 +29,7 @@ class GameScene: SKScene{
}
return
}
override func didMove(to view: SKView) {
NotificationCenter.default.addObserver(self, selector: #selector(pauseGame), name: Notification.Name("pauseGame"), object: nil)
NotificationCenter.default.addObserver(self, selector: #selector(resumeGame), name: Notification.Name("resumeGame"), object: nil)
@ -78,6 +79,7 @@ class GameScene: SKScene{
override func update(_ currentTime: TimeInterval) {
if entityManager.entities.count != 0 {
entityManager.getBackground()?.update(deltaTime: currentTime)
print("Update")
if GameCenterManager.sharedInstance.gameEnded && !gameEndEffects {
gameEnd()
}
@ -127,6 +129,7 @@ class GameScene: SKScene{
}
func gameEnd(){
print("Game END")
gameEndEffects = true
let winnerNode:String?
GameCenterManager.sharedInstance.gameEnded = false