From 1dc97c3bab7cf794a6b211da895d6c7dbfdbe321 Mon Sep 17 00:00:00 2001 From: Aldin Duraki Date: Sun, 17 May 2020 21:48:17 +0200 Subject: [PATCH] Solve Mergeconflicts --- GoldWars/GoldWars/Entities/Modal.swift | 14 +++++++------- GoldWars/GoldWars/RoundCalculatorService.swift | 2 +- GoldWars/GoldWars/Scenes/GameScene.swift | 15 +++++++-------- 3 files changed, 15 insertions(+), 16 deletions(-) diff --git a/GoldWars/GoldWars/Entities/Modal.swift b/GoldWars/GoldWars/Entities/Modal.swift index 516efb0..31b9940 100644 --- a/GoldWars/GoldWars/Entities/Modal.swift +++ b/GoldWars/GoldWars/Entities/Modal.swift @@ -12,7 +12,7 @@ class Modal: GKEntity{ var unitCount:Int - init(modaltype: ModalType, base: Base, anchorPoint: CGPoint, entityManager: EntityManager, gameScene: SKScene) { + init(modaltype: ModalType, base: Base, anchorPoint: CGPoint, gameScene: SKScene) { unitCount = base.unitCount super.init() switch modaltype{ @@ -20,7 +20,7 @@ class Modal: GKEntity{ addComponent(ModalBackgroundComponent(anchorPoint: anchorPoint)) addComponent(ModalContentComponent(header: "Basis Information", body: "Diese Basis enthält \(base.unitCount) Einheiten", footer: "", anchorPoint: anchorPoint)) addComponent(ButtonComponent(iconName: "", text: "Zurück", position: CGPoint(x: anchorPoint.x , y: anchorPoint.y - 120), isEnabled: true, onButtonPress: { - self.removeModalEntities(entityManager: entityManager, gameScene: gameScene) + self.removeModalEntities(gameScene: gameScene) })) case .BaseAttack: addComponent(ModalBackgroundComponent(anchorPoint: anchorPoint)) @@ -28,7 +28,7 @@ class Modal: GKEntity{ addComponent(ModalContentComponent(header: "Angriff", body: "Schicke \(unitCount / 2) Einheiten", footer: "", anchorPoint: anchorPoint)) addComponent(ButtonComponent(iconName: "", text: "Senden", position: CGPoint(x: anchorPoint.x , y: anchorPoint.y - 120), isEnabled: true, onButtonPress: { - self.removeModalEntities(entityManager: entityManager, gameScene: gameScene) + self.removeModalEntities(gameScene: gameScene) })) } } @@ -37,10 +37,10 @@ class Modal: GKEntity{ fatalError("init(coder:) has not been implemented") } - func removeModalEntities(entityManager: EntityManager, gameScene: SKScene){ - for entity in entityManager.entities { - if entityManager.isModal && entity.isMember(of: Modal.self) { - entityManager.remove(entity) + func removeModalEntities(gameScene: SKScene){ + for entity in EntityManager.sharedInstance.entities { + if EntityManager.sharedInstance.isModal && entity.isMember(of: Modal.self) { + EntityManager.sharedInstance.remove(entity) } for child in gameScene.children { if(child.name != "fire"){ diff --git a/GoldWars/GoldWars/RoundCalculatorService.swift b/GoldWars/GoldWars/RoundCalculatorService.swift index fd300b7..117a715 100644 --- a/GoldWars/GoldWars/RoundCalculatorService.swift +++ b/GoldWars/GoldWars/RoundCalculatorService.swift @@ -56,7 +56,7 @@ class RoundCalculatorServie { playerMovesByBase.removeValue(forKey: playerName) } - for (playerName, playerMove) in playerMovesByBase { + for (_, playerMove) in playerMovesByBase { for var base in currentSnapshotModel! { if base.baseId == playerMove.fromBase { base.unitCount -= playerMove.unitCount diff --git a/GoldWars/GoldWars/Scenes/GameScene.swift b/GoldWars/GoldWars/Scenes/GameScene.swift index 58ea2e2..a6934bd 100644 --- a/GoldWars/GoldWars/Scenes/GameScene.swift +++ b/GoldWars/GoldWars/Scenes/GameScene.swift @@ -24,8 +24,8 @@ class GameScene: SKScene{ } func initMap() { - MapFactory(scene: self, entityManager: self.entityManager).loadMap(playerCount: 2) - DataService.sharedInstance.safeSnapshot(snapshotModel: entityManager.getSnapshotModel()) + MapFactory(scene: self, entityManager: EntityManager.sharedInstance).loadMap(playerCount: 2) + DataService.sharedInstance.safeSnapshot(snapshotModel: EntityManager.sharedInstance.getSnapshotModel()) } override func touchesEnded(_ touches: Set, with event: UIEvent?) { @@ -48,14 +48,13 @@ class GameScene: SKScene{ EntityManager.sharedInstance.add(Modal(modaltype: .BaseAttack, base: currentDraggedBase!, anchorPoint: CGPoint(x: self.size.width / 2 , y: self.size.height / 2), - entityManager: EntityManager.sharedInstance, gameScene: self)) - EntityManager.sharedInstance.update((currentDraggedBase?.attackBase(base: base, units: 100))!) + gameScene: self)) + EntityManager.sharedInstance.update((currentDraggedBase?.doPlayerMoveTypeToBase(base: base, playerMoveType: PlayerMoveType.AtkMove, units: 100))!) }else { EntityManager.sharedInstance.add(Modal(modaltype: .BaseAttack, base: currentDraggedBase!, - anchorPoint: CGPoint(x: self.size.width / 2 , y: self.size.height / 2), - entityManager: entityManager, gameScene: self)) - entityManager.update((currentDraggedBase?.doPlayerMoveTypeToBase(base: base,playerMoveType: PlayerMoveType.TxnMove, units: -100))!) + anchorPoint: CGPoint(x: self.size.width / 2 , y: self.size.height / 2), gameScene: self)) + EntityManager.sharedInstance.update((currentDraggedBase?.doPlayerMoveTypeToBase(base: base,playerMoveType: PlayerMoveType.TxnMove, units: -100))!) } } @@ -76,7 +75,7 @@ class GameScene: SKScene{ EntityManager.sharedInstance.add(Modal(modaltype: .BaseDetails, base: entity as! Base, anchorPoint: CGPoint(x: self.size.width / 2 , y: self.size.height / 2), - entityManager: EntityManager.sharedInstance, gameScene: self)) + gameScene: self)) } } }