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 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

View File

@ -122,6 +122,7 @@ 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 {
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) 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: refactor this quick and dirty fix
@ -134,6 +135,7 @@ class GameScene: SKScene{
} }
} }
} }
}
func checkBases(bases: Set<Base>, touchLocation: CGPoint){ func checkBases(bases: Set<Base>, touchLocation: CGPoint){
for base in bases { for base in bases {