Introduce column based layout

This commit is contained in:
Marcel Schwarz 2020-05-02 20:22:31 +02:00
parent ffd4e0dfe0
commit 918979d750

View File

@ -30,33 +30,36 @@ class TwoPlayerDefaultTestMap: MapProtocoll {
position: CGPoint(x: self.size.width * 0.1, y: self.size.height / 2),
team: .team1
)
entityManager.add(basePlayerOne)
var genericBasePositions = Array<CGPoint>()
let column1 = [
Base(position: CGPoint(x: self.size.width * 0.25, y: self.size.height * 0.25)),
Base(position: CGPoint(x: self.size.width * 0.25, y: self.size.height * 0.5)),
Base(position: CGPoint(x: self.size.width * 0.25, y: self.size.height * 0.75))
]
// First column
genericBasePositions.append(CGPoint(x: self.size.width * 0.25, y: self.size.height * 0.25))
genericBasePositions.append(CGPoint(x: self.size.width * 0.25, y: self.size.height * 0.5))
genericBasePositions.append(CGPoint(x: self.size.width * 0.25, y: self.size.height * 0.75))
let column2 = [
Base(position: CGPoint(x: self.size.width * 0.5, y: self.size.height * 0.333)),
Base(position: CGPoint(x: self.size.width * 0.5, y: self.size.height * 0.666))
]
// Second column
genericBasePositions.append(CGPoint(x: self.size.width * 0.5, y: self.size.height * 0.333))
genericBasePositions.append(CGPoint(x: self.size.width * 0.5, y: self.size.height * 0.666))
// Third column
genericBasePositions.append(CGPoint(x: self.size.width * 0.75, y: self.size.height * 0.25))
genericBasePositions.append(CGPoint(x: self.size.width * 0.75, y: self.size.height * 0.5))
genericBasePositions.append(CGPoint(x: self.size.width * 0.75, y: self.size.height * 0.75))
for pos in genericBasePositions {
entityManager.add(Base(position: pos))
}
let column3 = [
Base(position: CGPoint(x: self.size.width * 0.75, y: self.size.height * 0.25)),
Base(position: CGPoint(x: self.size.width * 0.75, y: self.size.height * 0.5)),
Base(position: CGPoint(x: self.size.width * 0.75, y: self.size.height * 0.75))
]
// Player two (rightest base)
let basePlayerTwo = Base(
position: CGPoint(x: self.size.width * 0.9, y: self.size.height / 2),
team: .team2
)
entityManager.add(basePlayerOne)
column1.forEach({base in entityManager.add(base)})
column2.forEach({base in entityManager.add(base)})
column3.forEach({base in entityManager.add(base)})
entityManager.add(basePlayerTwo)
}
}