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 diff --git a/GoldWars/GoldWars/Game/GameScene.swift b/GoldWars/GoldWars/Game/GameScene.swift index 00b152a..8dcdebf 100644 --- a/GoldWars/GoldWars/Game/GameScene.swift +++ b/GoldWars/GoldWars/Game/GameScene.swift @@ -34,8 +34,8 @@ class GameScene: SKScene, SKPhysicsContactDelegate { let maxX = self.size.width let midY = self.size.height / 2 - let basePlayer1 = Base(color: SKColor.red, position: CGPoint(x: maxX * 0.1, y: midY), name: "Player1" ) - let basePlayer2 = Base(color: SKColor.blue, position: CGPoint(x: maxX * 0.9, y: midY), name: "Player2" ) + let basePlayer1 = Base(color: SKColor.red, position: CGPoint(x: maxX * 0.1, y: midY), name: "Player1", unitCount: 100, unitType: Unit.General) + let basePlayer2 = Base(color: SKColor.blue, position: CGPoint(x: maxX * 0.9, y: midY), name: "Player2", unitCount: 100, unitType: Unit.General) basePlayer2.physicsBody = SKPhysicsBody(circleOfRadius: 50) basePlayer2.physicsBody?.categoryBitMask = physicsBodyNumber.basePlayer2Number basePlayer2.physicsBody?.collisionBitMask = physicsBodyNumber.emptyNumber diff --git a/GoldWars/GoldWars/Unit/Unit.swift b/GoldWars/GoldWars/Unit/Unit.swift index f01eba3..a4fa851 100644 --- a/GoldWars/GoldWars/Unit/Unit.swift +++ b/GoldWars/GoldWars/Unit/Unit.swift @@ -6,8 +6,8 @@ // Copyright © 2020 SP2. All rights reserved. // -struct Unit{ - var strength: Float - var health: Float - var defence: Float +enum Unit{ + case General + case Defence + case Attack }