resolved Merge conflicts

This commit is contained in:
Chauntalle Schüle 2020-05-17 21:09:38 +02:00
parent 9ec8158c4e
commit 7350654122
2 changed files with 23 additions and 23 deletions

View File

@ -12,7 +12,7 @@ class Modal: GKEntity{
var unitCount:Int var unitCount:Int
init(modaltype: ModalType, base: Base, anchorPoint: CGPoint, entityManager: EntityManager, gameScene: GameScene, currentDraggedBase: Base?, touchLocation: CGPoint) { init(modaltype: ModalType, base: Base, anchorPoint: CGPoint, gameScene: GameScene, currentDraggedBase: Base?, touchLocation: CGPoint) {
unitCount = base.unitCount unitCount = base.unitCount
super.init() super.init()
switch modaltype{ switch modaltype{
@ -20,7 +20,7 @@ class Modal: GKEntity{
addComponent(ModalBackgroundComponent(anchorPoint: anchorPoint)) addComponent(ModalBackgroundComponent(anchorPoint: anchorPoint))
addComponent(ModalContentComponent(header: "Basis Information", body: "Diese Basis enthält \(base.unitCount) Einheiten", footer: "", anchorPoint: anchorPoint)) addComponent(ModalContentComponent(header: "Basis Information", body: "Diese Basis enthält \(base.unitCount) Einheiten", footer: "", anchorPoint: anchorPoint))
addComponent(ButtonComponent(iconName: "", text: "Zurück", position: CGPoint(x: anchorPoint.x , y: anchorPoint.y - 120), isEnabled: true, onButtonPress: { addComponent(ButtonComponent(iconName: "", text: "Zurück", position: CGPoint(x: anchorPoint.x , y: anchorPoint.y - 120), isEnabled: true, onButtonPress: {
self.removeModalEntities(entityManager: entityManager, gameScene: gameScene) self.removeModalEntities(gameScene: gameScene)
})) }))
case .BaseAttack: case .BaseAttack:
addComponent(ModalBackgroundComponent(anchorPoint: anchorPoint)) addComponent(ModalBackgroundComponent(anchorPoint: anchorPoint))
@ -28,11 +28,11 @@ class Modal: GKEntity{
addComponent(ModalContentComponent(header: "Angriff", body: "Schicke \(unitCount / 2) Einheiten", addComponent(ModalContentComponent(header: "Angriff", body: "Schicke \(unitCount / 2) Einheiten",
footer: "", anchorPoint: anchorPoint)) footer: "", anchorPoint: anchorPoint))
addComponent(ButtonComponent(iconName: "", text: "Senden", position: CGPoint(x: anchorPoint.x , y: anchorPoint.y - 120), isEnabled: true, onButtonPress: { addComponent(ButtonComponent(iconName: "", text: "Senden", position: CGPoint(x: anchorPoint.x , y: anchorPoint.y - 120), isEnabled: true, onButtonPress: {
self.sendUnits(currentDraggedBase: currentDraggedBase, touchLocation: touchLocation, entityManager: entityManager, gameScene: gameScene) self.sendUnits(currentDraggedBase: currentDraggedBase, touchLocation: touchLocation, gameScene: gameScene)
self.removeModalEntities(entityManager: entityManager, gameScene: gameScene) self.removeModalEntities(gameScene: gameScene)
})) }))
addComponent(CancelBtnComponent(iconName: "", text: "", position: CGPoint(x: anchorPoint.x + 160, y: anchorPoint.y + 140), isEnabled: true, onButtonPress: { addComponent(CancelBtnComponent(iconName: "", text: "", position: CGPoint(x: anchorPoint.x + 160, y: anchorPoint.y + 140), isEnabled: true, onButtonPress: {
self.removeModalEntities(entityManager: entityManager, gameScene: gameScene) self.removeModalEntities(gameScene: gameScene)
})) }))
} }
} }
@ -41,10 +41,10 @@ class Modal: GKEntity{
fatalError("init(coder:) has not been implemented") fatalError("init(coder:) has not been implemented")
} }
func removeModalEntities(entityManager: EntityManager, gameScene: SKScene){ func removeModalEntities(gameScene: SKScene){
for entity in entityManager.entities { for entity in EntityManager.sharedInstance.entities {
if entityManager.isModal && entity.isMember(of: Modal.self) { if EntityManager.sharedInstance.isModal && entity.isMember(of: Modal.self) {
entityManager.remove(entity) EntityManager.sharedInstance.remove(entity)
} }
for child in gameScene.children { for child in gameScene.children {
if(child.name != "fire"){ if(child.name != "fire"){
@ -54,11 +54,11 @@ class Modal: GKEntity{
} }
} }
func sendUnits(currentDraggedBase: Base?, touchLocation: CGPoint, entityManager: EntityManager, gameScene: GameScene){ func sendUnits(currentDraggedBase: Base?, touchLocation: CGPoint, gameScene: GameScene){
for base in currentDraggedBase!.adjacencyList { for base in currentDraggedBase!.adjacencyList {
if gameScene.atPoint(touchLocation) == base.component(ofType: DefaultBaseComponent.self)?.spriteNode { if gameScene.atPoint(touchLocation) == base.component(ofType: DefaultBaseComponent.self)?.spriteNode {
if !(entityManager.getTeamByBase(base: currentDraggedBase!) == entityManager.getTeamByBase(base: base)){ if !(EntityManager.sharedInstance.getTeamByBase(base: currentDraggedBase!) == EntityManager.sharedInstance.getTeamByBase(base: base)){
entityManager.update((currentDraggedBase?.attackBase(base: base, units: Int(GameScene.sendUnits)))!) EntityManager.sharedInstance.update((currentDraggedBase?.attackBase(base: base, units: Int(GameScene.sendUnits)))!)
} }
} }
} }

View File

@ -43,7 +43,7 @@ class GameScene: SKScene{
addAttackDetails(touchLocation: touchLocation) addAttackDetails(touchLocation: touchLocation)
} }
else { else {
for entity in entityManager.entities { for entity in EntityManager.sharedInstance.entities {
let spriteNode = entity.component(ofType: DefaultBaseComponent.self)?.spriteNode let spriteNode = entity.component(ofType: DefaultBaseComponent.self)?.spriteNode
addBaseDetails(touchLocation: touchLocation, spriteNode: spriteNode, touches: touches, event: event, entity: entity) addBaseDetails(touchLocation: touchLocation, spriteNode: spriteNode, touches: touches, event: event, entity: entity)
@ -65,29 +65,29 @@ class GameScene: SKScene{
} }
checkSlider() checkSlider()
let bases = entityManager.getBasesByPlayer(for: GKLocalPlayer.local) let bases = EntityManager.sharedInstance.getBasesByPlayer(for: GKLocalPlayer.local)
checkBases(bases: bases, touchLocation: touchLocation) checkBases(bases: bases, touchLocation: touchLocation)
} }
override func update(_ currentTime: TimeInterval) { override func update(_ currentTime: TimeInterval) {
entityManager.getBackground()?.update(deltaTime: currentTime) EntityManager.sharedInstance.getBackground()?.update(deltaTime: currentTime)
entityManager.getHUD()?.component(ofType: TimerComponent.self)?.update() EntityManager.sharedInstance.getHUD()?.component(ofType: TimerComponent.self)?.update()
} }
func addBaseDetails(touchLocation: CGPoint, spriteNode: SKNode?, touches: Set<UITouch>, event: UIEvent?, entity: GKEntity){ func addBaseDetails(touchLocation: CGPoint, spriteNode: SKNode?, touches: Set<UITouch>, event: UIEvent?, entity: GKEntity){
if atPoint(touchLocation) == spriteNode && !entityManager.isModal { if atPoint(touchLocation) == spriteNode && !EntityManager.sharedInstance.isModal {
spriteNode?.touchesBegan(touches, with: event) spriteNode?.touchesBegan(touches, with: event)
if !entityManager.isModal { if !EntityManager.sharedInstance.isModal {
for child in self.children { for child in self.children {
if(child.name != "fire"){ if(child.name != "fire"){
child.alpha = 0.3 child.alpha = 0.3
} }
} }
entityManager.add(Modal(modaltype: .BaseDetails, EntityManager.sharedInstance.add(Modal(modaltype: .BaseDetails,
base: entity as! Base, base: entity as! Base,
anchorPoint: CGPoint(x: self.size.width / 2 , y: self.size.height / 2), anchorPoint: CGPoint(x: self.size.width / 2 , y: self.size.height / 2),
entityManager: entityManager, gameScene: self, currentDraggedBase: currentDraggedBase, touchLocation: touchLocation)) gameScene: self, currentDraggedBase: currentDraggedBase, touchLocation: touchLocation))
} }
} }
} }
@ -96,16 +96,16 @@ class GameScene: SKScene{
for base in currentDraggedBase!.adjacencyList { for base in currentDraggedBase!.adjacencyList {
if atPoint(touchLocation) == base.component(ofType: DefaultBaseComponent.self)?.spriteNode { if atPoint(touchLocation) == base.component(ofType: DefaultBaseComponent.self)?.spriteNode {
// TODO: change interaction based on collision instead of touchlocation // TODO: change interaction based on collision instead of touchlocation
entityManager.add(Modal(modaltype: .BaseAttack, EntityManager.sharedInstance.add(Modal(modaltype: .BaseAttack,
base: currentDraggedBase!, base: currentDraggedBase!,
anchorPoint: CGPoint(x: self.size.width / 2 , y: self.size.height / 2), anchorPoint: CGPoint(x: self.size.width / 2 , y: self.size.height / 2),
entityManager: entityManager, gameScene: self, currentDraggedBase: currentDraggedBase, touchLocation: touchLocation)) gameScene: self, currentDraggedBase: currentDraggedBase, touchLocation: touchLocation))
} }
} }
} }
func checkSlider(){ func checkSlider(){
for e in entityManager.entities{ for e in EntityManager.sharedInstance.entities{
if let body = e.component(ofType: ModalContentComponent.self)?.body{ if let body = e.component(ofType: ModalContentComponent.self)?.body{
GameScene.sendUnits = ((e.component(ofType: SliderComponent.self)?.sliderNode.getValue ?? 0) * CGFloat((e as! Modal).unitCount)).rounded(.up) GameScene.sendUnits = ((e.component(ofType: SliderComponent.self)?.sliderNode.getValue ?? 0) * CGFloat((e as! Modal).unitCount)).rounded(.up)
body.text = "Schicke \(GameScene.sendUnits) Einheiten " body.text = "Schicke \(GameScene.sendUnits) Einheiten "