Merge branch '17-popup-action-auf-basis-click' into 'development'

Resolve "PopUp Action auf Basis-click"

Closes #17

See merge request marcel.schwarz/software-projekt-2!26
This commit is contained in:
Aldin Duraki 2020-05-01 19:50:23 +00:00
commit f7fbeba1cc
20 changed files with 267 additions and 12 deletions

View File

@ -21,8 +21,13 @@
116060F7245C57D2004E5A36 /* EntityManager.swift in Sources */ = {isa = PBXBuildFile; fileRef = 116060F6245C57D2004E5A36 /* EntityManager.swift */; }; 116060F7245C57D2004E5A36 /* EntityManager.swift in Sources */ = {isa = PBXBuildFile; fileRef = 116060F6245C57D2004E5A36 /* EntityManager.swift */; };
11738A3B24508F68004426F1 /* Unit.swift in Sources */ = {isa = PBXBuildFile; fileRef = 11738A3A24508F68004426F1 /* Unit.swift */; }; 11738A3B24508F68004426F1 /* Unit.swift in Sources */ = {isa = PBXBuildFile; fileRef = 11738A3A24508F68004426F1 /* Unit.swift */; };
9E286A88245C6C6800EB32B8 /* TeamComponent.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9E286A87245C6C6800EB32B8 /* TeamComponent.swift */; }; 9E286A88245C6C6800EB32B8 /* TeamComponent.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9E286A87245C6C6800EB32B8 /* TeamComponent.swift */; };
9E78ACB6245C9A5300526FF7 /* GameKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 9E78ACB5245C9A5300526FF7 /* GameKit.framework */; };
9EA3ABE9245C6DAA006BC61D /* DefaultBaseComponent.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9EA3ABE8245C6DAA006BC61D /* DefaultBaseComponent.swift */; }; 9EA3ABE9245C6DAA006BC61D /* DefaultBaseComponent.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9EA3ABE8245C6DAA006BC61D /* DefaultBaseComponent.swift */; };
9EA3ABEB245C6DFA006BC61D /* BaseNode.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9EA3ABEA245C6DFA006BC61D /* BaseNode.swift */; }; 9EA3ABEB245C6DFA006BC61D /* BaseNode.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9EA3ABEA245C6DFA006BC61D /* BaseNode.swift */; };
9EA3ABED245C8143006BC61D /* ModalBackgroundComponent.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9EA3ABEC245C8143006BC61D /* ModalBackgroundComponent.swift */; };
9EA3ABEF245C834B006BC61D /* ModalContentComponent.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9EA3ABEE245C834B006BC61D /* ModalContentComponent.swift */; };
9EC86B9F245C88A300796EF3 /* Modal.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9EC86B9E245C88A300796EF3 /* Modal.swift */; };
9EC86BA6245C8AD000796EF3 /* ModalType.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9EC86BA5245C8AD000796EF3 /* ModalType.swift */; };
ABA03DA0244BD54F00A66916 /* Base.swift in Sources */ = {isa = PBXBuildFile; fileRef = ABA03D9F244BD54F00A66916 /* Base.swift */; }; ABA03DA0244BD54F00A66916 /* Base.swift in Sources */ = {isa = PBXBuildFile; fileRef = ABA03D9F244BD54F00A66916 /* Base.swift */; };
/* End PBXBuildFile section */ /* End PBXBuildFile section */
@ -64,8 +69,14 @@
116060F6245C57D2004E5A36 /* EntityManager.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = EntityManager.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>"; }; 11738A3A24508F68004426F1 /* Unit.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Unit.swift; sourceTree = "<group>"; };
9E286A87245C6C6800EB32B8 /* TeamComponent.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = TeamComponent.swift; path = ../../../../MonsterWars/MonsterWars/Components/TeamComponent.swift; sourceTree = "<group>"; }; 9E286A87245C6C6800EB32B8 /* TeamComponent.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = TeamComponent.swift; path = ../../../../MonsterWars/MonsterWars/Components/TeamComponent.swift; sourceTree = "<group>"; };
9E78ACB5245C9A5300526FF7 /* GameKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = GameKit.framework; path = System/Library/Frameworks/GameKit.framework; sourceTree = SDKROOT; };
9EA3ABE8245C6DAA006BC61D /* DefaultBaseComponent.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DefaultBaseComponent.swift; sourceTree = "<group>"; }; 9EA3ABE8245C6DAA006BC61D /* DefaultBaseComponent.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DefaultBaseComponent.swift; sourceTree = "<group>"; };
9EA3ABEA245C6DFA006BC61D /* BaseNode.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = BaseNode.swift; sourceTree = "<group>"; }; 9EA3ABEA245C6DFA006BC61D /* BaseNode.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = BaseNode.swift; sourceTree = "<group>"; };
9EA3ABEC245C8143006BC61D /* ModalBackgroundComponent.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ModalBackgroundComponent.swift; sourceTree = "<group>"; };
9EA3ABEE245C834B006BC61D /* ModalContentComponent.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ModalContentComponent.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>"; };
9ECD3699245C91F7008DEEBD /* GoldWars.entitlements */ = {isa = PBXFileReference; lastKnownFileType = text.plist.entitlements; path = GoldWars.entitlements; sourceTree = "<group>"; };
ABA03D9F244BD54F00A66916 /* Base.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Base.swift; sourceTree = "<group>"; }; ABA03D9F244BD54F00A66916 /* Base.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Base.swift; sourceTree = "<group>"; };
/* End PBXFileReference section */ /* End PBXFileReference section */
@ -74,6 +85,7 @@
isa = PBXFrameworksBuildPhase; isa = PBXFrameworksBuildPhase;
buildActionMask = 2147483647; buildActionMask = 2147483647;
files = ( files = (
9E78ACB6245C9A5300526FF7 /* GameKit.framework in Frameworks */,
); );
runOnlyForDeploymentPostprocessing = 0; runOnlyForDeploymentPostprocessing = 0;
}; };
@ -101,6 +113,7 @@
110360EC244B101B008610AF /* GoldWarsTests */, 110360EC244B101B008610AF /* GoldWarsTests */,
110360F7244B101B008610AF /* GoldWarsUITests */, 110360F7244B101B008610AF /* GoldWarsUITests */,
110360D0244B101A008610AF /* Products */, 110360D0244B101A008610AF /* Products */,
9E78ACB4245C9A5300526FF7 /* Frameworks */,
); );
sourceTree = "<group>"; sourceTree = "<group>";
}; };
@ -117,20 +130,16 @@
110360D1244B101A008610AF /* GoldWars */ = { 110360D1244B101A008610AF /* GoldWars */ = {
isa = PBXGroup; isa = PBXGroup;
children = ( children = (
9ECD3699245C91F7008DEEBD /* GoldWars.entitlements */,
116060F5245C5709004E5A36 /* Entities */, 116060F5245C5709004E5A36 /* Entities */,
116060F4245C56EA004E5A36 /* Components */, 116060F4245C56EA004E5A36 /* Components */,
11738A3A24508F68004426F1 /* Unit.swift */, 9EC86BA2245C89B200796EF3 /* Enums */,
11036112244B3E30008610AF /* MenuScene.swift */, 9EC86BA4245C8A1E00796EF3 /* Scenes */,
11036110244B3D6A008610AF /* MenuScene.sks */, 9EC86BA3245C89F400796EF3 /* Storyboards */,
110360D2244B101A008610AF /* AppDelegate.swift */, 110360D2244B101A008610AF /* AppDelegate.swift */,
110360D8244B101A008610AF /* GameScene.swift */,
110360D4244B101A008610AF /* GameScene.sks */,
110360DA244B101A008610AF /* GameViewController.swift */, 110360DA244B101A008610AF /* GameViewController.swift */,
110360DC244B101A008610AF /* Main.storyboard */,
110360DF244B101B008610AF /* Assets.xcassets */, 110360DF244B101B008610AF /* Assets.xcassets */,
110360E1244B101B008610AF /* LaunchScreen.storyboard */,
110360E4244B101B008610AF /* Info.plist */, 110360E4244B101B008610AF /* Info.plist */,
116060F6245C57D2004E5A36 /* EntityManager.swift */,
); );
path = GoldWars; path = GoldWars;
sourceTree = "<group>"; sourceTree = "<group>";
@ -158,6 +167,8 @@
children = ( children = (
9E286A87245C6C6800EB32B8 /* TeamComponent.swift */, 9E286A87245C6C6800EB32B8 /* TeamComponent.swift */,
9EA3ABE8245C6DAA006BC61D /* DefaultBaseComponent.swift */, 9EA3ABE8245C6DAA006BC61D /* DefaultBaseComponent.swift */,
9EA3ABEC245C8143006BC61D /* ModalBackgroundComponent.swift */,
9EA3ABEE245C834B006BC61D /* ModalContentComponent.swift */,
9EA3ABEA245C6DFA006BC61D /* BaseNode.swift */, 9EA3ABEA245C6DFA006BC61D /* BaseNode.swift */,
); );
path = Components; path = Components;
@ -167,10 +178,49 @@
isa = PBXGroup; isa = PBXGroup;
children = ( children = (
ABA03D9F244BD54F00A66916 /* Base.swift */, ABA03D9F244BD54F00A66916 /* Base.swift */,
9EC86B9E245C88A300796EF3 /* Modal.swift */,
116060F6245C57D2004E5A36 /* EntityManager.swift */,
); );
path = Entities; path = Entities;
sourceTree = "<group>"; sourceTree = "<group>";
}; };
9E78ACB4245C9A5300526FF7 /* Frameworks */ = {
isa = PBXGroup;
children = (
9E78ACB5245C9A5300526FF7 /* GameKit.framework */,
);
name = Frameworks;
sourceTree = "<group>";
};
9EC86BA2245C89B200796EF3 /* Enums */ = {
isa = PBXGroup;
children = (
11738A3A24508F68004426F1 /* Unit.swift */,
9EC86BA5245C8AD000796EF3 /* ModalType.swift */,
);
path = Enums;
sourceTree = "<group>";
};
9EC86BA3245C89F400796EF3 /* Storyboards */ = {
isa = PBXGroup;
children = (
110360DC244B101A008610AF /* Main.storyboard */,
110360E1244B101B008610AF /* LaunchScreen.storyboard */,
);
path = Storyboards;
sourceTree = "<group>";
};
9EC86BA4245C8A1E00796EF3 /* Scenes */ = {
isa = PBXGroup;
children = (
11036110244B3D6A008610AF /* MenuScene.sks */,
11036112244B3E30008610AF /* MenuScene.swift */,
110360D8244B101A008610AF /* GameScene.swift */,
110360D4244B101A008610AF /* GameScene.sks */,
);
path = Scenes;
sourceTree = "<group>";
};
/* End PBXGroup section */ /* End PBXGroup section */
/* Begin PBXNativeTarget section */ /* Begin PBXNativeTarget section */
@ -304,16 +354,20 @@
isa = PBXSourcesBuildPhase; isa = PBXSourcesBuildPhase;
buildActionMask = 2147483647; buildActionMask = 2147483647;
files = ( files = (
9EA3ABEF245C834B006BC61D /* ModalContentComponent.swift in Sources */,
9EC86BA6245C8AD000796EF3 /* ModalType.swift in Sources */,
9EA3ABEB245C6DFA006BC61D /* BaseNode.swift in Sources */, 9EA3ABEB245C6DFA006BC61D /* BaseNode.swift in Sources */,
110360D9244B101A008610AF /* GameScene.swift in Sources */, 110360D9244B101A008610AF /* GameScene.swift in Sources */,
116060F7245C57D2004E5A36 /* EntityManager.swift in Sources */, 116060F7245C57D2004E5A36 /* EntityManager.swift in Sources */,
11738A3B24508F68004426F1 /* Unit.swift in Sources */, 11738A3B24508F68004426F1 /* Unit.swift in Sources */,
11036113244B3E30008610AF /* MenuScene.swift in Sources */, 11036113244B3E30008610AF /* MenuScene.swift in Sources */,
9EA3ABE9245C6DAA006BC61D /* DefaultBaseComponent.swift in Sources */, 9EA3ABE9245C6DAA006BC61D /* DefaultBaseComponent.swift in Sources */,
9EA3ABED245C8143006BC61D /* ModalBackgroundComponent.swift in Sources */,
ABA03DA0244BD54F00A66916 /* Base.swift in Sources */, ABA03DA0244BD54F00A66916 /* Base.swift in Sources */,
9E286A88245C6C6800EB32B8 /* TeamComponent.swift in Sources */, 9E286A88245C6C6800EB32B8 /* TeamComponent.swift in Sources */,
110360DB244B101A008610AF /* GameViewController.swift in Sources */, 110360DB244B101A008610AF /* GameViewController.swift in Sources */,
110360D3244B101A008610AF /* AppDelegate.swift in Sources */, 110360D3244B101A008610AF /* AppDelegate.swift in Sources */,
9EC86B9F245C88A300796EF3 /* Modal.swift in Sources */,
); );
runOnlyForDeploymentPostprocessing = 0; runOnlyForDeploymentPostprocessing = 0;
}; };
@ -486,6 +540,8 @@
isa = XCBuildConfiguration; isa = XCBuildConfiguration;
buildSettings = { buildSettings = {
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
CODE_SIGN_ENTITLEMENTS = GoldWars/GoldWars.entitlements;
CODE_SIGN_IDENTITY = "Apple Development";
CODE_SIGN_STYLE = Automatic; CODE_SIGN_STYLE = Automatic;
DEVELOPMENT_TEAM = DDKFQG46BQ; DEVELOPMENT_TEAM = DDKFQG46BQ;
INFOPLIST_FILE = GoldWars/Info.plist; INFOPLIST_FILE = GoldWars/Info.plist;
@ -493,8 +549,9 @@
"$(inherited)", "$(inherited)",
"@executable_path/Frameworks", "@executable_path/Frameworks",
); );
PRODUCT_BUNDLE_IDENTIFIER = com.hft.stuttgart.GoldWars; PRODUCT_BUNDLE_IDENTIFIER = de.hft.stuttgart.ip2.goldwars;
PRODUCT_NAME = "$(TARGET_NAME)"; PRODUCT_NAME = "$(TARGET_NAME)";
PROVISIONING_PROFILE_SPECIFIER = "";
SWIFT_VERSION = 5.0; SWIFT_VERSION = 5.0;
TARGETED_DEVICE_FAMILY = 2; TARGETED_DEVICE_FAMILY = 2;
}; };
@ -504,6 +561,8 @@
isa = XCBuildConfiguration; isa = XCBuildConfiguration;
buildSettings = { buildSettings = {
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
CODE_SIGN_ENTITLEMENTS = GoldWars/GoldWars.entitlements;
CODE_SIGN_IDENTITY = "Apple Development";
CODE_SIGN_STYLE = Automatic; CODE_SIGN_STYLE = Automatic;
DEVELOPMENT_TEAM = DDKFQG46BQ; DEVELOPMENT_TEAM = DDKFQG46BQ;
INFOPLIST_FILE = GoldWars/Info.plist; INFOPLIST_FILE = GoldWars/Info.plist;
@ -511,8 +570,9 @@
"$(inherited)", "$(inherited)",
"@executable_path/Frameworks", "@executable_path/Frameworks",
); );
PRODUCT_BUNDLE_IDENTIFIER = com.hft.stuttgart.GoldWars; PRODUCT_BUNDLE_IDENTIFIER = de.hft.stuttgart.ip2.goldwars;
PRODUCT_NAME = "$(TARGET_NAME)"; PRODUCT_NAME = "$(TARGET_NAME)";
PROVISIONING_PROFILE_SPECIFIER = "";
SWIFT_VERSION = 5.0; SWIFT_VERSION = 5.0;
TARGETED_DEVICE_FAMILY = 2; TARGETED_DEVICE_FAMILY = 2;
}; };

View File

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

Binary file not shown.

After

Width:  |  Height:  |  Size: 400 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 400 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 400 KiB

View File

@ -0,0 +1,27 @@
//
// ModalBackgroundComponent.swift
// GoldWars
//
// Created by Niko Jochim on 01.05.20.
// Copyright © 2020 SP2. All rights reserved.
//
import Foundation
import GameplayKit
import SpriteKit
class ModalBackgroundComponent: GKComponent {
let spriteNode : SKSpriteNode
init(anchorPoint: CGPoint) {
let texture = SKTexture(imageNamed:"ModalBackground")
spriteNode = SKSpriteNode(texture: texture, size: texture.size())
spriteNode.setScale(2)
spriteNode.position = anchorPoint
super.init()
}
required init?(coder aDecoder: NSCoder) {
fatalError("init(coder:) has not been implemented")
}
}

View File

@ -0,0 +1,43 @@
//
// ModalComponent.swift
// GoldWars
//
// Created by Niko Jochim on 01.05.20.
// Copyright © 2020 SP2. All rights reserved.
//
import Foundation
import GameplayKit
import SpriteKit
class ModalContentComponent: GKComponent{
var header: SKLabelNode
var body: SKLabelNode
var footer: SKLabelNode
init(header: String, body: String, footer: String , anchorPoint: CGPoint) {
self.header = SKLabelNode(text: header)
self.header.position = CGPoint(x: anchorPoint.x, y: anchorPoint.y + 125)
self.header.fontName = "HelveticaNeue-Bold"
self.header.fontSize = 40
self.body = SKLabelNode(text: body)
self.body.position = CGPoint(x: anchorPoint.x, y: anchorPoint.y - 20)
self.body.numberOfLines = 2
self.body.preferredMaxLayoutWidth = 390
self.body.horizontalAlignmentMode = SKLabelHorizontalAlignmentMode.center
self.body.fontName = "HelveticaNeue-Bold"
self.body.fontSize = 40
self.footer = SKLabelNode(text: footer)
self.footer.position = CGPoint(x: anchorPoint.x, y: anchorPoint.y - 20)
self.footer.fontName = "HelveticaNeue-Bold"
self.footer.fontSize = 40
super.init()
}
required init?(coder aDecoder: NSCoder) {
fatalError("init(coder:) has not been implemented")
}
}

View File

@ -10,13 +10,16 @@ import SpriteKit
import GameplayKit import GameplayKit
class Base : GKEntity{ class Base : GKEntity{
var unitCount:Int
init(textureName:String, team: Team? ) { init(textureName:String, team: Team? ) {
self.unitCount = 0
super.init() super.init()
addComponent(DefaultBaseComponent(texture: SKTexture(imageNamed: textureName))) addComponent(DefaultBaseComponent(texture: SKTexture(imageNamed: textureName)))
if(team != nil){ if(team != nil){
addComponent(TeamComponent(team: team!)) addComponent(TeamComponent(team: team!))
} }
} }
required init?(coder: NSCoder) { required init?(coder: NSCoder) {

View File

@ -14,9 +14,11 @@ class EntityManager {
var entities = Set<GKEntity>() var entities = Set<GKEntity>()
let scene: SKScene let scene: SKScene
var isModal:Bool
init(scene: SKScene) { init(scene: SKScene) {
self.scene = scene self.scene = scene
isModal = false
} }
func add(_ entity: GKEntity) { func add(_ entity: GKEntity) {
@ -24,6 +26,16 @@ class EntityManager {
if let spriteNode = entity.component(ofType: DefaultBaseComponent.self)?.spriteNode { if let spriteNode = entity.component(ofType: DefaultBaseComponent.self)?.spriteNode {
scene.addChild(spriteNode) scene.addChild(spriteNode)
} }
if let spriteNode = entity.component(ofType: ModalBackgroundComponent.self)?.spriteNode {
scene.addChild(spriteNode)
isModal = true
}
if let modal = entity.component(ofType: ModalContentComponent.self) {
scene.addChild(modal.header)
scene.addChild(modal.body)
scene.addChild(modal.footer)
}
} }
@ -31,6 +43,15 @@ class EntityManager {
if let spriteNode = entity.component(ofType: DefaultBaseComponent.self)?.spriteNode { if let spriteNode = entity.component(ofType: DefaultBaseComponent.self)?.spriteNode {
spriteNode.removeFromParent() spriteNode.removeFromParent()
} }
if let spriteNode = entity.component(ofType: ModalBackgroundComponent.self)?.spriteNode {
spriteNode.removeFromParent()
isModal = false
}
if let modal = entity.component(ofType: ModalContentComponent.self) {
modal.header.removeFromParent()
modal.body.removeFromParent()
modal.footer.removeFromParent()
}
entities.remove(entity) entities.remove(entity)
} }

View File

@ -0,0 +1,33 @@
//
// Modal.swift
// GoldWars
//
// Created by Niko Jochim on 01.05.20.
// Copyright © 2020 SP2. All rights reserved.
//
import Foundation
import GameplayKit
class Modal:GKEntity{
init(modaltype: ModalType, base: Base, anchorPoint: CGPoint) {
super.init()
switch modaltype{
case .BaseDetails:
addComponent(ModalBackgroundComponent(anchorPoint: anchorPoint))
addComponent(ModalContentComponent(header: "Basis Information",
body: "Diese Basis enthält \(base.unitCount) Einheiten",
footer: "",anchorPoint: anchorPoint))
default:
print("Bisch du dumm")
}
}
required init?(coder: NSCoder) {
fatalError("init(coder:) has not been implemented")
}
}

View File

@ -0,0 +1,14 @@
//
// ModalType.swift
// GoldWars
//
// Created by Niko Jochim on 01.05.20.
// Copyright © 2020 SP2. All rights reserved.
//
import Foundation
enum ModalType: String{
case BaseDetails
case BaseAttack
}

View File

@ -0,0 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict/>
</plist>

View File

@ -28,6 +28,8 @@
<array> <array>
<string>armv7</string> <string>armv7</string>
</array> </array>
<key>UIRequiresFullScreen</key>
<true/>
<key>UIStatusBarHidden</key> <key>UIStatusBarHidden</key>
<true/> <true/>
<key>UISupportedInterfaceOrientations</key> <key>UISupportedInterfaceOrientations</key>

View File

@ -18,6 +18,7 @@ class GameScene: SKScene{
entityManager.add(Base(textureName: "Base", team: .team1)) entityManager.add(Base(textureName: "Base", team: .team1))
entityManager.add(Base(textureName: "Base", team: .team2)) entityManager.add(Base(textureName: "Base", team: .team2))
initMap() initMap()
} }
@ -26,6 +27,7 @@ class GameScene: SKScene{
entityManager.baseNode(for: .team1)?.position = CGPoint(x: self.size.width * 0.1, y: self.size.height / 2) 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.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() createVirginBases()
} }
@ -81,20 +83,42 @@ class GameScene: SKScene{
} }
override func touchesBegan(_ touches: Set<UITouch>, with event: UIEvent?) { override func touchesBegan(_ touches: Set<UITouch>, with event: UIEvent?) {
guard let touch = touches.first else { guard let touch = touches.first else {
return return
} }
let touchLocation = touch.location(in: self) let touchLocation = touch.location(in: self)
for entity in entityManager.entities { for entity in entityManager.entities {
let spriteNode = entity.component(ofType: DefaultBaseComponent.self)?.spriteNode let spriteNode = entity.component(ofType: DefaultBaseComponent.self)?.spriteNode
if atPoint(touchLocation) == spriteNode { if entityManager.isModal && entity.isMember(of: Modal.self) {
spriteNode?.touchesBegan(touches, with: event) entityManager.remove(entity)
for child in self.children {
child.alpha = 1
}
} }
if atPoint(touchLocation) == spriteNode && !entityManager.isModal {
spriteNode?.touchesBegan(touches, with: event)
if !entityManager.isModal {
for child in self.children {
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)))
}
}
} }
} }