Merge branch '19-einheiten-bewegen' into 'development'

Resolve "Einheiten bewegen"

See merge request marcel.schwarz/software-projekt-2!30
This commit is contained in:
Aldin Duraki 2020-05-01 23:24:42 +00:00
commit 8a3357280e
10 changed files with 78 additions and 14 deletions

View File

@ -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 = "<group>"; };
116060F6245C57D2004E5A36 /* EntityManager.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = EntityManager.swift; sourceTree = "<group>"; };
11738A3A24508F68004426F1 /* Unit.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Unit.swift; sourceTree = "<group>"; };
9E11FF77245CD81100EED3BE /* Fire.sks */ = {isa = PBXFileReference; lastKnownFileType = file.sks; path = Fire.sks; sourceTree = "<group>"; };
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 = "<group>"; };
9E78ACB9245CBDAF00526FF7 /* HUD.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = HUD.swift; sourceTree = "<group>"; };
@ -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 = "<group>";
};
9E11FF74245CD79100EED3BE /* Partikels */ = {
isa = PBXGroup;
children = (
9E11FF77245CD81100EED3BE /* Fire.sks */,
);
path = Partikels;
sourceTree = "<group>";
};
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 = (

View File

@ -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
}
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.1 KiB

View File

@ -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()
}

View File

@ -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()
}

View File

@ -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))
}
}

View File

@ -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

Binary file not shown.

View File

@ -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,8 +111,10 @@ class GameScene: SKScene{
if entityManager.isModal && entity.isMember(of: Modal.self) {
entityManager.remove(entity)
for child in self.children {
if(child.name != "fire"){
child.alpha = 1
}
}
}
@ -119,8 +122,11 @@ class GameScene: SKScene{
spriteNode?.touchesBegan(touches, with: event)
if !entityManager.isModal {
for child in self.children {
if(child.name != "fire"){
child.alpha = 0.3
}
}
entityManager.add(Modal(modaltype: .BaseDetails,
base: entity as! Base,
anchorPoint: CGPoint(x: self.size.width / 2 , y: self.size.height / 2)))
@ -129,6 +135,8 @@ class GameScene: SKScene{
}
}
override func update(_ currentTime: TimeInterval) {
self.enumerateChildNodes(withName: "clouds", using: ({
(node, error) in