- added new asset questionmark

- added new Scene: RulesScene
- added button to menuScene to load RulesScene
- finished layout of RulesScene
- finished rules of Spielbeschreibung
This commit is contained in:
Chauntalle Schüle 2020-06-19 02:15:51 +02:00
parent dc3ef818df
commit e878016e4f
6 changed files with 426 additions and 1 deletions

View File

@ -45,6 +45,7 @@
AB21D7D5246C748A00B09CBA /* MapFactory.swift in Sources */ = {isa = PBXBuildFile; fileRef = AB21D7D4246C748A00B09CBA /* MapFactory.swift */; };
ABA03DA0244BD54F00A66916 /* Base.swift in Sources */ = {isa = PBXBuildFile; fileRef = ABA03D9F244BD54F00A66916 /* Base.swift */; };
ABC0C3732481509300387B8F /* MapUtils.swift in Sources */ = {isa = PBXBuildFile; fileRef = ABC0C3722481509300387B8F /* MapUtils.swift */; };
AE0C8E2F249BCC2A00996360 /* RulesScene.swift in Sources */ = {isa = PBXBuildFile; fileRef = AE0C8E2E249BCC2A00996360 /* RulesScene.swift */; };
C04783EE2468583F004961FB /* intro-music.mp3 in Resources */ = {isa = PBXBuildFile; fileRef = C04783ED2468583F004961FB /* intro-music.mp3 */; };
C04783F024685995004961FB /* SettingsScene.swift in Sources */ = {isa = PBXBuildFile; fileRef = C04783EF24685995004961FB /* SettingsScene.swift */; };
C05BB9C4247D890C00411249 /* SliderComponent.swift in Sources */ = {isa = PBXBuildFile; fileRef = C05BB9C3247D890C00411249 /* SliderComponent.swift */; };
@ -109,6 +110,7 @@
AB21D7D4246C748A00B09CBA /* MapFactory.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MapFactory.swift; sourceTree = "<group>"; };
ABA03D9F244BD54F00A66916 /* Base.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Base.swift; sourceTree = "<group>"; };
ABC0C3722481509300387B8F /* MapUtils.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MapUtils.swift; sourceTree = "<group>"; };
AE0C8E2E249BCC2A00996360 /* RulesScene.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = RulesScene.swift; sourceTree = "<group>"; };
C04783ED2468583F004961FB /* intro-music.mp3 */ = {isa = PBXFileReference; lastKnownFileType = audio.mp3; path = "intro-music.mp3"; sourceTree = "<group>"; };
C04783EF24685995004961FB /* SettingsScene.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SettingsScene.swift; sourceTree = "<group>"; };
C05BB9C3247D890C00411249 /* SliderComponent.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = SliderComponent.swift; sourceTree = "<group>"; };
@ -180,6 +182,7 @@
9E0E459624796262009817A6 /* GameCenterManager.swift */,
C04783EF24685995004961FB /* SettingsScene.swift */,
3EAD889424801B6A0048A10A /* RoundTimer.swift */,
AE0C8E2E249BCC2A00996360 /* RulesScene.swift */,
);
path = GoldWars;
sourceTree = "<group>";
@ -412,6 +415,7 @@
C064E9A8246C0EA50022B228 /* LabelNode.swift in Sources */,
3F745DF0246F48FC00CE7375 /* PlayerMoveType.swift in Sources */,
3EAD889524801B6A0048A10A /* RoundTimer.swift in Sources */,
AE0C8E2F249BCC2A00996360 /* RulesScene.swift in Sources */,
3E67854024728368007B9DE4 /* CElements.swift in Sources */,
ABA03DA0244BD54F00A66916 /* Base.swift in Sources */,
C064E9AC246C151F0022B228 /* Label.swift in Sources */,

View File

@ -0,0 +1,21 @@
{
"images" : [
{
"filename" : "yellow_questionmark.png",
"idiom" : "universal",
"scale" : "1x"
},
{
"idiom" : "universal",
"scale" : "2x"
},
{
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.9 KiB

View File

@ -15,13 +15,16 @@ class EntityManager {
static let gameEMInstance = EntityManager()
static let menuEMInstance = EntityManager()
static let settingsEMInstance = EntityManager()
static let rulesEMInstance = EntityManager()
var entities = Set<GKEntity>()
var scene: SKScene
var isModal: Bool
var isRules: Bool
private init() {
isModal = false
isRules = false
scene = SKScene.init()
}
@ -60,6 +63,19 @@ class EntityManager {
scene.addChild(hudEntitiy.blockWholeScreenPane)
}
if let rulesEntity = entity as? Rules {
scene.addChild(rulesEntity.header)
scene.addChild(rulesEntity.text1)
scene.addChild(rulesEntity.text2)
scene.addChild(rulesEntity.text3)
scene.addChild(rulesEntity.text4)
scene.addChild(rulesEntity.node1)
scene.addChild(rulesEntity.node2)
scene.addChild(rulesEntity.node3)
// scene.addChild(rulesEntity.overlay)
isRules = true
}
if let wayEntity = entity as? Way {
scene.addChild(wayEntity.localWayComponent)
}
@ -359,4 +375,26 @@ class EntityManager {
func updateTime(time: String) {
getHUD()?.roundTimerLabel.text = time
}
func removeRules(){
entities.forEach({entity in
if let rules = entity as? Rules {
rules.header.removeFromParent()
rules.text1.removeFromParent()
rules.text2.removeFromParent()
rules.text3.removeFromParent()
rules.text4.removeFromParent()
rules.node1.removeFromParent()
rules.node2.removeFromParent()
rules.node3.removeFromParent()
if let button = rules.component(ofType: ButtonComponent.self) {
button.buttonNode.removeFromParent()
}
self.remove(rules)
isRules = false
}
})
}
}

View File

@ -0,0 +1,353 @@
//
// RulesScene.swift
// GoldWars
//
// Created by Chauntalle Schüle on 18.06.20.
// Copyright © 2020 SP2. All rights reserved.
//
import SpriteKit
import GameplayKit
class RulesScene: SKScene {
var entityManager = EntityManager.rulesEMInstance
override func sceneDidLoad() {
entityManager.setScene(scene: self)
entityManager.add(Button(name: "backToMenuScene",
textureName: "yellow_questionmark",
text: "",
position: CGPoint(x: self.size.width - 50, y: self.size.height - 50),
onButtonPress: {
let scene = MenuScene(size: self.size)
self.loadScene(scene: scene)
}))
entityManager.add(Label(fontnamed: "Courier-Bold",
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)
)
entityManager.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.entityManager.removeRules()
self.entityManager.add(Rules(rulesScene: self, rulesCategory: .Spielbeschreibung))
}))
entityManager.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.entityManager.removeRules()
self.entityManager.add(Rules(rulesScene: self, rulesCategory: .Basen))
}))
entityManager.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.entityManager.removeRules()
self.entityManager.add(Rules(rulesScene: self, rulesCategory: .Einheiten))
}))
entityManager.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.entityManager.removeRules()
self.entityManager.add(Rules(rulesScene: self, rulesCategory: .Spielende))
}))
entityManager.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.entityManager.removeRules()
self.entityManager.add(Rules(rulesScene: self, rulesCategory: .Boost))
}))
entityManager.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.entityManager.removeRules()
self.entityManager.add(Rules(rulesScene: self, rulesCategory: .Achievements))
}))
entityManager.add(Background(size: self.size))
entityManager.add(Rules(rulesScene: self, rulesCategory: .Basen))
}
func loadScene(scene: SKScene) {
let transition = SKTransition.flipVertical(withDuration: 0.5)
entityManager.entities.removeAll()
self.view?.presentScene(scene, transition: transition)
}
override func update(_ currentTime: TimeInterval) {
if entityManager.entities.count != 0 {
entityManager.getBackground()!.update(deltaTime: currentTime)
}
}
}
enum RulesCategory: String{
case Spielbeschreibung
case Basen
case Spielende
case Achievements
case Einheiten
case Boost
}
class Rules: GKEntity {
var entityManager = EntityManager.menuEMInstance
//var rulesCategory: RulesCategory
var header: SKLabelNode
var text1: SKLabelNode
var text2: SKLabelNode
var text3: SKLabelNode
var text4: SKLabelNode
var node1: SKSpriteNode
var node2: SKSpriteNode
var node3: SKSpriteNode
init(rulesScene: RulesScene, rulesCategory: RulesCategory) {
switch rulesCategory {
case .Spielbeschreibung:
header = SKLabelNode(text: "Kurze Spielbeschreibung:")
text1 = SKLabelNode(text: "GoldWars ist ein strategisches, rundenbasiertes Kampfspiel.\nZwei Spieler treten gegeneinander an und versuchen ihre Basen zu erweitern. Dazu schickst du Einheiten auf eine neue Basis.")
text1.position = CGPoint(x: rulesScene.size.width * 0.5 + 50, y: rulesScene.size.height * 0.6 - 20)
text1.numberOfLines = 4
text1.preferredMaxLayoutWidth = 750
let texture = SKTexture(imageNamed:"yellow_boxTick")
node1 = SKSpriteNode(texture: texture, size: CGSize(width: 30.0, height: 30.0) )
node1.position = CGPoint(x: rulesScene.size.width * 0.5 - 200, y: rulesScene.size.height * 0.6 - 100)
node1.zPosition = 4
text2 = SKLabelNode(text: "30 Sekunden Zeit pro Runde")
text2.position = CGPoint(x: rulesScene.size.width * 0.5 + 25, y: rulesScene.size.height * 0.6 - 110)
node2 = SKSpriteNode(texture: texture, size: CGSize(width: 30.0, height: 30.0) )
node2.position = CGPoint(x: rulesScene.size.width * 0.5 - 200, y: rulesScene.size.height * 0.6 - 160)
node2.zPosition = 4
text3 = SKLabelNode(text: "20 Runden")
text3.position = CGPoint(x: rulesScene.size.width * 0.5 - 100, y: rulesScene.size.height * 0.6 - 170)
node3 = SKSpriteNode(texture: texture, size: CGSize(width: 30.0, height: 30.0) )
node3.position = CGPoint(x: rulesScene.size.width * 0.5 - 200, y: rulesScene.size.height * 0.6 - 220)
node3.zPosition = 4
text4 = SKLabelNode(text: "Nach jeder Runde kämpfen die\ngegnerischen Einheiten gegeneinander.\nWer die Basis eingenommen hat siehst\ndu an der Farbe der Basis.")
text4.position = CGPoint(x: rulesScene.size.width * 0.5 + 115, y: rulesScene.size.height * 0.2 + 10)
text4.numberOfLines = 4
case .Basen:
header = SKLabelNode(text: "Erklärung der Basen:")
text1 = SKLabelNode(text: "Initialisierung")
self.text1.position = CGPoint(x: rulesScene.size.width * 0.5 - 300 , y: rulesScene.size.height * 0.8 - 100)
self.text1.numberOfLines = 2
self.text1.preferredMaxLayoutWidth = 390
let texture = SKTexture(imageNamed:"yellow_boxTick")
node1 = SKSpriteNode(texture: texture, size: texture.size())
node1.setScale(2.4)
node1.position = CGPoint(x: rulesScene.size.width * 0.5 - 200, y: rulesScene.size.height * 0.6 - 100)
node1.zPosition = 4
text2 = SKLabelNode(text: "30 Sekunden Zeit pro Runde")
self.text2.position = CGPoint(x: rulesScene.size.width * 0.5 - 220, y: rulesScene.size.height * 0.8 - 100)
node2 = SKSpriteNode(texture: texture, size: CGSize(width: 30.0, height: 30.0) )
node2.position = CGPoint(x: rulesScene.size.width * 0.5 - 200, y: rulesScene.size.height * 0.6 - 100)
node2.zPosition = 4
text3 = SKLabelNode(text: "30 Sekunden Zeit pro Runde")
text3.position = CGPoint(x: rulesScene.size.width * 0.5 + 25, y: rulesScene.size.height * 0.6 - 110)
node3 = SKSpriteNode(texture: texture, size: CGSize(width: 30.0, height: 30.0) )
node3.position = CGPoint(x: rulesScene.size.width * 0.5 - 200, y: rulesScene.size.height * 0.6 - 160)
node3.zPosition = 4
text4 = SKLabelNode(text: "20 Runden")
text4.position = CGPoint(x: rulesScene.size.width * 0.5 - 100, y: rulesScene.size.height * 0.6 - 170)
case .Spielende:
header = SKLabelNode(text: "Erklärung des Spielendes:")
text1 = SKLabelNode(text: "Initialisierung")
self.text1.position = CGPoint(x: rulesScene.size.width * 0.5 - 300 , y: rulesScene.size.height * 0.8 - 100)
self.text1.numberOfLines = 2
self.text1.preferredMaxLayoutWidth = 390
let texture = SKTexture(imageNamed:"yellow_boxTick")
node1 = SKSpriteNode(texture: texture, size: texture.size())
node1.setScale(2.4)
node1.position = CGPoint(x: rulesScene.size.width * 0.5 - 200, y: rulesScene.size.height * 0.6 - 100)
node1.zPosition = 4
text2 = SKLabelNode(text: "wtf")
self.text2.position = CGPoint(x: rulesScene.size.width * 0.5 , y: rulesScene.size.height * 0.8 - 500)
node2 = SKSpriteNode(texture: texture, size: CGSize(width: 30.0, height: 30.0) )
node2.position = CGPoint(x: rulesScene.size.width * 0.5 - 200, y: rulesScene.size.height * 0.6 - 100)
node2.zPosition = 4
text3 = SKLabelNode(text: "30 Sekunden Zeit pro Runde")
text3.position = CGPoint(x: rulesScene.size.width * 0.5 + 25, y: rulesScene.size.height * 0.6 - 110)
node3 = SKSpriteNode(texture: texture, size: CGSize(width: 30.0, height: 30.0) )
node3.position = CGPoint(x: rulesScene.size.width * 0.5 - 200, y: rulesScene.size.height * 0.6 - 160)
node3.zPosition = 4
text4 = SKLabelNode(text: "20 Runden")
text4.position = CGPoint(x: rulesScene.size.width * 0.5 - 100, y: rulesScene.size.height * 0.6 - 170)
case .Achievements:
header = SKLabelNode(text: "Erklärung der Achievements:")
text1 = SKLabelNode(text: "Initialisierung")
self.text1.position = CGPoint(x: rulesScene.size.width * 0.5 - 300 , y: rulesScene.size.height * 0.8 - 100)
self.text1.numberOfLines = 2
self.text1.preferredMaxLayoutWidth = 390
let texture = SKTexture(imageNamed:"yellow_boxTick")
node1 = SKSpriteNode(texture: texture, size: texture.size())
node1.setScale(2.4)
node1.position = CGPoint(x: rulesScene.size.width * 0.5 - 200, y: rulesScene.size.height * 0.6 - 100)
node1.zPosition = 4
text2 = SKLabelNode(text: "wtf")
self.text2.position = CGPoint(x: rulesScene.size.width * 0.5 , y: rulesScene.size.height * 0.8 - 500)
node2 = SKSpriteNode(texture: texture, size: CGSize(width: 30.0, height: 30.0) )
node2.position = CGPoint(x: rulesScene.size.width * 0.5 - 200, y: rulesScene.size.height * 0.6 - 100)
node2.zPosition = 4
text3 = SKLabelNode(text: "30 Sekunden Zeit pro Runde")
text3.position = CGPoint(x: rulesScene.size.width * 0.5 + 25, y: rulesScene.size.height * 0.6 - 110)
node3 = SKSpriteNode(texture: texture, size: CGSize(width: 30.0, height: 30.0) )
node3.position = CGPoint(x: rulesScene.size.width * 0.5 - 200, y: rulesScene.size.height * 0.6 - 160)
node3.zPosition = 4
text4 = SKLabelNode(text: "20 Runden")
text4.position = CGPoint(x: rulesScene.size.width * 0.5 - 100, y: rulesScene.size.height * 0.6 - 170)
case .Einheiten:
header = SKLabelNode(text: "Erklärung der Einheiten:")
text1 = SKLabelNode(text: "Initialisierung")
self.text1.position = CGPoint(x: rulesScene.size.width * 0.5 - 300 , y: rulesScene.size.height * 0.8 - 100)
self.text1.numberOfLines = 2
self.text1.preferredMaxLayoutWidth = 390
let texture = SKTexture(imageNamed:"yellow_boxTick")
node1 = SKSpriteNode(texture: texture, size: texture.size())
node1.setScale(2.4)
node1.position = CGPoint(x: rulesScene.size.width * 0.5 - 200, y: rulesScene.size.height * 0.6 - 100)
node1.zPosition = 4
text2 = SKLabelNode(text: "wtf")
self.text2.position = CGPoint(x: rulesScene.size.width * 0.5 , y: rulesScene.size.height * 0.8 - 500)
node2 = SKSpriteNode(texture: texture, size: CGSize(width: 30.0, height: 30.0) )
node2.position = CGPoint(x: rulesScene.size.width * 0.5 - 200, y: rulesScene.size.height * 0.6 - 100)
node2.zPosition = 4
text3 = SKLabelNode(text: "30 Sekunden Zeit pro Runde")
text3.position = CGPoint(x: rulesScene.size.width * 0.5 + 25, y: rulesScene.size.height * 0.6 - 110)
node3 = SKSpriteNode(texture: texture, size: CGSize(width: 30.0, height: 30.0) )
node3.position = CGPoint(x: rulesScene.size.width * 0.5 - 200, y: rulesScene.size.height * 0.6 - 160)
node3.zPosition = 4
text4 = SKLabelNode(text: "20 Runden")
text4.position = CGPoint(x: rulesScene.size.width * 0.5 - 100, y: rulesScene.size.height * 0.6 - 170)
case .Boost:
header = SKLabelNode(text: "Erklärung der Boosts:")
text1 = SKLabelNode(text: "Initialisierung")
self.text1.position = CGPoint(x: rulesScene.size.width * 0.5 - 300 , y: rulesScene.size.height * 0.8 - 100)
self.text1.numberOfLines = 2
self.text1.preferredMaxLayoutWidth = 390
let texture = SKTexture(imageNamed:"yellow_boxTick")
node1 = SKSpriteNode(texture: texture, size: CGSize(width: 5.0, height: 5.0))
node1.position = CGPoint(x: rulesScene.size.width * 0.5 - 200, y: rulesScene.size.height * 0.6 - 100)
node1.zPosition = 4
text2 = SKLabelNode(text: "wtf")
self.text2.position = CGPoint(x: rulesScene.size.width * 0.5 , y: rulesScene.size.height * 0.8 - 500)
node2 = SKSpriteNode(texture: texture, size: CGSize(width: 30.0, height: 30.0) )
node2.position = CGPoint(x: rulesScene.size.width * 0.5 - 200, y: rulesScene.size.height * 0.6 - 100)
node2.zPosition = 4
text3 = SKLabelNode(text: "30 Sekunden Zeit pro Runde")
text3.position = CGPoint(x: rulesScene.size.width * 0.5 + 25, y: rulesScene.size.height * 0.6 - 110)
node3 = SKSpriteNode(texture: texture, size: CGSize(width: 30.0, height: 30.0) )
node3.position = CGPoint(x: rulesScene.size.width * 0.5 - 200, y: rulesScene.size.height * 0.6 - 160)
node3.zPosition = 4
text4 = SKLabelNode(text: "20 Runden")
text4.position = CGPoint(x: rulesScene.size.width * 0.5 - 100, y: rulesScene.size.height * 0.6 - 170)
}
self.header.position = CGPoint(x: rulesScene.size.width * 0.5 - 100 , y: rulesScene.size.height * 0.8)
self.header.fontName = "Courier-Bold"
self.header.fontColor = .black
self.header.fontSize = 30
self.header.zPosition = 5
self.text1.fontName = "Courier-Bold"
self.text1.fontColor = .black
self.text1.fontSize = 25
self.text1.zPosition = 5
self.text2.fontName = "Courier-Bold"
self.text2.fontColor = .black
self.text2.fontSize = 25
self.text2.zPosition = 5
self.text3.fontName = "Courier-Bold"
self.text3.fontColor = .black
self.text3.fontSize = 25
self.text3.zPosition = 5
self.text4.fontName = "Courier-Bold"
self.text4.fontColor = .black
self.text4.fontSize = 25
self.text4.zPosition = 5
super.init()
/* overlay = SKSpriteNode(color: UIColor.init(red: 0, green: 0, blue: 0, alpha: 0.7), size: menuScene.size)
overlay.anchorPoint = menuScene.anchorPoint
overlay.zPosition = 3 */
}
required init?(coder: NSCoder) {
fatalError("init(coder:) has not been implemented")
}
}

View File

@ -53,6 +53,15 @@ class MenuScene: SKScene {
GameCenterManager.sharedInstance.authUser()
}
}))
entityManager.add(Button(name: "regelwerkButton",
textureName: "yellow_questionmark",
text: "",
position: CGPoint(x: self.size.width - 50, y: self.size.height - 50),
onButtonPress: {
print("pressed button")
let scene = RulesScene(size: self.size)
self.loadScene(scene: scene)
}))
entityManager.add(Background(size: self.size))
entityManager.add(SpinningLogoEntity(position: CGPoint(x: midX, y: midY + 200)))