diff --git a/GoldWars/.idea/.gitignore b/GoldWars/.idea/.gitignore
new file mode 100644
index 0000000..73f69e0
--- /dev/null
+++ b/GoldWars/.idea/.gitignore
@@ -0,0 +1,8 @@
+# Default ignored files
+/shelf/
+/workspace.xml
+# Datasource local storage ignored files
+/dataSources/
+/dataSources.local.xml
+# Editor-based HTTP Client requests
+/httpRequests/
diff --git a/GoldWars/.idea/GoldWars.iml b/GoldWars/.idea/GoldWars.iml
new file mode 100644
index 0000000..74121dc
--- /dev/null
+++ b/GoldWars/.idea/GoldWars.iml
@@ -0,0 +1,2 @@
+
+
\ No newline at end of file
diff --git a/GoldWars/.idea/misc.xml b/GoldWars/.idea/misc.xml
new file mode 100644
index 0000000..28a804d
--- /dev/null
+++ b/GoldWars/.idea/misc.xml
@@ -0,0 +1,6 @@
+
+
+
+
+
+
\ No newline at end of file
diff --git a/GoldWars/.idea/modules.xml b/GoldWars/.idea/modules.xml
new file mode 100644
index 0000000..3bd1ffb
--- /dev/null
+++ b/GoldWars/.idea/modules.xml
@@ -0,0 +1,8 @@
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/GoldWars/.idea/runConfigurations/GoldWars.xml b/GoldWars/.idea/runConfigurations/GoldWars.xml
new file mode 100644
index 0000000..447b8da
--- /dev/null
+++ b/GoldWars/.idea/runConfigurations/GoldWars.xml
@@ -0,0 +1,11 @@
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/GoldWars/.idea/vcs.xml b/GoldWars/.idea/vcs.xml
new file mode 100644
index 0000000..6c0b863
--- /dev/null
+++ b/GoldWars/.idea/vcs.xml
@@ -0,0 +1,6 @@
+
+
+
+
+
+
\ No newline at end of file
diff --git a/GoldWars/.idea/xcode.xml b/GoldWars/.idea/xcode.xml
new file mode 100644
index 0000000..62ab3fc
--- /dev/null
+++ b/GoldWars/.idea/xcode.xml
@@ -0,0 +1,4 @@
+
+
+
+
\ No newline at end of file
diff --git a/GoldWars/GoldWars.xcodeproj/project.pbxproj b/GoldWars/GoldWars.xcodeproj/project.pbxproj
index b532d49..481812b 100644
--- a/GoldWars/GoldWars.xcodeproj/project.pbxproj
+++ b/GoldWars/GoldWars.xcodeproj/project.pbxproj
@@ -45,6 +45,8 @@
9EC7E48B2461FBF700396BCD /* SliderNode.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9EC7E48A2461FBF700396BCD /* SliderNode.swift */; };
9EC86B9F245C88A300796EF3 /* Modal.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9EC86B9E245C88A300796EF3 /* Modal.swift */; };
9EC86BA6245C8AD000796EF3 /* ModalType.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9EC86BA5245C8AD000796EF3 /* ModalType.swift */; };
+ 9EEDE02D246FCD770096C735 /* SpinningLogoEntity.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9EEDE02C246FCD770096C735 /* SpinningLogoEntity.swift */; };
+ 9EEDE02F246FCD800096C735 /* SpinningLogoComponent.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9EEDE02E246FCD800096C735 /* SpinningLogoComponent.swift */; };
AB1D759C245DD18100671525 /* MapProtocol.swift in Sources */ = {isa = PBXBuildFile; fileRef = AB1D759A245DD18100671525 /* MapProtocol.swift */; };
AB1D759D245DD18100671525 /* TwoPlayerDefaultTestMap.swift in Sources */ = {isa = PBXBuildFile; fileRef = AB1D759B245DD18100671525 /* TwoPlayerDefaultTestMap.swift */; };
AB1D75A0245DEC0500671525 /* MapFactory.swift in Sources */ = {isa = PBXBuildFile; fileRef = AB1D759F245DEC0500671525 /* MapFactory.swift */; };
@@ -113,6 +115,8 @@
9EC86B9E245C88A300796EF3 /* Modal.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Modal.swift; sourceTree = ""; };
9EC86BA5245C8AD000796EF3 /* ModalType.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ModalType.swift; sourceTree = ""; };
9ECD3699245C91F7008DEEBD /* GoldWars.entitlements */ = {isa = PBXFileReference; lastKnownFileType = text.plist.entitlements; path = GoldWars.entitlements; sourceTree = ""; };
+ 9EEDE02C246FCD770096C735 /* SpinningLogoEntity.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = SpinningLogoEntity.swift; sourceTree = ""; };
+ 9EEDE02E246FCD800096C735 /* SpinningLogoComponent.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = SpinningLogoComponent.swift; sourceTree = ""; };
AB1D759A245DD18100671525 /* MapProtocol.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = MapProtocol.swift; sourceTree = ""; };
AB1D759B245DD18100671525 /* TwoPlayerDefaultTestMap.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = TwoPlayerDefaultTestMap.swift; sourceTree = ""; };
AB1D759F245DEC0500671525 /* MapFactory.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MapFactory.swift; sourceTree = ""; };
@@ -207,6 +211,7 @@
116060F4245C56EA004E5A36 /* Components */ = {
isa = PBXGroup;
children = (
+ 9EEDE02E246FCD800096C735 /* SpinningLogoComponent.swift */,
9E174C81245DD81D00209FF0 /* ButtonNode.swift */,
9EA3ABE8245C6DAA006BC61D /* DefaultBaseComponent.swift */,
9EA3ABEC245C8143006BC61D /* ModalBackgroundComponent.swift */,
@@ -229,6 +234,7 @@
116060F5245C5709004E5A36 /* Entities */ = {
isa = PBXGroup;
children = (
+ 9EEDE02C246FCD770096C735 /* SpinningLogoEntity.swift */,
ABA03D9F244BD54F00A66916 /* Base.swift */,
9EC86B9E245C88A300796EF3 /* Modal.swift */,
116060F6245C57D2004E5A36 /* EntityManager.swift */,
@@ -415,6 +421,7 @@
3EBD242E245D9332003CECE7 /* Team.swift in Sources */,
9E174C88245DF1FF00209FF0 /* BackgroundComponent.swift in Sources */,
9E78ACBA245CBDAF00526FF7 /* HUD.swift in Sources */,
+ 9EEDE02D246FCD770096C735 /* SpinningLogoEntity.swift in Sources */,
11738A3B24508F68004426F1 /* Unit.swift in Sources */,
9E174C86245DD91500209FF0 /* ButtonComponent.swift in Sources */,
AE151589245F18EF001D363E /* MatchmakingHelper.swift in Sources */,
@@ -434,6 +441,7 @@
C064E9AC246C151F0022B228 /* Label.swift in Sources */,
9E174C82245DD81D00209FF0 /* ButtonNode.swift in Sources */,
9EC7E48B2461FBF700396BCD /* SliderNode.swift in Sources */,
+ 9EEDE02F246FCD800096C735 /* SpinningLogoComponent.swift in Sources */,
9E174C84245DD8CE00209FF0 /* Button.swift in Sources */,
110360DB244B101A008610AF /* GameViewController.swift in Sources */,
2086465C2461B66200817C23 /* TimerComponent.swift in Sources */,
diff --git a/GoldWars/GoldWars/Assets.xcassets/logo_kante.imageset/Contents.json b/GoldWars/GoldWars/Assets.xcassets/logo_kante.imageset/Contents.json
new file mode 100644
index 0000000..72ffd48
--- /dev/null
+++ b/GoldWars/GoldWars/Assets.xcassets/logo_kante.imageset/Contents.json
@@ -0,0 +1,23 @@
+{
+ "images" : [
+ {
+ "filename" : "logo_kante.jpg",
+ "idiom" : "universal",
+ "scale" : "1x"
+ },
+ {
+ "filename" : "logo_kante-1.jpg",
+ "idiom" : "universal",
+ "scale" : "2x"
+ },
+ {
+ "filename" : "logo_kante-2.jpg",
+ "idiom" : "universal",
+ "scale" : "3x"
+ }
+ ],
+ "info" : {
+ "author" : "xcode",
+ "version" : 1
+ }
+}
diff --git a/GoldWars/GoldWars/Assets.xcassets/logo_kante.imageset/logo_kante-1.jpg b/GoldWars/GoldWars/Assets.xcassets/logo_kante.imageset/logo_kante-1.jpg
new file mode 100644
index 0000000..1ef166f
Binary files /dev/null and b/GoldWars/GoldWars/Assets.xcassets/logo_kante.imageset/logo_kante-1.jpg differ
diff --git a/GoldWars/GoldWars/Assets.xcassets/logo_kante.imageset/logo_kante-2.jpg b/GoldWars/GoldWars/Assets.xcassets/logo_kante.imageset/logo_kante-2.jpg
new file mode 100644
index 0000000..1ef166f
Binary files /dev/null and b/GoldWars/GoldWars/Assets.xcassets/logo_kante.imageset/logo_kante-2.jpg differ
diff --git a/GoldWars/GoldWars/Assets.xcassets/logo_kante.imageset/logo_kante.jpg b/GoldWars/GoldWars/Assets.xcassets/logo_kante.imageset/logo_kante.jpg
new file mode 100644
index 0000000..1ef166f
Binary files /dev/null and b/GoldWars/GoldWars/Assets.xcassets/logo_kante.imageset/logo_kante.jpg differ
diff --git a/GoldWars/GoldWars/Assets.xcassets/logo_no_background.imageset/Contents.json b/GoldWars/GoldWars/Assets.xcassets/logo_no_background.imageset/Contents.json
new file mode 100644
index 0000000..8401033
--- /dev/null
+++ b/GoldWars/GoldWars/Assets.xcassets/logo_no_background.imageset/Contents.json
@@ -0,0 +1,23 @@
+{
+ "images" : [
+ {
+ "filename" : "logo_no_background.png",
+ "idiom" : "universal",
+ "scale" : "1x"
+ },
+ {
+ "filename" : "logo_no_background-1.png",
+ "idiom" : "universal",
+ "scale" : "2x"
+ },
+ {
+ "filename" : "logo_no_background-2.png",
+ "idiom" : "universal",
+ "scale" : "3x"
+ }
+ ],
+ "info" : {
+ "author" : "xcode",
+ "version" : 1
+ }
+}
diff --git a/GoldWars/GoldWars/Assets.xcassets/logo_no_background.imageset/logo_no_background-1.png b/GoldWars/GoldWars/Assets.xcassets/logo_no_background.imageset/logo_no_background-1.png
new file mode 100644
index 0000000..07b8c65
Binary files /dev/null and b/GoldWars/GoldWars/Assets.xcassets/logo_no_background.imageset/logo_no_background-1.png differ
diff --git a/GoldWars/GoldWars/Assets.xcassets/logo_no_background.imageset/logo_no_background-2.png b/GoldWars/GoldWars/Assets.xcassets/logo_no_background.imageset/logo_no_background-2.png
new file mode 100644
index 0000000..07b8c65
Binary files /dev/null and b/GoldWars/GoldWars/Assets.xcassets/logo_no_background.imageset/logo_no_background-2.png differ
diff --git a/GoldWars/GoldWars/Assets.xcassets/logo_no_background.imageset/logo_no_background.png b/GoldWars/GoldWars/Assets.xcassets/logo_no_background.imageset/logo_no_background.png
new file mode 100644
index 0000000..07b8c65
Binary files /dev/null and b/GoldWars/GoldWars/Assets.xcassets/logo_no_background.imageset/logo_no_background.png differ
diff --git a/GoldWars/GoldWars/Components/SpinningLogoComponent.swift b/GoldWars/GoldWars/Components/SpinningLogoComponent.swift
new file mode 100644
index 0000000..ab01672
--- /dev/null
+++ b/GoldWars/GoldWars/Components/SpinningLogoComponent.swift
@@ -0,0 +1,45 @@
+//
+// SpinningLogoComponent.swift
+// GoldWars
+//
+// Created by Niko Jochim on 15.05.20.
+// Copyright © 2020 SP2. All rights reserved.
+//
+
+import Foundation
+import GameKit
+
+class SpinningLogoComponent: GKComponent{
+
+ var node : SK3DNode
+
+ init(position: CGPoint) {
+
+ let scnScene: SCNScene = {
+ let scnScene = SCNScene()
+ let cylinder = SCNCylinder(radius: 250, height: 50)
+ let logoMaterial = SCNMaterial()
+ let colorMaterial = SCNMaterial()
+ logoMaterial.diffuse.contents = UIImage(named: "logo_no_background")
+ colorMaterial.diffuse.contents = UIColor(red: 0.852, green: 0.649, blue: 0.123, alpha: 1)
+ cylinder.materials = [colorMaterial,logoMaterial,logoMaterial]
+ let cylinderNode = SCNNode(geometry: cylinder)
+ cylinderNode.eulerAngles = SCNVector3(x: Float(CGFloat.pi / 2), y: 0, z: Float(CGFloat.pi / 2))
+ let action = SCNAction.rotateBy(x: CGFloat(GLKMathDegreesToRadians(360)), y:0 , z: 0, duration: 8)
+ let forever = SCNAction.repeatForever(action)
+ cylinderNode.runAction(forever)
+ scnScene.rootNode.addChildNode(cylinderNode)
+ return scnScene
+ }()
+
+ self.node = SK3DNode(viewportSize: CGSize(width: 250, height: 250))
+ node.scnScene = scnScene
+ node.position = position
+ super.init()
+ }
+
+ required init?(coder: NSCoder) {
+ fatalError("init(coder:) has not been implemented")
+ }
+
+}
diff --git a/GoldWars/GoldWars/Entities/EntityManager.swift b/GoldWars/GoldWars/Entities/EntityManager.swift
index a2ddeaa..2e4713f 100644
--- a/GoldWars/GoldWars/Entities/EntityManager.swift
+++ b/GoldWars/GoldWars/Entities/EntityManager.swift
@@ -12,15 +12,22 @@ import GameKit
class EntityManager {
+ static let sharedInstance = EntityManager()
+
var entities = Set()
- let scene: SKScene
+ var scene: SKScene
var isModal: Bool
- init(scene: SKScene) {
- self.scene = scene
+ private init() {
isModal = false
+ scene = SKScene.init()
}
+ func setScene(scene: SKScene){
+ self.scene = scene
+ }
+
+
func add(_ entity: GKEntity) {
entities.insert(entity)
if let spriteNode = entity.component(ofType: DefaultBaseComponent.self)?.spriteNode {
@@ -68,6 +75,9 @@ class EntityManager {
if let labelNode = entity.component(ofType: LabelComponent.self)?.labelNode {
scene.addChild(labelNode)
}
+ if let node = entity.component(ofType: SpinningLogoComponent.self)?.node {
+ scene.addChild(node)
+ }
}
func remove(_ entity: GKEntity) {
@@ -100,9 +110,9 @@ class EntityManager {
if base.changeOwnership {
base.addComponent(TeamComponent(
- team: (entities[0] as! Base).component(ofType: TeamComponent.self)!.team,
- player: (entities[0] as! Base).component(ofType: TeamComponent.self)!.player,
- position: (base.component(ofType: DefaultBaseComponent.self)?.spriteNode.position)!
+ team: (entities[0] as! Base).component(ofType: TeamComponent.self)!.team,
+ player: (entities[0] as! Base).component(ofType: TeamComponent.self)!.player,
+ position: (base.component(ofType: DefaultBaseComponent.self)?.spriteNode.position)!
)
)
base.changeOwnership = false
diff --git a/GoldWars/GoldWars/Entities/SpinningLogoEntity.swift b/GoldWars/GoldWars/Entities/SpinningLogoEntity.swift
new file mode 100644
index 0000000..0e84923
--- /dev/null
+++ b/GoldWars/GoldWars/Entities/SpinningLogoEntity.swift
@@ -0,0 +1,22 @@
+//
+// SpinningLogoEntity.swift
+// GoldWars
+//
+// Created by Niko Jochim on 15.05.20.
+// Copyright © 2020 SP2. All rights reserved.
+//
+
+import Foundation
+import GameplayKit
+
+class SpinningLogoEntity: GKEntity {
+
+ init(position: CGPoint) {
+ super.init()
+ self.addComponent(SpinningLogoComponent(position: position))
+ }
+
+ required init?(coder: NSCoder) {
+ fatalError("init(coder:) has not been implemented")
+ }
+}
diff --git a/GoldWars/GoldWars/GameViewController.swift b/GoldWars/GoldWars/GameViewController.swift
index e4a2f43..05b2706 100644
--- a/GoldWars/GoldWars/GameViewController.swift
+++ b/GoldWars/GoldWars/GameViewController.swift
@@ -11,7 +11,7 @@ import SpriteKit
import GameplayKit
class GameViewController: UIViewController {
-
+
override func viewDidLoad() {
super.viewDidLoad()
diff --git a/GoldWars/GoldWars/Scenes/GameScene.swift b/GoldWars/GoldWars/Scenes/GameScene.swift
index 3a5a5c8..58ea2e2 100644
--- a/GoldWars/GoldWars/Scenes/GameScene.swift
+++ b/GoldWars/GoldWars/Scenes/GameScene.swift
@@ -12,15 +12,14 @@ import GameKit
class GameScene: SKScene{
- var entityManager: EntityManager!
var isMoveTouch = false
var currentDraggedBasePos = CGPoint()
var currentDraggedBase : Base?
override func sceneDidLoad() {
- entityManager = EntityManager(scene: self)
- entityManager.add(HUD(size: self.size))
- entityManager.add(Background(size: self.size))
+ EntityManager.sharedInstance.setScene(scene: self)
+ EntityManager.sharedInstance.add(HUD(size: self.size))
+ EntityManager.sharedInstance.add(Background(size: self.size))
initMap()
}
@@ -45,14 +44,14 @@ class GameScene: SKScene{
if atPoint(touchLocation) == base.component(ofType: DefaultBaseComponent.self)?.spriteNode {
// TODO: change interaction based on collision instead of touchlocation
- if !(entityManager.getTeamByBase(base: currentDraggedBase!) == entityManager.getTeamByBase(base: base)){
- entityManager.add(Modal(modaltype: .BaseAttack,
+ if !(EntityManager.sharedInstance.getTeamByBase(base: currentDraggedBase!) == EntityManager.sharedInstance.getTeamByBase(base: base)){
+ EntityManager.sharedInstance.add(Modal(modaltype: .BaseAttack,
base: currentDraggedBase!,
anchorPoint: CGPoint(x: self.size.width / 2 , y: self.size.height / 2),
- entityManager: entityManager, gameScene: self))
- entityManager.update((currentDraggedBase?.doPlayerMoveTypeToBase(base: base, playerMoveType: PlayerMoveType.AtkMove, units: 100))!)
+ entityManager: EntityManager.sharedInstance, gameScene: self))
+ EntityManager.sharedInstance.update((currentDraggedBase?.attackBase(base: base, units: 100))!)
}else {
- entityManager.add(Modal(modaltype: .BaseAttack,
+ EntityManager.sharedInstance.add(Modal(modaltype: .BaseAttack,
base: currentDraggedBase!,
anchorPoint: CGPoint(x: self.size.width / 2 , y: self.size.height / 2),
entityManager: entityManager, gameScene: self))
@@ -63,21 +62,21 @@ class GameScene: SKScene{
}
}
else {
- for entity in entityManager.entities {
+ for entity in EntityManager.sharedInstance.entities {
let spriteNode = entity.component(ofType: DefaultBaseComponent.self)?.spriteNode
- if atPoint(touchLocation) == spriteNode && !entityManager.isModal {
+ if atPoint(touchLocation) == spriteNode && !EntityManager.sharedInstance.isModal {
spriteNode?.touchesBegan(touches, with: event)
- if !entityManager.isModal {
+ if !EntityManager.sharedInstance.isModal {
for child in self.children {
if(child.name != "fire"){
child.alpha = 0.3
}
}
- entityManager.add(Modal(modaltype: .BaseDetails,
+ EntityManager.sharedInstance.add(Modal(modaltype: .BaseDetails,
base: entity as! Base,
anchorPoint: CGPoint(x: self.size.width / 2 , y: self.size.height / 2),
- entityManager: entityManager, gameScene: self))
+ entityManager: EntityManager.sharedInstance, gameScene: self))
}
}
}
@@ -97,12 +96,12 @@ class GameScene: SKScene{
}
}
- for e in entityManager.entities{
+ for e in EntityManager.sharedInstance.entities{
if let body = e.component(ofType: ModalContentComponent.self)?.body{
body.text = "Schicke \( ((e.component(ofType: SliderComponent.self)?.sliderNode.getValue ?? 0) * CGFloat((e as! Modal).unitCount)).rounded(.up)) Einheiten "
} }
- let bases = entityManager.getBasesByPlayer(for: GKLocalPlayer.local)
+ let bases = EntityManager.sharedInstance.getBasesByPlayer(for: GKLocalPlayer.local)
for base in bases {
if atPoint(touchLocation) == base.component(ofType: DefaultBaseComponent.self)?.spriteNode{
@@ -126,7 +125,7 @@ class GameScene: SKScene{
}
override func update(_ currentTime: TimeInterval) {
- entityManager.getBackground()?.update(deltaTime: currentTime)
- entityManager.getHUD()?.component(ofType: TimerComponent.self)?.update()
+ EntityManager.sharedInstance.getBackground()?.update(deltaTime: currentTime)
+ EntityManager.sharedInstance.getHUD()?.component(ofType: TimerComponent.self)?.update()
}
}
diff --git a/GoldWars/GoldWars/Scenes/MenuScene.swift b/GoldWars/GoldWars/Scenes/MenuScene.swift
index bca03d2..764a1da 100644
--- a/GoldWars/GoldWars/Scenes/MenuScene.swift
+++ b/GoldWars/GoldWars/Scenes/MenuScene.swift
@@ -7,16 +7,14 @@
//
import SpriteKit
-
+import SceneKit
class MenuScene: SKScene {
-
- var entityManager: EntityManager!
-
+
override func sceneDidLoad() {
- entityManager = EntityManager(scene: self)
+ EntityManager.sharedInstance.setScene(scene: self)
let midX = self.size.width / 2
let midY = self.size.height / 2
- entityManager.add(Button(name: "startGameButton",
+ EntityManager.sharedInstance.add(Button(name: "startGameButton",
iconName: "",
text: "Start Game",
position: CGPoint(x: midX, y: midY),
@@ -25,30 +23,31 @@ class MenuScene: SKScene {
self.loadScene(scene: GameScene(size: self.size))
SoundManager.sharedInstance.stopMenuMusic()
} else {
- MatchmakingHelper.sharedInstance.presentMatchmaker(scene: self)
+ MatchmakingHelper.sharedInstance.presentMatchmaker(scene: self)
}
- }))
- entityManager.add(Button(name: "settingsButton",
+ }))
+ EntityManager.sharedInstance.add(Button(name: "settingsButton",
iconName: "",
text: "Settings",
position: CGPoint(x: midX, y: midY - 80 ),
onButtonPress: {
self.loadScene(scene: SettingsScene(size: self.size))
}))
- entityManager.add(Background(size: self.size))
+ EntityManager.sharedInstance.add(Background(size: self.size))
+ EntityManager.sharedInstance.add(SpinningLogoEntity(position: CGPoint(x: midX, y: midY + 200)))
if SoundManager.sharedInstance.isMusicPlaying == false && SoundManager.sharedInstance.isMusicEnabled == true {
SoundManager.sharedInstance.startMenuMusic()
}
}
-
+
func loadScene(scene: SKScene) {
let transition = SKTransition.flipVertical(withDuration: 0.5)
self.view?.presentScene(scene, transition: transition)
}
-
+
override func update(_ currentTime: TimeInterval) {
- entityManager.getBackground()!.update(deltaTime: currentTime)
- entityManager.getButtonByName(buttonName: "startGameButton").component(ofType: ButtonComponent.self)?.buttonNode.isEnabled = GameCenterHelper.isAuthenticated
+ EntityManager.sharedInstance.getBackground()!.update(deltaTime: currentTime)
+ EntityManager.sharedInstance.getButtonByName(buttonName: "startGameButton").component(ofType: ButtonComponent.self)?.buttonNode.isEnabled = GameCenterHelper.isAuthenticated
}
}
diff --git a/GoldWars/GoldWars/SettingsScene.swift b/GoldWars/GoldWars/SettingsScene.swift
index 8eb22f5..a9cd9e0 100644
--- a/GoldWars/GoldWars/SettingsScene.swift
+++ b/GoldWars/GoldWars/SettingsScene.swift
@@ -9,21 +9,20 @@
import SpriteKit
class SettingsScene: SKScene {
- var entityManager: EntityManager!
override func sceneDidLoad() {
- entityManager = EntityManager(scene: self)
+ EntityManager.sharedInstance.setScene(scene: self)
let positionX = self.size.width * 0.1
let positionY = self.size.height * 0.05
- entityManager.add(Button(name: "backToMenuScene",
+ EntityManager.sharedInstance.add(Button(name: "backToMenuScene",
iconName: "",
text: "Back",
position: CGPoint(x: positionX, y: positionY),
onButtonPress: {
self.loadScene(scene: MenuScene(size: self.size))
}))
- entityManager.add(Button(name: "StopMenuMusic",
+ EntityManager.sharedInstance.add(Button(name: "StopMenuMusic",
iconName: "",
text: "ON/OFF",
position: CGPoint(x: self.size.width * 0.6, y: self.size.height / 2),
@@ -36,7 +35,7 @@ class SettingsScene: SKScene {
SoundManager.sharedInstance.startMenuMusic()
}
}))
- entityManager.add(Button(name: "StopMovingBackground",
+ EntityManager.sharedInstance.add(Button(name: "StopMovingBackground",
iconName: "",
text: "MOVE/STOP",
position: CGPoint(x: self.size.width * 0.6, y: self.size.height / 2 - 100),
@@ -47,7 +46,7 @@ class SettingsScene: SKScene {
BackgroundComponent.isMovingBackgroundEnabled = true
}
}))
- entityManager.add(Label(fontnamed: "Courier-Bold",
+ EntityManager.sharedInstance.add(Label(fontnamed: "Courier-Bold",
name: "SettingsLabel",
text: "Settings",
fontSize: 200.0,
@@ -58,7 +57,7 @@ class SettingsScene: SKScene {
isAnimationEnabled: true,
isAnimationInfinite: true)
)
- entityManager.add(Label(fontnamed: "Courier-Bold",
+ EntityManager.sharedInstance.add(Label(fontnamed: "Courier-Bold",
name: "LabelMusic",
text: "Music", fontSize: 50.0,
fontColor: .black,
@@ -68,7 +67,7 @@ class SettingsScene: SKScene {
isAnimationEnabled: true,
isAnimationInfinite: false)
)
- entityManager.add(Label(fontnamed: "Courier-Bold",
+ EntityManager.sharedInstance.add(Label(fontnamed: "Courier-Bold",
name: "LabelBackground",
text: "Background",
fontSize: 50.0,
@@ -79,7 +78,7 @@ class SettingsScene: SKScene {
isAnimationEnabled: true,
isAnimationInfinite: false)
)
- entityManager.add(Background(size: self.size))
+ EntityManager.sharedInstance.add(Background(size: self.size))
}
func loadScene(scene: SKScene) {
@@ -88,7 +87,7 @@ class SettingsScene: SKScene {
}
override func update(_ currentTime: TimeInterval) {
- entityManager.getBackground()!.update(deltaTime: currentTime)
+ EntityManager.sharedInstance.getBackground()!.update(deltaTime: currentTime)
}
}