|
|
|
@ -20,7 +20,7 @@ class GameScene : SKScene {
|
|
|
|
|
.wolf: SpriteMeeple(imageNamed: AppImages.Wolf, size: CGSize(width: 100, height: 100), backgroundColor: Colors.MeepleP1!),
|
|
|
|
|
.leopard: SpriteMeeple(imageNamed: AppImages.Leopard, size: CGSize(width: 100, height: 100), backgroundColor: Colors.MeepleP1!),
|
|
|
|
|
.lion: SpriteMeeple(imageNamed: AppImages.Lion, size: CGSize(width: 100, height: 100), backgroundColor: Colors.MeepleP1!),
|
|
|
|
|
.tiger: SpriteMeeple(imageNamed: "", size: CGSize(width: 100, height: 100), backgroundColor: Colors.MeepleP1!),
|
|
|
|
|
.tiger: SpriteMeeple(imageNamed: AppImages.Tigger, size: CGSize(width: 100, height: 100), backgroundColor: Colors.MeepleP1!),
|
|
|
|
|
.elephant: SpriteMeeple(imageNamed: AppImages.Elephant, size: CGSize(width: 100, height: 100), backgroundColor: Colors.MeepleP1!),
|
|
|
|
|
],
|
|
|
|
|
.player2: [
|
|
|
|
@ -30,7 +30,7 @@ class GameScene : SKScene {
|
|
|
|
|
.wolf: SpriteMeeple(imageNamed: AppImages.Wolf, size: CGSize(width: 100, height: 100), backgroundColor: .blue, imageRotation: 180),
|
|
|
|
|
.leopard: SpriteMeeple(imageNamed: AppImages.Leopard, size: CGSize(width: 100, height: 100), backgroundColor: .blue, imageRotation: 180),
|
|
|
|
|
.lion: SpriteMeeple(imageNamed: AppImages.Lion, size: CGSize(width: 100, height: 100), backgroundColor: .blue, imageRotation: 180),
|
|
|
|
|
.tiger: SpriteMeeple(imageNamed: "", size: CGSize(width: 100, height: 100), backgroundColor: .blue, imageRotation: 180),
|
|
|
|
|
.tiger: SpriteMeeple(imageNamed: AppImages.Tigger, size: CGSize(width: 100, height: 100), backgroundColor: .blue, imageRotation: 180),
|
|
|
|
|
.elephant: SpriteMeeple(imageNamed: AppImages.Elephant, size: CGSize(width: 100, height: 100), backgroundColor: .blue, imageRotation: 180),
|
|
|
|
|
],
|
|
|
|
|
]
|
|
|
|
@ -51,32 +51,46 @@ class GameScene : SKScene {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
initializeBoard(game.board)
|
|
|
|
|
displayBoard(game.board)
|
|
|
|
|
//displayBoard(game.board)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func initializeBoard(_ board: Board) {
|
|
|
|
|
let player1Animals: [Animal] = [.rat, .cat, .dog, .wolf, .leopard, .lion, .tiger, .elephant]
|
|
|
|
|
let player2Animals: [Animal] = [.rat, .cat, .dog, .wolf, .leopard, .lion, .tiger, .elephant]
|
|
|
|
|
|
|
|
|
|
for (index, animal) in player1Animals.enumerated() {
|
|
|
|
|
pieces[.player1]?[animal]?.cellPosition = CGPoint(x: index, y: 0)
|
|
|
|
|
pieces[.player1]?[animal]?.cellPosition = CGPoint(x: index, y: 1)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
for (index, animal) in player2Animals.enumerated() {
|
|
|
|
|
pieces[.player2]?[animal]?.cellPosition = CGPoint(x: index, y: board.nbRows - 1)
|
|
|
|
|
pieces[.player2]?[animal]?.cellPosition = CGPoint(x: index, y: board.nbRows - 2)
|
|
|
|
|
}
|
|
|
|
|
let player1AnimalsLigne1: [Animal] = [.elephant, .wolf, .tiger, .rat]
|
|
|
|
|
let player1AnimalsLigne2: [Animal] = [.cat, .dog]
|
|
|
|
|
let player1AnimalsLigne3: [Animal] = [.leopard, .lion]
|
|
|
|
|
|
|
|
|
|
let player2AnimalsLigne1: [Animal] = [.elephant, .wolf, .tiger, .rat]
|
|
|
|
|
let player2AnimalsLigne2: [Animal] = [.cat, .dog]
|
|
|
|
|
let player2AnimalsLigne3: [Animal] = [.leopard, .lion]
|
|
|
|
|
|
|
|
|
|
for (index, animal) in player1AnimalsLigne1.enumerated() {
|
|
|
|
|
pieces[.player1]?[animal]?.cellPosition = CGPoint(x: index-3, y: -2)
|
|
|
|
|
pieces[.player1]?[animal]?.cellPosition = CGPoint(x: index, y: 1)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
func displayBoard(_ board: Board) {
|
|
|
|
|
for row in 0..<board.nbRows {
|
|
|
|
|
for col in 0..<board.nbColumns {
|
|
|
|
|
if let p = board.grid[row][col].piece, let sprite = pieces[p.owner]?[p.animal] {
|
|
|
|
|
sprite.cellPosition = CGPoint(x: row, y: col)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
for (index, animal) in player1AnimalsLigne2.enumerated() {
|
|
|
|
|
pieces[.player1]?[animal]?.cellPosition = CGPoint(x: index-3, y: -3)
|
|
|
|
|
pieces[.player1]?[animal]?.cellPosition = CGPoint(x: index, y: 1)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
for (index, animal) in player1AnimalsLigne3.enumerated() {
|
|
|
|
|
pieces[.player1]?[animal]?.cellPosition = CGPoint(x: index-3, y: -3)
|
|
|
|
|
pieces[.player1]?[animal]?.cellPosition = CGPoint(x: index, y: 1)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
for (index, animal) in player2AnimalsLigne1.enumerated() {
|
|
|
|
|
pieces[.player2]?[animal]?.cellPosition = CGPoint(x: index-3, y: 3)
|
|
|
|
|
pieces[.player2]?[animal]?.cellPosition = CGPoint(x: index, y: 1)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
for (index, animal) in player2AnimalsLigne2.enumerated() {
|
|
|
|
|
pieces[.player2]?[animal]?.cellPosition = CGPoint(x: index-3, y: 3)
|
|
|
|
|
pieces[.player2]?[animal]?.cellPosition = CGPoint(x: index, y: 1)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
for (index, animal) in player2AnimalsLigne3.enumerated() {
|
|
|
|
|
pieces[.player2]?[animal]?.cellPosition = CGPoint(x: index-3, y: 3)
|
|
|
|
|
pieces[.player2]?[animal]?.cellPosition = CGPoint(x: index, y: 1)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|