Merge branch '60-global-accessible-entitymanager'
Conflicts: GoldWars/GoldWars/Scenes/GameScene.swift
This commit is contained in:
commit
69e41a9cd3
8
GoldWars/.idea/.gitignore
vendored
Normal file
8
GoldWars/.idea/.gitignore
vendored
Normal file
@ -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/
|
2
GoldWars/.idea/GoldWars.iml
Normal file
2
GoldWars/.idea/GoldWars.iml
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<module classpath="AppCode" type="CIDR_MODULE" version="4" />
|
6
GoldWars/.idea/misc.xml
Normal file
6
GoldWars/.idea/misc.xml
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project version="4">
|
||||||
|
<component name="JavaScriptSettings">
|
||||||
|
<option name="languageLevel" value="ES6" />
|
||||||
|
</component>
|
||||||
|
</project>
|
8
GoldWars/.idea/modules.xml
Normal file
8
GoldWars/.idea/modules.xml
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project version="4">
|
||||||
|
<component name="ProjectModuleManager">
|
||||||
|
<modules>
|
||||||
|
<module fileurl="file://$PROJECT_DIR$/.idea/GoldWars.iml" filepath="$PROJECT_DIR$/.idea/GoldWars.iml" />
|
||||||
|
</modules>
|
||||||
|
</component>
|
||||||
|
</project>
|
11
GoldWars/.idea/runConfigurations/GoldWars.xml
Normal file
11
GoldWars/.idea/runConfigurations/GoldWars.xml
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
<component name="ProjectRunConfigurationManager">
|
||||||
|
<configuration default="false" name="GoldWars" type="AppleRunConfiguration" factoryName="Application" REDIRECT_INPUT="false" PASS_PARENT_ENVS_2="true" PROJECT_NAME="GoldWars" TARGET_NAME="GoldWars" CONFIG_NAME="Debug" SCHEME_NAME="GoldWars" IS_LOCATION_SIMULATION_ALLOWED="true" APPLICATION_LANGUAGE="IDELaunchSchemeLanguageUseSystemLanguage" APPLICATION_REGION="" RUN_TARGET_PROJECT_NAME="GoldWars" RUN_TARGET_NAME="GoldWars" MAKE_ACTIVE="TRUE" SHOULD_DEBUG_EXTENSIONS="false">
|
||||||
|
<EXTENSION ID="org.jetbrains.appcode.reveal.RevealRunConfigurationExtension">
|
||||||
|
<REVEAL_SETTINGS autoInject="false" autoInstall="true" askToEnableAutoInstall="true" />
|
||||||
|
</EXTENSION>
|
||||||
|
<embedded_app_extension_list />
|
||||||
|
<method v="2">
|
||||||
|
<option name="com.jetbrains.cidr.execution.CidrBuildBeforeRunTaskProvider$BuildBeforeRunTask" enabled="true" />
|
||||||
|
</method>
|
||||||
|
</configuration>
|
||||||
|
</component>
|
6
GoldWars/.idea/vcs.xml
Normal file
6
GoldWars/.idea/vcs.xml
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project version="4">
|
||||||
|
<component name="VcsDirectoryMappings">
|
||||||
|
<mapping directory="$PROJECT_DIR$/.." vcs="Git" />
|
||||||
|
</component>
|
||||||
|
</project>
|
4
GoldWars/.idea/xcode.xml
Normal file
4
GoldWars/.idea/xcode.xml
Normal file
@ -0,0 +1,4 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project version="4">
|
||||||
|
<component name="XcodeMetaData" PROJECT_FILE="$PROJECT_DIR$/GoldWars.xcodeproj" />
|
||||||
|
</project>
|
@ -45,6 +45,8 @@
|
|||||||
9EC7E48B2461FBF700396BCD /* SliderNode.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9EC7E48A2461FBF700396BCD /* SliderNode.swift */; };
|
9EC7E48B2461FBF700396BCD /* SliderNode.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9EC7E48A2461FBF700396BCD /* SliderNode.swift */; };
|
||||||
9EC86B9F245C88A300796EF3 /* Modal.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9EC86B9E245C88A300796EF3 /* Modal.swift */; };
|
9EC86B9F245C88A300796EF3 /* Modal.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9EC86B9E245C88A300796EF3 /* Modal.swift */; };
|
||||||
9EC86BA6245C8AD000796EF3 /* ModalType.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9EC86BA5245C8AD000796EF3 /* ModalType.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 */; };
|
AB1D759C245DD18100671525 /* MapProtocol.swift in Sources */ = {isa = PBXBuildFile; fileRef = AB1D759A245DD18100671525 /* MapProtocol.swift */; };
|
||||||
AB1D759D245DD18100671525 /* TwoPlayerDefaultTestMap.swift in Sources */ = {isa = PBXBuildFile; fileRef = AB1D759B245DD18100671525 /* TwoPlayerDefaultTestMap.swift */; };
|
AB1D759D245DD18100671525 /* TwoPlayerDefaultTestMap.swift in Sources */ = {isa = PBXBuildFile; fileRef = AB1D759B245DD18100671525 /* TwoPlayerDefaultTestMap.swift */; };
|
||||||
AB1D75A0245DEC0500671525 /* MapFactory.swift in Sources */ = {isa = PBXBuildFile; fileRef = AB1D759F245DEC0500671525 /* MapFactory.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 = "<group>"; };
|
9EC86B9E245C88A300796EF3 /* Modal.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Modal.swift; sourceTree = "<group>"; };
|
||||||
9EC86BA5245C8AD000796EF3 /* ModalType.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ModalType.swift; sourceTree = "<group>"; };
|
9EC86BA5245C8AD000796EF3 /* ModalType.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ModalType.swift; sourceTree = "<group>"; };
|
||||||
9ECD3699245C91F7008DEEBD /* GoldWars.entitlements */ = {isa = PBXFileReference; lastKnownFileType = text.plist.entitlements; path = GoldWars.entitlements; sourceTree = "<group>"; };
|
9ECD3699245C91F7008DEEBD /* GoldWars.entitlements */ = {isa = PBXFileReference; lastKnownFileType = text.plist.entitlements; path = GoldWars.entitlements; sourceTree = "<group>"; };
|
||||||
|
9EEDE02C246FCD770096C735 /* SpinningLogoEntity.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = SpinningLogoEntity.swift; sourceTree = "<group>"; };
|
||||||
|
9EEDE02E246FCD800096C735 /* SpinningLogoComponent.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = SpinningLogoComponent.swift; sourceTree = "<group>"; };
|
||||||
AB1D759A245DD18100671525 /* MapProtocol.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = MapProtocol.swift; sourceTree = "<group>"; };
|
AB1D759A245DD18100671525 /* MapProtocol.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = MapProtocol.swift; sourceTree = "<group>"; };
|
||||||
AB1D759B245DD18100671525 /* TwoPlayerDefaultTestMap.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = TwoPlayerDefaultTestMap.swift; sourceTree = "<group>"; };
|
AB1D759B245DD18100671525 /* TwoPlayerDefaultTestMap.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = TwoPlayerDefaultTestMap.swift; sourceTree = "<group>"; };
|
||||||
AB1D759F245DEC0500671525 /* MapFactory.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MapFactory.swift; sourceTree = "<group>"; };
|
AB1D759F245DEC0500671525 /* MapFactory.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MapFactory.swift; sourceTree = "<group>"; };
|
||||||
@ -207,6 +211,7 @@
|
|||||||
116060F4245C56EA004E5A36 /* Components */ = {
|
116060F4245C56EA004E5A36 /* Components */ = {
|
||||||
isa = PBXGroup;
|
isa = PBXGroup;
|
||||||
children = (
|
children = (
|
||||||
|
9EEDE02E246FCD800096C735 /* SpinningLogoComponent.swift */,
|
||||||
9E174C81245DD81D00209FF0 /* ButtonNode.swift */,
|
9E174C81245DD81D00209FF0 /* ButtonNode.swift */,
|
||||||
9EA3ABE8245C6DAA006BC61D /* DefaultBaseComponent.swift */,
|
9EA3ABE8245C6DAA006BC61D /* DefaultBaseComponent.swift */,
|
||||||
9EA3ABEC245C8143006BC61D /* ModalBackgroundComponent.swift */,
|
9EA3ABEC245C8143006BC61D /* ModalBackgroundComponent.swift */,
|
||||||
@ -229,6 +234,7 @@
|
|||||||
116060F5245C5709004E5A36 /* Entities */ = {
|
116060F5245C5709004E5A36 /* Entities */ = {
|
||||||
isa = PBXGroup;
|
isa = PBXGroup;
|
||||||
children = (
|
children = (
|
||||||
|
9EEDE02C246FCD770096C735 /* SpinningLogoEntity.swift */,
|
||||||
ABA03D9F244BD54F00A66916 /* Base.swift */,
|
ABA03D9F244BD54F00A66916 /* Base.swift */,
|
||||||
9EC86B9E245C88A300796EF3 /* Modal.swift */,
|
9EC86B9E245C88A300796EF3 /* Modal.swift */,
|
||||||
116060F6245C57D2004E5A36 /* EntityManager.swift */,
|
116060F6245C57D2004E5A36 /* EntityManager.swift */,
|
||||||
@ -415,6 +421,7 @@
|
|||||||
3EBD242E245D9332003CECE7 /* Team.swift in Sources */,
|
3EBD242E245D9332003CECE7 /* Team.swift in Sources */,
|
||||||
9E174C88245DF1FF00209FF0 /* BackgroundComponent.swift in Sources */,
|
9E174C88245DF1FF00209FF0 /* BackgroundComponent.swift in Sources */,
|
||||||
9E78ACBA245CBDAF00526FF7 /* HUD.swift in Sources */,
|
9E78ACBA245CBDAF00526FF7 /* HUD.swift in Sources */,
|
||||||
|
9EEDE02D246FCD770096C735 /* SpinningLogoEntity.swift in Sources */,
|
||||||
11738A3B24508F68004426F1 /* Unit.swift in Sources */,
|
11738A3B24508F68004426F1 /* Unit.swift in Sources */,
|
||||||
9E174C86245DD91500209FF0 /* ButtonComponent.swift in Sources */,
|
9E174C86245DD91500209FF0 /* ButtonComponent.swift in Sources */,
|
||||||
AE151589245F18EF001D363E /* MatchmakingHelper.swift in Sources */,
|
AE151589245F18EF001D363E /* MatchmakingHelper.swift in Sources */,
|
||||||
@ -434,6 +441,7 @@
|
|||||||
C064E9AC246C151F0022B228 /* Label.swift in Sources */,
|
C064E9AC246C151F0022B228 /* Label.swift in Sources */,
|
||||||
9E174C82245DD81D00209FF0 /* ButtonNode.swift in Sources */,
|
9E174C82245DD81D00209FF0 /* ButtonNode.swift in Sources */,
|
||||||
9EC7E48B2461FBF700396BCD /* SliderNode.swift in Sources */,
|
9EC7E48B2461FBF700396BCD /* SliderNode.swift in Sources */,
|
||||||
|
9EEDE02F246FCD800096C735 /* SpinningLogoComponent.swift in Sources */,
|
||||||
9E174C84245DD8CE00209FF0 /* Button.swift in Sources */,
|
9E174C84245DD8CE00209FF0 /* Button.swift in Sources */,
|
||||||
110360DB244B101A008610AF /* GameViewController.swift in Sources */,
|
110360DB244B101A008610AF /* GameViewController.swift in Sources */,
|
||||||
2086465C2461B66200817C23 /* TimerComponent.swift in Sources */,
|
2086465C2461B66200817C23 /* TimerComponent.swift in Sources */,
|
||||||
|
23
GoldWars/GoldWars/Assets.xcassets/logo_kante.imageset/Contents.json
vendored
Normal file
23
GoldWars/GoldWars/Assets.xcassets/logo_kante.imageset/Contents.json
vendored
Normal file
@ -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
|
||||||
|
}
|
||||||
|
}
|
BIN
GoldWars/GoldWars/Assets.xcassets/logo_kante.imageset/logo_kante-1.jpg
vendored
Normal file
BIN
GoldWars/GoldWars/Assets.xcassets/logo_kante.imageset/logo_kante-1.jpg
vendored
Normal file
Binary file not shown.
After Width: | Height: | Size: 1.8 KiB |
BIN
GoldWars/GoldWars/Assets.xcassets/logo_kante.imageset/logo_kante-2.jpg
vendored
Normal file
BIN
GoldWars/GoldWars/Assets.xcassets/logo_kante.imageset/logo_kante-2.jpg
vendored
Normal file
Binary file not shown.
After Width: | Height: | Size: 1.8 KiB |
BIN
GoldWars/GoldWars/Assets.xcassets/logo_kante.imageset/logo_kante.jpg
vendored
Normal file
BIN
GoldWars/GoldWars/Assets.xcassets/logo_kante.imageset/logo_kante.jpg
vendored
Normal file
Binary file not shown.
After Width: | Height: | Size: 1.8 KiB |
23
GoldWars/GoldWars/Assets.xcassets/logo_no_background.imageset/Contents.json
vendored
Normal file
23
GoldWars/GoldWars/Assets.xcassets/logo_no_background.imageset/Contents.json
vendored
Normal file
@ -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
|
||||||
|
}
|
||||||
|
}
|
BIN
GoldWars/GoldWars/Assets.xcassets/logo_no_background.imageset/logo_no_background-1.png
vendored
Normal file
BIN
GoldWars/GoldWars/Assets.xcassets/logo_no_background.imageset/logo_no_background-1.png
vendored
Normal file
Binary file not shown.
After Width: | Height: | Size: 48 KiB |
BIN
GoldWars/GoldWars/Assets.xcassets/logo_no_background.imageset/logo_no_background-2.png
vendored
Normal file
BIN
GoldWars/GoldWars/Assets.xcassets/logo_no_background.imageset/logo_no_background-2.png
vendored
Normal file
Binary file not shown.
After Width: | Height: | Size: 48 KiB |
BIN
GoldWars/GoldWars/Assets.xcassets/logo_no_background.imageset/logo_no_background.png
vendored
Normal file
BIN
GoldWars/GoldWars/Assets.xcassets/logo_no_background.imageset/logo_no_background.png
vendored
Normal file
Binary file not shown.
After Width: | Height: | Size: 48 KiB |
45
GoldWars/GoldWars/Components/SpinningLogoComponent.swift
Normal file
45
GoldWars/GoldWars/Components/SpinningLogoComponent.swift
Normal file
@ -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")
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -12,15 +12,22 @@ import GameKit
|
|||||||
|
|
||||||
class EntityManager {
|
class EntityManager {
|
||||||
|
|
||||||
|
static let sharedInstance = EntityManager()
|
||||||
|
|
||||||
var entities = Set<GKEntity>()
|
var entities = Set<GKEntity>()
|
||||||
let scene: SKScene
|
var scene: SKScene
|
||||||
var isModal: Bool
|
var isModal: Bool
|
||||||
|
|
||||||
init(scene: SKScene) {
|
private init() {
|
||||||
self.scene = scene
|
|
||||||
isModal = false
|
isModal = false
|
||||||
|
scene = SKScene.init()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func setScene(scene: SKScene){
|
||||||
|
self.scene = scene
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
func add(_ entity: GKEntity) {
|
func add(_ entity: GKEntity) {
|
||||||
entities.insert(entity)
|
entities.insert(entity)
|
||||||
if let spriteNode = entity.component(ofType: DefaultBaseComponent.self)?.spriteNode {
|
if let spriteNode = entity.component(ofType: DefaultBaseComponent.self)?.spriteNode {
|
||||||
@ -68,6 +75,9 @@ class EntityManager {
|
|||||||
if let labelNode = entity.component(ofType: LabelComponent.self)?.labelNode {
|
if let labelNode = entity.component(ofType: LabelComponent.self)?.labelNode {
|
||||||
scene.addChild(labelNode)
|
scene.addChild(labelNode)
|
||||||
}
|
}
|
||||||
|
if let node = entity.component(ofType: SpinningLogoComponent.self)?.node {
|
||||||
|
scene.addChild(node)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func remove(_ entity: GKEntity) {
|
func remove(_ entity: GKEntity) {
|
||||||
|
22
GoldWars/GoldWars/Entities/SpinningLogoEntity.swift
Normal file
22
GoldWars/GoldWars/Entities/SpinningLogoEntity.swift
Normal file
@ -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")
|
||||||
|
}
|
||||||
|
}
|
@ -12,15 +12,14 @@ import GameKit
|
|||||||
|
|
||||||
class GameScene: SKScene{
|
class GameScene: SKScene{
|
||||||
|
|
||||||
var entityManager: EntityManager!
|
|
||||||
var isMoveTouch = false
|
var isMoveTouch = false
|
||||||
var currentDraggedBasePos = CGPoint()
|
var currentDraggedBasePos = CGPoint()
|
||||||
var currentDraggedBase : Base?
|
var currentDraggedBase : Base?
|
||||||
|
|
||||||
override func sceneDidLoad() {
|
override func sceneDidLoad() {
|
||||||
entityManager = EntityManager(scene: self)
|
EntityManager.sharedInstance.setScene(scene: self)
|
||||||
entityManager.add(HUD(size: self.size))
|
EntityManager.sharedInstance.add(HUD(size: self.size))
|
||||||
entityManager.add(Background(size: self.size))
|
EntityManager.sharedInstance.add(Background(size: self.size))
|
||||||
initMap()
|
initMap()
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -45,14 +44,14 @@ class GameScene: SKScene{
|
|||||||
if atPoint(touchLocation) == base.component(ofType: DefaultBaseComponent.self)?.spriteNode {
|
if atPoint(touchLocation) == base.component(ofType: DefaultBaseComponent.self)?.spriteNode {
|
||||||
// TODO: change interaction based on collision instead of touchlocation
|
// TODO: change interaction based on collision instead of touchlocation
|
||||||
|
|
||||||
if !(entityManager.getTeamByBase(base: currentDraggedBase!) == entityManager.getTeamByBase(base: base)){
|
if !(EntityManager.sharedInstance.getTeamByBase(base: currentDraggedBase!) == EntityManager.sharedInstance.getTeamByBase(base: base)){
|
||||||
entityManager.add(Modal(modaltype: .BaseAttack,
|
EntityManager.sharedInstance.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, gameScene: self))
|
entityManager: EntityManager.sharedInstance, gameScene: self))
|
||||||
entityManager.update((currentDraggedBase?.doPlayerMoveTypeToBase(base: base, playerMoveType: PlayerMoveType.AtkMove, units: 100))!)
|
EntityManager.sharedInstance.update((currentDraggedBase?.attackBase(base: base, units: 100))!)
|
||||||
}else {
|
}else {
|
||||||
entityManager.add(Modal(modaltype: .BaseAttack,
|
EntityManager.sharedInstance.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, gameScene: self))
|
entityManager: entityManager, gameScene: self))
|
||||||
@ -63,21 +62,21 @@ class GameScene: SKScene{
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
for entity in entityManager.entities {
|
for entity in EntityManager.sharedInstance.entities {
|
||||||
let spriteNode = entity.component(ofType: DefaultBaseComponent.self)?.spriteNode
|
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)
|
spriteNode?.touchesBegan(touches, with: event)
|
||||||
if !entityManager.isModal {
|
if !EntityManager.sharedInstance.isModal {
|
||||||
for child in self.children {
|
for child in self.children {
|
||||||
if(child.name != "fire"){
|
if(child.name != "fire"){
|
||||||
child.alpha = 0.3
|
child.alpha = 0.3
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
entityManager.add(Modal(modaltype: .BaseDetails,
|
EntityManager.sharedInstance.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, 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{
|
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 "
|
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 {
|
for base in bases {
|
||||||
if atPoint(touchLocation) == base.component(ofType: DefaultBaseComponent.self)?.spriteNode{
|
if atPoint(touchLocation) == base.component(ofType: DefaultBaseComponent.self)?.spriteNode{
|
||||||
@ -126,7 +125,7 @@ class GameScene: SKScene{
|
|||||||
}
|
}
|
||||||
|
|
||||||
override func update(_ currentTime: TimeInterval) {
|
override func update(_ currentTime: TimeInterval) {
|
||||||
entityManager.getBackground()?.update(deltaTime: currentTime)
|
EntityManager.sharedInstance.getBackground()?.update(deltaTime: currentTime)
|
||||||
entityManager.getHUD()?.component(ofType: TimerComponent.self)?.update()
|
EntityManager.sharedInstance.getHUD()?.component(ofType: TimerComponent.self)?.update()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -7,16 +7,14 @@
|
|||||||
//
|
//
|
||||||
|
|
||||||
import SpriteKit
|
import SpriteKit
|
||||||
|
import SceneKit
|
||||||
class MenuScene: SKScene {
|
class MenuScene: SKScene {
|
||||||
|
|
||||||
var entityManager: EntityManager!
|
|
||||||
|
|
||||||
override func sceneDidLoad() {
|
override func sceneDidLoad() {
|
||||||
entityManager = EntityManager(scene: self)
|
EntityManager.sharedInstance.setScene(scene: self)
|
||||||
let midX = self.size.width / 2
|
let midX = self.size.width / 2
|
||||||
let midY = self.size.height / 2
|
let midY = self.size.height / 2
|
||||||
entityManager.add(Button(name: "startGameButton",
|
EntityManager.sharedInstance.add(Button(name: "startGameButton",
|
||||||
iconName: "",
|
iconName: "",
|
||||||
text: "Start Game",
|
text: "Start Game",
|
||||||
position: CGPoint(x: midX, y: midY),
|
position: CGPoint(x: midX, y: midY),
|
||||||
@ -28,14 +26,15 @@ class MenuScene: SKScene {
|
|||||||
MatchmakingHelper.sharedInstance.presentMatchmaker(scene: self)
|
MatchmakingHelper.sharedInstance.presentMatchmaker(scene: self)
|
||||||
}
|
}
|
||||||
}))
|
}))
|
||||||
entityManager.add(Button(name: "settingsButton",
|
EntityManager.sharedInstance.add(Button(name: "settingsButton",
|
||||||
iconName: "",
|
iconName: "",
|
||||||
text: "Settings",
|
text: "Settings",
|
||||||
position: CGPoint(x: midX, y: midY - 80 ),
|
position: CGPoint(x: midX, y: midY - 80 ),
|
||||||
onButtonPress: {
|
onButtonPress: {
|
||||||
self.loadScene(scene: SettingsScene(size: self.size))
|
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 {
|
if SoundManager.sharedInstance.isMusicPlaying == false && SoundManager.sharedInstance.isMusicEnabled == true {
|
||||||
SoundManager.sharedInstance.startMenuMusic()
|
SoundManager.sharedInstance.startMenuMusic()
|
||||||
@ -48,7 +47,7 @@ class MenuScene: SKScene {
|
|||||||
}
|
}
|
||||||
|
|
||||||
override func update(_ currentTime: TimeInterval) {
|
override func update(_ currentTime: TimeInterval) {
|
||||||
entityManager.getBackground()!.update(deltaTime: currentTime)
|
EntityManager.sharedInstance.getBackground()!.update(deltaTime: currentTime)
|
||||||
entityManager.getButtonByName(buttonName: "startGameButton").component(ofType: ButtonComponent.self)?.buttonNode.isEnabled = GameCenterHelper.isAuthenticated
|
EntityManager.sharedInstance.getButtonByName(buttonName: "startGameButton").component(ofType: ButtonComponent.self)?.buttonNode.isEnabled = GameCenterHelper.isAuthenticated
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -9,21 +9,20 @@
|
|||||||
import SpriteKit
|
import SpriteKit
|
||||||
|
|
||||||
class SettingsScene: SKScene {
|
class SettingsScene: SKScene {
|
||||||
var entityManager: EntityManager!
|
|
||||||
|
|
||||||
override func sceneDidLoad() {
|
override func sceneDidLoad() {
|
||||||
entityManager = EntityManager(scene: self)
|
EntityManager.sharedInstance.setScene(scene: self)
|
||||||
let positionX = self.size.width * 0.1
|
let positionX = self.size.width * 0.1
|
||||||
let positionY = self.size.height * 0.05
|
let positionY = self.size.height * 0.05
|
||||||
|
|
||||||
entityManager.add(Button(name: "backToMenuScene",
|
EntityManager.sharedInstance.add(Button(name: "backToMenuScene",
|
||||||
iconName: "",
|
iconName: "",
|
||||||
text: "Back",
|
text: "Back",
|
||||||
position: CGPoint(x: positionX, y: positionY),
|
position: CGPoint(x: positionX, y: positionY),
|
||||||
onButtonPress: {
|
onButtonPress: {
|
||||||
self.loadScene(scene: MenuScene(size: self.size))
|
self.loadScene(scene: MenuScene(size: self.size))
|
||||||
}))
|
}))
|
||||||
entityManager.add(Button(name: "StopMenuMusic",
|
EntityManager.sharedInstance.add(Button(name: "StopMenuMusic",
|
||||||
iconName: "",
|
iconName: "",
|
||||||
text: "ON/OFF",
|
text: "ON/OFF",
|
||||||
position: CGPoint(x: self.size.width * 0.6, y: self.size.height / 2),
|
position: CGPoint(x: self.size.width * 0.6, y: self.size.height / 2),
|
||||||
@ -36,7 +35,7 @@ class SettingsScene: SKScene {
|
|||||||
SoundManager.sharedInstance.startMenuMusic()
|
SoundManager.sharedInstance.startMenuMusic()
|
||||||
}
|
}
|
||||||
}))
|
}))
|
||||||
entityManager.add(Button(name: "StopMovingBackground",
|
EntityManager.sharedInstance.add(Button(name: "StopMovingBackground",
|
||||||
iconName: "",
|
iconName: "",
|
||||||
text: "MOVE/STOP",
|
text: "MOVE/STOP",
|
||||||
position: CGPoint(x: self.size.width * 0.6, y: self.size.height / 2 - 100),
|
position: CGPoint(x: self.size.width * 0.6, y: self.size.height / 2 - 100),
|
||||||
@ -47,7 +46,7 @@ class SettingsScene: SKScene {
|
|||||||
BackgroundComponent.isMovingBackgroundEnabled = true
|
BackgroundComponent.isMovingBackgroundEnabled = true
|
||||||
}
|
}
|
||||||
}))
|
}))
|
||||||
entityManager.add(Label(fontnamed: "Courier-Bold",
|
EntityManager.sharedInstance.add(Label(fontnamed: "Courier-Bold",
|
||||||
name: "SettingsLabel",
|
name: "SettingsLabel",
|
||||||
text: "Settings",
|
text: "Settings",
|
||||||
fontSize: 200.0,
|
fontSize: 200.0,
|
||||||
@ -58,7 +57,7 @@ class SettingsScene: SKScene {
|
|||||||
isAnimationEnabled: true,
|
isAnimationEnabled: true,
|
||||||
isAnimationInfinite: true)
|
isAnimationInfinite: true)
|
||||||
)
|
)
|
||||||
entityManager.add(Label(fontnamed: "Courier-Bold",
|
EntityManager.sharedInstance.add(Label(fontnamed: "Courier-Bold",
|
||||||
name: "LabelMusic",
|
name: "LabelMusic",
|
||||||
text: "Music", fontSize: 50.0,
|
text: "Music", fontSize: 50.0,
|
||||||
fontColor: .black,
|
fontColor: .black,
|
||||||
@ -68,7 +67,7 @@ class SettingsScene: SKScene {
|
|||||||
isAnimationEnabled: true,
|
isAnimationEnabled: true,
|
||||||
isAnimationInfinite: false)
|
isAnimationInfinite: false)
|
||||||
)
|
)
|
||||||
entityManager.add(Label(fontnamed: "Courier-Bold",
|
EntityManager.sharedInstance.add(Label(fontnamed: "Courier-Bold",
|
||||||
name: "LabelBackground",
|
name: "LabelBackground",
|
||||||
text: "Background",
|
text: "Background",
|
||||||
fontSize: 50.0,
|
fontSize: 50.0,
|
||||||
@ -79,7 +78,7 @@ class SettingsScene: SKScene {
|
|||||||
isAnimationEnabled: true,
|
isAnimationEnabled: true,
|
||||||
isAnimationInfinite: false)
|
isAnimationInfinite: false)
|
||||||
)
|
)
|
||||||
entityManager.add(Background(size: self.size))
|
EntityManager.sharedInstance.add(Background(size: self.size))
|
||||||
}
|
}
|
||||||
|
|
||||||
func loadScene(scene: SKScene) {
|
func loadScene(scene: SKScene) {
|
||||||
@ -88,7 +87,7 @@ class SettingsScene: SKScene {
|
|||||||
}
|
}
|
||||||
|
|
||||||
override func update(_ currentTime: TimeInterval) {
|
override func update(_ currentTime: TimeInterval) {
|
||||||
entityManager.getBackground()!.update(deltaTime: currentTime)
|
EntityManager.sharedInstance.getBackground()!.update(deltaTime: currentTime)
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user