diff --git a/GoldWars/GoldWars/Entities/Modal.swift b/GoldWars/GoldWars/Entities/Modal.swift index 3cbcf1d..64be9ea 100644 --- a/GoldWars/GoldWars/Entities/Modal.swift +++ b/GoldWars/GoldWars/Entities/Modal.swift @@ -8,8 +8,7 @@ import GameplayKit -enum ModalType: String{ - case BaseDetails +enum ModalType: String { case BaseAttack case BaseMoveOwnUnits case PauseGame @@ -52,10 +51,6 @@ class Modal: GKEntity{ overlay.zPosition = 3 switch modaltype { - case .BaseDetails: - header = SKLabelNode(text: "Information") - body = SKLabelNode(text: "Diese Basis enthält \(base!.unitCount) Einheiten") - footer = SKLabelNode() case .BaseAttack: header = SKLabelNode(text: "Angriff") body = SKLabelNode(text: "Schicke \(unitCount / 2)\nEinheiten") @@ -92,10 +87,6 @@ class Modal: GKEntity{ super.init() switch modaltype{ - case .BaseDetails: - addComponent(ButtonComponent(textureName: "yellow_button04", text: "Zurück", position: CGPoint(x: anchorPoint.x , y: anchorPoint.y - 105), isEnabled: true, onButtonPress: { - EntityManager.gameEMInstance.removeModal() - })) case .BaseAttack, .BaseMoveOwnUnits: let text = (modaltype == .BaseAttack) ? "Angriff" : "Senden" addComponent(SliderComponent(width: 300, position: CGPoint(x: anchorPoint.x , y: anchorPoint.y - 50))) diff --git a/GoldWars/GoldWars/RoundTimer.swift b/GoldWars/GoldWars/RoundTimer.swift index 8435b7e..819b5d7 100644 --- a/GoldWars/GoldWars/RoundTimer.swift +++ b/GoldWars/GoldWars/RoundTimer.swift @@ -50,6 +50,7 @@ class RoundTimer: Timer { EntityManager.gameEMInstance.updateTime(time: (timeLeft > 0 ? String(timeLeft) : roundEnded)) if timeLeft == 0 { + EntityManager.gameEMInstance.removeModal() RoundCalculatorService.sharedInstance.resetNumberOfAttacksAndFormats() if !MultiplayerNetwork.sharedInstance.isSending { MultiplayerNetwork.sharedInstance.sendPlayerMoves(localRoundData: DataService.sharedInstance.localRoundData) diff --git a/GoldWars/GoldWars/Scenes/GameScene.swift b/GoldWars/GoldWars/Scenes/GameScene.swift index b857f8d..c8be9a7 100644 --- a/GoldWars/GoldWars/Scenes/GameScene.swift +++ b/GoldWars/GoldWars/Scenes/GameScene.swift @@ -50,12 +50,11 @@ class GameScene: SKScene{ entityManager.getBasesByPlayer(for: GKLocalPlayer.local).forEach({base in moveFireAndBase(base: base, touchLocation: base.position) }) - } - else { + } else { for entity in entityManager.entities { - let spriteNode = entity.component(ofType: DefaultBaseComponent.self)?.spriteNode - //FIXME: this is confusing - addBaseDetails(touchLocation: touchLocation, spriteNode: spriteNode, touches: touches, event: event, entity: entity) + if atPoint(touchLocation) == entity.component(ofType: DefaultBaseComponent.self)?.spriteNode { + entity.component(ofType: DefaultBaseComponent.self)?.spriteNode.touchesBegan(touches, with: event) + } } } } @@ -80,21 +79,6 @@ class GameScene: SKScene{ entityManager.getBackground()?.update(deltaTime: currentTime) } - func addBaseDetails(touchLocation: CGPoint, spriteNode: SKNode?, touches: Set, event: UIEvent?, entity: GKEntity){ - if atPoint(touchLocation) == spriteNode && !entityManager.isModal { - spriteNode?.touchesBegan(touches, with: event) - if let baseEntity = entity as? Base { - if baseEntity.ownershipPlayer == GKLocalPlayer.local { - entityManager.add(Modal(modaltype: .BaseDetails, - base: entity as? Base, - anchorPoint: CGPoint(x: self.size.width / 2 , y: self.size.height / 2), - gameScene: self, - currentDraggedBase: currentDraggedBase, touchLocation: touchLocation, collisionBase: collisionBase)) - } - } - } - } - func addAttackDetails(touchLocation: CGPoint){ for base in currentDraggedBase!.adjacencyList { if atPoint(touchLocation) == base.component(ofType: DefaultBaseComponent.self)?.spriteNode {