Merge branch '33-basisownership-anhand-des-gkplayers' into 'development'
Resolve "Basisownership anhand des GKPlayers" Closes #33 See merge request marcel.schwarz/software-projekt-2!54
This commit is contained in:
commit
3f73a6f64d
@ -8,17 +8,20 @@
|
|||||||
|
|
||||||
import SpriteKit
|
import SpriteKit
|
||||||
import GameplayKit
|
import GameplayKit
|
||||||
|
import GameKit
|
||||||
|
|
||||||
class Base: GKEntity {
|
class Base: GKEntity {
|
||||||
|
|
||||||
var unitCount: Int
|
var unitCount: Int
|
||||||
var adjacencyList: Array<Base>
|
var adjacencyList: Array<Base>
|
||||||
var changeOwnerShip: Bool
|
var changeOwnerShip: Bool
|
||||||
|
var ownerShipPlayer: GKPlayer?
|
||||||
|
|
||||||
init(position: CGPoint, team: Team! = nil) {
|
init(position: CGPoint, player: GKPlayer? = nil, team: Team? = nil) {
|
||||||
self.unitCount = 0
|
self.unitCount = 0
|
||||||
self.adjacencyList = [Base]()
|
self.adjacencyList = [Base]()
|
||||||
self.changeOwnerShip = false
|
self.changeOwnerShip = false
|
||||||
|
self.ownerShipPlayer = player
|
||||||
super.init()
|
super.init()
|
||||||
|
|
||||||
addComponent(DefaultBaseComponent(texture: SKTexture(imageNamed: "Base"), position: position))
|
addComponent(DefaultBaseComponent(texture: SKTexture(imageNamed: "Base"), position: position))
|
||||||
@ -30,6 +33,7 @@ class Base: GKEntity {
|
|||||||
|
|
||||||
func attackBase(base: Base, units:Int) -> [GKEntity]{
|
func attackBase(base: Base, units:Int) -> [GKEntity]{
|
||||||
base.changeOwnerShip = true
|
base.changeOwnerShip = true
|
||||||
|
base.ownerShipPlayer = self.ownerShipPlayer
|
||||||
self.unitCount -= units
|
self.unitCount -= units
|
||||||
base.unitCount += units
|
base.unitCount += units
|
||||||
return [self, base]
|
return [self, base]
|
||||||
|
@ -18,17 +18,27 @@ class Modal: GKEntity{
|
|||||||
switch modaltype{
|
switch modaltype{
|
||||||
case .BaseDetails:
|
case .BaseDetails:
|
||||||
addComponent(ModalBackgroundComponent(anchorPoint: anchorPoint))
|
addComponent(ModalBackgroundComponent(anchorPoint: anchorPoint))
|
||||||
addComponent(ModalContentComponent(header: "Basis Information",
|
addComponent(ModalContentComponent(
|
||||||
|
header: "Basis Information",
|
||||||
body: "Diese Basis enthält \(base.unitCount) Einheiten",
|
body: "Diese Basis enthält \(base.unitCount) Einheiten",
|
||||||
footer: "",
|
footer: "",
|
||||||
anchorPoint: anchorPoint))
|
anchorPoint: anchorPoint
|
||||||
|
)
|
||||||
|
)
|
||||||
case .BaseAttack:
|
case .BaseAttack:
|
||||||
addComponent(ModalBackgroundComponent(anchorPoint: anchorPoint))
|
addComponent(ModalBackgroundComponent(anchorPoint: anchorPoint))
|
||||||
addComponent(SliderComponent(width: 300, position: CGPoint(x: anchorPoint.x , y: anchorPoint.y - 80)))
|
addComponent(SliderComponent(
|
||||||
addComponent(ModalContentComponent(header: "Angriff",
|
width: 300,
|
||||||
|
position: CGPoint(x: anchorPoint.x , y: anchorPoint.y - 80)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
addComponent(ModalContentComponent(
|
||||||
|
header: "Angriff",
|
||||||
body: "Schicke \(unitCount / 2) Einheiten",
|
body: "Schicke \(unitCount / 2) Einheiten",
|
||||||
footer: "",
|
footer: "",
|
||||||
anchorPoint: anchorPoint))
|
anchorPoint: anchorPoint
|
||||||
|
)
|
||||||
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -8,6 +8,7 @@
|
|||||||
|
|
||||||
import Foundation
|
import Foundation
|
||||||
import SpriteKit
|
import SpriteKit
|
||||||
|
import GameKit
|
||||||
|
|
||||||
class TwoPlayerDefaultTestMap: MapProtocol {
|
class TwoPlayerDefaultTestMap: MapProtocol {
|
||||||
|
|
||||||
@ -24,6 +25,8 @@ class TwoPlayerDefaultTestMap: MapProtocol {
|
|||||||
// Create Bases
|
// Create Bases
|
||||||
let basePlayerOne = Base(
|
let basePlayerOne = Base(
|
||||||
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),
|
||||||
|
// ToDo: not final version. Better would be something like MatchmakingHelper.spieler1 but does not work yet
|
||||||
|
player: GKLocalPlayer.local,
|
||||||
team: .team1
|
team: .team1
|
||||||
)
|
)
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user