From ffd4e0dfe0e8e7756ce88400d850bb4afe3359bc Mon Sep 17 00:00:00 2001 From: Marcel Schwarz Date: Sat, 2 May 2020 20:13:31 +0200 Subject: [PATCH] Initialize team in Base model with default nil --- GoldWars/GoldWars/Entities/Base.swift | 2 +- GoldWars/GoldWars/Map/TwoPlayerDefaultTestMap.swift | 10 +++++----- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/GoldWars/GoldWars/Entities/Base.swift b/GoldWars/GoldWars/Entities/Base.swift index db68ee4..e7c62e1 100644 --- a/GoldWars/GoldWars/Entities/Base.swift +++ b/GoldWars/GoldWars/Entities/Base.swift @@ -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)) diff --git a/GoldWars/GoldWars/Map/TwoPlayerDefaultTestMap.swift b/GoldWars/GoldWars/Map/TwoPlayerDefaultTestMap.swift index 887f78a..d7d388c 100644 --- a/GoldWars/GoldWars/Map/TwoPlayerDefaultTestMap.swift +++ b/GoldWars/GoldWars/Map/TwoPlayerDefaultTestMap.swift @@ -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) }