Remove base details modal
This commit is contained in:
parent
0d8a134445
commit
afad3e808e
@ -8,8 +8,7 @@
|
|||||||
|
|
||||||
import GameplayKit
|
import GameplayKit
|
||||||
|
|
||||||
enum ModalType: String{
|
enum ModalType: String {
|
||||||
case BaseDetails
|
|
||||||
case BaseAttack
|
case BaseAttack
|
||||||
case BaseMoveOwnUnits
|
case BaseMoveOwnUnits
|
||||||
case PauseGame
|
case PauseGame
|
||||||
@ -52,10 +51,6 @@ class Modal: GKEntity{
|
|||||||
overlay.zPosition = 3
|
overlay.zPosition = 3
|
||||||
|
|
||||||
switch modaltype {
|
switch modaltype {
|
||||||
case .BaseDetails:
|
|
||||||
header = SKLabelNode(text: "Information")
|
|
||||||
body = SKLabelNode(text: "Diese Basis enthält \(base!.unitCount) Einheiten")
|
|
||||||
footer = SKLabelNode()
|
|
||||||
case .BaseAttack:
|
case .BaseAttack:
|
||||||
header = SKLabelNode(text: "Angriff")
|
header = SKLabelNode(text: "Angriff")
|
||||||
body = SKLabelNode(text: "Schicke \(unitCount / 2)\nEinheiten")
|
body = SKLabelNode(text: "Schicke \(unitCount / 2)\nEinheiten")
|
||||||
@ -92,10 +87,6 @@ class Modal: GKEntity{
|
|||||||
super.init()
|
super.init()
|
||||||
|
|
||||||
switch modaltype{
|
switch modaltype{
|
||||||
case .BaseDetails:
|
|
||||||
addComponent(ButtonComponent(textureName: "yellow_button04", text: "Zurück", position: CGPoint(x: anchorPoint.x , y: anchorPoint.y - 105), isEnabled: true, onButtonPress: {
|
|
||||||
EntityManager.gameEMInstance.removeModal()
|
|
||||||
}))
|
|
||||||
case .BaseAttack, .BaseMoveOwnUnits:
|
case .BaseAttack, .BaseMoveOwnUnits:
|
||||||
let text = (modaltype == .BaseAttack) ? "Angriff" : "Senden"
|
let text = (modaltype == .BaseAttack) ? "Angriff" : "Senden"
|
||||||
addComponent(SliderComponent(width: 300, position: CGPoint(x: anchorPoint.x , y: anchorPoint.y - 50)))
|
addComponent(SliderComponent(width: 300, position: CGPoint(x: anchorPoint.x , y: anchorPoint.y - 50)))
|
||||||
|
@ -50,12 +50,11 @@ class GameScene: SKScene{
|
|||||||
entityManager.getBasesByPlayer(for: GKLocalPlayer.local).forEach({base in
|
entityManager.getBasesByPlayer(for: GKLocalPlayer.local).forEach({base in
|
||||||
moveFireAndBase(base: base, touchLocation: base.position)
|
moveFireAndBase(base: base, touchLocation: base.position)
|
||||||
})
|
})
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
for entity in entityManager.entities {
|
for entity in entityManager.entities {
|
||||||
let spriteNode = entity.component(ofType: DefaultBaseComponent.self)?.spriteNode
|
if atPoint(touchLocation) == entity.component(ofType: DefaultBaseComponent.self)?.spriteNode {
|
||||||
//FIXME: this is confusing
|
entity.component(ofType: DefaultBaseComponent.self)?.spriteNode.touchesBegan(touches, with: event)
|
||||||
addBaseDetails(touchLocation: touchLocation, spriteNode: spriteNode, touches: touches, event: event, entity: entity)
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -80,21 +79,6 @@ class GameScene: SKScene{
|
|||||||
entityManager.getBackground()?.update(deltaTime: currentTime)
|
entityManager.getBackground()?.update(deltaTime: currentTime)
|
||||||
}
|
}
|
||||||
|
|
||||||
func addBaseDetails(touchLocation: CGPoint, spriteNode: SKNode?, touches: Set<UITouch>, event: UIEvent?, entity: GKEntity){
|
|
||||||
if atPoint(touchLocation) == spriteNode && !entityManager.isModal {
|
|
||||||
spriteNode?.touchesBegan(touches, with: event)
|
|
||||||
if let baseEntity = entity as? Base {
|
|
||||||
if baseEntity.ownershipPlayer == GKLocalPlayer.local {
|
|
||||||
entityManager.add(Modal(modaltype: .BaseDetails,
|
|
||||||
base: entity as? Base,
|
|
||||||
anchorPoint: CGPoint(x: self.size.width / 2 , y: self.size.height / 2),
|
|
||||||
gameScene: self,
|
|
||||||
currentDraggedBase: currentDraggedBase, touchLocation: touchLocation, collisionBase: collisionBase))
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func addAttackDetails(touchLocation: CGPoint){
|
func addAttackDetails(touchLocation: CGPoint){
|
||||||
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 {
|
||||||
|
Loading…
Reference in New Issue
Block a user