For better understanding

This commit is contained in:
Aldin Duraki 2020-06-06 19:20:13 +02:00
parent a37187bbad
commit e6d866bc70
2 changed files with 12 additions and 9 deletions

View File

@ -25,9 +25,10 @@ class Modal: GKEntity{
var body: SKLabelNode
var footer: SKLabelNode
var overlay: SKSpriteNode
var type: ModalType
init(modaltype: ModalType, base: Base?, anchorPoint: CGPoint, gameScene: GameScene, currentDraggedBase: Base?, touchLocation: CGPoint?, collisionBase: Base?) {
self.type = modaltype
unitCount = 0
if base != nil {
unitCount = base!.unitCount

View File

@ -122,15 +122,17 @@ class GameScene: SKScene{
func checkSlider(){
for e in entityManager.entities{
if let modal = e as? Modal {
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
if modal.type == ModalType.BaseAttack || modal.type == ModalType.BaseMoveOwnUnits {
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
}
modal.body.text = "Schicke \(GameScene.sendUnits) Einheiten "
}
modal.body.text = "Schicke \(GameScene.sendUnits) Einheiten "
}
}
}