Revert "Merge branch '33-basisownership-anhand-des-gkplayers' into 'development'"

This reverts merge request !54
This commit is contained in:
Marcel Schwarz 2020-05-10 16:48:04 +00:00 committed by Jakob Haag
parent bd5d142a43
commit 4189d0f634
30 changed files with 454 additions and 465 deletions

View File

@ -10,32 +10,32 @@ import UIKit
@UIApplicationMain @UIApplicationMain
class AppDelegate: UIResponder, UIApplicationDelegate { class AppDelegate: UIResponder, UIApplicationDelegate {
var window: UIWindow? var window: UIWindow?
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool { func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
// Override point for customization after application launch. // Override point for customization after application launch.
return true return true
} }
func applicationWillResignActive(_ application: UIApplication) { func applicationWillResignActive(_ application: UIApplication) {
// Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state. // Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state.
// Use this method to pause ongoing tasks, disable timers, and invalidate graphics rendering callbacks. Games should use this method to pause the game. // Use this method to pause ongoing tasks, disable timers, and invalidate graphics rendering callbacks. Games should use this method to pause the game.
} }
func applicationDidEnterBackground(_ application: UIApplication) { func applicationDidEnterBackground(_ application: UIApplication) {
// Use this method to release shared resources, save user data, invalidate timers, and store enough application state information to restore your application to its current state in case it is terminated later. // Use this method to release shared resources, save user data, invalidate timers, and store enough application state information to restore your application to its current state in case it is terminated later.
} }
func applicationWillEnterForeground(_ application: UIApplication) { func applicationWillEnterForeground(_ application: UIApplication) {
// Called as part of the transition from the background to the active state; here you can undo many of the changes made on entering the background. // Called as part of the transition from the background to the active state; here you can undo many of the changes made on entering the background.
} }
func applicationDidBecomeActive(_ application: UIApplication) { func applicationDidBecomeActive(_ application: UIApplication) {
// Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface. // Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface.
} }
} }

View File

@ -9,25 +9,25 @@
import GameplayKit import GameplayKit
class AtkBoostSkillComponent: GKComponent{ class AtkBoostSkillComponent: GKComponent{
let shapeNode: SKShapeNode let shapeNode: SKShapeNode
let labelNode: SKLabelNode let labelNode: SKLabelNode
init(text: String, texture: SKTexture?, anchorPoint: CGPoint) { init(text: String, texture: SKTexture?, anchorPoint: CGPoint) {
self.labelNode = SKLabelNode(text: text) self.labelNode = SKLabelNode(text: text)
self.shapeNode = SKShapeNode(circleOfRadius: 30) self.shapeNode = SKShapeNode(circleOfRadius: 30)
self.shapeNode.position = anchorPoint self.shapeNode.position = anchorPoint
self.labelNode.position = CGPoint(x: anchorPoint.x, y: anchorPoint.y - 15) self.labelNode.position = CGPoint(x: anchorPoint.x, y: anchorPoint.y - 15)
if texture != nil { if texture != nil {
shapeNode.fillTexture = texture shapeNode.fillTexture = texture
}else { }else {
shapeNode.fillColor = SKColor.gray shapeNode.fillColor = SKColor.gray
} }
super.init() super.init()
} }
required init?(coder: NSCoder) { required init?(coder: NSCoder) {
fatalError("init(coder:) has not been implemented") fatalError("init(coder:) has not been implemented")
} }
} }

View File

@ -9,19 +9,19 @@
import GameplayKit import GameplayKit
class AttackActionComponent: GKComponent { class AttackActionComponent: GKComponent {
init(unitCount: Int, adjacencyList: Array<Base>, position: CGPoint) { init(unitCount: Int, adjacencyList: Array<Base>, position: CGPoint) {
super.init() super.init()
} }
required init?(coder: NSCoder) { required init?(coder: NSCoder) {
fatalError("init(coder:) has not been implemented") fatalError("init(coder:) has not been implemented")
} }
func action() { func action() {
// Not implemented yet // Not implemented yet
} }
} }

View File

@ -9,10 +9,10 @@
import GameplayKit import GameplayKit
class BackgroundComponent: GKComponent{ class BackgroundComponent: GKComponent{
var nodes = [SKSpriteNode]() var nodes = [SKSpriteNode]()
let size: CGSize let size: CGSize
init(size: CGSize) { init(size: CGSize) {
self.size = size self.size = size
for i in 0...2 { for i in 0...2 {
@ -24,8 +24,8 @@ class BackgroundComponent: GKComponent{
nodes.append(sky) nodes.append(sky)
} }
super.init() super.init()
} }
func update(){ func update(){
for node in nodes{ for node in nodes{
node.position.x -= 2 node.position.x -= 2
@ -34,9 +34,9 @@ class BackgroundComponent: GKComponent{
} }
} }
} }
required init?(coder: NSCoder) { required init?(coder: NSCoder) {
fatalError("init(coder:) has not been implemented") fatalError("init(coder:) has not been implemented")
} }
} }

View File

@ -9,26 +9,26 @@
import SpriteKit import SpriteKit
class BaseNode: SKSpriteNode{ class BaseNode: SKSpriteNode{
override func touchesBegan(_ touches: Set<UITouch>, with event: UIEvent?) { override func touchesBegan(_ touches: Set<UITouch>, with event: UIEvent?) {
// TODO: PopUp Einheiten + Close PopUp // TODO: PopUp Einheiten + Close PopUp
self.run( self.run(
SKAction.sequence( SKAction.sequence(
[ [
SKAction.resize(byWidth: 20, height: 20, duration: 0.5), SKAction.resize(byWidth: 20, height: 20, duration: 0.5),
SKAction.resize(byWidth: -20, height: -20, duration: 0.5) SKAction.resize(byWidth: -20, height: -20, duration: 0.5)
] ]
) )
) )
} }
override func touchesMoved(_ touches: Set<UITouch>, with event: UIEvent?) { override func touchesMoved(_ touches: Set<UITouch>, with event: UIEvent?) {
// TODO: zeige Angirff Effect // TODO: zeige Angirff Effect
} }
override func touchesEnded(_ touches: Set<UITouch>, with event: UIEvent?) { override func touchesEnded(_ touches: Set<UITouch>, with event: UIEvent?) {
// TODO: Open Slider PopUp // TODO: Open Slider PopUp
} }
} }

View File

@ -9,9 +9,9 @@
import GameplayKit import GameplayKit
class ButtonComponent: GKComponent { class ButtonComponent: GKComponent {
var buttonNode: ButtonNode var buttonNode: ButtonNode
init(iconName: String, text: String, position: CGPoint, isEnabled:Bool, onButtonPress: @escaping () -> ()) { init(iconName: String, text: String, position: CGPoint, isEnabled:Bool, onButtonPress: @escaping () -> ()) {
buttonNode = ButtonNode(iconName: iconName, buttonNode = ButtonNode(iconName: iconName,
text: text, text: text,

View File

@ -9,7 +9,7 @@
import SpriteKit import SpriteKit
class ButtonNode: SKSpriteNode { class ButtonNode: SKSpriteNode {
var isEnabled: Bool{ var isEnabled: Bool{
didSet{ didSet{
if isEnabled { if isEnabled {
@ -18,19 +18,19 @@ class ButtonNode: SKSpriteNode {
} else { } else {
self.alpha = 0.3 self.alpha = 0.3
self.childNode(withName: "label")?.alpha = 0.3 self.childNode(withName: "label")?.alpha = 0.3
} }
} }
} }
let onButtonPress: () -> () let onButtonPress: () -> ()
init(iconName: String, text: String, isEnabled: Bool, position: CGPoint, onButtonPress: @escaping () -> ()) { init(iconName: String, text: String, isEnabled: Bool, position: CGPoint, onButtonPress: @escaping () -> ()) {
self.onButtonPress = onButtonPress self.onButtonPress = onButtonPress
self.isEnabled = isEnabled self.isEnabled = isEnabled
let texture = SKTexture(imageNamed: "yellow_button04") let texture = SKTexture(imageNamed: "yellow_button04")
super.init(texture: texture, color: SKColor.white, size: texture.size()) super.init(texture: texture, color: SKColor.white, size: texture.size())
self.position = position self.position = position
let label = SKLabelNode(fontNamed: "Courier-Bold") let label = SKLabelNode(fontNamed: "Courier-Bold")
label.fontSize = 30 label.fontSize = 30
label.fontColor = SKColor.black label.fontColor = SKColor.black
@ -38,7 +38,7 @@ class ButtonNode: SKSpriteNode {
label.verticalAlignmentMode = .center label.verticalAlignmentMode = .center
label.text = text label.text = text
label.name = "label" label.name = "label"
if iconName.isEmpty { if iconName.isEmpty {
label.position = CGPoint(x: 0, y: 0) label.position = CGPoint(x: 0, y: 0)
} else { } else {
@ -50,26 +50,26 @@ class ButtonNode: SKSpriteNode {
} }
self.addChild(label) self.addChild(label)
isUserInteractionEnabled = true isUserInteractionEnabled = true
}
override func touchesBegan(_ touches: Set<UITouch>, with event: UIEvent?) {
if isEnabled {
let action = SKAction.sequence(
[
SKAction.scale(by: (3/4), duration: 0.3),
SKAction.scale(by: (4/3), duration: 0.3),
]
)
self.childNode(withName: "label")?.run(action)
self.run(action)
onButtonPress()
} }
}
override func touchesBegan(_ touches: Set<UITouch>, with event: UIEvent?) {
if isEnabled {
let action = SKAction.sequence( required init?(coder aDecoder: NSCoder) {
[ fatalError("init(coder:) has not been implemented")
SKAction.scale(by: (3/4), duration: 0.3), }
SKAction.scale(by: (4/3), duration: 0.3),
]
)
self.childNode(withName: "label")?.run(action)
self.run(action)
onButtonPress()
}
}
required init?(coder aDecoder: NSCoder) {
fatalError("init(coder:) has not been implemented")
}
} }

View File

@ -9,25 +9,25 @@
import GameplayKit import GameplayKit
class DefBoostSkillComponent: GKComponent{ class DefBoostSkillComponent: GKComponent{
let shapeNode: SKShapeNode let shapeNode: SKShapeNode
let labelNode: SKLabelNode let labelNode: SKLabelNode
init(text: String, texture: SKTexture?, anchorPoint: CGPoint) { init(text: String, texture: SKTexture?, anchorPoint: CGPoint) {
self.labelNode = SKLabelNode(text: text) self.labelNode = SKLabelNode(text: text)
self.shapeNode = SKShapeNode(circleOfRadius: 30) self.shapeNode = SKShapeNode(circleOfRadius: 30)
self.shapeNode.position = anchorPoint self.shapeNode.position = anchorPoint
self.labelNode.position = CGPoint(x: anchorPoint.x, y: anchorPoint.y - 15) self.labelNode.position = CGPoint(x: anchorPoint.x, y: anchorPoint.y - 15)
if texture != nil { if texture != nil {
shapeNode.fillTexture = texture shapeNode.fillTexture = texture
}else { }else {
shapeNode.fillColor = SKColor.gray shapeNode.fillColor = SKColor.gray
} }
super.init() super.init()
} }
required init?(coder: NSCoder) { required init?(coder: NSCoder) {
fatalError("init(coder:) has not been implemented") fatalError("init(coder:) has not been implemented")
} }
} }

View File

@ -10,15 +10,15 @@ import GameplayKit
import SpriteKit import SpriteKit
class DefaultBaseComponent: GKComponent { class DefaultBaseComponent: GKComponent {
var spriteNode: BaseNode var spriteNode: BaseNode
init(texture: SKTexture, position: CGPoint) { init(texture: SKTexture, position: CGPoint) {
spriteNode = BaseNode(texture: texture, size: CGSize(width: 80, height: 80)) spriteNode = BaseNode(texture: texture, size: CGSize(width: 80, height: 80))
spriteNode.position = position spriteNode.position = position
super.init() super.init()
} }
required init?(coder aDecoder: NSCoder) { required init?(coder aDecoder: NSCoder) {
fatalError("init(coder:) has not been implemented") fatalError("init(coder:) has not been implemented")
} }
} }

View File

@ -10,17 +10,17 @@ import GameplayKit
import SpriteKit import SpriteKit
class ModalBackgroundComponent: GKComponent { class ModalBackgroundComponent: GKComponent {
let spriteNode: SKSpriteNode let spriteNode: SKSpriteNode
init(anchorPoint: CGPoint) { init(anchorPoint: CGPoint) {
let texture = SKTexture(imageNamed:"ModalBackground") let texture = SKTexture(imageNamed:"ModalBackground")
spriteNode = SKSpriteNode(texture: texture, size: texture.size()) spriteNode = SKSpriteNode(texture: texture, size: texture.size())
spriteNode.setScale(2) spriteNode.setScale(2)
spriteNode.position = anchorPoint spriteNode.position = anchorPoint
super.init() super.init()
} }
required init?(coder aDecoder: NSCoder) { required init?(coder aDecoder: NSCoder) {
fatalError("init(coder:) has not been implemented") fatalError("init(coder:) has not been implemented")
} }
} }

View File

@ -10,33 +10,33 @@ import GameplayKit
import SpriteKit import SpriteKit
class ModalContentComponent: GKComponent{ class ModalContentComponent: GKComponent{
var header: SKLabelNode var header: SKLabelNode
var body: SKLabelNode var body: SKLabelNode
var footer: SKLabelNode var footer: SKLabelNode
init(header: String, body: String, footer: String , anchorPoint: CGPoint) { init(header: String, body: String, footer: String , anchorPoint: CGPoint) {
self.header = SKLabelNode(text: header) self.header = SKLabelNode(text: header)
self.header.position = CGPoint(x: anchorPoint.x, y: anchorPoint.y + 125) self.header.position = CGPoint(x: anchorPoint.x, y: anchorPoint.y + 125)
self.header.fontName = "HelveticaNeue-Bold" self.header.fontName = "HelveticaNeue-Bold"
self.header.fontSize = 40 self.header.fontSize = 40
self.body = SKLabelNode(text: body) self.body = SKLabelNode(text: body)
self.body.position = CGPoint(x: anchorPoint.x, y: anchorPoint.y - 20) self.body.position = CGPoint(x: anchorPoint.x, y: anchorPoint.y - 20)
self.body.numberOfLines = 2 self.body.numberOfLines = 2
self.body.preferredMaxLayoutWidth = 390 self.body.preferredMaxLayoutWidth = 390
self.body.horizontalAlignmentMode = SKLabelHorizontalAlignmentMode.center self.body.horizontalAlignmentMode = SKLabelHorizontalAlignmentMode.center
self.body.fontName = "HelveticaNeue-Bold" self.body.fontName = "HelveticaNeue-Bold"
self.body.fontSize = 40 self.body.fontSize = 40
self.footer = SKLabelNode(text: footer) self.footer = SKLabelNode(text: footer)
self.footer.position = CGPoint(x: anchorPoint.x, y: anchorPoint.y - 40) self.footer.position = CGPoint(x: anchorPoint.x, y: anchorPoint.y - 40)
self.footer.fontName = "HelveticaNeue-Bold" self.footer.fontName = "HelveticaNeue-Bold"
self.footer.fontSize = 40 self.footer.fontSize = 40
super.init() super.init()
} }
required init?(coder aDecoder: NSCoder) { required init?(coder aDecoder: NSCoder) {
fatalError("init(coder:) has not been implemented") fatalError("init(coder:) has not been implemented")
} }
} }

View File

@ -9,15 +9,15 @@
import GameplayKit import GameplayKit
class SliderComponent: GKComponent { class SliderComponent: GKComponent {
var sliderNode: SliderNode var sliderNode: SliderNode
init(width: CGFloat, position: CGPoint) { init(width: CGFloat, position: CGPoint) {
sliderNode = SliderNode(width: width, position: position) sliderNode = SliderNode(width: width, position: position)
super.init() super.init()
} }
required init?(coder: NSCoder) { required init?(coder: NSCoder) {
fatalError("init(coder:) has not been implemented") fatalError("init(coder:) has not been implemented")
} }
} }

View File

@ -10,57 +10,57 @@ import SpriteKit
class SliderNode :SKNode { class SliderNode :SKNode {
var sliderLine :SKShapeNode var sliderLine :SKShapeNode
var sliderKnob :SliderKnob var sliderKnob :SliderKnob
var width: CGFloat var width: CGFloat
var getValue: CGFloat{ var getValue: CGFloat{
get{ get{
return ((sliderKnob.position.x.rounded() - sliderKnob.min) / width) return ((sliderKnob.position.x.rounded() - sliderKnob.min) / width)
} }
} }
init(width: CGFloat, position: CGPoint) { init(width: CGFloat, position: CGPoint) {
self.width = width self.width = width
sliderLine = SKShapeNode(rectOf: CGSize(width: width, height: 8)) sliderLine = SKShapeNode(rectOf: CGSize(width: width, height: 8))
sliderLine.position = position sliderLine.position = position
sliderLine.fillColor = SKColor.white sliderLine.fillColor = SKColor.white
sliderKnob = SliderKnob(circleOfRadius: 20) sliderKnob = SliderKnob(circleOfRadius: 20)
sliderKnob.min = position.x - width / 2 sliderKnob.min = position.x - width / 2
sliderKnob.max = position.x + width / 2 sliderKnob.max = position.x + width / 2
sliderKnob.fillColor = SKColor.red sliderKnob.fillColor = SKColor.red
sliderKnob.zPosition = sliderLine.zPosition + 1 sliderKnob.zPosition = sliderLine.zPosition + 1
sliderKnob.position = CGPoint(x: sliderLine.position.x, y: sliderLine.position.y + 1) sliderKnob.position = CGPoint(x: sliderLine.position.x, y: sliderLine.position.y + 1)
super.init() super.init()
} }
required init?(coder aDecoder: NSCoder) { required init?(coder aDecoder: NSCoder) {
fatalError("init(coder:) has not been implemented") fatalError("init(coder:) has not been implemented")
} }
} }
class SliderKnob: SKShapeNode { class SliderKnob: SKShapeNode {
var min = CGFloat() var min = CGFloat()
var max = CGFloat() var max = CGFloat()
override func touchesMoved(_ touches: Set<UITouch>, with event: UIEvent?) { override func touchesMoved(_ touches: Set<UITouch>, with event: UIEvent?) {
for touch in touches { for touch in touches {
let touchLocation = touch.location(in: self.scene!) let touchLocation = touch.location(in: self.scene!)
if self.position.x >= min - 1 && self.position.x <= max + 1{ if self.position.x >= min - 1 && self.position.x <= max + 1{
self.position.x = touchLocation.x self.position.x = touchLocation.x
} }
if(self.position.x <= min){ if(self.position.x <= min){
self.position.x = min self.position.x = min
} }
if(self.position.x >= max){ if(self.position.x >= max){
self.position.x = max self.position.x = max
} }
} }
} }
} }

View File

@ -9,26 +9,26 @@
import GameplayKit import GameplayKit
class SpySkillComponent: GKComponent{ class SpySkillComponent: GKComponent{
let shapeNode: SKShapeNode let shapeNode: SKShapeNode
let labelNode: SKLabelNode let labelNode: SKLabelNode
init(text: String, texture: SKTexture?, anchorPoint: CGPoint) { init(text: String, texture: SKTexture?, anchorPoint: CGPoint) {
self.labelNode = SKLabelNode(text: text) self.labelNode = SKLabelNode(text: text)
self.shapeNode = SKShapeNode(circleOfRadius: 30) self.shapeNode = SKShapeNode(circleOfRadius: 30)
self.shapeNode.position = anchorPoint self.shapeNode.position = anchorPoint
self.labelNode.position = CGPoint(x: anchorPoint.x, y: anchorPoint.y - 15) self.labelNode.position = CGPoint(x: anchorPoint.x, y: anchorPoint.y - 15)
if texture != nil { if texture != nil {
shapeNode.fillTexture = texture shapeNode.fillTexture = texture
}else { }else {
shapeNode.fillColor = SKColor.gray shapeNode.fillColor = SKColor.gray
} }
super.init() super.init()
} }
required init?(coder: NSCoder) { required init?(coder: NSCoder) {
fatalError("init(coder:) has not been implemented") fatalError("init(coder:) has not been implemented")
} }
} }

View File

@ -24,17 +24,17 @@ class TeamComponent: GKComponent {
fire.particleColorBlendFactor = 1.0 fire.particleColorBlendFactor = 1.0
switch team { switch team {
case .team1: fire.particleColor = SKColor.red case .team1: fire.particleColor = SKColor.red
case .team2: fire.particleColor = SKColor.purple case .team2: fire.particleColor = SKColor.purple
case .team3: fire.particleColor = SKColor.green case .team3: fire.particleColor = SKColor.green
case .team4: fire.particleColor = SKColor.gray case .team4: fire.particleColor = SKColor.gray
} }
self.team = team self.team = team
self.player = player self.player = player
super.init() super.init()
} }
required init?(coder aDecoder: NSCoder) { required init?(coder aDecoder: NSCoder) {
fatalError("init(coder:) has not been implemented") fatalError("init(coder:) has not been implemented")
} }

View File

@ -9,12 +9,12 @@
import GameplayKit import GameplayKit
class TimerComponent: GKComponent { class TimerComponent: GKComponent {
let labelNode :SKLabelNode let labelNode :SKLabelNode
var endTime :Date! var endTime :Date!
var duration :Double var duration :Double
init(text: String, anchorPoint: CGPoint, duration: TimeInterval) { init(text: String, anchorPoint: CGPoint, duration: TimeInterval) {
self.labelNode = SKLabelNode(text: text) self.labelNode = SKLabelNode(text: text)
self.labelNode.fontColor = UIColor.black self.labelNode.fontColor = UIColor.black
self.labelNode.fontSize = CGFloat(45) self.labelNode.fontSize = CGFloat(45)
@ -51,6 +51,6 @@ class TimerComponent: GKComponent {
required init?(coder: NSCoder) { required init?(coder: NSCoder) {
fatalError("init(coder:) has not been implemented") fatalError("init(coder:) has not been implemented")
} }
} }

View File

@ -9,16 +9,16 @@
import GameplayKit import GameplayKit
class Background: GKEntity { class Background: GKEntity {
init(size: CGSize) { init(size: CGSize) {
super.init() super.init()
addComponent(BackgroundComponent(size: size)) addComponent(BackgroundComponent(size: size))
} }
override func update(deltaTime seconds: TimeInterval) { override func update(deltaTime seconds: TimeInterval) {
component(ofType: BackgroundComponent.self)?.update() component(ofType: BackgroundComponent.self)?.update()
} }
required init?(coder: NSCoder) { required init?(coder: NSCoder) {
fatalError("init(coder:) has not been implemented") fatalError("init(coder:) has not been implemented")
} }

View File

@ -8,7 +8,6 @@
import SpriteKit import SpriteKit
import GameplayKit import GameplayKit
import GameKit
class Base: GKEntity { class Base: GKEntity {
@ -17,7 +16,7 @@ class Base: GKEntity {
var changeOwnership: Bool var changeOwnership: Bool
var ownershipPlayer: GKPlayer? var ownershipPlayer: GKPlayer?
init(position: CGPoint, player: GKPlayer? = nil, team: Team? = nil) { init(position: CGPoint, team: Team! = nil) {
self.unitCount = 0 self.unitCount = 0
self.adjacencyList = [Base]() self.adjacencyList = [Base]()
self.changeOwnership = false self.changeOwnership = false

View File

@ -12,7 +12,7 @@ class Button: GKEntity{
let name: String let name: String
var isEnabled = true var isEnabled = true
init(name: String, iconName: String, text: String, position: CGPoint, onButtonPress: @escaping () -> ()) { init(name: String, iconName: String, text: String, position: CGPoint, onButtonPress: @escaping () -> ()) {
self.name = name self.name = name
super.init() super.init()

View File

@ -14,42 +14,42 @@ class EntityManager {
var entities = Set<GKEntity>() var entities = Set<GKEntity>()
let scene: SKScene let scene: SKScene
var isModal: Bool var isModal: Bool
init(scene: SKScene) { init(scene: SKScene) {
self.scene = scene self.scene = scene
isModal = false isModal = false
} }
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 {
scene.addChild(spriteNode) scene.addChild(spriteNode)
} }
if let fire = entity.component(ofType: TeamComponent.self)?.fire{ if let fire = entity.component(ofType: TeamComponent.self)?.fire{
scene.addChild(fire) scene.addChild(fire)
} }
if let spriteNode = entity.component(ofType: ModalBackgroundComponent.self)?.spriteNode { if let spriteNode = entity.component(ofType: ModalBackgroundComponent.self)?.spriteNode {
scene.addChild(spriteNode) scene.addChild(spriteNode)
isModal = true isModal = true
} }
if let modal = entity.component(ofType: ModalContentComponent.self) { if let modal = entity.component(ofType: ModalContentComponent.self) {
scene.addChild(modal.header) scene.addChild(modal.header)
scene.addChild(modal.body) scene.addChild(modal.body)
scene.addChild(modal.footer) scene.addChild(modal.footer)
} }
if let skill = entity.component(ofType: AtkBoostSkillComponent.self) { if let skill = entity.component(ofType: AtkBoostSkillComponent.self) {
scene.addChild(skill.shapeNode) scene.addChild(skill.shapeNode)
scene.addChild(skill.labelNode) scene.addChild(skill.labelNode)
} }
if let skill = entity.component(ofType: DefBoostSkillComponent.self) { if let skill = entity.component(ofType: DefBoostSkillComponent.self) {
scene.addChild(skill.shapeNode) scene.addChild(skill.shapeNode)
scene.addChild(skill.labelNode) scene.addChild(skill.labelNode)
} }
if let skill = entity.component(ofType: SpySkillComponent.self) { if let skill = entity.component(ofType: SpySkillComponent.self) {
scene.addChild(skill.shapeNode) scene.addChild(skill.shapeNode)
scene.addChild(skill.labelNode) scene.addChild(skill.labelNode)
} }
if let timer = entity.component(ofType: TimerComponent.self) { if let timer = entity.component(ofType: TimerComponent.self) {
scene.addChild(timer.labelNode) scene.addChild(timer.labelNode)
} }
@ -61,29 +61,29 @@ class EntityManager {
scene.addChild(node) scene.addChild(node)
} }
} }
if let sliderNode = entity.component(ofType: SliderComponent.self)?.sliderNode { if let sliderNode = entity.component(ofType: SliderComponent.self)?.sliderNode {
scene.addChild(sliderNode.sliderKnob) scene.addChild(sliderNode.sliderKnob)
scene.addChild(sliderNode.sliderLine) scene.addChild(sliderNode.sliderLine)
} }
} }
func remove(_ entity: GKEntity) { func remove(_ entity: GKEntity) {
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 { if let spriteNode = entity.component(ofType: ModalBackgroundComponent.self)?.spriteNode {
spriteNode.removeFromParent() spriteNode.removeFromParent()
isModal = false isModal = false
} }
if let modal = entity.component(ofType: ModalContentComponent.self) { if let modal = entity.component(ofType: ModalContentComponent.self) {
modal.header.removeFromParent() modal.header.removeFromParent()
modal.body.removeFromParent() modal.body.removeFromParent()
modal.footer.removeFromParent() modal.footer.removeFromParent()
} }
if let sliderNode = entity.component(ofType: SliderComponent.self)?.sliderNode { if let sliderNode = entity.component(ofType: SliderComponent.self)?.sliderNode {
sliderNode.sliderKnob.removeFromParent() sliderNode.sliderKnob.removeFromParent()
sliderNode.sliderLine.removeFromParent() sliderNode.sliderLine.removeFromParent()
} }
entities.remove(entity) entities.remove(entity)
} }
@ -115,37 +115,37 @@ class EntityManager {
let _ = entity.component(ofType: DefaultBaseComponent.self) { let _ = entity.component(ofType: DefaultBaseComponent.self) {
if teamComponent.team == team { if teamComponent.team == team {
return entity return entity
} }
} }
} }
return nil return nil
} }
func getBasesByTeam(for team: Team) -> Set<Base> { func getBasesByTeam(for team: Team) -> Set<Base> {
return entities.filter{$0 is Base && ($0 as! Base).component(ofType: TeamComponent.self)?.team == team } as! Set<Base> return entities.filter{$0 is Base && ($0 as! Base).component(ofType: TeamComponent.self)?.team == team } as! Set<Base>
} }
func getTeamByBase(base: Base) -> Team? { func getTeamByBase(base: Base) -> Team? {
for entity in entities { for entity in entities {
if entity is Base && entity == base{ if entity is Base && entity == base{
for component in entity.components{ for component in entity.components{
if component is TeamComponent { if component is TeamComponent {
return entity.component(ofType: TeamComponent.self)!.team return entity.component(ofType: TeamComponent.self)!.team
} }
} }
} }
} }
return nil return nil
} }
func getBackground() -> GKEntity? { func getBackground() -> GKEntity? {
return entities.filter{$0 is Background}[0] return entities.filter{$0 is Background}[0]
} }
func getBaseNodeByTeam(for team: Team) -> SKSpriteNode? { func getBaseNodeByTeam(for team: Team) -> SKSpriteNode? {
return getBaseByTeam(for: team)?.component(ofType: DefaultBaseComponent.self)?.spriteNode return getBaseByTeam(for: team)?.component(ofType: DefaultBaseComponent.self)?.spriteNode
} }
func getButtonByName(buttonName:String) -> Button { func getButtonByName(buttonName:String) -> Button {
return entities.filter{$0 is Button && ($0 as! Button).name == buttonName }[0] as! Button return entities.filter{$0 is Button && ($0 as! Button).name == buttonName }[0] as! Button
} }

View File

@ -9,29 +9,29 @@
import GameplayKit import GameplayKit
class HUD: GKEntity { class HUD: GKEntity {
init(size: CGSize) { init(size: CGSize) {
super.init() super.init()
addComponent(SpySkillComponent(text: "Spy", addComponent(SpySkillComponent(text: "Spy",
texture: nil, texture: nil,
anchorPoint: CGPoint(x: size.width * 0.75, y: size.height * 0.1))) anchorPoint: CGPoint(x: size.width * 0.75, y: size.height * 0.1)))
addComponent(AtkBoostSkillComponent(text: "Atk", addComponent(AtkBoostSkillComponent(text: "Atk",
texture: nil, texture: nil,
anchorPoint: CGPoint(x: size.width * 0.85, y: size.height * 0.1))) anchorPoint: CGPoint(x: size.width * 0.85, y: size.height * 0.1)))
addComponent(DefBoostSkillComponent(text: "Def", addComponent(DefBoostSkillComponent(text: "Def",
texture: nil, texture: nil,
anchorPoint: CGPoint(x: size.width * 0.95, y: size.height * 0.1))) anchorPoint: CGPoint(x: size.width * 0.95, y: size.height * 0.1)))
addComponent(TimerComponent(text: "", addComponent(TimerComponent(text: "",
anchorPoint: CGPoint(x: size.width * 0.5, y: size.height * 0.9), duration: 30)) anchorPoint: CGPoint(x: size.width * 0.5, y: size.height * 0.9), duration: 30))
} }
required init?(coder: NSCoder) { required init?(coder: NSCoder) {
fatalError("init(coder:) has not been implemented") fatalError("init(coder:) has not been implemented")
} }
} }

View File

@ -9,41 +9,31 @@
import GameplayKit import GameplayKit
class Modal: GKEntity{ class Modal: GKEntity{
var unitCount:Int
var unitCount:Int init(modaltype: ModalType, base: Base, anchorPoint: CGPoint) {
unitCount = base.unitCount
init(modaltype: ModalType, base: Base, anchorPoint: CGPoint) { super.init()
unitCount = base.unitCount switch modaltype{
super.init() case .BaseDetails:
switch modaltype{ addComponent(ModalBackgroundComponent(anchorPoint: anchorPoint))
case .BaseDetails: addComponent(ModalContentComponent(header: "Basis Information",
addComponent(ModalBackgroundComponent(anchorPoint: anchorPoint)) body: "Diese Basis enthält \(base.unitCount) Einheiten",
addComponent(ModalContentComponent( footer: "",
header: "Basis Information", anchorPoint: anchorPoint))
body: "Diese Basis enthält \(base.unitCount) Einheiten", case .BaseAttack:
footer: "", addComponent(ModalBackgroundComponent(anchorPoint: anchorPoint))
anchorPoint: anchorPoint addComponent(SliderComponent(width: 300, position: CGPoint(x: anchorPoint.x , y: anchorPoint.y - 80)))
) addComponent(ModalContentComponent(header: "Angriff",
) body: "Schicke \(unitCount / 2) Einheiten",
case .BaseAttack: footer: "",
addComponent(ModalBackgroundComponent(anchorPoint: anchorPoint)) anchorPoint: anchorPoint))
addComponent(SliderComponent( }
width: 300, }
position: CGPoint(x: anchorPoint.x , y: anchorPoint.y - 80)
) required init?(coder: NSCoder) {
) fatalError("init(coder:) has not been implemented")
addComponent(ModalContentComponent( }
header: "Angriff",
body: "Schicke \(unitCount / 2) Einheiten",
footer: "",
anchorPoint: anchorPoint
)
)
}
}
required init?(coder: NSCoder) {
fatalError("init(coder:) has not been implemented")
}
} }

View File

@ -7,6 +7,6 @@
// //
enum ModalType: String{ enum ModalType: String{
case BaseDetails case BaseDetails
case BaseAttack case BaseAttack
} }

View File

@ -11,6 +11,6 @@ enum Team: Int {
case team2 = 2 case team2 = 2
case team3 = 3 case team3 = 3
case team4 = 4 case team4 = 4
static let allValues = [team1, team2,team3,team4] static let allValues = [team1, team2,team3,team4]
} }

View File

@ -12,20 +12,20 @@ final class GameCenterHelper: NSObject {
typealias CompletionBlock = (Error?) -> Void typealias CompletionBlock = (Error?) -> Void
static let helper = GameCenterHelper() static let helper = GameCenterHelper()
var viewController: UIViewController? var viewController: UIViewController?
static var isAuthenticated: Bool { static var isAuthenticated: Bool {
return GKLocalPlayer.local.isAuthenticated return GKLocalPlayer.local.isAuthenticated
} }
override init() { override init() {
super.init() super.init()
GKLocalPlayer.local.authenticateHandler = { gcAuthVC, error in GKLocalPlayer.local.authenticateHandler = { gcAuthVC, error in
NotificationCenter.default NotificationCenter.default
.post(name: .authenticationChanged, object: GKLocalPlayer.local.isAuthenticated) .post(name: .authenticationChanged, object: GKLocalPlayer.local.isAuthenticated)
if GKLocalPlayer.local.isAuthenticated { if GKLocalPlayer.local.isAuthenticated {
print("Authenticated to Game Center!") print("Authenticated to Game Center!")
} else if let vc = gcAuthVC { } else if let vc = gcAuthVC {

View File

@ -11,10 +11,10 @@ import SpriteKit
import GameplayKit import GameplayKit
class GameViewController: UIViewController { class GameViewController: UIViewController {
override func viewDidLoad() { override func viewDidLoad() {
super.viewDidLoad() super.viewDidLoad()
if let view = self.view as! SKView? { if let view = self.view as! SKView? {
let scene = MenuScene(size: self.view.bounds.size) let scene = MenuScene(size: self.view.bounds.size)
scene.scaleMode = .aspectFill scene.scaleMode = .aspectFill
@ -22,16 +22,16 @@ class GameViewController: UIViewController {
//TODO: create dev profile or remove on delivery //TODO: create dev profile or remove on delivery
view.showsFPS = true view.showsFPS = true
view.showsNodeCount = true view.showsNodeCount = true
GameCenterHelper.helper.viewController = self GameCenterHelper.helper.viewController = self
MatchmakingHelper.sharedInstance.viewController = self MatchmakingHelper.sharedInstance.viewController = self
}
} }
}
override var shouldAutorotate: Bool { override var shouldAutorotate: Bool {
return true return true
} }
override var supportedInterfaceOrientations: UIInterfaceOrientationMask { override var supportedInterfaceOrientations: UIInterfaceOrientationMask {
if UIDevice.current.userInterfaceIdiom == .phone { if UIDevice.current.userInterfaceIdiom == .phone {
return .allButUpsideDown return .allButUpsideDown
@ -39,7 +39,7 @@ class GameViewController: UIViewController {
return .all return .all
} }
} }
override var prefersStatusBarHidden: Bool { override var prefersStatusBarHidden: Bool {
return true return true
} }

View File

@ -71,15 +71,15 @@ class MatchmakingHelper: NSObject, GKMatchmakerViewControllerDelegate, GKMatchDe
/* /*
Der User hat die Verbindung mit "Abbrechen" unterbrochen. GameCenter MatchMaking wird beendet. Der User hat die Verbindung mit "Abbrechen" unterbrochen. GameCenter MatchMaking wird beendet.
*/ */
func matchmakerViewControllerWasCancelled(_ viewController: GKMatchmakerViewController) { func matchmakerViewControllerWasCancelled(_ viewController: GKMatchmakerViewController) {
viewController.dismiss(animated: true, completion: nil) viewController.dismiss(animated: true, completion: nil)
delegate?.matchEnded() delegate?.matchEnded()
} }
/* /*
Wenn GameCenter kein match erstellen kann, wird der viewcontroller dismissed. Wenn GameCenter kein match erstellen kann, wird der viewcontroller dismissed.
*/ */
func matchmakerViewController(_ viewController: GKMatchmakerViewController, didFailWithError error: Error) { func matchmakerViewController(_ viewController: GKMatchmakerViewController, didFailWithError error: Error) {
viewController.dismiss(animated: true, completion: nil) viewController.dismiss(animated: true, completion: nil)
print("Error finding match", error.localizedDescription) print("Error finding match", error.localizedDescription)
@ -90,7 +90,7 @@ class MatchmakingHelper: NSObject, GKMatchmakerViewControllerDelegate, GKMatchDe
Gamecenter hat erfolgreich ein Match gefunden, das Spiel kann gestartet werden. Gamecenter hat erfolgreich ein Match gefunden, das Spiel kann gestartet werden.
expectedPlayerCount: Die verbleibende Anzahl von Spielern, die sich noch nicht mit dem Spiel verbunden haben expectedPlayerCount: Die verbleibende Anzahl von Spielern, die sich noch nicht mit dem Spiel verbunden haben
z.B 0 gibt an, dass keine weiteren Spieler benötigt werden um das Match zu starten z.B 0 gibt an, dass keine weiteren Spieler benötigt werden um das Match zu starten
*/ */
func matchmakerViewController(_ viewController: GKMatchmakerViewController, didFind match: GKMatch) { func matchmakerViewController(_ viewController: GKMatchmakerViewController, didFind match: GKMatch) {
viewController.dismiss(animated: true, completion: nil) viewController.dismiss(animated: true, completion: nil)
mpMatch = match mpMatch = match
@ -101,8 +101,8 @@ class MatchmakingHelper: NSObject, GKMatchmakerViewControllerDelegate, GKMatchDe
} }
/* /*
Vom match erhaltene Spielerdaten Vom match erhaltene Spielerdaten
*/ */
private func match(match: GKMatch!, didReceiveData data: NSData!,fromPlayer playerID: String!) { private func match(match: GKMatch!, didReceiveData data: NSData!,fromPlayer playerID: String!) {
if mpMatch != match { return } if mpMatch != match { return }
delegate?.matchReceivedData(match: match, data: data, fromPlayer: playerID) delegate?.matchReceivedData(match: match, data: data, fromPlayer: playerID)
@ -142,15 +142,15 @@ class MatchmakingHelper: NSObject, GKMatchmakerViewControllerDelegate, GKMatchDe
} }
/* /*
Ein Spieler wird als Host für das Match gewählt. Dieser ist Spieler 1. Im Anschluss wird die GameScene geladen. Ein Spieler wird als Host für das Match gewählt. Dieser ist Spieler 1. Im Anschluss wird die GameScene geladen.
*/ */
func startMatch() { func startMatch() {
mpMatch!.chooseBestHostingPlayer(completionHandler: { mpMatch!.chooseBestHostingPlayer(completionHandler: {
(player) in (player) in
self.mpMatchStarted = true self.mpMatchStarted = true
if player == GKLocalPlayer.local { if player == GKLocalPlayer.local {
self.isServer = true self.isServer = true
} else { } else {
@ -160,7 +160,7 @@ class MatchmakingHelper: NSObject, GKMatchmakerViewControllerDelegate, GKMatchDe
self.menusc!.loadScene(scene: GameScene(size: self.menusc!.size)) self.menusc!.loadScene(scene: GameScene(size: self.menusc!.size))
}) })
} }
/* /*
Trennt die Verbindung vom Match Trennt die Verbindung vom Match

View File

@ -23,45 +23,45 @@ class GameScene: SKScene{
entityManager.add(Background(size: self.size)) entityManager.add(Background(size: self.size))
initMap() initMap()
} }
func initMap() { func initMap() {
MapFactory(scene: self, entityManager: self.entityManager).loadMap(playerCount: 2) MapFactory(scene: self, entityManager: self.entityManager).loadMap(playerCount: 2)
} }
override func touchesEnded(_ touches: Set<UITouch>, with event: UIEvent?) { override func touchesEnded(_ 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)
if isMoveTouch{ if isMoveTouch{
isMoveTouch = false isMoveTouch = false
currentDraggedBase!.component(ofType: DefaultBaseComponent.self)?.spriteNode.position = currentDraggedBasePos currentDraggedBase!.component(ofType: DefaultBaseComponent.self)?.spriteNode.position = currentDraggedBasePos
currentDraggedBase!.component(ofType: TeamComponent.self)?.fire.position = currentDraggedBasePos currentDraggedBase!.component(ofType: TeamComponent.self)?.fire.position = currentDraggedBasePos
for base in currentDraggedBase!.adjacencyList { for base in currentDraggedBase!.adjacencyList {
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.getTeamByBase(base: currentDraggedBase!) == entityManager.getTeamByBase(base: base)){
entityManager.add(Modal(modaltype: .BaseAttack, entityManager.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.update((currentDraggedBase?.attackBase(base: base, units: 100))!) entityManager.update((currentDraggedBase?.attackBase(base: base, units: 100))!)
}else { }else {
entityManager.add(Modal(modaltype: .BaseAttack, entityManager.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)))
} }
} }
} }
} }
else { else {
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 entityManager.isModal && entity.isMember(of: Modal.self) { if entityManager.isModal && entity.isMember(of: Modal.self) {
entityManager.remove(entity) entityManager.remove(entity)
for child in self.children { for child in self.children {
@ -70,7 +70,7 @@ class GameScene: SKScene{
} }
} }
} }
if atPoint(touchLocation) == spriteNode && !entityManager.isModal { if atPoint(touchLocation) == spriteNode && !entityManager.isModal {
spriteNode?.touchesBegan(touches, with: event) spriteNode?.touchesBegan(touches, with: event)
if !entityManager.isModal { if !entityManager.isModal {
@ -86,9 +86,9 @@ class GameScene: SKScene{
} }
} }
} }
} }
override func touchesMoved(_ touches: Set<UITouch>, with event: UIEvent?) { override func touchesMoved(_ touches: Set<UITouch>, with event: UIEvent?) {
guard let touch = touches.first else { guard let touch = touches.first else {
return return
@ -115,7 +115,7 @@ class GameScene: SKScene{
currentDraggedBase = base currentDraggedBase = base
} }
isMoveTouch = true isMoveTouch = true
base.component(ofType: DefaultBaseComponent.self)?.spriteNode.position = touchLocation base.component(ofType: DefaultBaseComponent.self)?.spriteNode.position = touchLocation
base.component(ofType: TeamComponent.self)?.fire.position = touchLocation base.component(ofType: TeamComponent.self)?.fire.position = touchLocation
for adjacencyBase in base.adjacencyList { for adjacencyBase in base.adjacencyList {

View File

@ -9,9 +9,9 @@
import SpriteKit import SpriteKit
class MenuScene: SKScene { class MenuScene: SKScene {
var entityManager: EntityManager! var entityManager: EntityManager!
override func sceneDidLoad() { override func sceneDidLoad() {
entityManager = EntityManager(scene: self) entityManager = EntityManager(scene: self)
let midX = self.size.width / 2 let midX = self.size.width / 2
@ -24,24 +24,24 @@ class MenuScene: SKScene {
if CommandLine.arguments.contains("--no-matchmaking") { if CommandLine.arguments.contains("--no-matchmaking") {
self.loadScene(scene: GameScene(size: self.size)) self.loadScene(scene: GameScene(size: self.size))
} else { } else {
MatchmakingHelper.sharedInstance.presentMatchmaker(scene: self) MatchmakingHelper.sharedInstance.presentMatchmaker(scene: self)
} }
})) }))
entityManager.add(Button(name: "settingsButton", entityManager.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: {
//TODO: create Settings Scene //TODO: create Settings Scene
})) }))
entityManager.add(Background(size: self.size)) entityManager.add(Background(size: self.size))
} }
func loadScene(scene: SKScene) { func loadScene(scene: SKScene) {
let transition = SKTransition.flipVertical(withDuration: 0.5) let transition = SKTransition.flipVertical(withDuration: 0.5)
self.view?.presentScene(scene, transition: transition) self.view?.presentScene(scene, transition: transition)
} }
override func update(_ currentTime: TimeInterval) { override func update(_ currentTime: TimeInterval) {
entityManager.getBackground()!.update(deltaTime: currentTime) entityManager.getBackground()!.update(deltaTime: currentTime)
entityManager.getButtonByName(buttonName: "startGameButton").component(ofType: ButtonComponent.self)?.buttonNode.isEnabled = GameCenterHelper.isAuthenticated entityManager.getButtonByName(buttonName: "startGameButton").component(ofType: ButtonComponent.self)?.buttonNode.isEnabled = GameCenterHelper.isAuthenticated

View File

@ -10,25 +10,25 @@ import XCTest
@testable import GoldWars @testable import GoldWars
class GoldWarsTests: XCTestCase { class GoldWarsTests: XCTestCase {
override func setUp() { override func setUp() {
// Put setup code here. This method is called before the invocation of each test method in the class. // Put setup code here. This method is called before the invocation of each test method in the class.
} }
override func tearDown() { override func tearDown() {
// Put teardown code here. This method is called after the invocation of each test method in the class. // Put teardown code here. This method is called after the invocation of each test method in the class.
} }
func testExample() { func testExample() {
// This is an example of a functional test case. // This is an example of a functional test case.
// Use XCTAssert and related functions to verify your tests produce the correct results. // Use XCTAssert and related functions to verify your tests produce the correct results.
} }
func testPerformanceExample() { func testPerformanceExample() {
// This is an example of a performance test case. // This is an example of a performance test case.
self.measure { self.measure {
// Put the code you want to measure the time of here. // Put the code you want to measure the time of here.
} }
} }
} }