Initialize team in Base model with default nil

This commit is contained in:
Marcel Schwarz 2020-05-02 20:13:31 +02:00
parent c1bb6a47de
commit ffd4e0dfe0
2 changed files with 6 additions and 6 deletions

View File

@ -12,7 +12,7 @@ import GameplayKit
class Base : GKEntity{
var unitCount:Int
init(team: Team?, position: CGPoint ) {
init(position: CGPoint, team: Team! = nil) {
self.unitCount = 0
super.init()
addComponent(DefaultBaseComponent(texture: SKTexture(imageNamed: "Base"), position: position))

View File

@ -27,8 +27,8 @@ class TwoPlayerDefaultTestMap: MapProtocoll {
func create() {
// Player one (leftest base)
let basePlayerOne = Base(
team: .team1 ,
position: CGPoint(x: self.size.width * 0.1, y: self.size.height / 2)
position: CGPoint(x: self.size.width * 0.1, y: self.size.height / 2),
team: .team1
)
entityManager.add(basePlayerOne)
@ -49,13 +49,13 @@ class TwoPlayerDefaultTestMap: MapProtocoll {
genericBasePositions.append(CGPoint(x: self.size.width * 0.75, y: self.size.height * 0.75))
for pos in genericBasePositions {
entityManager.add(Base(team: nil, position: pos))
entityManager.add(Base(position: pos))
}
// Player two (rightest base)
let basePlayerTwo = Base(
team: .team2 ,
position: CGPoint(x: self.size.width * 0.9, y: self.size.height / 2)
position: CGPoint(x: self.size.width * 0.9, y: self.size.height / 2),
team: .team2
)
entityManager.add(basePlayerTwo)
}