For better understanding
This commit is contained in:
parent
a37187bbad
commit
e6d866bc70
@ -25,9 +25,10 @@ class Modal: GKEntity{
|
|||||||
var body: SKLabelNode
|
var body: SKLabelNode
|
||||||
var footer: SKLabelNode
|
var footer: SKLabelNode
|
||||||
var overlay: SKSpriteNode
|
var overlay: SKSpriteNode
|
||||||
|
var type: ModalType
|
||||||
|
|
||||||
init(modaltype: ModalType, base: Base?, anchorPoint: CGPoint, gameScene: GameScene, currentDraggedBase: Base?, touchLocation: CGPoint?, collisionBase: Base?) {
|
init(modaltype: ModalType, base: Base?, anchorPoint: CGPoint, gameScene: GameScene, currentDraggedBase: Base?, touchLocation: CGPoint?, collisionBase: Base?) {
|
||||||
|
self.type = modaltype
|
||||||
unitCount = 0
|
unitCount = 0
|
||||||
if base != nil {
|
if base != nil {
|
||||||
unitCount = base!.unitCount
|
unitCount = base!.unitCount
|
||||||
|
@ -122,15 +122,17 @@ class GameScene: SKScene{
|
|||||||
func checkSlider(){
|
func checkSlider(){
|
||||||
for e in entityManager.entities{
|
for e in entityManager.entities{
|
||||||
if let modal = e as? Modal {
|
if let modal = e as? Modal {
|
||||||
GameScene.sendUnits = ((e.component(ofType: SliderComponent.self)?.sliderNode.getValue ?? 0) * CGFloat((e as! Modal).unitCount)).rounded(.up)
|
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 {
|
//TODO: refactor this quick and dirty fix
|
||||||
GameScene.sendUnits = 1
|
if GameScene.sendUnits == 0 {
|
||||||
} else if Int(GameScene.sendUnits) == currentDraggedBase?.unitCount {
|
GameScene.sendUnits = 1
|
||||||
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 "
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user