From 735065412247678549e6e8dd5e0184e9c085ec8c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Chauntalle=20Schu=CC=88le?= Date: Sun, 17 May 2020 21:09:38 +0200 Subject: [PATCH] resolved Merge conflicts --- GoldWars/GoldWars/Entities/Modal.swift | 24 ++++++++++++------------ GoldWars/GoldWars/Scenes/GameScene.swift | 22 +++++++++++----------- 2 files changed, 23 insertions(+), 23 deletions(-) diff --git a/GoldWars/GoldWars/Entities/Modal.swift b/GoldWars/GoldWars/Entities/Modal.swift index 66e8ae6..0414657 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: GameScene, currentDraggedBase: Base?, touchLocation: CGPoint) { + init(modaltype: ModalType, base: Base, anchorPoint: CGPoint, gameScene: GameScene, currentDraggedBase: Base?, touchLocation: CGPoint) { 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,11 +28,11 @@ 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.sendUnits(currentDraggedBase: currentDraggedBase, touchLocation: touchLocation, entityManager: entityManager, gameScene: gameScene) - self.removeModalEntities(entityManager: entityManager, gameScene: gameScene) + self.sendUnits(currentDraggedBase: currentDraggedBase, touchLocation: touchLocation, gameScene: gameScene) + self.removeModalEntities(gameScene: gameScene) })) addComponent(CancelBtnComponent(iconName: "", text: "", position: CGPoint(x: anchorPoint.x + 160, y: anchorPoint.y + 140), isEnabled: true, onButtonPress: { - self.removeModalEntities(entityManager: entityManager, gameScene: gameScene) + self.removeModalEntities(gameScene: gameScene) })) } } @@ -41,10 +41,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"){ @@ -54,11 +54,11 @@ class Modal: GKEntity{ } } - func sendUnits(currentDraggedBase: Base?, touchLocation: CGPoint, entityManager: EntityManager, gameScene: GameScene){ + func sendUnits(currentDraggedBase: Base?, touchLocation: CGPoint, gameScene: GameScene){ for base in currentDraggedBase!.adjacencyList { if gameScene.atPoint(touchLocation) == base.component(ofType: DefaultBaseComponent.self)?.spriteNode { - if !(entityManager.getTeamByBase(base: currentDraggedBase!) == entityManager.getTeamByBase(base: base)){ - entityManager.update((currentDraggedBase?.attackBase(base: base, units: Int(GameScene.sendUnits)))!) + if !(EntityManager.sharedInstance.getTeamByBase(base: currentDraggedBase!) == EntityManager.sharedInstance.getTeamByBase(base: base)){ + EntityManager.sharedInstance.update((currentDraggedBase?.attackBase(base: base, units: Int(GameScene.sendUnits)))!) } } } diff --git a/GoldWars/GoldWars/Scenes/GameScene.swift b/GoldWars/GoldWars/Scenes/GameScene.swift index 723bad6..ff7264a 100644 --- a/GoldWars/GoldWars/Scenes/GameScene.swift +++ b/GoldWars/GoldWars/Scenes/GameScene.swift @@ -43,7 +43,7 @@ class GameScene: SKScene{ addAttackDetails(touchLocation: touchLocation) } else { - for entity in entityManager.entities { + for entity in EntityManager.sharedInstance.entities { let spriteNode = entity.component(ofType: DefaultBaseComponent.self)?.spriteNode addBaseDetails(touchLocation: touchLocation, spriteNode: spriteNode, touches: touches, event: event, entity: entity) @@ -65,29 +65,29 @@ class GameScene: SKScene{ } checkSlider() - let bases = entityManager.getBasesByPlayer(for: GKLocalPlayer.local) + let bases = EntityManager.sharedInstance.getBasesByPlayer(for: GKLocalPlayer.local) checkBases(bases: bases, touchLocation: touchLocation) } override func update(_ currentTime: TimeInterval) { - entityManager.getBackground()?.update(deltaTime: currentTime) - entityManager.getHUD()?.component(ofType: TimerComponent.self)?.update() + EntityManager.sharedInstance.getBackground()?.update(deltaTime: currentTime) + EntityManager.sharedInstance.getHUD()?.component(ofType: TimerComponent.self)?.update() } func addBaseDetails(touchLocation: CGPoint, spriteNode: SKNode?, touches: Set, event: UIEvent?, entity: GKEntity){ - if atPoint(touchLocation) == spriteNode && !entityManager.isModal { + if atPoint(touchLocation) == spriteNode && !EntityManager.sharedInstance.isModal { spriteNode?.touchesBegan(touches, with: event) - if !entityManager.isModal { + if !EntityManager.sharedInstance.isModal { for child in self.children { if(child.name != "fire"){ child.alpha = 0.3 } } - entityManager.add(Modal(modaltype: .BaseDetails, + EntityManager.sharedInstance.add(Modal(modaltype: .BaseDetails, base: entity as! Base, anchorPoint: CGPoint(x: self.size.width / 2 , y: self.size.height / 2), - entityManager: entityManager, gameScene: self, currentDraggedBase: currentDraggedBase, touchLocation: touchLocation)) + gameScene: self, currentDraggedBase: currentDraggedBase, touchLocation: touchLocation)) } } } @@ -96,16 +96,16 @@ class GameScene: SKScene{ for base in currentDraggedBase!.adjacencyList { if atPoint(touchLocation) == base.component(ofType: DefaultBaseComponent.self)?.spriteNode { // TODO: change interaction based on collision instead of touchlocation - entityManager.add(Modal(modaltype: .BaseAttack, + EntityManager.sharedInstance.add(Modal(modaltype: .BaseAttack, base: currentDraggedBase!, anchorPoint: CGPoint(x: self.size.width / 2 , y: self.size.height / 2), - entityManager: entityManager, gameScene: self, currentDraggedBase: currentDraggedBase, touchLocation: touchLocation)) + gameScene: self, currentDraggedBase: currentDraggedBase, touchLocation: touchLocation)) } } } func checkSlider(){ - for e in entityManager.entities{ + for e in EntityManager.sharedInstance.entities{ if let body = e.component(ofType: ModalContentComponent.self)?.body{ GameScene.sendUnits = ((e.component(ofType: SliderComponent.self)?.sliderNode.getValue ?? 0) * CGFloat((e as! Modal).unitCount)).rounded(.up) body.text = "Schicke \(GameScene.sendUnits) Einheiten "