deleted comments
This commit is contained in:
parent
35ff2208fb
commit
c4a4a8f755
@ -110,7 +110,6 @@ final class GameCenterManager: NSObject, GKMatchmakerViewControllerDelegate, GKG
|
|||||||
}
|
}
|
||||||
|
|
||||||
func match(_ match: GKMatch, didReceive data: Data, fromRemotePlayer player: GKPlayer) {
|
func match(_ match: GKMatch, didReceive data: Data, fromRemotePlayer player: GKPlayer) {
|
||||||
print("I am here")
|
|
||||||
if myMatch != match { return }
|
if myMatch != match { return }
|
||||||
let jsonDecoder = JSONDecoder()
|
let jsonDecoder = JSONDecoder()
|
||||||
if let randomNumberFromPeer = try? jsonDecoder.decode(RandomNumber.self, from: data) {
|
if let randomNumberFromPeer = try? jsonDecoder.decode(RandomNumber.self, from: data) {
|
||||||
@ -171,14 +170,12 @@ final class GameCenterManager: NSObject, GKMatchmakerViewControllerDelegate, GKG
|
|||||||
DataService.sharedInstance.addRemotePlayerMoves(playerName: player.displayName, localRoundData: roundData)
|
DataService.sharedInstance.addRemotePlayerMoves(playerName: player.displayName, localRoundData: roundData)
|
||||||
}
|
}
|
||||||
if let snapshotModel = try? jsonDecoder.decode(SnapshotModel.self, from: data) {
|
if let snapshotModel = try? jsonDecoder.decode(SnapshotModel.self, from: data) {
|
||||||
print("entered syncing state in match")
|
|
||||||
StateManager.sharedInstance.changeState(wantedState: .syncingSt)
|
StateManager.sharedInstance.changeState(wantedState: .syncingSt)
|
||||||
DataService.sharedInstance.snapshotModel = snapshotModel
|
DataService.sharedInstance.snapshotModel = snapshotModel
|
||||||
RoundCalculatorService.sharedInstance.currentRound += 1
|
RoundCalculatorService.sharedInstance.currentRound += 1
|
||||||
entityManager.getHUD()?.setCurrentRound(round: RoundCalculatorService.sharedInstance.currentRound)
|
entityManager.getHUD()?.setCurrentRound(round: RoundCalculatorService.sharedInstance.currentRound)
|
||||||
entityManager.updateSnapshotModel(snapshotModel: snapshotModel)
|
entityManager.updateSnapshotModel(snapshotModel: snapshotModel)
|
||||||
entityManager.getHUD()?.startWithDuration()
|
entityManager.getHUD()?.startWithDuration()
|
||||||
print("entered gameSt in match snapshot")
|
|
||||||
StateManager.sharedInstance.changeState(wantedState: .gameSt)
|
StateManager.sharedInstance.changeState(wantedState: .gameSt)
|
||||||
}
|
}
|
||||||
if let mapModel = try? jsonDecoder.decode(MapGenerationModel.self, from: data) {
|
if let mapModel = try? jsonDecoder.decode(MapGenerationModel.self, from: data) {
|
||||||
@ -192,8 +189,8 @@ final class GameCenterManager: NSObject, GKMatchmakerViewControllerDelegate, GKG
|
|||||||
StateManager.sharedInstance.gameSc = scene
|
StateManager.sharedInstance.gameSc = 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
|
||||||
}
|
}
|
||||||
@ -252,7 +249,6 @@ final class GameCenterManager: NSObject, GKMatchmakerViewControllerDelegate, GKG
|
|||||||
}
|
}
|
||||||
|
|
||||||
func matchmakerViewController(_ viewController: GKMatchmakerViewController, didFind match: GKMatch) {
|
func matchmakerViewController(_ viewController: GKMatchmakerViewController, didFind match: GKMatch) {
|
||||||
print("entered syncing state in didfindmatch")
|
|
||||||
StateManager.sharedInstance.changeState(wantedState: .syncingSt)
|
StateManager.sharedInstance.changeState(wantedState: .syncingSt)
|
||||||
viewController.dismiss(animated: true, completion: nil)
|
viewController.dismiss(animated: true, completion: nil)
|
||||||
myMatch = match
|
myMatch = match
|
||||||
|
@ -25,20 +25,14 @@ class RoundCalculatorService {
|
|||||||
var isCalculating = false
|
var isCalculating = false
|
||||||
var numberOfAttacks = 0
|
var numberOfAttacks = 0
|
||||||
var numberOfOwnUnitMoves = 0
|
var numberOfOwnUnitMoves = 0
|
||||||
|
|
||||||
var roundNr = 1
|
var roundNr = 1
|
||||||
|
|
||||||
func calculateRound() {
|
func calculateRound() {
|
||||||
roundNr += 1
|
|
||||||
print("roundNR \(roundNr)")
|
|
||||||
|
|
||||||
print("entered syncingSt in calculateRound")
|
|
||||||
StateManager.sharedInstance.changeState(wantedState: .syncingSt)
|
StateManager.sharedInstance.changeState(wantedState: .syncingSt)
|
||||||
|
|
||||||
os_log("Started calculating Round", log: RoundCalculatorService.LOG, type: .info)
|
os_log("Started calculating Round", log: RoundCalculatorService.LOG, type: .info)
|
||||||
|
roundNr += 1
|
||||||
isCalculating = true
|
isCalculating = true
|
||||||
let currentSnapshotModel = DataService.sharedInstance.snapshotModel
|
let currentSnapshotModel = DataService.sharedInstance.snapshotModel
|
||||||
|
|
||||||
var baseSpecificMoves = collectBaseSpecificMoves()
|
var baseSpecificMoves = collectBaseSpecificMoves()
|
||||||
|
|
||||||
// TODO: Refactor to a less complex way
|
// TODO: Refactor to a less complex way
|
||||||
@ -177,7 +171,6 @@ class RoundCalculatorService {
|
|||||||
entityManager.updateSnapshotModel(snapshotModel: currentSnapshotModel!)
|
entityManager.updateSnapshotModel(snapshotModel: currentSnapshotModel!)
|
||||||
entityManager.getHUD()?.startWithDuration()
|
entityManager.getHUD()?.startWithDuration()
|
||||||
os_log("Finished calculating Round", log: RoundCalculatorService.LOG, type: .info)
|
os_log("Finished calculating Round", log: RoundCalculatorService.LOG, type: .info)
|
||||||
print("entered gameSt in calculateRound")
|
|
||||||
StateManager.sharedInstance.changeState(wantedState: .gameSt)
|
StateManager.sharedInstance.changeState(wantedState: .gameSt)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -73,9 +73,6 @@ class GameScene: SKScene{
|
|||||||
|
|
||||||
override func update(_ currentTime: TimeInterval) {
|
override func update(_ currentTime: TimeInterval) {
|
||||||
StateManager.sharedInstance.stateMachine!.update(deltaTime: currentTime)
|
StateManager.sharedInstance.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){
|
||||||
|
@ -26,7 +26,6 @@ class MenuScene: SKScene {
|
|||||||
onButtonPress: {
|
onButtonPress: {
|
||||||
if CommandLine.arguments.contains("--no-matchmaking") {
|
if CommandLine.arguments.contains("--no-matchmaking") {
|
||||||
StateManager.sharedInstance.changeState(wantedState: .gameSt)
|
StateManager.sharedInstance.changeState(wantedState: .gameSt)
|
||||||
/*self.loadScene(scene: GameScene(size: self.size))*/
|
|
||||||
SoundManager.sharedInstance.stopMenuMusic()
|
SoundManager.sharedInstance.stopMenuMusic()
|
||||||
} else {
|
} else {
|
||||||
if GameCenterManager.isAuthenticated {
|
if GameCenterManager.isAuthenticated {
|
||||||
@ -71,16 +70,6 @@ class MenuScene: SKScene {
|
|||||||
|
|
||||||
override func update(_ currentTime: TimeInterval) {
|
override func update(_ currentTime: TimeInterval) {
|
||||||
StateManager.sharedInstance.stateMachine!.update(deltaTime: currentTime)
|
StateManager.sharedInstance.stateMachine!.update(deltaTime: currentTime)
|
||||||
/*
|
|
||||||
if entityManager.entities.count != 0 {
|
|
||||||
entityManager.getBackground()!.update(deltaTime: currentTime)
|
|
||||||
entityManager.getButtonByName(buttonName: "startGameButton").component(ofType: ButtonComponent.self)?.buttonNode.isEnabled = GameCenterManager.isAuthenticated
|
|
||||||
}
|
|
||||||
|
|
||||||
if GameCenterManager.sharedInstance.initIsFinish {
|
|
||||||
self.loadScene(scene: GameCenterManager.sharedInstance.gameScene!)
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -12,7 +12,7 @@ import os
|
|||||||
class GameState: GKState {
|
class GameState: GKState {
|
||||||
|
|
||||||
let LOG = OSLog.init(subsystem: "GameState", category: "GameState")
|
let LOG = OSLog.init(subsystem: "GameState", category: "GameState")
|
||||||
var aufruf = 0
|
var roundNr = RoundCalculatorService.sharedInstance.roundNr
|
||||||
|
|
||||||
override func isValidNextState(_ stateClass: AnyClass) -> Bool {
|
override func isValidNextState(_ stateClass: AnyClass) -> Bool {
|
||||||
return stateClass is SyncingState.Type
|
return stateClass is SyncingState.Type
|
||||||
@ -20,13 +20,12 @@ 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") {
|
if CommandLine.arguments.contains("--no-matchmaking"){
|
||||||
StateManager.sharedInstance.menuSc!.loadScene(scene: GameScene(size: StateManager.sharedInstance.menuSc!.size))
|
StateManager.sharedInstance.menuSc!.loadScene(scene: GameScene(size: StateManager.sharedInstance.menuSc!.size))
|
||||||
}
|
}
|
||||||
if aufruf == 0{
|
if roundNr == 1{
|
||||||
StateManager.sharedInstance.menuSc!.loadScene(scene: StateManager.sharedInstance.gameSc!)
|
StateManager.sharedInstance.menuSc!.loadScene(scene: StateManager.sharedInstance.gameSc!)
|
||||||
}
|
}
|
||||||
aufruf += 1
|
|
||||||
}
|
}
|
||||||
|
|
||||||
override func update(deltaTime seconds: TimeInterval) {
|
override func update(deltaTime seconds: TimeInterval) {
|
||||||
|
@ -26,12 +26,6 @@ class MenuState: GKState {
|
|||||||
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
|
||||||
}
|
}
|
||||||
|
|
||||||
// if GameCenterManager.sharedInstance.initIsFinish {
|
|
||||||
// StateManager.sharedInstance.menuSc!.loadScene(scene: GameCenterManager.sharedInstance.gameScene!)
|
|
||||||
// }
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
override func didEnter(from previousState: GKState?) {
|
override func didEnter(from previousState: GKState?) {
|
||||||
|
@ -82,13 +82,6 @@ class StateManager{
|
|||||||
stateMachine = GKStateMachine(states: [menuSt, syncingSt, playingSt, endGameSt])
|
stateMachine = GKStateMachine(states: [menuSt, syncingSt, playingSt, endGameSt])
|
||||||
}
|
}
|
||||||
|
|
||||||
/* func changeState(wantedState: StateTypes, menuSc: MenuScene?, gameVC: GameViewController?){
|
|
||||||
self.wantedState = wantedState
|
|
||||||
self.menuSc = menuSc
|
|
||||||
self.gameVC = gameVC
|
|
||||||
enterState()
|
|
||||||
}*/
|
|
||||||
|
|
||||||
func changeState(wantedState: StateTypes){
|
func changeState(wantedState: StateTypes){
|
||||||
self.wantedState = wantedState
|
self.wantedState = wantedState
|
||||||
enterState()
|
enterState()
|
||||||
|
Loading…
Reference in New Issue
Block a user