Extract player bases, simplify layout definition
This commit is contained in:
parent
ffc4c05a46
commit
5a7c29b3b8
@ -30,52 +30,41 @@ class TwoPlayerDefaultTestMap: MapProtocoll {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func createNodes() {
|
func createNodes() {
|
||||||
for i in 0...7 {
|
// Player one (leftest base)
|
||||||
let base: Base
|
let basePlayerOne = Base(
|
||||||
var position = CGPoint(x: 0, y: 0)
|
textureName: "Base",
|
||||||
switch i {
|
team: .team1 ,
|
||||||
case 0...2:
|
position: CGPoint(x: self.size.width * 0.1, y: self.size.height / 2)
|
||||||
let width = self.size.width * 0.25
|
)
|
||||||
|
entityManager.add(basePlayerOne)
|
||||||
|
|
||||||
if i == 0 {
|
var genericBasePositions = Array<CGPoint>()
|
||||||
position = CGPoint(x: width, y: self.size.height * 0.25)
|
|
||||||
}
|
// First column
|
||||||
if i == 1 {
|
genericBasePositions.append(CGPoint(x: self.size.width * 0.25, y: self.size.height * 0.25))
|
||||||
position = CGPoint(x: width, y: self.size.height * 0.5)
|
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))
|
||||||
if i == 2 {
|
|
||||||
position = CGPoint(x: width, y: self.size.height * 0.75)
|
// 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(textureName: "Base", team: nil, position: pos))
|
||||||
}
|
}
|
||||||
|
|
||||||
case 3...4:
|
// Player two (rightest base)
|
||||||
let width = self.size.width * 0.5
|
let basePlayerTwo = Base(
|
||||||
|
textureName: "Base",
|
||||||
if i == 3 {
|
team: .team2 ,
|
||||||
position = CGPoint(x: width, y: self.size.height * 0.333)
|
position: CGPoint(x: self.size.width * 0.9, y: self.size.height / 2)
|
||||||
}
|
)
|
||||||
if i == 4 {
|
entityManager.add(basePlayerTwo)
|
||||||
position = CGPoint(x: width, y: self.size.height * 0.666)
|
|
||||||
}
|
|
||||||
|
|
||||||
case 5...7:
|
|
||||||
let width = self.size.width * 0.75
|
|
||||||
|
|
||||||
if i == 5 {
|
|
||||||
position = CGPoint(x: width, y: self.size.height * 0.25)
|
|
||||||
}
|
|
||||||
if i == 6 {
|
|
||||||
position = CGPoint(x: width, y: self.size.height * 0.5)
|
|
||||||
}
|
|
||||||
if i == 7 {
|
|
||||||
position = CGPoint(x: width, y: self.size.height * 0.75)
|
|
||||||
}
|
|
||||||
|
|
||||||
default:
|
|
||||||
break
|
|
||||||
}
|
|
||||||
base = Base(textureName: "Base", team: nil, position: position)
|
|
||||||
entityManager.add(base)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func createNeighbourMapping() {
|
func createNeighbourMapping() {
|
||||||
|
@ -16,13 +16,6 @@ class GameScene: SKScene{
|
|||||||
|
|
||||||
override func sceneDidLoad() {
|
override func sceneDidLoad() {
|
||||||
entityManager = EntityManager(scene: self)
|
entityManager = EntityManager(scene: self)
|
||||||
entityManager.add(Base(textureName: "Base",
|
|
||||||
team: .team1 ,
|
|
||||||
position: CGPoint(x: self.size.width * 0.1, y: self.size.height / 2)))
|
|
||||||
|
|
||||||
entityManager.add(Base(textureName: "Base",
|
|
||||||
team: .team2 ,
|
|
||||||
position: CGPoint(x: self.size.width * 0.9, y: self.size.height / 2)))
|
|
||||||
entityManager.add(HUD(size: self.size))
|
entityManager.add(HUD(size: self.size))
|
||||||
initMap()
|
initMap()
|
||||||
createBackground()
|
createBackground()
|
||||||
|
Loading…
Reference in New Issue
Block a user