From a8c42fa0b0eee0172491c95e2390a51578d516d8 Mon Sep 17 00:00:00 2001 From: Aldin Duraki Date: Wed, 20 May 2020 23:36:48 +0200 Subject: [PATCH] Fix slider min max unit values --- GoldWars/GoldWars/Entities/Modal.swift | 1 + GoldWars/GoldWars/Scenes/GameScene.swift | 5 ++++- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/GoldWars/GoldWars/Entities/Modal.swift b/GoldWars/GoldWars/Entities/Modal.swift index c01999e..489aed4 100644 --- a/GoldWars/GoldWars/Entities/Modal.swift +++ b/GoldWars/GoldWars/Entities/Modal.swift @@ -58,6 +58,7 @@ class Modal: GKEntity{ for base in currentDraggedBase!.adjacencyList { if base == collisionBase { EntityManager.sharedInstance.update((currentDraggedBase?.doPlayerMoveTypeToBase(base: base, playerMoveType: PlayerMoveType.AtkMove, units: Int(GameScene.sendUnits)))!) + GameScene.sendUnits = 0 } } } diff --git a/GoldWars/GoldWars/Scenes/GameScene.swift b/GoldWars/GoldWars/Scenes/GameScene.swift index e4cf1a2..31eec3b 100644 --- a/GoldWars/GoldWars/Scenes/GameScene.swift +++ b/GoldWars/GoldWars/Scenes/GameScene.swift @@ -93,6 +93,7 @@ class GameScene: SKScene{ base: entity as! Base, anchorPoint: CGPoint(x: self.size.width / 2 , y: self.size.height / 2), gameScene: self, currentDraggedBase: currentDraggedBase, touchLocation: touchLocation, collisionBase: collisionBase)) + } } } @@ -106,6 +107,8 @@ class GameScene: SKScene{ base: currentDraggedBase!, anchorPoint: CGPoint(x: self.size.width / 2 , y: self.size.height / 2), gameScene: self, currentDraggedBase: currentDraggedBase, touchLocation: touchLocation, collisionBase: collisionBase)) + GameScene.sendUnits = CGFloat(currentDraggedBase!.unitCount / 2) + } } } @@ -115,7 +118,7 @@ class GameScene: SKScene{ 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) - //TODO: refactor this quick and dirty fix + //TODO: quick fix chauntalle die olle mach augen auf if GameScene.sendUnits == 0 { GameScene.sendUnits = 1 } else if Int(GameScene.sendUnits) == currentDraggedBase?.unitCount {