diff --git a/GoldWars/GoldWars.xcodeproj/project.pbxproj b/GoldWars/GoldWars.xcodeproj/project.pbxproj index 41c82b9..adf2cf1 100644 --- a/GoldWars/GoldWars.xcodeproj/project.pbxproj +++ b/GoldWars/GoldWars.xcodeproj/project.pbxproj @@ -20,6 +20,7 @@ 11036113244B3E30008610AF /* MenuScene.swift in Sources */ = {isa = PBXBuildFile; fileRef = 11036112244B3E30008610AF /* MenuScene.swift */; }; 116060F7245C57D2004E5A36 /* EntityManager.swift in Sources */ = {isa = PBXBuildFile; fileRef = 116060F6245C57D2004E5A36 /* EntityManager.swift */; }; 11738A3B24508F68004426F1 /* Unit.swift in Sources */ = {isa = PBXBuildFile; fileRef = 11738A3A24508F68004426F1 /* Unit.swift */; }; + 9E11FF79245CD81100EED3BE /* Fire.sks in Resources */ = {isa = PBXBuildFile; fileRef = 9E11FF77245CD81100EED3BE /* Fire.sks */; }; 9E78ACB6245C9A5300526FF7 /* GameKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 9E78ACB5245C9A5300526FF7 /* GameKit.framework */; }; 9E78ACB8245CB75B00526FF7 /* TeamComponent.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9E78ACB7245CB75B00526FF7 /* TeamComponent.swift */; }; 9E78ACBA245CBDAF00526FF7 /* HUD.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9E78ACB9245CBDAF00526FF7 /* HUD.swift */; }; @@ -72,6 +73,7 @@ 11036112244B3E30008610AF /* MenuScene.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MenuScene.swift; sourceTree = ""; }; 116060F6245C57D2004E5A36 /* EntityManager.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = EntityManager.swift; sourceTree = ""; }; 11738A3A24508F68004426F1 /* Unit.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Unit.swift; sourceTree = ""; }; + 9E11FF77245CD81100EED3BE /* Fire.sks */ = {isa = PBXFileReference; lastKnownFileType = file.sks; path = Fire.sks; sourceTree = ""; }; 9E78ACB5245C9A5300526FF7 /* GameKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = GameKit.framework; path = System/Library/Frameworks/GameKit.framework; sourceTree = SDKROOT; }; 9E78ACB7245CB75B00526FF7 /* TeamComponent.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TeamComponent.swift; sourceTree = ""; }; 9E78ACB9245CBDAF00526FF7 /* HUD.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = HUD.swift; sourceTree = ""; }; @@ -139,6 +141,7 @@ isa = PBXGroup; children = ( 9ECD3699245C91F7008DEEBD /* GoldWars.entitlements */, + 9E11FF74245CD79100EED3BE /* Partikels */, 116060F5245C5709004E5A36 /* Entities */, 116060F4245C56EA004E5A36 /* Components */, 9EC86BA2245C89B200796EF3 /* Enums */, @@ -196,6 +199,14 @@ path = Entities; sourceTree = ""; }; + 9E11FF74245CD79100EED3BE /* Partikels */ = { + isa = PBXGroup; + children = ( + 9E11FF77245CD81100EED3BE /* Fire.sks */, + ); + path = Partikels; + sourceTree = ""; + }; 9E78ACB4245C9A5300526FF7 /* Frameworks */ = { isa = PBXGroup; children = ( @@ -340,6 +351,7 @@ 110360DE244B101A008610AF /* Main.storyboard in Resources */, 11036111244B3D6A008610AF /* MenuScene.sks in Resources */, 110360D5244B101A008610AF /* GameScene.sks in Resources */, + 9E11FF79245CD81100EED3BE /* Fire.sks in Resources */, 110360E0244B101B008610AF /* Assets.xcassets in Resources */, 110360E3244B101B008610AF /* LaunchScreen.storyboard in Resources */, ); @@ -599,7 +611,9 @@ buildSettings = { ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = YES; BUNDLE_LOADER = "$(TEST_HOST)"; + "CODE_SIGN_IDENTITY[sdk=macosx*]" = "Apple Development"; CODE_SIGN_STYLE = Automatic; + DEVELOPMENT_TEAM = DDKFQG46BQ; INFOPLIST_FILE = GoldWarsTests/Info.plist; IPHONEOS_DEPLOYMENT_TARGET = 13.2; LD_RUNPATH_SEARCH_PATHS = ( @@ -620,7 +634,9 @@ buildSettings = { ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = YES; BUNDLE_LOADER = "$(TEST_HOST)"; + "CODE_SIGN_IDENTITY[sdk=macosx*]" = "Apple Development"; CODE_SIGN_STYLE = Automatic; + DEVELOPMENT_TEAM = DDKFQG46BQ; INFOPLIST_FILE = GoldWarsTests/Info.plist; IPHONEOS_DEPLOYMENT_TARGET = 13.2; LD_RUNPATH_SEARCH_PATHS = ( diff --git a/GoldWars/GoldWars/Assets.xcassets/spark.imageset/Contents.json b/GoldWars/GoldWars/Assets.xcassets/spark.imageset/Contents.json new file mode 100644 index 0000000..5fdc9ea --- /dev/null +++ b/GoldWars/GoldWars/Assets.xcassets/spark.imageset/Contents.json @@ -0,0 +1,21 @@ +{ + "images" : [ + { + "filename" : "spark.png", + "idiom" : "universal", + "scale" : "1x" + }, + { + "idiom" : "universal", + "scale" : "2x" + }, + { + "idiom" : "universal", + "scale" : "3x" + } + ], + "info" : { + "author" : "xcode", + "version" : 1 + } +} diff --git a/GoldWars/GoldWars/Assets.xcassets/spark.imageset/spark.png b/GoldWars/GoldWars/Assets.xcassets/spark.imageset/spark.png new file mode 100644 index 0000000..3383a21 Binary files /dev/null and b/GoldWars/GoldWars/Assets.xcassets/spark.imageset/spark.png differ diff --git a/GoldWars/GoldWars/Components/DefaultBaseComponent.swift b/GoldWars/GoldWars/Components/DefaultBaseComponent.swift index fe5645d..f668990 100644 --- a/GoldWars/GoldWars/Components/DefaultBaseComponent.swift +++ b/GoldWars/GoldWars/Components/DefaultBaseComponent.swift @@ -13,8 +13,9 @@ import SpriteKit class DefaultBaseComponent: GKComponent { var spriteNode: BaseNode - init(texture: SKTexture) { + init(texture: SKTexture,position: CGPoint) { spriteNode = BaseNode(texture: texture, size: CGSize(width: 80, height: 80)) + spriteNode.position = position super.init() } diff --git a/GoldWars/GoldWars/Components/TeamComponent.swift b/GoldWars/GoldWars/Components/TeamComponent.swift index 4413436..0509a36 100644 --- a/GoldWars/GoldWars/Components/TeamComponent.swift +++ b/GoldWars/GoldWars/Components/TeamComponent.swift @@ -21,8 +21,22 @@ enum Team: Int { class TeamComponent: GKComponent { let team: Team + let fire:SKEmitterNode + + init(team: Team, position: CGPoint) { + fire = SKEmitterNode(fileNamed: "Fire")! + fire.zPosition = -1 + fire.position = position + fire.name = "fire" + fire.particleColorSequence = nil + fire.particleColorBlendFactor = 1.0 + switch team { + case .team1: fire.particleColor = SKColor.red + case .team2: fire.particleColor = SKColor.purple + case .team3: fire.particleColor = SKColor.green + case .team4: fire.particleColor = SKColor.gray + } - init(team: Team) { self.team = team super.init() } diff --git a/GoldWars/GoldWars/Entities/Base.swift b/GoldWars/GoldWars/Entities/Base.swift index 85aafb2..1358b97 100644 --- a/GoldWars/GoldWars/Entities/Base.swift +++ b/GoldWars/GoldWars/Entities/Base.swift @@ -12,12 +12,13 @@ import GameplayKit class Base : GKEntity{ var unitCount:Int - init(textureName:String, team: Team? ) { + init(textureName:String, team: Team?,position: CGPoint ) { self.unitCount = 0 super.init() - addComponent(DefaultBaseComponent(texture: SKTexture(imageNamed: textureName))) + addComponent(DefaultBaseComponent(texture: SKTexture(imageNamed: textureName), position: position)) if(team != nil){ - addComponent(TeamComponent(team: team!)) + addComponent(TeamComponent(team: team!, position: position)) + } } diff --git a/GoldWars/GoldWars/Entities/EntityManager.swift b/GoldWars/GoldWars/Entities/EntityManager.swift index 0ef959e..8f94ce6 100644 --- a/GoldWars/GoldWars/Entities/EntityManager.swift +++ b/GoldWars/GoldWars/Entities/EntityManager.swift @@ -26,6 +26,9 @@ class EntityManager { if let spriteNode = entity.component(ofType: DefaultBaseComponent.self)?.spriteNode { scene.addChild(spriteNode) } + if let fire = entity.component(ofType: TeamComponent.self)?.fire{ + scene.addChild(fire) + } if let spriteNode = entity.component(ofType: ModalBackgroundComponent.self)?.spriteNode { scene.addChild(spriteNode) isModal = true diff --git a/GoldWars/GoldWars/Partikels/Fire.sks b/GoldWars/GoldWars/Partikels/Fire.sks new file mode 100644 index 0000000..839f2ca Binary files /dev/null and b/GoldWars/GoldWars/Partikels/Fire.sks differ diff --git a/GoldWars/GoldWars/Scenes/GameScene.swift b/GoldWars/GoldWars/Scenes/GameScene.swift index 8a2f2d4..e9380f2 100644 --- a/GoldWars/GoldWars/Scenes/GameScene.swift +++ b/GoldWars/GoldWars/Scenes/GameScene.swift @@ -15,8 +15,13 @@ class GameScene: SKScene{ override func sceneDidLoad() { entityManager = EntityManager(scene: self) - entityManager.add(Base(textureName: "Base", team: .team1)) - entityManager.add(Base(textureName: "Base", team: .team2)) + entityManager.add(Base(textureName: "Base", + team: .team1 , + position: CGPoint(x: self.size.width * 0.1, y: self.size.height / 2))) + + entityManager.add(Base(textureName: "Base", + team: .team2 , + position: CGPoint(x: self.size.width * 0.9, y: self.size.height / 2))) entityManager.add(HUD(size: self.size)) initMap() createBackground() @@ -38,9 +43,6 @@ class GameScene: SKScene{ // TODO: Issue #24 create Map generation Service func initMap() { - entityManager.baseNode(for: .team1)?.position = CGPoint(x: self.size.width * 0.1, y: self.size.height / 2) - entityManager.baseNode(for: .team2)?.position = CGPoint(x: self.size.width * 0.9, y: self.size.height / 2) - (entityManager.base(for: .team2) as! Base).unitCount = 3 createVirginBases() } @@ -88,8 +90,7 @@ class GameScene: SKScene{ default: break } - base = Base(textureName: "Base", team: nil) - base.component(ofType: DefaultBaseComponent.self)?.spriteNode.position = position + base = Base(textureName: "Base", team: nil, position: position) entityManager.add(base) } @@ -110,7 +111,9 @@ class GameScene: SKScene{ if entityManager.isModal && entity.isMember(of: Modal.self) { entityManager.remove(entity) for child in self.children { - child.alpha = 1 + if(child.name != "fire"){ + child.alpha = 1 + } } } @@ -119,7 +122,10 @@ class GameScene: SKScene{ spriteNode?.touchesBegan(touches, with: event) if !entityManager.isModal { for child in self.children { - child.alpha = 0.3 + if(child.name != "fire"){ + child.alpha = 0.3 + } + } entityManager.add(Modal(modaltype: .BaseDetails, base: entity as! Base, @@ -129,6 +135,8 @@ class GameScene: SKScene{ } } + + override func update(_ currentTime: TimeInterval) { self.enumerateChildNodes(withName: "clouds", using: ({ (node, error) in diff --git a/GoldWars/GoldWars/Scenes/MenuScene.sks b/GoldWars/GoldWars/Scenes/MenuScene.sks index 487cd23..0e09135 100644 Binary files a/GoldWars/GoldWars/Scenes/MenuScene.sks and b/GoldWars/GoldWars/Scenes/MenuScene.sks differ