fix getBackground to return a optional
This commit is contained in:
parent
b22e645163
commit
3c4ae97b61
@ -277,7 +277,7 @@ class EntityManager {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func getBackground() -> GKEntity? {
|
func getBackground() -> GKEntity? {
|
||||||
return entities.filter{$0 is Background}[0]
|
return entities.filter{$0 is Background}.first
|
||||||
}
|
}
|
||||||
|
|
||||||
func getBaseNodeByTeam(for team: Team) -> SKSpriteNode? {
|
func getBaseNodeByTeam(for team: Team) -> SKSpriteNode? {
|
||||||
@ -289,7 +289,7 @@ class EntityManager {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func getHUD() -> HUD? {
|
func getHUD() -> HUD? {
|
||||||
return entities.filter{$0 is HUD}[0] as? HUD
|
return entities.filter{$0 is HUD}.first as? HUD
|
||||||
}
|
}
|
||||||
|
|
||||||
func getSnapshotModel() -> SnapshotModel {
|
func getSnapshotModel() -> SnapshotModel {
|
||||||
|
@ -45,7 +45,7 @@ final class GameCenterManager: NSObject, GKMatchmakerViewControllerDelegate, GKG
|
|||||||
var localPlayerRandomNumber: RandomNumber?
|
var localPlayerRandomNumber: RandomNumber?
|
||||||
var initIsFinish = false
|
var initIsFinish = false
|
||||||
var gameEnded = false
|
var gameEnded = false
|
||||||
var winner:String?
|
var winner: String?
|
||||||
var gameScene: GameScene?
|
var gameScene: GameScene?
|
||||||
static var isAuthenticated: Bool {
|
static var isAuthenticated: Bool {
|
||||||
return GKLocalPlayer.local.isAuthenticated
|
return GKLocalPlayer.local.isAuthenticated
|
||||||
@ -58,7 +58,7 @@ final class GameCenterManager: NSObject, GKMatchmakerViewControllerDelegate, GKG
|
|||||||
localPlayerRandomNumber = RandomNumber()
|
localPlayerRandomNumber = RandomNumber()
|
||||||
}
|
}
|
||||||
|
|
||||||
func reset(){
|
func reset() {
|
||||||
isMatchStarted = false
|
isMatchStarted = false
|
||||||
isServer = false
|
isServer = false
|
||||||
localPlayerRandomNumber = RandomNumber()
|
localPlayerRandomNumber = RandomNumber()
|
||||||
|
@ -77,11 +77,9 @@ class GameScene: SKScene{
|
|||||||
}
|
}
|
||||||
|
|
||||||
override func update(_ currentTime: TimeInterval) {
|
override func update(_ currentTime: TimeInterval) {
|
||||||
if entityManager.entities.count != 0 {
|
entityManager.getBackground()?.update(deltaTime: currentTime)
|
||||||
entityManager.getBackground()?.update(deltaTime: currentTime)
|
if GameCenterManager.sharedInstance.gameEnded && !gameEndEffects {
|
||||||
if GameCenterManager.sharedInstance.gameEnded && !gameEndEffects {
|
gameEnd()
|
||||||
gameEnd()
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -128,6 +126,7 @@ class GameScene: SKScene{
|
|||||||
}
|
}
|
||||||
|
|
||||||
func gameEnd(){
|
func gameEnd(){
|
||||||
|
entityManager.getHUD()?.blockWholeScreenPane.isHidden = true
|
||||||
gameEndEffects = true
|
gameEndEffects = true
|
||||||
GameCenterManager.sharedInstance.gameEnded = false
|
GameCenterManager.sharedInstance.gameEnded = false
|
||||||
let move = SKAction.move(to: CGPoint(x: self.size.width / 2, y: self.size.height / 2), duration: 1)
|
let move = SKAction.move(to: CGPoint(x: self.size.width / 2, y: self.size.height / 2), duration: 1)
|
||||||
|
Loading…
Reference in New Issue
Block a user