From 5f7b12c28c79b8862982b2db68d020db9dee0a97 Mon Sep 17 00:00:00 2001 From: Aldin Duraki Date: Wed, 20 May 2020 23:20:05 +0200 Subject: [PATCH] * Changed slider behavior to not take MAX and 0 value as unit counts to send --- GoldWars/GoldWars/Components/AtkBoostSkillComponent.swift | 3 +-- GoldWars/GoldWars/Scenes/GameScene.swift | 7 +++++++ 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/GoldWars/GoldWars/Components/AtkBoostSkillComponent.swift b/GoldWars/GoldWars/Components/AtkBoostSkillComponent.swift index 3f2e1c3..8829c19 100644 --- a/GoldWars/GoldWars/Components/AtkBoostSkillComponent.swift +++ b/GoldWars/GoldWars/Components/AtkBoostSkillComponent.swift @@ -25,8 +25,7 @@ class AtkBoostSkillComponent: GKComponent{ }else { base.unitType = .Attack } - } - }) + }}) super.init() } diff --git a/GoldWars/GoldWars/Scenes/GameScene.swift b/GoldWars/GoldWars/Scenes/GameScene.swift index be67b35..e4cf1a2 100644 --- a/GoldWars/GoldWars/Scenes/GameScene.swift +++ b/GoldWars/GoldWars/Scenes/GameScene.swift @@ -114,6 +114,13 @@ class GameScene: SKScene{ 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) + + //TODO: refactor this quick and dirty fix + if GameScene.sendUnits == 0 { + GameScene.sendUnits = 1 + } else if Int(GameScene.sendUnits) == currentDraggedBase?.unitCount { + GameScene.sendUnits -= 1 + } body.text = "Schicke \(GameScene.sendUnits) Einheiten " } }