Adding Button to ModalEinheiten, you can now exit via Button and not anymore via Slider
This commit is contained in:
parent
a78b9269c0
commit
c14731dff6
@ -9,31 +9,38 @@
|
|||||||
import GameplayKit
|
import GameplayKit
|
||||||
|
|
||||||
class Modal: GKEntity{
|
class Modal: GKEntity{
|
||||||
|
|
||||||
var unitCount:Int
|
|
||||||
|
|
||||||
init(modaltype: ModalType, base: Base, anchorPoint: CGPoint) {
|
var unitCount:Int
|
||||||
unitCount = base.unitCount
|
var modalEntityManager: EntityManager
|
||||||
super.init()
|
|
||||||
switch modaltype{
|
init(modaltype: ModalType, base: Base, anchorPoint: CGPoint, entityManager: EntityManager) {
|
||||||
case .BaseDetails:
|
unitCount = base.unitCount
|
||||||
addComponent(ModalBackgroundComponent(anchorPoint: anchorPoint))
|
modalEntityManager = entityManager
|
||||||
addComponent(ModalContentComponent(header: "Basis Information",
|
super.init()
|
||||||
body: "Diese Basis enthält \(base.unitCount) Einheiten",
|
switch modaltype{
|
||||||
footer: "",
|
case .BaseDetails:
|
||||||
anchorPoint: anchorPoint))
|
addComponent(ModalBackgroundComponent(anchorPoint: anchorPoint))
|
||||||
case .BaseAttack:
|
addComponent(ModalContentComponent(header: "Basis Information", body: "Diese Basis enthält \(base.unitCount) Einheiten", footer: "", anchorPoint: anchorPoint))
|
||||||
addComponent(ModalBackgroundComponent(anchorPoint: anchorPoint))
|
case .BaseAttack:
|
||||||
addComponent(SliderComponent(width: 300, position: CGPoint(x: anchorPoint.x , y: anchorPoint.y - 80)))
|
addComponent(ModalBackgroundComponent(anchorPoint: anchorPoint))
|
||||||
addComponent(ModalContentComponent(header: "Angriff",
|
addComponent(SliderComponent(width: 300, position: CGPoint(x: anchorPoint.x , y: anchorPoint.y - 50)))
|
||||||
body: "Schicke \(unitCount / 2) Einheiten",
|
addComponent(ModalContentComponent(header: "Angriff", body: "Schicke \(unitCount / 2) Einheiten",
|
||||||
footer: "",
|
footer: "", anchorPoint: anchorPoint))
|
||||||
anchorPoint: anchorPoint))
|
addComponent(ButtonComponent(iconName: "", text: "Senden", position: CGPoint(x: anchorPoint.x , y: anchorPoint.y - 120), isEnabled: true, onButtonPress: {
|
||||||
}
|
self.removeModalEntities(entityManager: self.modalEntityManager)
|
||||||
}
|
}))
|
||||||
|
}
|
||||||
required init?(coder: NSCoder) {
|
}
|
||||||
fatalError("init(coder:) has not been implemented")
|
|
||||||
}
|
required init?(coder: NSCoder) {
|
||||||
|
fatalError("init(coder:) has not been implemented")
|
||||||
|
}
|
||||||
|
|
||||||
|
func removeModalEntities(entityManager: EntityManager){
|
||||||
|
for entity in entityManager.entities {
|
||||||
|
if entityManager.isModal && entity.isMember(of: Modal.self) {
|
||||||
|
entityManager.remove(entity)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -46,12 +46,12 @@ class GameScene: SKScene{
|
|||||||
if !(entityManager.getTeamByBase(base: currentDraggedBase!) == entityManager.getTeamByBase(base: base)){
|
if !(entityManager.getTeamByBase(base: currentDraggedBase!) == entityManager.getTeamByBase(base: base)){
|
||||||
entityManager.add(Modal(modaltype: .BaseAttack,
|
entityManager.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))
|
||||||
entityManager.update((currentDraggedBase?.attackBase(base: base, units: 100))!)
|
entityManager.update((currentDraggedBase?.attackBase(base: base, units: 100))!)
|
||||||
}else {
|
}else {
|
||||||
entityManager.add(Modal(modaltype: .BaseAttack,
|
entityManager.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))
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -60,15 +60,16 @@ class GameScene: SKScene{
|
|||||||
else {
|
else {
|
||||||
for entity in entityManager.entities {
|
for entity in entityManager.entities {
|
||||||
let spriteNode = entity.component(ofType: DefaultBaseComponent.self)?.spriteNode
|
let spriteNode = entity.component(ofType: DefaultBaseComponent.self)?.spriteNode
|
||||||
|
|
||||||
if entityManager.isModal && entity.isMember(of: Modal.self) {
|
if entityManager.isModal && entity.isMember(of: Modal.self) {
|
||||||
entityManager.remove(entity)
|
// entityManager.remove(entity)
|
||||||
for child in self.children {
|
for child in self.children {
|
||||||
if(child.name != "fire"){
|
if(child.name != "fire"){
|
||||||
child.alpha = 1
|
child.alpha = 1
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
if atPoint(touchLocation) == spriteNode && !entityManager.isModal {
|
if atPoint(touchLocation) == spriteNode && !entityManager.isModal {
|
||||||
spriteNode?.touchesBegan(touches, with: event)
|
spriteNode?.touchesBegan(touches, with: event)
|
||||||
@ -80,7 +81,7 @@ class GameScene: SKScene{
|
|||||||
}
|
}
|
||||||
entityManager.add(Modal(modaltype: .BaseDetails,
|
entityManager.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))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user