Merge branch '33-basisownership-anhand-des-gkplayers' into 'development'
Resolve "Basisownership anhand des GKPlayers" Closes #33 See merge request marcel.schwarz/software-projekt-2!60
This commit is contained in:
commit
d595cb4235
@ -8,6 +8,7 @@
|
||||
|
||||
import SpriteKit
|
||||
import GameplayKit
|
||||
import GameKit
|
||||
|
||||
class TeamComponent: GKComponent {
|
||||
let team: Team
|
||||
@ -29,6 +30,7 @@ class TeamComponent: GKComponent {
|
||||
}
|
||||
|
||||
self.team = team
|
||||
self.player = player
|
||||
super.init()
|
||||
}
|
||||
|
||||
|
@ -22,8 +22,8 @@ class Base: GKEntity {
|
||||
super.init()
|
||||
|
||||
addComponent(DefaultBaseComponent(texture: SKTexture(imageNamed: "Base"), position: position))
|
||||
if(team != nil){
|
||||
addComponent(TeamComponent(team: team!, position: position))
|
||||
if(team != nil && player != nil){
|
||||
addComponent(TeamComponent(team: team!, position: position, player: player!))
|
||||
self.unitCount = 500
|
||||
}
|
||||
}
|
||||
|
@ -8,6 +8,7 @@
|
||||
|
||||
import SpriteKit
|
||||
import GameplayKit
|
||||
import GameKit
|
||||
|
||||
class EntityManager {
|
||||
|
||||
|
@ -12,6 +12,8 @@ class Modal: GKEntity{
|
||||
|
||||
var unitCount:Int
|
||||
|
||||
var unitCount:Int
|
||||
|
||||
init(modaltype: ModalType, base: Base, anchorPoint: CGPoint, entityManager: EntityManager, gameScene: SKScene) {
|
||||
unitCount = base.unitCount
|
||||
super.init()
|
||||
|
@ -21,6 +21,7 @@ class TwoPlayerDefaultTestMap: MapProtocol {
|
||||
|
||||
func load() {
|
||||
|
||||
|
||||
// Create Bases
|
||||
let basePlayerOne = Base(
|
||||
position: CGPoint(x: self.size.width * 0.1, y: self.size.height / 2),
|
||||
@ -46,6 +47,7 @@ class TwoPlayerDefaultTestMap: MapProtocol {
|
||||
|
||||
let basePlayerTwo = Base(
|
||||
position: CGPoint(x: self.size.width * 0.9, y: self.size.height / 2),
|
||||
player: (!MatchmakingHelper.sharedInstance.isServer) ? GKLocalPlayer.local : MatchmakingHelper.sharedInstance.mpMatch?.players[0],
|
||||
team: .team2
|
||||
)
|
||||
|
||||
|
@ -33,7 +33,6 @@ class MatchmakingHelper: NSObject, GKMatchmakerViewControllerDelegate, GKMatchDe
|
||||
var viewController: UIViewController?
|
||||
var mpMatchStarted: Bool
|
||||
var isServer: Bool
|
||||
var spieler1: GKPlayer?
|
||||
var nameSpieler1 = ""
|
||||
var menusc: MenuScene?
|
||||
let localPlayer: GKLocalPlayer = GKLocalPlayer.local
|
||||
@ -154,13 +153,9 @@ class MatchmakingHelper: NSObject, GKMatchmakerViewControllerDelegate, GKMatchDe
|
||||
|
||||
if player == GKLocalPlayer.local {
|
||||
self.isServer = true
|
||||
self.spieler1 = player
|
||||
self.nameSpieler1 = self.spieler1!.displayName
|
||||
|
||||
} else {
|
||||
self.isServer = false
|
||||
}
|
||||
|
||||
self.delegate?.matchStarted()
|
||||
self.menusc!.loadScene(scene: GameScene(size: self.menusc!.size))
|
||||
})
|
||||
|
@ -8,6 +8,7 @@
|
||||
|
||||
import SpriteKit
|
||||
import GameplayKit
|
||||
import GameKit
|
||||
|
||||
class GameScene: SKScene{
|
||||
|
||||
@ -96,7 +97,7 @@ class GameScene: SKScene{
|
||||
body.text = "Schicke \( ((e.component(ofType: SliderComponent.self)?.sliderNode.getValue ?? 0) * CGFloat((e as! Modal).unitCount)).rounded(.up)) Einheiten "
|
||||
} }
|
||||
|
||||
let bases = entityManager.getBasesByTeam(for: .team1)
|
||||
let bases = entityManager.getBaseByPlayer(for: GKLocalPlayer.local)
|
||||
|
||||
for base in bases {
|
||||
if atPoint(touchLocation) == base.component(ofType: DefaultBaseComponent.self)?.spriteNode{
|
||||
|
Loading…
Reference in New Issue
Block a user