From 8b840b5089ad799b31484abf24fadb30eb9711ef Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Chauntalle=20Schu=CC=88le?= Date: Fri, 15 May 2020 13:29:03 +0200 Subject: [PATCH] Adding Abbrechen Button to ModalAttack --- GoldWars/GoldWars/Entities/EntityManager.swift | 14 +++++++++++--- GoldWars/GoldWars/Entities/Modal.swift | 3 +++ 2 files changed, 14 insertions(+), 3 deletions(-) diff --git a/GoldWars/GoldWars/Entities/EntityManager.swift b/GoldWars/GoldWars/Entities/EntityManager.swift index 6afa00e..27758c7 100644 --- a/GoldWars/GoldWars/Entities/EntityManager.swift +++ b/GoldWars/GoldWars/Entities/EntityManager.swift @@ -68,6 +68,10 @@ class EntityManager { if let labelNode = entity.component(ofType: LabelComponent.self)?.labelNode { scene.addChild(labelNode) } + if let cancelBtnNode = entity.component(ofType: CancelBtnComponent.self)?.cancelBtnNode { + scene.addChild(cancelBtnNode) + isModal = true + } } func remove(_ entity: GKEntity) { @@ -90,6 +94,10 @@ class EntityManager { modalButton.buttonNode.removeFromParent() isModal = false } + if let cancelBtnNode = entity.component(ofType: CancelBtnComponent.self)?.cancelBtnNode { + cancelBtnNode.removeFromParent() + isModal = false + } entities.remove(entity) } @@ -100,9 +108,9 @@ class EntityManager { if base.changeOwnership { base.addComponent(TeamComponent( - team: (entities[0] as! Base).component(ofType: TeamComponent.self)!.team, - player: (entities[0] as! Base).component(ofType: TeamComponent.self)!.player, - position: (base.component(ofType: DefaultBaseComponent.self)?.spriteNode.position)! + team: (entities[0] as! Base).component(ofType: TeamComponent.self)!.team, + player: (entities[0] as! Base).component(ofType: TeamComponent.self)!.player, + position: (base.component(ofType: DefaultBaseComponent.self)?.spriteNode.position)! ) ) base.changeOwnership = false diff --git a/GoldWars/GoldWars/Entities/Modal.swift b/GoldWars/GoldWars/Entities/Modal.swift index 516efb0..d7e7be9 100644 --- a/GoldWars/GoldWars/Entities/Modal.swift +++ b/GoldWars/GoldWars/Entities/Modal.swift @@ -30,6 +30,9 @@ class Modal: GKEntity{ addComponent(ButtonComponent(iconName: "", text: "Senden", position: CGPoint(x: anchorPoint.x , y: anchorPoint.y - 120), isEnabled: true, onButtonPress: { self.removeModalEntities(entityManager: entityManager, 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) + })) } }