Remove unnecessary complexity, Reformat code
This commit is contained in:
parent
a52e4cd8d1
commit
9a041c7310
@ -67,10 +67,6 @@ class EntityManager {
|
|||||||
scene.addChild(spinningLogoEntity.warsLetteringNode)
|
scene.addChild(spinningLogoEntity.warsLetteringNode)
|
||||||
}
|
}
|
||||||
|
|
||||||
if let rulesEntity = entity as? Rules {
|
|
||||||
scene.addChild(rulesEntity.image)
|
|
||||||
}
|
|
||||||
|
|
||||||
if let wayEntity = entity as? Way {
|
if let wayEntity = entity as? Way {
|
||||||
scene.addChild(wayEntity.localWayComponent)
|
scene.addChild(wayEntity.localWayComponent)
|
||||||
}
|
}
|
||||||
@ -370,17 +366,4 @@ class EntityManager {
|
|||||||
func updateTime(time: String) {
|
func updateTime(time: String) {
|
||||||
getHUD()?.roundTimerLabel.text = time
|
getHUD()?.roundTimerLabel.text = time
|
||||||
}
|
}
|
||||||
|
|
||||||
func removeRules(){
|
|
||||||
entities.forEach({entity in
|
|
||||||
if let rules = entity as? Rules {
|
|
||||||
rules.image.removeFromParent()
|
|
||||||
|
|
||||||
if let button = rules.component(ofType: ButtonComponent.self) {
|
|
||||||
button.buttonNode.removeFromParent()
|
|
||||||
}
|
|
||||||
self.remove(rules)
|
|
||||||
}
|
|
||||||
})
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -11,83 +11,95 @@ import GameplayKit
|
|||||||
|
|
||||||
class RulesScene: SKScene {
|
class RulesScene: SKScene {
|
||||||
|
|
||||||
|
var image: SKSpriteNode?
|
||||||
|
|
||||||
override func sceneDidLoad() {
|
override func sceneDidLoad() {
|
||||||
EntityManager.rulesEMInstance.setScene(scene: self)
|
EntityManager.rulesEMInstance.setScene(scene: self)
|
||||||
EntityManager.rulesEMInstance.add(Button(name: "backToMenuScene",
|
EntityManager.rulesEMInstance.add(
|
||||||
textureName: "questionmark",
|
Button(name: "backToMenuScene",
|
||||||
text: "",
|
textureName: "questionmark",
|
||||||
position: CGPoint(x: self.size.width - 50, y: self.size.height - 50),
|
text: "",
|
||||||
onButtonPress: {
|
position: CGPoint(x: self.size.width - 50, y: self.size.height - 50),
|
||||||
let scene = MenuScene(size: self.size)
|
onButtonPress: {
|
||||||
self.loadScene(scene: scene)
|
EntityManager.rulesEMInstance.entities.removeAll()
|
||||||
}))
|
self.view?.presentScene(
|
||||||
EntityManager.rulesEMInstance.add(Label(fontnamed: "Courier-Bold",
|
MenuScene(size: self.size),
|
||||||
name: "rulesLabel",
|
transition: SKTransition.flipVertical(withDuration: 0.5)
|
||||||
text: "Regelwerk",
|
)
|
||||||
fontSize: 90,
|
}
|
||||||
fontColor: .black,
|
)
|
||||||
position: CGPoint(x: self.size.width * 0.5, y: self.size.height - 100),
|
)
|
||||||
horizontalAlignmentMode: .center,
|
|
||||||
vertikalAligmentMode: .baseline,
|
EntityManager.rulesEMInstance.add(
|
||||||
isAnimationEnabled: true,
|
Label(fontnamed: "Courier-Bold",
|
||||||
isAnimationInfinite: true)
|
name: "rulesLabel",
|
||||||
|
text: "Regelwerk",
|
||||||
|
fontSize: 90,
|
||||||
|
fontColor: .black,
|
||||||
|
position: CGPoint(x: self.size.width * 0.5, y: self.size.height - 100),
|
||||||
|
horizontalAlignmentMode: .center,
|
||||||
|
vertikalAligmentMode: .baseline,
|
||||||
|
isAnimationEnabled: true,
|
||||||
|
isAnimationInfinite: true
|
||||||
|
)
|
||||||
|
)
|
||||||
|
|
||||||
|
image = SKSpriteNode(imageNamed: "RulesSpiel")
|
||||||
|
image!.size = CGSize(width: size.width * 0.8, height: size.height * 0.8)
|
||||||
|
image!.position = CGPoint(x: size.width * 0.6, y: size.height * 0.6 - 150)
|
||||||
|
image!.zPosition = 4
|
||||||
|
|
||||||
|
self.addChild(image!)
|
||||||
|
|
||||||
|
EntityManager.rulesEMInstance.add(
|
||||||
|
Button(name: "Spiel",
|
||||||
|
textureName: "yellow_button13",
|
||||||
|
text: "Spiel",
|
||||||
|
position: CGPoint(x: self.size.width * 0.1, y: self.size.height * 0.5 + 150),
|
||||||
|
onButtonPress: { self.image!.texture = SKTexture(imageNamed: "RulesSpiel") }
|
||||||
|
)
|
||||||
|
)
|
||||||
|
EntityManager.rulesEMInstance.add(
|
||||||
|
Button(name: "Basen",
|
||||||
|
textureName: "yellow_button13",
|
||||||
|
text: "Basen",
|
||||||
|
position: CGPoint(x: self.size.width * 0.1, y: self.size.height * 0.5 + 85),
|
||||||
|
onButtonPress: { self.image!.texture = SKTexture(imageNamed: "RulesBasen") }
|
||||||
|
)
|
||||||
|
)
|
||||||
|
EntityManager.rulesEMInstance.add(
|
||||||
|
Button(name: "Einheiten",
|
||||||
|
textureName: "yellow_button13",
|
||||||
|
text: "Einheiten",
|
||||||
|
position: CGPoint(x: self.size.width * 0.1, y: self.size.height * 0.5 + 20),
|
||||||
|
onButtonPress: { self.image!.texture = SKTexture(imageNamed: "RulesEinheiten") }
|
||||||
|
)
|
||||||
|
)
|
||||||
|
EntityManager.rulesEMInstance.add(
|
||||||
|
Button(name: "Spielende",
|
||||||
|
textureName: "yellow_button13",
|
||||||
|
text: "Spielende",
|
||||||
|
position: CGPoint(x: self.size.width * 0.1, y: self.size.height * 0.5 - 45),
|
||||||
|
onButtonPress: { self.image!.texture = SKTexture(imageNamed: "RulesSpielende") }
|
||||||
|
)
|
||||||
|
)
|
||||||
|
EntityManager.rulesEMInstance.add(
|
||||||
|
Button(name: "Boost",
|
||||||
|
textureName: "yellow_button13",
|
||||||
|
text: "Boost",
|
||||||
|
position: CGPoint(x: self.size.width * 0.1, y: self.size.height * 0.5 - 110),
|
||||||
|
onButtonPress: { self.image!.texture = SKTexture(imageNamed: "RulesBoost") }
|
||||||
|
)
|
||||||
|
)
|
||||||
|
EntityManager.rulesEMInstance.add(
|
||||||
|
Button(name: "Erfolge",
|
||||||
|
textureName: "yellow_button13",
|
||||||
|
text: "Erfolge",
|
||||||
|
position: CGPoint(x: self.size.width * 0.1, y: self.size.height * 0.5 - 175),
|
||||||
|
onButtonPress: { self.image!.texture = SKTexture(imageNamed: "RulesErfolge") }
|
||||||
|
)
|
||||||
)
|
)
|
||||||
EntityManager.rulesEMInstance.add(Button(name: "Spiel",
|
|
||||||
textureName: "yellow_button13",
|
|
||||||
text: "Spiel",
|
|
||||||
position: CGPoint(x: self.size.width * 0.1, y: self.size.height * 0.5 + 150),
|
|
||||||
onButtonPress: {
|
|
||||||
EntityManager.rulesEMInstance.removeRules()
|
|
||||||
EntityManager.rulesEMInstance.add(Rules(rulesScene: self, textureName: "RulesSpiel"))
|
|
||||||
}))
|
|
||||||
EntityManager.rulesEMInstance.add(Button(name: "Basen",
|
|
||||||
textureName: "yellow_button13",
|
|
||||||
text: "Basen",
|
|
||||||
position: CGPoint(x: self.size.width * 0.1, y: self.size.height * 0.5 + 85),
|
|
||||||
onButtonPress: {
|
|
||||||
EntityManager.rulesEMInstance.removeRules()
|
|
||||||
EntityManager.rulesEMInstance.add(Rules(rulesScene: self, textureName: "RulesBasen"))
|
|
||||||
}))
|
|
||||||
EntityManager.rulesEMInstance.add(Button(name: "Einheiten",
|
|
||||||
textureName: "yellow_button13",
|
|
||||||
text: "Einheiten",
|
|
||||||
position: CGPoint(x: self.size.width * 0.1, y: self.size.height * 0.5 + 20),
|
|
||||||
onButtonPress: {
|
|
||||||
EntityManager.rulesEMInstance.removeRules()
|
|
||||||
EntityManager.rulesEMInstance.add(Rules(rulesScene: self, textureName: "RulesEinheiten"))
|
|
||||||
}))
|
|
||||||
EntityManager.rulesEMInstance.add(Button(name: "Spielende",
|
|
||||||
textureName: "yellow_button13",
|
|
||||||
text: "Spielende",
|
|
||||||
position: CGPoint(x: self.size.width * 0.1, y: self.size.height * 0.5 - 45),
|
|
||||||
onButtonPress: {
|
|
||||||
EntityManager.rulesEMInstance.removeRules()
|
|
||||||
EntityManager.rulesEMInstance.add(Rules(rulesScene: self, textureName: "RulesSpielende"))
|
|
||||||
}))
|
|
||||||
EntityManager.rulesEMInstance.add(Button(name: "Boost",
|
|
||||||
textureName: "yellow_button13",
|
|
||||||
text: "Boost",
|
|
||||||
position: CGPoint(x: self.size.width * 0.1, y: self.size.height * 0.5 - 110),
|
|
||||||
onButtonPress: {
|
|
||||||
EntityManager.rulesEMInstance.removeRules()
|
|
||||||
EntityManager.rulesEMInstance.add(Rules(rulesScene: self, textureName: "RulesBoost"))
|
|
||||||
}))
|
|
||||||
EntityManager.rulesEMInstance.add(Button(name: "Erfolge",
|
|
||||||
textureName: "yellow_button13",
|
|
||||||
text: "Erfolge",
|
|
||||||
position: CGPoint(x: self.size.width * 0.1, y: self.size.height * 0.5 - 175),
|
|
||||||
onButtonPress: {
|
|
||||||
EntityManager.rulesEMInstance.removeRules()
|
|
||||||
EntityManager.rulesEMInstance.add(Rules(rulesScene: self, textureName: "RulesErfolge"))
|
|
||||||
}))
|
|
||||||
EntityManager.rulesEMInstance.add(Background(size: self.size))
|
EntityManager.rulesEMInstance.add(Background(size: self.size))
|
||||||
EntityManager.rulesEMInstance.add(Rules(rulesScene: self, textureName: "RulesSpiel"))
|
|
||||||
}
|
|
||||||
|
|
||||||
func loadScene(scene: SKScene) {
|
|
||||||
let transition = SKTransition.flipVertical(withDuration: 0.5)
|
|
||||||
EntityManager.rulesEMInstance.entities.removeAll()
|
|
||||||
self.view?.presentScene(scene, transition: transition)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
override func update(_ currentTime: TimeInterval) {
|
override func update(_ currentTime: TimeInterval) {
|
||||||
@ -96,20 +108,3 @@ class RulesScene: SKScene {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
class Rules: GKEntity {
|
|
||||||
|
|
||||||
var image: SKSpriteNode
|
|
||||||
|
|
||||||
init(rulesScene: RulesScene, textureName: String) {
|
|
||||||
let texture = SKTexture(imageNamed: textureName)
|
|
||||||
image = SKSpriteNode(texture: texture, size: CGSize(width: rulesScene.size.width * 0.8, height: rulesScene.size.height * 0.8))
|
|
||||||
image.position = CGPoint(x: rulesScene.size.width * 0.6, y: rulesScene.size.height * 0.6 - 150)
|
|
||||||
image.zPosition = 4
|
|
||||||
super.init()
|
|
||||||
}
|
|
||||||
|
|
||||||
required init?(coder: NSCoder) {
|
|
||||||
fatalError("init(coder:) has not been implemented")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
Loading…
Reference in New Issue
Block a user