From 8fabdda71840ace6805b4f09747e64d8cba10f2b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Chauntalle=20Schu=CC=88le?= Date: Sat, 16 May 2020 18:46:40 +0200 Subject: [PATCH] Prints und Kommentare entfernt --- GoldWars/GoldWars/Scenes/GameScene.swift | 51 ++---------------------- 1 file changed, 4 insertions(+), 47 deletions(-) diff --git a/GoldWars/GoldWars/Scenes/GameScene.swift b/GoldWars/GoldWars/Scenes/GameScene.swift index 2f2fa08..5b29421 100644 --- a/GoldWars/GoldWars/Scenes/GameScene.swift +++ b/GoldWars/GoldWars/Scenes/GameScene.swift @@ -16,7 +16,7 @@ class GameScene: SKScene{ var isMoveTouch = false var currentDraggedBasePos = CGPoint() var currentDraggedBase : Base? - static var sendUnits: CGFloat = 0 + static var sendUnits: CGFloat = 0 override func sceneDidLoad() { entityManager = EntityManager(scene: self) @@ -29,11 +29,7 @@ class GameScene: SKScene{ MapFactory(scene: self, entityManager: self.entityManager).loadMap(playerCount: 2) } - /* - Aufgerufen: wenn Prozess beendet: Basis auf eine andere gezogen - */ override func touchesEnded(_ touches: Set, with event: UIEvent?) { - print("touchesEnded") guard let touch = touches.first else { return } @@ -41,57 +37,29 @@ class GameScene: SKScene{ let touchLocation = touch.location(in: self) if isMoveTouch{ - /* - Aufgerufen: wenn Prozess beendet: Basis auf eine andere gezogen - sendet 0 Einheiten, weil noch nicht slider betätugt wurde - */ isMoveTouch = false - print("isMoveTouch false") currentDraggedBase!.component(ofType: DefaultBaseComponent.self)?.spriteNode.position = currentDraggedBasePos //currentdraggedbase position gespeichert currentDraggedBase!.component(ofType: TeamComponent.self)?.fire.position = currentDraggedBasePos - //currentDraggedBase bekommt Feuerposition?: wenn auskommentiert verliert nur die alte Position das Feuer, 2 Feuer sind dann auf der neusten Position for base in currentDraggedBase!.adjacencyList { - //basis wurde berührt if atPoint(touchLocation) == base.component(ofType: DefaultBaseComponent.self)?.spriteNode { // TODO: change interaction based on collision instead of touchlocation if !(entityManager.getTeamByBase(base: currentDraggedBase!) == entityManager.getTeamByBase(base: base)){ - entityManager.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)) - /* print("if") - print("sendUnits \(Int(self.sendUnits))") - entityManager.update((currentDraggedBase?.attackBase(base: base, units: Int(self.sendUnits)))!)*/ - }else { + }else { entityManager.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)) - print("else") } } } } else { - print("else ismoveTouch is false") - /* - for base in currentDraggedBase!.adjacencyList { - print("in here") - if atPoint(touchLocation) == base.component(ofType: DefaultBaseComponent.self)?.spriteNode { - print("in here 2") - // if !(entityManager.getTeamByBase(base: currentDraggedBase!) == entityManager.getTeamByBase(base: base)){ - print("sendUnits \(Int(self.sendUnits))") - entityManager.update((currentDraggedBase?.attackBase(base: base, units: Int(self.sendUnits)))!) - // print("in here 3") - self.sendUnits = 0 - // } - } - }*/ - //add Base Details - for entity in entityManager.entities { let spriteNode = entity.component(ofType: DefaultBaseComponent.self)?.spriteNode @@ -107,7 +75,6 @@ class GameScene: SKScene{ base: entity as! Base, anchorPoint: CGPoint(x: self.size.width / 2 , y: self.size.height / 2), entityManager: entityManager, gameScene: self, currentDraggedBase: currentDraggedBase, touchLocation: touchLocation)) - print("Added Base Details") } } } @@ -115,11 +82,7 @@ class GameScene: SKScene{ } - /* - Dauernd aufgerufen beim Prozess: Eine Basis auf eine andere zu ziehen. - */ override func touchesMoved(_ touches: Set, with event: UIEvent?) { - print("touchesMoved") guard let touch = touches.first else { return } @@ -130,33 +93,27 @@ class GameScene: SKScene{ child.touchesMoved(touches, with: event) } } - //checken des Modals/slider des Modals, anzeigen der ausgewählten Units + for e in entityManager.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) - print("slider unit \(GameScene.sendUnits)") body.text = "Schicke \(GameScene.sendUnits) Einheiten " } } - // alle Basen eines Players + let bases = entityManager.getBasesByPlayer(for: GKLocalPlayer.local) for base in bases { - //wenn die Touchlocation die position der Basis trifft if atPoint(touchLocation) == base.component(ofType: DefaultBaseComponent.self)?.spriteNode{ if !isMoveTouch { - print("neue currentdraggedbase + position") currentDraggedBasePos = base.component(ofType: DefaultBaseComponent.self)!.spriteNode.position currentDraggedBase = base } isMoveTouch = true - print("isMoveTouch true") - //Feuer & Basis müssen sich mitbewegen können base.component(ofType: DefaultBaseComponent.self)?.spriteNode.position = touchLocation base.component(ofType: TeamComponent.self)?.fire.position = touchLocation - // jede basis die in der Nähe ist soll vergrößert werden. for adjacencyBase in base.adjacencyList { let node = adjacencyBase.component(ofType: DefaultBaseComponent.self)?.spriteNode node?.run(SKAction.sequence([