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 GameplayKit
|
||||
import GameKit
|
||||
|
||||
class Base: GKEntity {
|
||||
|
||||
var unitCount: Int
|
||||
var adjacencyList: Array<Base>
|
||||
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.adjacencyList = [Base]()
|
||||
self.changeOwnerShip = false
|
||||
self.ownerShipPlayer = player
|
||||
super.init()
|
||||
|
||||
addComponent(DefaultBaseComponent(texture: SKTexture(imageNamed: "Base"), position: position))
|
||||
@ -30,6 +33,7 @@ class Base: GKEntity {
|
||||
|
||||
func attackBase(base: Base, units:Int) -> [GKEntity]{
|
||||
base.changeOwnerShip = true
|
||||
base.ownerShipPlayer = self.ownerShipPlayer
|
||||
self.unitCount -= units
|
||||
base.unitCount += units
|
||||
return [self, base]
|
||||
|
@ -18,17 +18,27 @@ class Modal: GKEntity{
|
||||
switch modaltype{
|
||||
case .BaseDetails:
|
||||
addComponent(ModalBackgroundComponent(anchorPoint: anchorPoint))
|
||||
addComponent(ModalContentComponent(header: "Basis Information",
|
||||
addComponent(ModalContentComponent(
|
||||
header: "Basis Information",
|
||||
body: "Diese Basis enthält \(base.unitCount) Einheiten",
|
||||
footer: "",
|
||||
anchorPoint: anchorPoint))
|
||||
anchorPoint: anchorPoint
|
||||
)
|
||||
)
|
||||
case .BaseAttack:
|
||||
addComponent(ModalBackgroundComponent(anchorPoint: anchorPoint))
|
||||
addComponent(SliderComponent(width: 300, position: CGPoint(x: anchorPoint.x , y: anchorPoint.y - 80)))
|
||||
addComponent(ModalContentComponent(header: "Angriff",
|
||||
addComponent(SliderComponent(
|
||||
width: 300,
|
||||
position: CGPoint(x: anchorPoint.x , y: anchorPoint.y - 80)
|
||||
)
|
||||
)
|
||||
addComponent(ModalContentComponent(
|
||||
header: "Angriff",
|
||||
body: "Schicke \(unitCount / 2) Einheiten",
|
||||
footer: "",
|
||||
anchorPoint: anchorPoint))
|
||||
anchorPoint: anchorPoint
|
||||
)
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -8,6 +8,7 @@
|
||||
|
||||
import Foundation
|
||||
import SpriteKit
|
||||
import GameKit
|
||||
|
||||
class TwoPlayerDefaultTestMap: MapProtocol {
|
||||
|
||||
@ -24,6 +25,8 @@ class TwoPlayerDefaultTestMap: MapProtocol {
|
||||
// Create Bases
|
||||
let basePlayerOne = Base(
|
||||
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
|
||||
)
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user