Merge branch '16-einheiten-der-basis-hinzufugen' into 'development'
Resolve "Einheiten der Basis hinzufügen" Closes #16 See merge request marcel.schwarz/software-projekt-2!14
This commit is contained in:
commit
f5f45af111
@ -13,8 +13,10 @@ class Base : SKSpriteNode{
|
|||||||
public static let colorSelected = SKColor.yellow
|
public static let colorSelected = SKColor.yellow
|
||||||
var availableBases = [Base]()
|
var availableBases = [Base]()
|
||||||
var defaultColor = SKColor.green
|
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"),
|
super.init(texture: SKTexture(imageNamed: "Base"),
|
||||||
color: color,
|
color: color,
|
||||||
size: CGSize(width: 50.0, height: 50.0)
|
size: CGSize(width: 50.0, height: 50.0)
|
||||||
@ -26,6 +28,8 @@ class Base : SKSpriteNode{
|
|||||||
self.position = position
|
self.position = position
|
||||||
self.zPosition = 2
|
self.zPosition = 2
|
||||||
self.isUserInteractionEnabled = true
|
self.isUserInteractionEnabled = true
|
||||||
|
self.unitCount = unitCount
|
||||||
|
self.unitType = unitType
|
||||||
}
|
}
|
||||||
|
|
||||||
required init?(coder aDecoder: NSCoder) {
|
required init?(coder aDecoder: NSCoder) {
|
||||||
@ -45,7 +49,6 @@ class Base : SKSpriteNode{
|
|||||||
]
|
]
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
override func touchesMoved(_ touches: Set<UITouch>, with event: UIEvent?) {
|
override func touchesMoved(_ touches: Set<UITouch>, with event: UIEvent?) {
|
||||||
|
@ -34,8 +34,8 @@ class GameScene: SKScene, SKPhysicsContactDelegate {
|
|||||||
let maxX = self.size.width
|
let maxX = self.size.width
|
||||||
let midY = self.size.height / 2
|
let midY = self.size.height / 2
|
||||||
|
|
||||||
let basePlayer1 = Base(color: SKColor.red, position: CGPoint(x: maxX * 0.1, y: midY), name: "Player1" )
|
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" )
|
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 = SKPhysicsBody(circleOfRadius: 50)
|
||||||
basePlayer2.physicsBody?.categoryBitMask = physicsBodyNumber.basePlayer2Number
|
basePlayer2.physicsBody?.categoryBitMask = physicsBodyNumber.basePlayer2Number
|
||||||
basePlayer2.physicsBody?.collisionBitMask = physicsBodyNumber.emptyNumber
|
basePlayer2.physicsBody?.collisionBitMask = physicsBodyNumber.emptyNumber
|
||||||
|
@ -6,8 +6,8 @@
|
|||||||
// Copyright © 2020 SP2. All rights reserved.
|
// Copyright © 2020 SP2. All rights reserved.
|
||||||
//
|
//
|
||||||
|
|
||||||
struct Unit{
|
enum Unit{
|
||||||
var strength: Float
|
case General
|
||||||
var health: Float
|
case Defence
|
||||||
var defence: Float
|
case Attack
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user