From d8adce88d220c7b5c9e7a44d70e6635fef073c34 Mon Sep 17 00:00:00 2001 From: 72haja Date: Wed, 22 Apr 2020 18:16:25 +0200 Subject: [PATCH] add attributes to Base for unitCount and unitType. Init attributes in constructor with default parameters --- GoldWars/GoldWars/Base/Base.swift | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/GoldWars/GoldWars/Base/Base.swift b/GoldWars/GoldWars/Base/Base.swift index 57bd7bb..06d7071 100644 --- a/GoldWars/GoldWars/Base/Base.swift +++ b/GoldWars/GoldWars/Base/Base.swift @@ -13,8 +13,10 @@ class Base : SKSpriteNode{ public static let colorSelected = SKColor.yellow var availableBases = [Base]() var defaultColor = SKColor.green + var unitType: Unit = Unit.General; + var unitCount: Int = 0; - init(color: UIColor, position: CGPoint, name: String) { + init(color: UIColor, position: CGPoint, name: String, unitCount: Int = 0, unitType: Unit = Unit.General) { super.init(texture: SKTexture(imageNamed: "Base"), color: color, size: CGSize(width: 50.0, height: 50.0) @@ -26,6 +28,8 @@ class Base : SKSpriteNode{ self.position = position self.zPosition = 2 self.isUserInteractionEnabled = true + self.unitCount = unitCount + self.unitType = unitType } required init?(coder aDecoder: NSCoder) { @@ -45,8 +49,7 @@ class Base : SKSpriteNode{ ] ) ) - - } + } override func touchesMoved(_ touches: Set, with event: UIEvent?) { self.color = SKColor.yellow