Merge branch 'revert-d595cb42' into 'development'

Revert "Merge branch '33-basisownership-anhand-des-gkplayers' into 'development'"

See merge request marcel.schwarz/software-projekt-2!67
This commit is contained in:
Aldin Duraki 2020-05-15 09:18:46 +00:00
commit 8b87dc59ad
7 changed files with 17 additions and 20 deletions

View File

@ -8,7 +8,6 @@
import SpriteKit import SpriteKit
import GameplayKit import GameplayKit
import GameKit
class TeamComponent: GKComponent { class TeamComponent: GKComponent {
let team: Team let team: Team
@ -30,7 +29,6 @@ class TeamComponent: GKComponent {
} }
self.team = team self.team = team
self.player = player
super.init() super.init()
} }

View File

@ -22,8 +22,8 @@ class Base: GKEntity {
super.init() super.init()
addComponent(DefaultBaseComponent(texture: SKTexture(imageNamed: "Base"), position: position)) addComponent(DefaultBaseComponent(texture: SKTexture(imageNamed: "Base"), position: position))
if(team != nil && player != nil){ if(team != nil){
addComponent(TeamComponent(team: team!, position: position, player: player!)) addComponent(TeamComponent(team: team!, position: position))
self.unitCount = 500 self.unitCount = 500
} }
} }

View File

@ -8,7 +8,6 @@
import SpriteKit import SpriteKit
import GameplayKit import GameplayKit
import GameKit
class EntityManager { class EntityManager {

View File

@ -9,8 +9,6 @@
import GameplayKit import GameplayKit
class Modal: GKEntity{ class Modal: GKEntity{
var unitCount:Int
var unitCount:Int var unitCount:Int

View File

@ -21,7 +21,6 @@ class TwoPlayerDefaultTestMap: MapProtocol {
func load() { func load() {
// 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),
@ -47,7 +46,6 @@ class TwoPlayerDefaultTestMap: MapProtocol {
let basePlayerTwo = Base( let basePlayerTwo = Base(
position: CGPoint(x: self.size.width * 0.9, y: self.size.height / 2), 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 team: .team2
) )

View File

@ -33,6 +33,7 @@ class MatchmakingHelper: NSObject, GKMatchmakerViewControllerDelegate, GKMatchDe
var viewController: UIViewController? var viewController: UIViewController?
var mpMatchStarted: Bool var mpMatchStarted: Bool
var isServer: Bool var isServer: Bool
var spieler1: GKPlayer?
var nameSpieler1 = "" var nameSpieler1 = ""
var menusc: MenuScene? var menusc: MenuScene?
let localPlayer: GKLocalPlayer = GKLocalPlayer.local let localPlayer: GKLocalPlayer = GKLocalPlayer.local
@ -153,9 +154,13 @@ class MatchmakingHelper: NSObject, GKMatchmakerViewControllerDelegate, GKMatchDe
if player == GKLocalPlayer.local { if player == GKLocalPlayer.local {
self.isServer = true self.isServer = true
self.spieler1 = player
self.nameSpieler1 = self.spieler1!.displayName
} else { } else {
self.isServer = false self.isServer = false
} }
self.delegate?.matchStarted() self.delegate?.matchStarted()
self.menusc!.loadScene(scene: GameScene(size: self.menusc!.size)) self.menusc!.loadScene(scene: GameScene(size: self.menusc!.size))
}) })

View File

@ -8,7 +8,6 @@
import SpriteKit import SpriteKit
import GameplayKit import GameplayKit
import GameKit
class GameScene: SKScene{ class GameScene: SKScene{
@ -23,20 +22,20 @@ class GameScene: SKScene{
entityManager.add(Background(size: self.size)) entityManager.add(Background(size: self.size))
initMap() initMap()
} }
func initMap() { func initMap() {
MapFactory(scene: self, entityManager: self.entityManager).loadMap(playerCount: 2) MapFactory(scene: self, entityManager: self.entityManager).loadMap(playerCount: 2)
} }
override func touchesEnded(_ touches: Set<UITouch>, with event: UIEvent?) { override func touchesEnded(_ touches: Set<UITouch>, with event: UIEvent?) {
guard let touch = touches.first else { guard let touch = touches.first else {
return return
} }
let touchLocation = touch.location(in: self) let touchLocation = touch.location(in: self)
if isMoveTouch{ if isMoveTouch{
isMoveTouch = false isMoveTouch = false
currentDraggedBase!.component(ofType: DefaultBaseComponent.self)?.spriteNode.position = currentDraggedBasePos currentDraggedBase!.component(ofType: DefaultBaseComponent.self)?.spriteNode.position = currentDraggedBasePos
currentDraggedBase!.component(ofType: TeamComponent.self)?.fire.position = currentDraggedBasePos currentDraggedBase!.component(ofType: TeamComponent.self)?.fire.position = currentDraggedBasePos
@ -77,9 +76,9 @@ class GameScene: SKScene{
} }
} }
} }
} }
override func touchesMoved(_ touches: Set<UITouch>, with event: UIEvent?) { override func touchesMoved(_ touches: Set<UITouch>, with event: UIEvent?) {
guard let touch = touches.first else { guard let touch = touches.first else {
return return
@ -97,7 +96,7 @@ class GameScene: SKScene{
body.text = "Schicke \( ((e.component(ofType: SliderComponent.self)?.sliderNode.getValue ?? 0) * CGFloat((e as! Modal).unitCount)).rounded(.up)) Einheiten " body.text = "Schicke \( ((e.component(ofType: SliderComponent.self)?.sliderNode.getValue ?? 0) * CGFloat((e as! Modal).unitCount)).rounded(.up)) Einheiten "
} } } }
let bases = entityManager.getBaseByPlayer(for: GKLocalPlayer.local) let bases = entityManager.getBasesByTeam(for: .team1)
for base in bases { for base in bases {
if atPoint(touchLocation) == base.component(ofType: DefaultBaseComponent.self)?.spriteNode{ if atPoint(touchLocation) == base.component(ofType: DefaultBaseComponent.self)?.spriteNode{
@ -106,7 +105,7 @@ class GameScene: SKScene{
currentDraggedBase = base currentDraggedBase = base
} }
isMoveTouch = true isMoveTouch = true
base.component(ofType: DefaultBaseComponent.self)?.spriteNode.position = touchLocation base.component(ofType: DefaultBaseComponent.self)?.spriteNode.position = touchLocation
base.component(ofType: TeamComponent.self)?.fire.position = touchLocation base.component(ofType: TeamComponent.self)?.fire.position = touchLocation
for adjacencyBase in base.adjacencyList { for adjacencyBase in base.adjacencyList {