update the first three states before trying sth different
This commit is contained in:
parent
3ea48c399e
commit
f4847e79d7
@ -51,6 +51,7 @@ final class GameCenterManager: NSObject, GKMatchmakerViewControllerDelegate, GKG
|
|||||||
|
|
||||||
override init() {
|
override init() {
|
||||||
super.init()
|
super.init()
|
||||||
|
// StateManager.stateManager.changeState(wantedState: .syncingSt, menuSc: nil, gameVC: nil)
|
||||||
localPlayer.register(self)
|
localPlayer.register(self)
|
||||||
authUser();
|
authUser();
|
||||||
localPlayerRandomNumber = RandomNumber()
|
localPlayerRandomNumber = RandomNumber()
|
||||||
@ -182,8 +183,8 @@ final class GameCenterManager: NSObject, GKMatchmakerViewControllerDelegate, GKG
|
|||||||
self.gameScene = scene
|
self.gameScene = scene
|
||||||
sendStateToPeers(state: State(state: 2))
|
sendStateToPeers(state: State(state: 2))
|
||||||
os_log("State 2 wurde an Host gesendet", log: LOG, type: .info)
|
os_log("State 2 wurde an Host gesendet", log: LOG, type: .info)
|
||||||
initIsFinish = true
|
// initIsFinish = true
|
||||||
os_log("Peer startet Spiel", log: LOG, type: .info)
|
// os_log("Peer startet Spiel", log: LOG, type: .info)
|
||||||
}
|
}
|
||||||
MultiplayerNetwork.sharedInstance.isSending = false
|
MultiplayerNetwork.sharedInstance.isSending = false
|
||||||
}
|
}
|
||||||
@ -239,6 +240,7 @@ final class GameCenterManager: NSObject, GKMatchmakerViewControllerDelegate, GKG
|
|||||||
}
|
}
|
||||||
|
|
||||||
func matchmakerViewController(_ viewController: GKMatchmakerViewController, didFind match: GKMatch) {
|
func matchmakerViewController(_ viewController: GKMatchmakerViewController, didFind match: GKMatch) {
|
||||||
|
StateManager.stateManager.changeState(wantedState: .syncingSt, menuSc: menusc, gameVC: nil)
|
||||||
viewController.dismiss(animated: true, completion: nil)
|
viewController.dismiss(animated: true, completion: nil)
|
||||||
myMatch = match
|
myMatch = match
|
||||||
if !isMatchStarted && match.expectedPlayerCount == 0 {
|
if !isMatchStarted && match.expectedPlayerCount == 0 {
|
||||||
|
@ -72,7 +72,10 @@ class GameScene: SKScene{
|
|||||||
}
|
}
|
||||||
|
|
||||||
override func update(_ currentTime: TimeInterval) {
|
override func update(_ currentTime: TimeInterval) {
|
||||||
entityManager.getBackground()?.update(deltaTime: currentTime)
|
StateManager.stateManager.stateMachine!.update(deltaTime: currentTime)
|
||||||
|
/* entityManager.getBackground()?.update(deltaTime: currentTime)
|
||||||
|
entityManager.getHUD()?.component(ofType: TimerComponent.self)?.update()
|
||||||
|
*/
|
||||||
}
|
}
|
||||||
|
|
||||||
func addBaseDetails(touchLocation: CGPoint, spriteNode: SKNode?, touches: Set<UITouch>, event: UIEvent?, entity: GKEntity){
|
func addBaseDetails(touchLocation: CGPoint, spriteNode: SKNode?, touches: Set<UITouch>, event: UIEvent?, entity: GKEntity){
|
||||||
|
@ -29,7 +29,6 @@ class MenuScene: SKScene {
|
|||||||
SoundManager.sharedInstance.stopMenuMusic()
|
SoundManager.sharedInstance.stopMenuMusic()
|
||||||
} else {
|
} else {
|
||||||
if GameCenterManager.isAuthenticated {
|
if GameCenterManager.isAuthenticated {
|
||||||
StateManager.stateManager.changeState(wantedState: .syncingSt, menuSc: self, gameVC: nil)
|
|
||||||
GameCenterManager.sharedInstance.presentMatchmaker()
|
GameCenterManager.sharedInstance.presentMatchmaker()
|
||||||
}else {
|
}else {
|
||||||
GameCenterManager.sharedInstance.authUser()
|
GameCenterManager.sharedInstance.authUser()
|
||||||
|
@ -19,10 +19,14 @@ class GameState: GKState {
|
|||||||
|
|
||||||
override func didEnter(from previousState: GKState?) {
|
override func didEnter(from previousState: GKState?) {
|
||||||
os_log("Entered Game State", log: LOG, type: .info)
|
os_log("Entered Game State", log: LOG, type: .info)
|
||||||
|
if CommandLine.arguments.contains("--no-matchmaking") {
|
||||||
StateManager.stateManager.menuSc!.loadScene(scene: GameScene(size: StateManager.stateManager.menuSc!.size))
|
StateManager.stateManager.menuSc!.loadScene(scene: GameScene(size: StateManager.stateManager.menuSc!.size))
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
override func update(deltaTime seconds: TimeInterval) {
|
override func update(deltaTime seconds: TimeInterval) {
|
||||||
|
EntityManager.gameEMInstance.getBackground()?.update(deltaTime: seconds)
|
||||||
|
EntityManager.gameEMInstance.getHUD()?.component(ofType: TimerComponent.self)?.update()
|
||||||
}
|
}
|
||||||
|
|
||||||
override func willExit(to nextState: GKState) {
|
override func willExit(to nextState: GKState) {
|
||||||
|
@ -22,8 +22,8 @@ class MenuState: GKState {
|
|||||||
}
|
}
|
||||||
|
|
||||||
override func update(deltaTime seconds: TimeInterval) {
|
override func update(deltaTime seconds: TimeInterval) {
|
||||||
if menuEM.entities.count != 0 {
|
if menuEM.entities.count != 0 {
|
||||||
menuEM.getBackground()!.update(deltaTime: seconds)
|
menuEM.getBackground()!.update(deltaTime: seconds)
|
||||||
menuEM.getButtonByName(buttonName: "startGameButton").component(ofType: ButtonComponent.self)?.buttonNode.isEnabled = GameCenterManager.isAuthenticated
|
menuEM.getButtonByName(buttonName: "startGameButton").component(ofType: ButtonComponent.self)?.buttonNode.isEnabled = GameCenterManager.isAuthenticated
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -10,7 +10,10 @@ import GameKit
|
|||||||
import os
|
import os
|
||||||
|
|
||||||
class SyncingState: GKState {
|
class SyncingState: GKState {
|
||||||
|
|
||||||
let LOG = OSLog.init(subsystem: "SyncingState", category: "SyncingState")
|
let LOG = OSLog.init(subsystem: "SyncingState", category: "SyncingState")
|
||||||
|
var menuEM = EntityManager.menuEMInstance
|
||||||
|
var previousState: GKState?
|
||||||
|
|
||||||
override func isValidNextState(_ stateClass: AnyClass) -> Bool {
|
override func isValidNextState(_ stateClass: AnyClass) -> Bool {
|
||||||
return stateClass is GameState.Type || stateClass is EndGameState.Type
|
return stateClass is GameState.Type || stateClass is EndGameState.Type
|
||||||
@ -18,8 +21,20 @@ class SyncingState: GKState {
|
|||||||
|
|
||||||
override func didEnter(from previousState: GKState?) {
|
override func didEnter(from previousState: GKState?) {
|
||||||
os_log("Entered Syncing State", log: LOG, type: .info)
|
os_log("Entered Syncing State", log: LOG, type: .info)
|
||||||
|
self.previousState = previousState
|
||||||
}
|
}
|
||||||
|
|
||||||
override func update(deltaTime seconds: TimeInterval) {
|
override func update(deltaTime seconds: TimeInterval) {
|
||||||
|
if previousState is MenuState {
|
||||||
|
if menuEM.entities.count != 0 {
|
||||||
|
menuEM.getBackground()!.update(deltaTime: seconds)
|
||||||
|
menuEM.getButtonByName(buttonName: "startGameButton").component(ofType: ButtonComponent.self)?.buttonNode.isEnabled = GameCenterManager.isAuthenticated
|
||||||
|
}
|
||||||
|
|
||||||
|
if GameCenterManager.sharedInstance.initIsFinish {
|
||||||
|
StateManager.stateManager.changeState(wantedState: .gameSt, menuSc: self, gameVC: nil)
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
override func willExit(to nextState: GKState) {
|
override func willExit(to nextState: GKState) {
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user