├── screenshot ├── rule.png ├── state.png ├── agents.png ├── minmax.png ├── entities.png ├── procedural.png ├── pathfinding.png └── randomization.png ├── GameplayKitSandbox ├── fire.sks ├── rain.sks ├── spark.png ├── spark.sks ├── HouseState.swift ├── Move.swift ├── HouseDryState.swift ├── Mark.swift ├── HouseBurningState.swift ├── AttackComponent.swift ├── Assets.xcassets │ └── AppIcon.appiconset │ │ └── Contents.json ├── ControlComponent.swift ├── HouseWetState.swift ├── VisualComponent.swift ├── NoiseViewController.swift ├── Player.swift ├── RuleViewController.swift ├── AgentsViewController.swift ├── EntitiesViewController.swift ├── PathfindingViewController.swift ├── Info.plist ├── IntelligenceComponent.swift ├── MinmaxViewController.swift ├── ExampleViewController.swift ├── RandomizationViewController.swift ├── Base.lproj │ └── LaunchScreen.storyboard ├── AgentsScene.swift ├── ExampleScene.swift ├── StateViewController.swift ├── BurnableComponent.swift ├── AgentNode.swift ├── NoiseScene.swift ├── RandomizationScene.swift ├── AppDelegate.swift ├── StateScene.swift ├── EntitiesScene.swift ├── MinmaxScene.swift ├── ExamplesViewController.swift ├── RuleScene.swift ├── Board.swift └── PathfindingScene.swift ├── GameplayKitSandbox.xcodeproj ├── project.xcworkspace │ ├── contents.xcworkspacedata │ └── xcshareddata │ │ └── IDEWorkspaceChecks.plist └── project.pbxproj ├── README.md ├── GameplayKitSandboxTests ├── Info.plist └── GameplayKitSandboxTests.swift ├── GameplayKitSandboxUITests ├── Info.plist └── GameplayKitSandboxUITests.swift ├── .gitignore └── LICENSE /screenshot/rule.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tnantoka/GameplayKitSandbox/HEAD/screenshot/rule.png -------------------------------------------------------------------------------- /screenshot/state.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tnantoka/GameplayKitSandbox/HEAD/screenshot/state.png -------------------------------------------------------------------------------- /screenshot/agents.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tnantoka/GameplayKitSandbox/HEAD/screenshot/agents.png -------------------------------------------------------------------------------- /screenshot/minmax.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tnantoka/GameplayKitSandbox/HEAD/screenshot/minmax.png -------------------------------------------------------------------------------- /screenshot/entities.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tnantoka/GameplayKitSandbox/HEAD/screenshot/entities.png -------------------------------------------------------------------------------- /screenshot/procedural.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tnantoka/GameplayKitSandbox/HEAD/screenshot/procedural.png -------------------------------------------------------------------------------- /GameplayKitSandbox/fire.sks: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tnantoka/GameplayKitSandbox/HEAD/GameplayKitSandbox/fire.sks -------------------------------------------------------------------------------- /GameplayKitSandbox/rain.sks: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tnantoka/GameplayKitSandbox/HEAD/GameplayKitSandbox/rain.sks -------------------------------------------------------------------------------- /screenshot/pathfinding.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tnantoka/GameplayKitSandbox/HEAD/screenshot/pathfinding.png -------------------------------------------------------------------------------- /GameplayKitSandbox/spark.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tnantoka/GameplayKitSandbox/HEAD/GameplayKitSandbox/spark.png -------------------------------------------------------------------------------- /GameplayKitSandbox/spark.sks: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tnantoka/GameplayKitSandbox/HEAD/GameplayKitSandbox/spark.sks -------------------------------------------------------------------------------- /screenshot/randomization.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tnantoka/GameplayKitSandbox/HEAD/screenshot/randomization.png -------------------------------------------------------------------------------- /GameplayKitSandbox.xcodeproj/project.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /GameplayKitSandbox.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | IDEDidComputeMac32BitWarning 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /GameplayKitSandbox/HouseState.swift: -------------------------------------------------------------------------------- 1 | // 2 | // HouseState.swift 3 | // GameplayKitSandbox 4 | // 5 | // Created by Tatsuya Tobioka on 2015/09/22. 6 | // Copyright © 2015年 tnantoka. All rights reserved. 7 | // 8 | 9 | import UIKit 10 | 11 | import GameplayKit 12 | 13 | class HouseState: GKState { 14 | let entity: GKEntity 15 | 16 | init(entity: GKEntity) { 17 | self.entity = entity 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /GameplayKitSandbox/Move.swift: -------------------------------------------------------------------------------- 1 | // 2 | // Move.swift 3 | // GameplayKitSandbox 4 | // 5 | // Created by Tatsuya Tobioka on 2015/09/25. 6 | // Copyright © 2015年 tnantoka. All rights reserved. 7 | // 8 | 9 | import UIKit 10 | 11 | import GameplayKit 12 | 13 | class Move: NSObject, GKGameModelUpdate { 14 | var value = 0 15 | var index: Int 16 | 17 | init(index: Int) { 18 | self.index = index 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /GameplayKitSandbox/HouseDryState.swift: -------------------------------------------------------------------------------- 1 | // 2 | // HouseDryState.swift 3 | // GameplayKitSandbox 4 | // 5 | // Created by Tatsuya Tobioka on 2015/09/22. 6 | // Copyright © 2015年 tnantoka. All rights reserved. 7 | // 8 | 9 | import UIKit 10 | 11 | import GameplayKit 12 | 13 | class HouseDryState: HouseState { 14 | override func didEnter(from previousState: GKState?) { 15 | if let component = entity.component(ofType: BurnableComponent.self) { 16 | component.useDryAppearance() 17 | } 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /GameplayKitSandbox/Mark.swift: -------------------------------------------------------------------------------- 1 | // 2 | // Mark.swift 3 | // GameplayKitSandbox 4 | // 5 | // Created by Tatsuya Tobioka on 2015/09/24. 6 | // Copyright © 2015年 tnantoka. All rights reserved. 7 | // 8 | 9 | import UIKit 10 | 11 | enum Mark :Int { 12 | case none 13 | case o 14 | case x 15 | 16 | func text() -> String { 17 | switch self { 18 | case .o: 19 | return "o" 20 | case .x: 21 | return "x" 22 | default: 23 | return "" 24 | } 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # GameplayKitSandbox 2 | 3 | [GameplayKit](https://developer.apple.com/library/ios/documentation/General/Conceptual/GameplayKit_Guide/) examples with SpriteKit written in Swift. 4 | 5 | Major Feature | Screenshot 6 | --- | --- 7 | Randomization | ![](screenshot/randomization.png) 8 | Entities and Components | ![](screenshot/entities.png) 9 | State Machines | ![](screenshot/state.png) 10 | The Minmax Strategist | ![](screenshot/minmax.png) 11 | Pathfinding | ![](screenshot/pathfinding.png) 12 | Agents, Goals, and Behaviors | ![](screenshot/agents.png) 13 | Rule Systems | ![](screenshot/rule.png) 14 | Procedural Generation | ![](screenshot/procedural.png) 15 | -------------------------------------------------------------------------------- /GameplayKitSandbox/HouseBurningState.swift: -------------------------------------------------------------------------------- 1 | // 2 | // HouseBurningState.swift 3 | // GameplayKitSandbox 4 | // 5 | // Created by Tatsuya Tobioka on 2015/09/22. 6 | // Copyright © 2015年 tnantoka. All rights reserved. 7 | // 8 | 9 | import UIKit 10 | 11 | import GameplayKit 12 | 13 | class HouseBurningState: HouseState { 14 | override func isValidNextState(_ stateClass: AnyClass) -> Bool { 15 | return stateClass == HouseWetState.self 16 | } 17 | 18 | override func didEnter(from previousState: GKState?) { 19 | if let component = entity.component(ofType: BurnableComponent.self) { 20 | component.useBurningAppearance() 21 | } 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /GameplayKitSandbox/AttackComponent.swift: -------------------------------------------------------------------------------- 1 | // 2 | // AttackComponent.swift 3 | // GameplayKitSandbox 4 | // 5 | // Created by Tatsuya Tobioka on 2015/09/21. 6 | // Copyright © 2015年 tnantoka. All rights reserved. 7 | // 8 | 9 | import UIKit 10 | 11 | import SpriteKit 12 | import GameplayKit 13 | import GLKit 14 | 15 | class AttackComponent: GKComponent { 16 | func attack() { 17 | if let entity = entity { 18 | if let visualComponent = entity.component(ofType: VisualComponent.self) { 19 | let action = SKAction.rotate(byAngle: CGFloat(GLKMathDegreesToRadians(360.0)), duration: 0.3) 20 | visualComponent.sprite.run(action) 21 | } 22 | } 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /GameplayKitSandbox/Assets.xcassets/AppIcon.appiconset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "iphone", 5 | "size" : "29x29", 6 | "scale" : "2x" 7 | }, 8 | { 9 | "idiom" : "iphone", 10 | "size" : "29x29", 11 | "scale" : "3x" 12 | }, 13 | { 14 | "idiom" : "iphone", 15 | "size" : "40x40", 16 | "scale" : "2x" 17 | }, 18 | { 19 | "idiom" : "iphone", 20 | "size" : "40x40", 21 | "scale" : "3x" 22 | }, 23 | { 24 | "idiom" : "iphone", 25 | "size" : "60x60", 26 | "scale" : "2x" 27 | }, 28 | { 29 | "idiom" : "iphone", 30 | "size" : "60x60", 31 | "scale" : "3x" 32 | } 33 | ], 34 | "info" : { 35 | "version" : 1, 36 | "author" : "xcode" 37 | } 38 | } -------------------------------------------------------------------------------- /GameplayKitSandboxTests/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 7 | CFBundleExecutable 8 | $(EXECUTABLE_NAME) 9 | CFBundleIdentifier 10 | $(PRODUCT_BUNDLE_IDENTIFIER) 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | $(PRODUCT_NAME) 15 | CFBundlePackageType 16 | BNDL 17 | CFBundleShortVersionString 18 | 1.0 19 | CFBundleSignature 20 | ???? 21 | CFBundleVersion 22 | 1 23 | 24 | 25 | -------------------------------------------------------------------------------- /GameplayKitSandboxUITests/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 7 | CFBundleExecutable 8 | $(EXECUTABLE_NAME) 9 | CFBundleIdentifier 10 | $(PRODUCT_BUNDLE_IDENTIFIER) 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | $(PRODUCT_NAME) 15 | CFBundlePackageType 16 | BNDL 17 | CFBundleShortVersionString 18 | 1.0 19 | CFBundleSignature 20 | ???? 21 | CFBundleVersion 22 | 1 23 | 24 | 25 | -------------------------------------------------------------------------------- /GameplayKitSandbox/ControlComponent.swift: -------------------------------------------------------------------------------- 1 | // 2 | // ControlComponent.swift 3 | // GameplayKitSandbox 4 | // 5 | // Created by Tatsuya Tobioka on 2015/09/22. 6 | // Copyright © 2015年 tnantoka. All rights reserved. 7 | // 8 | 9 | import UIKit 10 | 11 | import SpriteKit 12 | import GameplayKit 13 | 14 | class ControlComponent: GKComponent { 15 | func touch(_ node: SKNode, location: CGPoint) { 16 | if let entity = entity { 17 | if let visualComponent = entity.component(ofType: VisualComponent.self) { 18 | if node == visualComponent.sprite { 19 | if let attackComponent = entity.component(ofType: AttackComponent.self) { 20 | attackComponent.attack() 21 | } 22 | } else { 23 | visualComponent.moveTo(location) 24 | } 25 | } 26 | } 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /GameplayKitSandbox/HouseWetState.swift: -------------------------------------------------------------------------------- 1 | // 2 | // HouseWetState.swift 3 | // GameplayKitSandbox 4 | // 5 | // Created by Tatsuya Tobioka on 2015/09/22. 6 | // Copyright © 2015年 tnantoka. All rights reserved. 7 | // 8 | 9 | import UIKit 10 | 11 | import GameplayKit 12 | 13 | class HouseWetState: HouseState { 14 | 15 | var remainingTime: TimeInterval = 0 16 | 17 | override func isValidNextState(_ stateClass: AnyClass) -> Bool { 18 | return stateClass == HouseDryState.self 19 | } 20 | 21 | override func didEnter(from previousState: GKState?) { 22 | if let component = entity.component(ofType: BurnableComponent.self) { 23 | component.useWetAppearance() 24 | remainingTime = 3.0 25 | } 26 | } 27 | 28 | override func update(deltaTime seconds: TimeInterval) { 29 | remainingTime -= seconds 30 | if remainingTime < 0 { 31 | stateMachine?.enter(HouseDryState.self) 32 | } 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Xcode 2 | # 3 | # gitignore contributors: remember to update Global/Xcode.gitignore, Objective-C.gitignore & Swift.gitignore 4 | 5 | ## Build generated 6 | build/ 7 | DerivedData 8 | 9 | ## Various settings 10 | *.pbxuser 11 | !default.pbxuser 12 | *.mode1v3 13 | !default.mode1v3 14 | *.mode2v3 15 | !default.mode2v3 16 | *.perspectivev3 17 | !default.perspectivev3 18 | xcuserdata 19 | 20 | ## Other 21 | *.xccheckout 22 | *.moved-aside 23 | *.xcuserstate 24 | *.xcscmblueprint 25 | 26 | ## Obj-C/Swift specific 27 | *.hmap 28 | *.ipa 29 | 30 | # CocoaPods 31 | # 32 | # We recommend against adding the Pods directory to your .gitignore. However 33 | # you should judge for yourself, the pros and cons are mentioned at: 34 | # http://guides.cocoapods.org/using/using-cocoapods.html#should-i-ignore-the-pods-directory-in-source-control 35 | # 36 | # Pods/ 37 | 38 | # Carthage 39 | # 40 | # Add this line if you want to avoid checking in source code from Carthage dependencies. 41 | # Carthage/Checkouts 42 | 43 | Carthage/Build 44 | 45 | .DS_Store 46 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2015 Tatsuya Tobioka 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | 23 | -------------------------------------------------------------------------------- /GameplayKitSandbox/VisualComponent.swift: -------------------------------------------------------------------------------- 1 | // 2 | // VisualComponent.swift 3 | // GameplayKitSandbox 4 | // 5 | // Created by Tatsuya Tobioka on 2015/09/21. 6 | // Copyright © 2015年 tnantoka. All rights reserved. 7 | // 8 | 9 | import UIKit 10 | 11 | import SpriteKit 12 | import GameplayKit 13 | 14 | class VisualComponent: GKComponent { 15 | let sprite: SKSpriteNode 16 | 17 | var position = CGPoint.zero { 18 | didSet { 19 | sprite.position = position 20 | } 21 | } 22 | 23 | init(color: SKColor, size: CGSize) { 24 | sprite = SKSpriteNode(color: color, size: size) 25 | super.init() 26 | } 27 | 28 | required init?(coder aDecoder: NSCoder) { 29 | fatalError("init(coder:) has not been implemented") 30 | } 31 | 32 | func moveTo(_ position: CGPoint) { 33 | let action = SKAction.move(to: position, duration: 0.3) 34 | sprite.run(action, completion: { 35 | self.position = position 36 | }) 37 | } 38 | 39 | func moveBy(_ x: CGFloat, _ y: CGFloat) { 40 | let p = CGPoint(x: position.x + x, y: position.y + y) 41 | moveTo(p) 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /GameplayKitSandbox/NoiseViewController.swift: -------------------------------------------------------------------------------- 1 | // 2 | // NoiseViewController.swift 3 | // GameplayKitSandbox 4 | // 5 | // Created by Tatsuya Tobioka on 9/25/16. 6 | // Copyright © 2016 tnantoka. All rights reserved. 7 | // 8 | 9 | import UIKit 10 | 11 | class NoiseViewController: ExampleViewController { 12 | 13 | var scene: NoiseScene! 14 | 15 | override func viewDidLoad() { 16 | super.viewDidLoad() 17 | 18 | // Do any additional setup after loading the view. 19 | scene = NoiseScene(size: skView.frame.size) 20 | skView.presentScene(scene) 21 | } 22 | 23 | override func didReceiveMemoryWarning() { 24 | super.didReceiveMemoryWarning() 25 | // Dispose of any resources that can be recreated. 26 | } 27 | 28 | 29 | /* 30 | // MARK: - Navigation 31 | 32 | // In a storyboard-based application, you will often want to do a little preparation before navigation 33 | override func prepare(for segue: UIStoryboardSegue, sender: Any?) { 34 | // Get the new view controller using segue.destinationViewController. 35 | // Pass the selected object to the new view controller. 36 | } 37 | */ 38 | 39 | } 40 | -------------------------------------------------------------------------------- /GameplayKitSandbox/Player.swift: -------------------------------------------------------------------------------- 1 | // 2 | // Player.swift 3 | // GameplayKitSandbox 4 | // 5 | // Created by Tatsuya Tobioka on 2015/09/23. 6 | // Copyright © 2015年 tnantoka. All rights reserved. 7 | // 8 | 9 | import UIKit 10 | 11 | import GameplayKit 12 | 13 | class Player: NSObject, GKGameModelPlayer { 14 | let mark: Mark 15 | 16 | init(mark: Mark) { 17 | self.mark = mark 18 | } 19 | 20 | static var _players = [ 21 | Player(mark: .o), 22 | Player(mark: .x), 23 | ] 24 | 25 | class func oPlayer() -> Player { 26 | return _players[Mark.o.rawValue - 1] 27 | } 28 | 29 | class func xPlayer() -> Player { 30 | return _players[Mark.x.rawValue - 1] 31 | } 32 | 33 | class func all() -> [Player] { 34 | return _players 35 | } 36 | 37 | func opponent() -> Player? { 38 | switch mark { 39 | case .o: 40 | return Player.xPlayer() 41 | case .x: 42 | return Player.oPlayer() 43 | default: 44 | return nil 45 | } 46 | } 47 | 48 | // MARK: GKGameModelPlayer 49 | 50 | var playerId: Int { 51 | return mark.rawValue 52 | } 53 | } 54 | -------------------------------------------------------------------------------- /GameplayKitSandbox/RuleViewController.swift: -------------------------------------------------------------------------------- 1 | // 2 | // RuleViewController.swift 3 | // GameplayKitSandbox 4 | // 5 | // Created by Tatsuya Tobioka on 2015/09/20. 6 | // Copyright © 2015年 tnantoka. All rights reserved. 7 | // 8 | 9 | import UIKit 10 | 11 | class RuleViewController: ExampleViewController { 12 | 13 | var scene: RuleScene! 14 | 15 | override func viewDidLoad() { 16 | super.viewDidLoad() 17 | 18 | // Do any additional setup after loading the view. 19 | scene = RuleScene(size: skView.frame.size) 20 | skView.presentScene(scene) 21 | } 22 | 23 | override func didReceiveMemoryWarning() { 24 | super.didReceiveMemoryWarning() 25 | // Dispose of any resources that can be recreated. 26 | } 27 | 28 | 29 | /* 30 | // MARK: - Navigation 31 | 32 | // In a storyboard-based application, you will often want to do a little preparation before navigation 33 | override func prepareForSegue(segue: UIStoryboardSegue, sender: AnyObject?) { 34 | // Get the new view controller using segue.destinationViewController. 35 | // Pass the selected object to the new view controller. 36 | } 37 | */ 38 | 39 | } 40 | -------------------------------------------------------------------------------- /GameplayKitSandboxTests/GameplayKitSandboxTests.swift: -------------------------------------------------------------------------------- 1 | // 2 | // GameplayKitSandboxTests.swift 3 | // GameplayKitSandboxTests 4 | // 5 | // Created by Tatsuya Tobioka on 2015/09/20. 6 | // Copyright © 2015年 tnantoka. All rights reserved. 7 | // 8 | 9 | import XCTest 10 | @testable import GameplayKitSandbox 11 | 12 | class GameplayKitSandboxTests: XCTestCase { 13 | 14 | override func setUp() { 15 | super.setUp() 16 | // Put setup code here. This method is called before the invocation of each test method in the class. 17 | } 18 | 19 | override func tearDown() { 20 | // Put teardown code here. This method is called after the invocation of each test method in the class. 21 | super.tearDown() 22 | } 23 | 24 | func testExample() { 25 | // This is an example of a functional test case. 26 | // Use XCTAssert and related functions to verify your tests produce the correct results. 27 | } 28 | 29 | func testPerformanceExample() { 30 | // This is an example of a performance test case. 31 | self.measure { 32 | // Put the code you want to measure the time of here. 33 | } 34 | } 35 | 36 | } 37 | -------------------------------------------------------------------------------- /GameplayKitSandbox/AgentsViewController.swift: -------------------------------------------------------------------------------- 1 | // 2 | // AgentsViewController.swift 3 | // GameplayKitSandbox 4 | // 5 | // Created by Tatsuya Tobioka on 2015/09/20. 6 | // Copyright © 2015年 tnantoka. All rights reserved. 7 | // 8 | 9 | import UIKit 10 | 11 | class AgentsViewController: ExampleViewController { 12 | 13 | var scene: AgentsScene! 14 | 15 | override func viewDidLoad() { 16 | super.viewDidLoad() 17 | 18 | // Do any additional setup after loading the view. 19 | scene = AgentsScene(size: skView.frame.size) 20 | skView.presentScene(scene) 21 | } 22 | 23 | override func didReceiveMemoryWarning() { 24 | super.didReceiveMemoryWarning() 25 | // Dispose of any resources that can be recreated. 26 | } 27 | 28 | 29 | /* 30 | // MARK: - Navigation 31 | 32 | // In a storyboard-based application, you will often want to do a little preparation before navigation 33 | override func prepareForSegue(segue: UIStoryboardSegue, sender: AnyObject?) { 34 | // Get the new view controller using segue.destinationViewController. 35 | // Pass the selected object to the new view controller. 36 | } 37 | */ 38 | 39 | } 40 | -------------------------------------------------------------------------------- /GameplayKitSandbox/EntitiesViewController.swift: -------------------------------------------------------------------------------- 1 | // 2 | // EntitiesViewController.swift 3 | // GameplayKitSandbox 4 | // 5 | // Created by Tatsuya Tobioka on 2015/09/20. 6 | // Copyright © 2015年 tnantoka. All rights reserved. 7 | // 8 | 9 | import UIKit 10 | 11 | class EntitiesViewController: ExampleViewController { 12 | 13 | var scene: EntitiesScene! 14 | 15 | override func viewDidLoad() { 16 | super.viewDidLoad() 17 | 18 | // Do any additional setup after loading the view. 19 | scene = EntitiesScene(size: skView.frame.size) 20 | skView.presentScene(scene) 21 | } 22 | 23 | override func didReceiveMemoryWarning() { 24 | super.didReceiveMemoryWarning() 25 | // Dispose of any resources that can be recreated. 26 | } 27 | 28 | 29 | /* 30 | // MARK: - Navigation 31 | 32 | // In a storyboard-based application, you will often want to do a little preparation before navigation 33 | override func prepareForSegue(segue: UIStoryboardSegue, sender: AnyObject?) { 34 | // Get the new view controller using segue.destinationViewController. 35 | // Pass the selected object to the new view controller. 36 | } 37 | */ 38 | 39 | } 40 | -------------------------------------------------------------------------------- /GameplayKitSandbox/PathfindingViewController.swift: -------------------------------------------------------------------------------- 1 | // 2 | // PathfindingViewController.swift 3 | // GameplayKitSandbox 4 | // 5 | // Created by Tatsuya Tobioka on 2015/09/20. 6 | // Copyright © 2015年 tnantoka. All rights reserved. 7 | // 8 | 9 | import UIKit 10 | 11 | class PathfindingViewController: ExampleViewController { 12 | 13 | var scene: PathfindingScene! 14 | 15 | override func viewDidLoad() { 16 | super.viewDidLoad() 17 | 18 | // Do any additional setup after loading the view. 19 | scene = PathfindingScene(size: skView.frame.size) 20 | skView.presentScene(scene) 21 | } 22 | 23 | override func didReceiveMemoryWarning() { 24 | super.didReceiveMemoryWarning() 25 | // Dispose of any resources that can be recreated. 26 | } 27 | 28 | 29 | /* 30 | // MARK: - Navigation 31 | 32 | // In a storyboard-based application, you will often want to do a little preparation before navigation 33 | override func prepareForSegue(segue: UIStoryboardSegue, sender: AnyObject?) { 34 | // Get the new view controller using segue.destinationViewController. 35 | // Pass the selected object to the new view controller. 36 | } 37 | */ 38 | 39 | } 40 | -------------------------------------------------------------------------------- /GameplayKitSandbox/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 7 | CFBundleExecutable 8 | $(EXECUTABLE_NAME) 9 | CFBundleIdentifier 10 | $(PRODUCT_BUNDLE_IDENTIFIER) 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | $(PRODUCT_NAME) 15 | CFBundlePackageType 16 | APPL 17 | CFBundleShortVersionString 18 | 1.0 19 | CFBundleSignature 20 | ???? 21 | CFBundleVersion 22 | 1 23 | LSRequiresIPhoneOS 24 | 25 | UILaunchStoryboardName 26 | LaunchScreen 27 | UIRequiredDeviceCapabilities 28 | 29 | armv7 30 | 31 | UISupportedInterfaceOrientations 32 | 33 | UIInterfaceOrientationPortrait 34 | UIInterfaceOrientationLandscapeLeft 35 | UIInterfaceOrientationLandscapeRight 36 | 37 | 38 | 39 | -------------------------------------------------------------------------------- /GameplayKitSandbox/IntelligenceComponent.swift: -------------------------------------------------------------------------------- 1 | // 2 | // IntelligenceComponent.swift 3 | // GameplayKitSandbox 4 | // 5 | // Created by Tatsuya Tobioka on 2015/09/21. 6 | // Copyright © 2015年 tnantoka. All rights reserved. 7 | // 8 | 9 | import UIKit 10 | 11 | import GameplayKit 12 | 13 | class IntelligenceComponent: GKComponent { 14 | 15 | var waitingMoveTime: TimeInterval = 0 16 | var waitingAttackTime: TimeInterval = 0 17 | let random = GKRandomDistribution(lowestValue: -30, highestValue: 30) 18 | 19 | override func update(deltaTime seconds: TimeInterval) { 20 | waitingMoveTime += seconds 21 | waitingAttackTime += seconds 22 | 23 | if waitingMoveTime > 1 { 24 | let x = CGFloat(random.nextInt()) 25 | let y = CGFloat(random.nextInt()) 26 | if let entity = entity { 27 | if let visualComponent = entity.component(ofType: VisualComponent.self) { 28 | visualComponent.moveBy(x, y) 29 | } 30 | 31 | } 32 | waitingMoveTime = 0 33 | } 34 | if waitingAttackTime > 3 { 35 | if let entity = entity { 36 | if let attackComponent = entity.component(ofType: AttackComponent.self) { 37 | attackComponent.attack() 38 | } 39 | } 40 | waitingAttackTime = 0 41 | } 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /GameplayKitSandboxUITests/GameplayKitSandboxUITests.swift: -------------------------------------------------------------------------------- 1 | // 2 | // GameplayKitSandboxUITests.swift 3 | // GameplayKitSandboxUITests 4 | // 5 | // Created by Tatsuya Tobioka on 2015/09/20. 6 | // Copyright © 2015年 tnantoka. All rights reserved. 7 | // 8 | 9 | import XCTest 10 | 11 | class GameplayKitSandboxUITests: XCTestCase { 12 | 13 | override func setUp() { 14 | super.setUp() 15 | 16 | // Put setup code here. This method is called before the invocation of each test method in the class. 17 | 18 | // In UI tests it is usually best to stop immediately when a failure occurs. 19 | continueAfterFailure = false 20 | // UI tests must launch the application that they test. Doing this in setup will make sure it happens for each test method. 21 | XCUIApplication().launch() 22 | 23 | // In UI tests it’s important to set the initial state - such as interface orientation - required for your tests before they run. The setUp method is a good place to do this. 24 | } 25 | 26 | override func tearDown() { 27 | // Put teardown code here. This method is called after the invocation of each test method in the class. 28 | super.tearDown() 29 | } 30 | 31 | func testExample() { 32 | // Use recording to get started writing UI tests. 33 | // Use XCTAssert and related functions to verify your tests produce the correct results. 34 | } 35 | 36 | } 37 | -------------------------------------------------------------------------------- /GameplayKitSandbox/MinmaxViewController.swift: -------------------------------------------------------------------------------- 1 | // 2 | // MinmaxViewController.swift 3 | // GameplayKitSandbox 4 | // 5 | // Created by Tatsuya Tobioka on 2015/09/20. 6 | // Copyright © 2015年 tnantoka. All rights reserved. 7 | // 8 | 9 | import UIKit 10 | 11 | class MinmaxViewController: ExampleViewController { 12 | 13 | var scene: MinmaxScene! 14 | 15 | override func viewDidLoad() { 16 | super.viewDidLoad() 17 | 18 | // Do any additional setup after loading the view. 19 | scene = MinmaxScene(size: skView.frame.size) 20 | scene.didGameOver = { scene, message in 21 | let alertController = UIAlertController(title: "Game Over", message: message, preferredStyle: .alert) 22 | let action = UIAlertAction(title: "OK", style: .default) { action in 23 | scene.reset() 24 | } 25 | alertController.addAction(action) 26 | self.present(alertController, animated: true, completion: nil) 27 | } 28 | skView.presentScene(scene) 29 | } 30 | 31 | override func didReceiveMemoryWarning() { 32 | super.didReceiveMemoryWarning() 33 | // Dispose of any resources that can be recreated. 34 | } 35 | 36 | 37 | /* 38 | // MARK: - Navigation 39 | 40 | // In a storyboard-based application, you will often want to do a little preparation before navigation 41 | override func prepareForSegue(segue: UIStoryboardSegue, sender: AnyObject?) { 42 | // Get the new view controller using segue.destinationViewController. 43 | // Pass the selected object to the new view controller. 44 | } 45 | */ 46 | 47 | } 48 | -------------------------------------------------------------------------------- /GameplayKitSandbox/ExampleViewController.swift: -------------------------------------------------------------------------------- 1 | // 2 | // ExampleViewController.swift 3 | // GameplayKitSandbox 4 | // 5 | // Created by Tatsuya Tobioka on 2015/09/20. 6 | // Copyright © 2015年 tnantoka. All rights reserved. 7 | // 8 | 9 | import UIKit 10 | 11 | import SpriteKit 12 | 13 | class ExampleViewController: UIViewController { 14 | 15 | weak var skView: SKView! 16 | 17 | override func viewDidLoad() { 18 | super.viewDidLoad() 19 | 20 | // Do any additional setup after loading the view. 21 | edgesForExtendedLayout = UIRectEdge() 22 | 23 | var frame = view.bounds 24 | frame.size.height -= navigationController!.navigationBar.frame.height + UIApplication.shared.statusBarFrame.height 25 | let skView = SKView(frame: frame) 26 | view.addSubview(skView) 27 | self.skView = skView 28 | 29 | #if DEBUG 30 | skView.showsDrawCount = true 31 | skView.showsFields = true 32 | skView.showsFPS = true 33 | skView.showsNodeCount = true 34 | skView.showsPhysics = true 35 | skView.showsQuadCount = true 36 | #endif 37 | } 38 | 39 | override func didReceiveMemoryWarning() { 40 | super.didReceiveMemoryWarning() 41 | // Dispose of any resources that can be recreated. 42 | } 43 | 44 | 45 | /* 46 | // MARK: - Navigation 47 | 48 | // In a storyboard-based application, you will often want to do a little preparation before navigation 49 | override func prepareForSegue(segue: UIStoryboardSegue, sender: AnyObject?) { 50 | // Get the new view controller using segue.destinationViewController. 51 | // Pass the selected object to the new view controller. 52 | } 53 | */ 54 | 55 | } 56 | -------------------------------------------------------------------------------- /GameplayKitSandbox/RandomizationViewController.swift: -------------------------------------------------------------------------------- 1 | // 2 | // RandomizationViewController.swift 3 | // GameplayKitSandbox 4 | // 5 | // Created by Tatsuya Tobioka on 2015/09/20. 6 | // Copyright © 2015年 tnantoka. All rights reserved. 7 | // 8 | 9 | import UIKit 10 | 11 | import SpriteKit 12 | 13 | class RandomizationViewController: ExampleViewController { 14 | 15 | var scene: RandomizationScene! 16 | 17 | override func viewDidLoad() { 18 | super.viewDidLoad() 19 | 20 | // Do any additional setup after loading the view. 21 | scene = RandomizationScene(size: skView.frame.size) 22 | skView.presentScene(scene) 23 | 24 | let segmentedControl = UISegmentedControl(items: ["Random", "Gaussian", "Shuffled"]) 25 | segmentedControl.selectedSegmentIndex = 0 26 | segmentedControl.addTarget(self, action: #selector(RandomizationViewController.segmentedControlDidChange(_:)), for: .valueChanged) 27 | navigationItem.titleView = segmentedControl 28 | } 29 | 30 | override func didReceiveMemoryWarning() { 31 | super.didReceiveMemoryWarning() 32 | // Dispose of any resources that can be recreated. 33 | } 34 | 35 | 36 | /* 37 | // MARK: - Navigation 38 | 39 | // In a storyboard-based application, you will often want to do a little preparation before navigation 40 | override func prepareForSegue(segue: UIStoryboardSegue, sender: AnyObject?) { 41 | // Get the new view controller using segue.destinationViewController. 42 | // Pass the selected object to the new view controller. 43 | } 44 | */ 45 | 46 | @objc func segmentedControlDidChange(_ sender: UISegmentedControl) { 47 | scene.distributionIndex = sender.selectedSegmentIndex 48 | } 49 | } 50 | -------------------------------------------------------------------------------- /GameplayKitSandbox/Base.lproj/LaunchScreen.storyboard: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | -------------------------------------------------------------------------------- /GameplayKitSandbox/AgentsScene.swift: -------------------------------------------------------------------------------- 1 | // 2 | // AgentsScene.swift 3 | // GameplayKitSandbox 4 | // 5 | // Created by Tatsuya Tobioka on 2015/09/29. 6 | // Copyright © 2015年 tnantoka. All rights reserved. 7 | // 8 | 9 | import UIKit 10 | 11 | import SpriteKit 12 | import GameplayKit 13 | 14 | class AgentsScene: ExampleScene { 15 | 16 | var targetNode: AgentNode! 17 | var agentSystem = GKComponentSystem(componentClass: GKAgent2D.self) 18 | 19 | override func createSceneContents() { 20 | targetNode = AgentNode(color: SKColor.magenta, radius: 30.0, position: center) 21 | addChild(targetNode) 22 | 23 | let goal = GKGoal(toWander: 10.0) 24 | let behavier = GKBehavior(goal: goal, weight: 100.0) 25 | targetNode.agent.behavior = behavier 26 | agentSystem.addComponent(targetNode.agent) 27 | } 28 | 29 | func createBullet() { 30 | let x = GKRandomDistribution(lowestValue: 0, highestValue: Int(frame.maxX)).nextInt() 31 | let y = GKRandomDistribution(lowestValue: 0, highestValue: Int(frame.maxY)).nextInt() 32 | let position = CGPoint(x: CGFloat(x), y: CGFloat(y)) 33 | 34 | let bullet = AgentNode(color: SKColor.cyan, radius: 10.0, position: position) 35 | addChild(bullet) 36 | 37 | let goal = GKGoal(toSeekAgent: targetNode.agent) 38 | let behavier = GKBehavior(goal: goal, weight: 100.0) 39 | bullet.agent.behavior = behavier 40 | agentSystem.addComponent(bullet.agent) 41 | } 42 | 43 | override func update(_ currentTime: TimeInterval) { 44 | super.update(currentTime) 45 | agentSystem.update(deltaTime: deltaTime) 46 | } 47 | 48 | override func touchesBegan(_ touches: Set, with event: UIEvent?) { 49 | createBullet() 50 | } 51 | } 52 | -------------------------------------------------------------------------------- /GameplayKitSandbox/ExampleScene.swift: -------------------------------------------------------------------------------- 1 | // 2 | // ExampleScene.swift 3 | // GameplayKitSandbox 4 | // 5 | // Created by Tatsuya Tobioka on 2015/09/20. 6 | // Copyright © 2015年 tnantoka. All rights reserved. 7 | // 8 | 9 | import UIKit 10 | 11 | import SpriteKit 12 | 13 | class ExampleScene: SKScene { 14 | 15 | var contentCreated = false 16 | 17 | var center: CGPoint { 18 | return CGPoint(x: frame.midX, y: frame.midY) 19 | } 20 | 21 | var prevUpdateTime: TimeInterval = -1; 22 | var deltaTime: TimeInterval = 0 23 | 24 | override init(size: CGSize) { 25 | super.init(size: size) 26 | isUserInteractionEnabled = true 27 | } 28 | 29 | required init?(coder aDecoder: NSCoder) { 30 | fatalError("init(coder:) has not been implemented") 31 | } 32 | 33 | override func didMove(to view: SKView) { 34 | if !contentCreated { 35 | createSceneContents() 36 | contentCreated = true 37 | } 38 | } 39 | 40 | func createSceneContents() { 41 | } 42 | 43 | override func update(_ currentTime: TimeInterval) { 44 | if (prevUpdateTime < 0) { 45 | prevUpdateTime = currentTime 46 | } 47 | deltaTime = currentTime - prevUpdateTime 48 | prevUpdateTime = currentTime 49 | } 50 | 51 | func createLabel(_ text: String, color: SKColor, order: Int) { 52 | let label = SKLabelNode(text: text) 53 | label.fontSize = 14.0 54 | label.fontName = UIFont.boldSystemFont(ofSize: UIFont.systemFontSize).fontName 55 | let padding: CGFloat = 10.0 56 | label.position = CGPoint(x: padding, y: frame.maxY - CGFloat(order) * label.fontSize - padding) 57 | label.fontColor = color 58 | label.horizontalAlignmentMode = .left 59 | label.verticalAlignmentMode = .top 60 | addChild(label) 61 | } 62 | } 63 | -------------------------------------------------------------------------------- /GameplayKitSandbox/StateViewController.swift: -------------------------------------------------------------------------------- 1 | // 2 | // StateViewController.swift 3 | // GameplayKitSandbox 4 | // 5 | // Created by Tatsuya Tobioka on 2015/09/20. 6 | // Copyright © 2015年 tnantoka. All rights reserved. 7 | // 8 | 9 | import UIKit 10 | 11 | class StateViewController: ExampleViewController { 12 | 13 | var scene: StateScene! 14 | 15 | override func viewDidLoad() { 16 | super.viewDidLoad() 17 | 18 | // Do any additional setup after loading the view. 19 | scene = StateScene(size: skView.frame.size) 20 | skView.presentScene(scene) 21 | 22 | let doubleTapRecognizer = UITapGestureRecognizer(target: self, action: #selector(StateViewController.viewDidDoubleTap(_:))) 23 | doubleTapRecognizer.numberOfTapsRequired = 2 24 | view.addGestureRecognizer(doubleTapRecognizer) 25 | 26 | let tapRecognizer = UITapGestureRecognizer(target: self, action: #selector(StateViewController.viewDidTap(_:))) 27 | tapRecognizer.require(toFail: doubleTapRecognizer) 28 | view.addGestureRecognizer(tapRecognizer) 29 | } 30 | 31 | override func didReceiveMemoryWarning() { 32 | super.didReceiveMemoryWarning() 33 | // Dispose of any resources that can be recreated. 34 | } 35 | 36 | 37 | /* 38 | // MARK: - Navigation 39 | 40 | // In a storyboard-based application, you will often want to do a little preparation before navigation 41 | override func prepareForSegue(segue: UIStoryboardSegue, sender: AnyObject?) { 42 | // Get the new view controller using segue.destinationViewController. 43 | // Pass the selected object to the new view controller. 44 | } 45 | */ 46 | 47 | @objc func viewDidDoubleTap(_ sender: UIGestureRecognizer) { 48 | scene.createRain() 49 | } 50 | 51 | @objc func viewDidTap(_ sender: UIGestureRecognizer) { 52 | scene.createSpark() 53 | } 54 | } 55 | -------------------------------------------------------------------------------- /GameplayKitSandbox/BurnableComponent.swift: -------------------------------------------------------------------------------- 1 | // 2 | // BurnableComponent.swift 3 | // GameplayKitSandbox 4 | // 5 | // Created by Tatsuya Tobioka on 2015/09/22. 6 | // Copyright © 2015年 tnantoka. All rights reserved. 7 | // 8 | 9 | import UIKit 10 | 11 | import SpriteKit 12 | import GameplayKit 13 | 14 | class BurnableComponent: GKComponent { 15 | 16 | let stateMachine: GKStateMachine 17 | let shapeNode: SKShapeNode 18 | var particleNode: SKEmitterNode? 19 | 20 | init(entity: GKEntity, shapeNode: SKShapeNode) { 21 | let dry = HouseDryState(entity: entity) 22 | let burning = HouseBurningState(entity: entity) 23 | let wet = HouseWetState(entity: entity) 24 | stateMachine = GKStateMachine(states: [dry, burning, wet]) 25 | 26 | self.shapeNode = shapeNode 27 | shapeNode.strokeColor = SKColor.clear 28 | 29 | super.init() 30 | } 31 | 32 | required init?(coder aDecoder: NSCoder) { 33 | fatalError("init(coder:) has not been implemented") 34 | } 35 | 36 | func useDryAppearance() { 37 | shapeNode.fillColor = SKColor.white 38 | particleNode?.removeFromParent() 39 | } 40 | 41 | func useBurningAppearance() { 42 | shapeNode.fillColor = SKColor.orange 43 | particleNode?.removeFromParent() 44 | if let firePath = Bundle.main.path(forResource: "fire", ofType: "sks") { 45 | if let fire = NSKeyedUnarchiver.unarchiveObject(withFile: firePath) as? SKEmitterNode { 46 | fire.position = CGPoint(x: 0, y: -30.0) 47 | shapeNode.addChild(fire) 48 | particleNode = fire 49 | } 50 | } 51 | } 52 | 53 | func useWetAppearance() { 54 | shapeNode.fillColor = SKColor.lightGray 55 | particleNode?.removeFromParent() 56 | } 57 | 58 | override func update(deltaTime seconds: TimeInterval) { 59 | stateMachine.update(deltaTime: seconds) 60 | } 61 | } 62 | -------------------------------------------------------------------------------- /GameplayKitSandbox/AgentNode.swift: -------------------------------------------------------------------------------- 1 | // 2 | // AgentNode.swift 3 | // GameplayKitSandbox 4 | // 5 | // Created by Tatsuya Tobioka on 2015/09/29. 6 | // Copyright © 2015年 tnantoka. All rights reserved. 7 | // 8 | 9 | import UIKit 10 | 11 | import SpriteKit 12 | import GLKit 13 | import GameplayKit 14 | 15 | class AgentNode: SKNode, GKAgentDelegate { 16 | 17 | let agent: GKAgent2D 18 | 19 | init(color: SKColor, radius: CGFloat, position: CGPoint) { 20 | var points = [CGPoint]() 21 | 22 | for degree in [0.0, 120.0, 240.0] as [Float] { 23 | let radian = CGFloat(GLKMathDegreesToRadians(degree)) 24 | let x = cos(radian) * radius 25 | let y = sin(radian) * radius 26 | points.append(CGPoint(x: x, y: y)) 27 | } 28 | 29 | let shape = SKShapeNode(points: &points, count: points.count) 30 | shape.fillColor = color 31 | shape.strokeColor = SKColor.clear 32 | 33 | let circle = SKShapeNode(circleOfRadius: 2.0) 34 | circle.strokeColor = SKColor.clear 35 | circle.fillColor = SKColor.yellow 36 | circle.position = CGPoint(x: points[0].x, y: points[0].y) 37 | 38 | agent = GKAgent2D() 39 | agent.position = vector_float2(x: Float(position.x), y: Float(position.y)) 40 | agent.radius = Float(radius) 41 | agent.maxSpeed = 50.0 42 | agent.maxAcceleration = 20.0 43 | 44 | super.init() 45 | self.position = position 46 | 47 | addChild(shape) 48 | addChild(circle) 49 | 50 | agent.delegate = self 51 | } 52 | 53 | required init?(coder aDecoder: NSCoder) { 54 | fatalError("init(coder:) has not been implemented") 55 | } 56 | 57 | // MARK: - GKAgentDelegate 58 | 59 | func agentWillUpdate(_ agent: GKAgent) { 60 | } 61 | 62 | func agentDidUpdate(_ agent: GKAgent) { 63 | guard let agent = agent as? GKAgent2D else { return } 64 | self.position = CGPoint(x: CGFloat(agent.position.x), y: CGFloat(agent.position.y)) 65 | self.zRotation = CGFloat(agent.rotation) 66 | 67 | } 68 | } 69 | -------------------------------------------------------------------------------- /GameplayKitSandbox/NoiseScene.swift: -------------------------------------------------------------------------------- 1 | // 2 | // NoiseScene.swift 3 | // GameplayKitSandbox 4 | // 5 | // Created by Tatsuya Tobioka on 9/25/16. 6 | // Copyright © 2016 tnantoka. All rights reserved. 7 | // 8 | 9 | import UIKit 10 | import GameplayKit 11 | 12 | class NoiseScene: ExampleScene { 13 | override func createSceneContents() { 14 | let noises: [(String, GKNoiseSource)] = [ 15 | ("Billow", GKBillowNoiseSource()), 16 | ("Checkerboard", GKCheckerboardNoiseSource(squareSize: 0.1)), 17 | ("Constant", GKConstantNoiseSource()), 18 | ("Cylinders", GKCylindersNoiseSource()), 19 | ("Perlin", GKPerlinNoiseSource()), 20 | ("Ridged", GKRidgedNoiseSource()), 21 | ("Spheres", GKSpheresNoiseSource()), 22 | ("Voronoi", GKVoronoiNoiseSource()), 23 | ] 24 | 25 | let height = frame.height / CGFloat(noises.count / 2) 26 | let width = frame.midX 27 | 28 | for (i, source) in noises.enumerated() { 29 | let y = frame.maxY - height * CGFloat(i / 2) 30 | let x = frame.midX * CGFloat(i % 2) 31 | 32 | let noise = GKNoise(source.1) 33 | let noiseMap = GKNoiseMap(noise) 34 | let texture = SKTexture(noiseMap: noiseMap) 35 | let noiseNode = SKSpriteNode(texture: texture, size: CGSize(width: width, height: height)) 36 | noiseNode.position = CGPoint(x: x, y: y) 37 | noiseNode.anchorPoint = CGPoint(x: 0.0, y: 1.0) 38 | addChild(noiseNode) 39 | 40 | let labelNode = SKLabelNode(text: source.0) 41 | labelNode.verticalAlignmentMode = .top 42 | labelNode.horizontalAlignmentMode = .left 43 | labelNode.color = UIColor.white 44 | labelNode.fontSize = 26.0 45 | 46 | let overlayNode = SKSpriteNode(color: UIColor(white: 0.0, alpha: 0.8), size: labelNode.frame.size) 47 | overlayNode.position = CGPoint(x: x, y: y) 48 | overlayNode.anchorPoint = CGPoint(x: 0.0, y: 1.0) 49 | overlayNode.addChild(labelNode) 50 | 51 | addChild(overlayNode) 52 | } 53 | } 54 | } 55 | -------------------------------------------------------------------------------- /GameplayKitSandbox/RandomizationScene.swift: -------------------------------------------------------------------------------- 1 | // 2 | // RandomizationScene.swift 3 | // GameplayKitSandbox 4 | // 5 | // Created by Tatsuya Tobioka on 2015/09/20. 6 | // Copyright © 2015年 tnantoka. All rights reserved. 7 | // 8 | 9 | import UIKit 10 | 11 | import SpriteKit 12 | import GameplayKit 13 | 14 | class RandomizationScene: ExampleScene { 15 | 16 | let degrees = [Int](0...72).map { $0 * (360 / 72) } 17 | let examples = [ 18 | [GKARC4RandomSource.self, SKColor.cyan, "ARC4"], 19 | [GKLinearCongruentialRandomSource.self, SKColor.magenta, "LinearCongruential"], 20 | [GKMersenneTwisterRandomSource.self, SKColor.yellow, "MersenneTwister"], 21 | ] 22 | 23 | var distributionIndex = 0 { 24 | didSet { 25 | removeAllChildren() 26 | createSceneContents() 27 | } 28 | } 29 | var distributions = [ 30 | GKRandomDistribution.self, 31 | GKGaussianDistribution.self, 32 | GKShuffledDistribution.self, 33 | ] 34 | 35 | override func createSceneContents() { 36 | for (i, example) in examples.enumerated() { 37 | let type = example[0] as! GKRandomSource.Type 38 | let source = type.sharedRandom() 39 | 40 | let color = example[1] as! UIColor 41 | let radius = frame.width * (0.4 - CGFloat(i) * 0.05) 42 | 43 | draw(distribution(source), color: color, radius: radius) 44 | 45 | let text = "● \(example[2] as! String)" 46 | createLabel(text, color: color, order: i) 47 | } 48 | } 49 | 50 | func distribution(_ source: GKRandomSource) -> GKRandomDistribution { 51 | return distributions[distributionIndex].init(randomSource: source, lowestValue: 0, highestValue: degrees.count - 1) 52 | } 53 | 54 | func draw(_ distribution: GKRandomDistribution, color: SKColor, radius: CGFloat) { 55 | let circle = SKShapeNode(circleOfRadius: radius) 56 | circle.position = center 57 | addChild(circle) 58 | 59 | for _ in 0.. Bool { 18 | // Override point for customization after application launch. 19 | self.window = UIWindow(frame: UIScreen.main.bounds) 20 | let examplesController = ExamplesViewController() 21 | let navController = UINavigationController(rootViewController: examplesController) 22 | self.window?.rootViewController = navController 23 | self.window?.makeKeyAndVisible() 24 | return true 25 | } 26 | 27 | func applicationWillResignActive(_ application: UIApplication) { 28 | // 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. 29 | // Use this method to pause ongoing tasks, disable timers, and throttle down OpenGL ES frame rates. Games should use this method to pause the game. 30 | } 31 | 32 | func applicationDidEnterBackground(_ application: UIApplication) { 33 | // 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. 34 | // If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits. 35 | } 36 | 37 | func applicationWillEnterForeground(_ application: UIApplication) { 38 | // Called as part of the transition from the background to the inactive state; here you can undo many of the changes made on entering the background. 39 | } 40 | 41 | func applicationDidBecomeActive(_ application: UIApplication) { 42 | // 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. 43 | } 44 | 45 | func applicationWillTerminate(_ application: UIApplication) { 46 | // Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:. 47 | } 48 | 49 | 50 | } 51 | 52 | -------------------------------------------------------------------------------- /GameplayKitSandbox/StateScene.swift: -------------------------------------------------------------------------------- 1 | // 2 | // StateScene.swift 3 | // GameplayKitSandbox 4 | // 5 | // Created by Tatsuya Tobioka on 2015/09/22. 6 | // Copyright © 2015年 tnantoka. All rights reserved. 7 | // 8 | 9 | import UIKit 10 | 11 | import SpriteKit 12 | import GameplayKit 13 | 14 | class StateScene: ExampleScene { 15 | 16 | var house: GKEntity! 17 | 18 | override func createSceneContents() { 19 | house = GKEntity() 20 | 21 | var points = [ 22 | CGPoint(x: 0, y: 40.0), 23 | CGPoint(x: -40.0, y: 0), 24 | CGPoint(x: -25.0, y: 0), 25 | CGPoint(x: -25.0, y: -40.0), 26 | CGPoint(x: 25.0, y: -40.0), 27 | CGPoint(x: 25.0, y: 0), 28 | CGPoint(x: 40.0, y: 0), 29 | ] 30 | let shapeNode = SKShapeNode(points: &points, count: points.count) 31 | shapeNode.position = center 32 | addChild(shapeNode) 33 | 34 | let burnableComponent = BurnableComponent(entity: house, shapeNode: shapeNode) 35 | house.addComponent(burnableComponent) 36 | burnableComponent.stateMachine.enter(HouseDryState.self) 37 | 38 | createLabel("Tap: Spark", color: SKColor.orange, order: 0) 39 | createLabel("Double Tap: Rain", color: SKColor.lightGray, order: 1) 40 | } 41 | 42 | func createSpark() { 43 | createParticle("spark", position: center, duration: 0.1) { 44 | if let burnableComponent = self.house.component(ofType: BurnableComponent.self) { 45 | burnableComponent.stateMachine.enter(HouseBurningState.self) 46 | } 47 | } 48 | } 49 | 50 | func createRain() { 51 | createParticle("rain", position: CGPoint(x: center.x + 50.0, y: center.y + 200.0), duration: 2.0) { 52 | if let burnableComponent = self.house.component(ofType: BurnableComponent.self) { 53 | burnableComponent.stateMachine.enter(HouseWetState.self) 54 | } 55 | } 56 | } 57 | 58 | func createParticle(_ name: String, position: CGPoint, duration: TimeInterval, callback: @escaping () -> Void) { 59 | if let particlePath = Bundle.main.path(forResource: name, ofType: "sks") { 60 | if let particle = NSKeyedUnarchiver.unarchiveObject(withFile: particlePath) as? SKEmitterNode { 61 | particle.position = position 62 | addChild(particle) 63 | 64 | let wait = SKAction.wait(forDuration: duration) 65 | let fadeOut = SKAction.fadeOut(withDuration: 1.0) 66 | let sequence = SKAction.sequence([wait, fadeOut]) 67 | particle.run(sequence, completion: callback) 68 | } 69 | } 70 | } 71 | 72 | override func update(_ currentTime: TimeInterval) { 73 | super.update(currentTime) 74 | 75 | house.update(deltaTime: deltaTime) 76 | } 77 | } 78 | -------------------------------------------------------------------------------- /GameplayKitSandbox/EntitiesScene.swift: -------------------------------------------------------------------------------- 1 | // 2 | // EntitiesScene.swift 3 | // GameplayKitSandbox 4 | // 5 | // Created by Tatsuya Tobioka on 2015/09/20. 6 | // Copyright © 2015年 tnantoka. All rights reserved. 7 | // 8 | 9 | import UIKit 10 | 11 | import SpriteKit 12 | import GameplayKit 13 | 14 | class EntitiesScene: ExampleScene { 15 | 16 | var player: GKEntity! 17 | var enemies = [GKEntity]() 18 | var boss: GKEntity! 19 | 20 | let intelligenceSystem = GKComponentSystem(componentClass: IntelligenceComponent.self) 21 | 22 | override func createSceneContents() { 23 | createLabel("■ Player: Visual, Attack, Control", color: SKColor.cyan, order: 0) 24 | createLabel("■ Boss: Visual, Attack, Intelligence", color: SKColor.magenta, order: 2) 25 | createLabel("■ Enemy: Visual, Intelligence", color: SKColor.yellow, order: 1) 26 | 27 | createPlayer() 28 | createEnemies() 29 | createBoss() 30 | } 31 | 32 | func createPlayer() { 33 | player = GKEntity() 34 | 35 | let visualComponent = VisualComponent(color: SKColor.cyan, size: CGSize(width: 30.0, height: 30.0)) 36 | visualComponent.position = center 37 | player.addComponent(visualComponent) 38 | addChild(visualComponent.sprite) 39 | 40 | let attackComponent = AttackComponent() 41 | player.addComponent(attackComponent) 42 | 43 | let controlComponent = ControlComponent() 44 | player.addComponent(controlComponent) 45 | } 46 | 47 | func createEnemies() { 48 | for _ in 0..<20 { 49 | let enemy = GKEntity() 50 | enemies.append(enemy) 51 | 52 | let visualComponent = VisualComponent(color: SKColor.yellow, size: CGSize(width: 20.0, height: 20.0)) 53 | visualComponent.position = randomPosition() 54 | enemy.addComponent(visualComponent) 55 | addChild(visualComponent.sprite) 56 | 57 | let intelligenceComponent = IntelligenceComponent() 58 | enemy.addComponent(intelligenceComponent) 59 | intelligenceSystem.addComponent(intelligenceComponent) 60 | } 61 | } 62 | 63 | func createBoss() { 64 | boss = GKEntity() 65 | 66 | let visualComponent = VisualComponent(color: SKColor.magenta, size: CGSize(width: 50.0, height: 50.0)) 67 | visualComponent.position = randomPosition() 68 | boss.addComponent(visualComponent) 69 | addChild(visualComponent.sprite) 70 | 71 | let attackComponent = AttackComponent() 72 | boss.addComponent(attackComponent) 73 | 74 | let intelligenceComponent = IntelligenceComponent() 75 | boss.addComponent(intelligenceComponent) 76 | intelligenceSystem.addComponent(intelligenceComponent) 77 | } 78 | 79 | func randomPosition() -> CGPoint { 80 | let x = GKRandomDistribution(lowestValue: 50, highestValue: Int(frame.maxX) - 50).nextInt() 81 | let y = GKRandomDistribution(lowestValue: 50, highestValue: Int(frame.maxY) - 50).nextInt() 82 | return CGPoint(x: CGFloat(x), y: CGFloat(y)) 83 | } 84 | 85 | override func update(_ currentTime: TimeInterval) { 86 | super.update(currentTime) 87 | 88 | player.update(deltaTime: deltaTime) 89 | intelligenceSystem.update(deltaTime: deltaTime) 90 | } 91 | 92 | override func touchesBegan(_ touches: Set, with event: UIEvent?) { 93 | guard let touch = touches.first else { return } 94 | let location = touch.location(in: self) 95 | let node = atPoint(location) 96 | if let controlComponent = player.component(ofType: ControlComponent.self) { 97 | controlComponent.touch(node, location: location) 98 | } 99 | } 100 | } 101 | -------------------------------------------------------------------------------- /GameplayKitSandbox/MinmaxScene.swift: -------------------------------------------------------------------------------- 1 | // 2 | // MinmaxScene.swift 3 | // GameplayKitSandbox 4 | // 5 | // Created by Tatsuya Tobioka on 2015/09/22. 6 | // Copyright © 2015年 tnantoka. All rights reserved. 7 | // 8 | 9 | import UIKit 10 | 11 | import SpriteKit 12 | import GameplayKit 13 | 14 | class MinmaxScene: ExampleScene { 15 | 16 | let cellSize: CGFloat = 60.0 17 | let margin: CGFloat = 2.0 18 | 19 | var board: Board! 20 | var cells: [SKSpriteNode]! 21 | var strategist: GKMinmaxStrategist! 22 | 23 | var didGameOver: ((MinmaxScene, String) -> Void)? 24 | 25 | override func createSceneContents() { 26 | board = Board(level: 3) 27 | //board.debug = true 28 | 29 | strategist = GKMinmaxStrategist() 30 | strategist.gameModel = board 31 | strategist.maxLookAheadDepth = board.level * 2 - 1 32 | 33 | let step = cellSize + margin 34 | 35 | let backgroundSize = step * CGFloat(board.level) - margin 36 | let background = SKSpriteNode(color: SKColor.white, size: CGSize(width: backgroundSize, height: backgroundSize)) 37 | background.position = center 38 | addChild(background) 39 | 40 | cells = [SKSpriteNode]() 41 | let base = CGFloat(board.level - 1) * 0.5 42 | let baseX = center.x - step * base 43 | let baseY = center.y - step * base 44 | for i in 0.., with event: UIEvent?) { 97 | guard let touch = touches.first else { return } 98 | let location = touch.location(in: self) 99 | if let node = atPoint(location) as? SKSpriteNode { 100 | if let index = cells.firstIndex(of: node) { 101 | board.updateCell(index) 102 | updateBoard() 103 | if let move = strategist.bestMove(for: board.currentPlayer) as? Move { 104 | board.apply(move) 105 | updateBoard() 106 | } 107 | } 108 | } 109 | } 110 | } 111 | -------------------------------------------------------------------------------- /GameplayKitSandbox/ExamplesViewController.swift: -------------------------------------------------------------------------------- 1 | // 2 | // ExamplesViewController.swift 3 | // GameplayKitSandbox 4 | // 5 | // Created by Tatsuya Tobioka on 2015/09/20. 6 | // Copyright © 2015年 tnantoka. All rights reserved. 7 | // 8 | 9 | import UIKit 10 | 11 | class ExamplesViewController: UITableViewController { 12 | 13 | let cellReuseIdentifier = "cellReuseIdentifier" 14 | let titles = [ 15 | "Randomization", 16 | "Entities and Components", 17 | "State Machines", 18 | "The Minmax Strategist", 19 | "Pathfinding", 20 | "Agents, Goals, and Behaviors", 21 | "Rule Systems", 22 | "Procedural Generation", 23 | ] 24 | let controllers: [UIViewController] = [ 25 | RandomizationViewController(), 26 | EntitiesViewController(), 27 | StateViewController(), 28 | MinmaxViewController(), 29 | PathfindingViewController(), 30 | AgentsViewController(), 31 | RuleViewController(), 32 | NoiseViewController(), 33 | ] 34 | 35 | override func viewDidLoad() { 36 | super.viewDidLoad() 37 | 38 | // Uncomment the following line to preserve selection between presentations 39 | // self.clearsSelectionOnViewWillAppear = false 40 | 41 | // Uncomment the following line to display an Edit button in the navigation bar for this view controller. 42 | // self.navigationItem.rightBarButtonItem = self.editButtonItem() 43 | 44 | tableView.register(UITableViewCell.self, forCellReuseIdentifier: cellReuseIdentifier) 45 | title = "GameplayKit Sandbox" 46 | } 47 | 48 | override func didReceiveMemoryWarning() { 49 | super.didReceiveMemoryWarning() 50 | // Dispose of any resources that can be recreated. 51 | } 52 | 53 | // MARK: - Table view data source 54 | 55 | override func numberOfSections(in tableView: UITableView) -> Int { 56 | // #warning Incomplete implementation, return the number of sections 57 | return 1 58 | } 59 | 60 | override func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int { 61 | // #warning Incomplete implementation, return the number of rows 62 | return titles.count 63 | } 64 | 65 | override func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell { 66 | let cell = tableView.dequeueReusableCell(withIdentifier: cellReuseIdentifier, for: indexPath) 67 | 68 | // Configure the cell... 69 | let title = titles[(indexPath as NSIndexPath).row] 70 | cell.textLabel?.text = title 71 | 72 | return cell 73 | } 74 | 75 | /* 76 | // Override to support conditional editing of the table view. 77 | override func tableView(tableView: UITableView, canEditRowAtIndexPath indexPath: NSIndexPath) -> Bool { 78 | // Return false if you do not want the specified item to be editable. 79 | return true 80 | } 81 | */ 82 | 83 | /* 84 | // Override to support editing the table view. 85 | override func tableView(tableView: UITableView, commitEditingStyle editingStyle: UITableViewCellEditingStyle, forRowAtIndexPath indexPath: NSIndexPath) { 86 | if editingStyle == .Delete { 87 | // Delete the row from the data source 88 | tableView.deleteRowsAtIndexPaths([indexPath], withRowAnimation: .Fade) 89 | } else if editingStyle == .Insert { 90 | // Create a new instance of the appropriate class, insert it into the array, and add a new row to the table view 91 | } 92 | } 93 | */ 94 | 95 | /* 96 | // Override to support rearranging the table view. 97 | override func tableView(tableView: UITableView, moveRowAtIndexPath fromIndexPath: NSIndexPath, toIndexPath: NSIndexPath) { 98 | 99 | } 100 | */ 101 | 102 | /* 103 | // Override to support conditional rearranging of the table view. 104 | override func tableView(tableView: UITableView, canMoveRowAtIndexPath indexPath: NSIndexPath) -> Bool { 105 | // Return false if you do not want the item to be re-orderable. 106 | return true 107 | } 108 | */ 109 | 110 | /* 111 | // MARK: - Navigation 112 | 113 | // In a storyboard-based application, you will often want to do a little preparation before navigation 114 | override func prepareForSegue(segue: UIStoryboardSegue, sender: AnyObject?) { 115 | // Get the new view controller using segue.destinationViewController. 116 | // Pass the selected object to the new view controller. 117 | } 118 | */ 119 | 120 | override func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) { 121 | let title = titles[(indexPath as NSIndexPath).row] 122 | let controller = controllers[(indexPath as NSIndexPath).row] 123 | controller.title = title 124 | self.navigationController?.pushViewController(controller, animated: true) 125 | } 126 | } 127 | -------------------------------------------------------------------------------- /GameplayKitSandbox/RuleScene.swift: -------------------------------------------------------------------------------- 1 | // 2 | // RuleScene.swift 3 | // GameplayKitSandbox 4 | // 5 | // Created by Tatsuya Tobioka on 2015/09/30. 6 | // Copyright © 2015年 tnantoka. All rights reserved. 7 | // 8 | 9 | import UIKit 10 | 11 | import SpriteKit 12 | import GameplayKit 13 | 14 | class RuleScene: ExampleScene, SKPhysicsContactDelegate { 15 | 16 | var powerNode: SKSpriteNode! 17 | var cleanerNode: SKShapeNode! 18 | var chargerNode: SKSpriteNode! 19 | 20 | var ruleSystem: GKRuleSystem! 21 | var power = 100 22 | 23 | var waitingTime: TimeInterval = 0 24 | 25 | enum ContactCategory: UInt32 { 26 | case cleaner = 1 27 | case garbage = 2 28 | } 29 | 30 | override func createSceneContents() { 31 | physicsWorld.contactDelegate = self 32 | 33 | chargerNode = SKSpriteNode(color: SKColor.yellow, size: CGSize(width: 30.0, height: 30.0)) 34 | chargerNode.position = CGPoint(x: frame.maxX - 15.0, y: frame.maxY - 15.0) 35 | addChild(chargerNode) 36 | 37 | cleanerNode = SKShapeNode(circleOfRadius: 20.0) 38 | cleanerNode.fillColor = SKColor.white 39 | cleanerNode.position = randomPosition() 40 | addChild(cleanerNode) 41 | cleanerNode.physicsBody = SKPhysicsBody(circleOfRadius: cleanerNode.frame.width / 2) 42 | cleanerNode.physicsBody?.affectedByGravity = false 43 | cleanerNode.physicsBody?.contactTestBitMask = ContactCategory.garbage.rawValue 44 | cleanerNode.physicsBody?.categoryBitMask = ContactCategory.cleaner.rawValue 45 | 46 | powerNode = SKSpriteNode(color: SKColor.cyan, size: CGSize(width: 50.0, height: 20.0)) 47 | powerNode.position = CGPoint(x: 10.0, y: frame.maxY - powerNode.size.height - 10.0) 48 | powerNode.anchorPoint = CGPoint.zero 49 | addChild(powerNode) 50 | 51 | ruleSystem = GKRuleSystem() 52 | let rules = [ 53 | GKRule(predicate: NSPredicate(format: "$distanceToCharger > 550"), assertingFact: "charge" as NSObjectProtocol, grade: 1.0), 54 | GKRule(predicate: NSPredicate(format: "$power <= 30"), assertingFact: "charge" as NSObjectProtocol, grade: 1.0), 55 | ] 56 | ruleSystem.add(rules) 57 | 58 | createGarbages() 59 | } 60 | 61 | func createGarbages() { 62 | let count = GKRandomDistribution.d6().nextInt() 63 | for _ in 0...count { 64 | let garbage = SKSpriteNode(color: SKColor.lightGray, size: CGSize(width: 10.0, height: 10.0)) 65 | garbage.position = randomPosition() 66 | addChild(garbage) 67 | garbage.physicsBody = SKPhysicsBody(rectangleOf: garbage.frame.size) 68 | garbage.physicsBody?.affectedByGravity = false 69 | garbage.physicsBody?.contactTestBitMask = ContactCategory.cleaner.rawValue 70 | garbage.physicsBody?.categoryBitMask = ContactCategory.garbage.rawValue 71 | } 72 | } 73 | 74 | func randomPosition() -> CGPoint { 75 | let x = GKRandomDistribution(lowestValue: 30, highestValue: Int(frame.maxX) - 30).nextInt() 76 | let y = GKRandomDistribution(lowestValue: 30, highestValue: Int(frame.maxY) - 30).nextInt() 77 | return CGPoint(x: CGFloat(x), y: CGFloat(y)) 78 | } 79 | 80 | override func update(_ currentTime: TimeInterval) { 81 | super.update(currentTime) 82 | 83 | self.updatePowerNode() 84 | 85 | waitingTime += deltaTime 86 | if waitingTime > 3.0 { 87 | 88 | createGarbages() 89 | 90 | let distance = sqrt(pow(cleanerNode.position.x - chargerNode.position.x, 2) + pow(cleanerNode.position.y - chargerNode.position.y, 2)) 91 | ruleSystem.state["distanceToCharger"] = distance 92 | ruleSystem.state["power"] = power 93 | 94 | ruleSystem.reset() 95 | ruleSystem.evaluate() 96 | 97 | let charge = ruleSystem.grade(forFact: "charge" as NSObjectProtocol) 98 | if charge > 0.0 { 99 | let action = SKAction.move(to: chargerNode.position, duration: 1.0) 100 | cleanerNode.run(action, completion: { 101 | self.power = 100 102 | }) 103 | } else { 104 | let action = SKAction.move(to: randomPosition(), duration: 1.0) 105 | cleanerNode.run(action, completion: { 106 | self.power -= 10 107 | }) 108 | } 109 | waitingTime = 0 110 | } 111 | } 112 | 113 | func updatePowerNode() { 114 | powerNode.size.width = CGFloat(power / 2) 115 | } 116 | 117 | // MARK: - SKPhysicsContactDelegate 118 | 119 | func didBegin(_ contact: SKPhysicsContact) { 120 | let firstBody: SKPhysicsBody 121 | let secondBody: SKPhysicsBody 122 | if contact.bodyA.categoryBitMask < contact.bodyB.categoryBitMask { 123 | firstBody = contact.bodyA 124 | secondBody = contact.bodyB 125 | } else { 126 | firstBody = contact.bodyB 127 | secondBody = contact.bodyA 128 | } 129 | 130 | if firstBody.categoryBitMask & ContactCategory.cleaner.rawValue > 0 && secondBody.categoryBitMask & ContactCategory.garbage.rawValue > 0 { 131 | secondBody.node?.removeFromParent() 132 | } 133 | } 134 | } 135 | -------------------------------------------------------------------------------- /GameplayKitSandbox/Board.swift: -------------------------------------------------------------------------------- 1 | // 2 | // Board.swift 3 | // GameplayKitSandbox 4 | // 5 | // Created by Tatsuya Tobioka on 2015/09/23. 6 | // Copyright © 2015年 tnantoka. All rights reserved. 7 | // 8 | 9 | import UIKit 10 | 11 | import GameplayKit 12 | 13 | class Board: NSObject, GKGameModel { 14 | 15 | let level: Int 16 | var debug = false 17 | 18 | var currentPlayer: Player 19 | var cells: [Mark] 20 | 21 | init(level: Int) { 22 | self.level = level 23 | currentPlayer = Player.oPlayer() 24 | cells = Array(repeating: .none, count: level * level) 25 | } 26 | 27 | func updateCell(_ index: Int) { 28 | if cells[index] == .none { 29 | cells[index] = currentPlayer.mark 30 | currentPlayer = currentPlayer.opponent()! 31 | } 32 | } 33 | 34 | func isGameOver() -> Bool { 35 | return cells.filter { $0 == Mark.none }.isEmpty || isWin(for: currentPlayer) || isLoss(for: currentPlayer) 36 | } 37 | 38 | func lines() -> [[Int]] { 39 | var lines = [[Int]]() 40 | 41 | for i in 0.. Int { 77 | guard let player = player as? Player else { return 0 } 78 | 79 | var count = 0 80 | 81 | for line in lines() { 82 | var opponentCount = 0 83 | var noneCount = 0 84 | for l in line { 85 | switch cells[l] { 86 | case player.mark: 87 | break 88 | case player.opponent()!.mark: 89 | opponentCount += 1 90 | default: 91 | noneCount += 1 92 | } 93 | } 94 | 95 | if noneCount == 1 && opponentCount == level - 1 { 96 | count += 1 97 | } 98 | } 99 | 100 | return count 101 | } 102 | 103 | // MARK: - GKGameModel 104 | 105 | var players: [GKGameModelPlayer]? { 106 | return Player.all() 107 | } 108 | var activePlayer: GKGameModelPlayer? { 109 | return currentPlayer 110 | } 111 | 112 | func gameModelUpdates(for player: GKGameModelPlayer) -> [GKGameModelUpdate]? { 113 | var moves = [Move]() 114 | for (i, cell) in cells.enumerated() { 115 | if cell == .none { 116 | moves.append(Move(index: i)) 117 | } 118 | } 119 | return moves 120 | } 121 | 122 | func apply(_ gameModelUpdate: GKGameModelUpdate) { 123 | if let move = gameModelUpdate as? Move { 124 | updateCell(move.index) 125 | } 126 | } 127 | 128 | func setGameModel(_ gameModel: GKGameModel) { 129 | if let board = gameModel as? Board { 130 | cells = board.cells 131 | debug = board.debug 132 | currentPlayer = board.currentPlayer 133 | } 134 | } 135 | 136 | func copy(with zone: NSZone?) -> Any { 137 | let board = Board(level: self.level) 138 | board.setGameModel(self) 139 | return board 140 | } 141 | 142 | func isWin(for player: GKGameModelPlayer) -> Bool { 143 | guard let player = player as? Player else { return false } 144 | 145 | for line in lines() { 146 | var count = 0 147 | for l in line { 148 | if cells[l] == player.mark { 149 | count += 1 150 | } 151 | } 152 | if count == level { 153 | return true 154 | } 155 | } 156 | 157 | return false 158 | } 159 | 160 | func isLoss(for player: GKGameModelPlayer) -> Bool { 161 | guard let player = player as? Player else { return false } 162 | 163 | return isWin(for: player.opponent()!) 164 | } 165 | 166 | func score(for player: GKGameModelPlayer) -> Int { 167 | let score: Int 168 | 169 | score = -checksForPlayer(player) 170 | 171 | if debug { 172 | var log = "" 173 | for i in 0.. frame.width - targetNode.frame.height / 2 { 102 | targetNode.userData!["vx"] = targetNode.userData!["vx"] as! CGFloat * -1.0 103 | } 104 | 105 | if targetNode.position.x < targetNode.frame.height / 2 { 106 | targetNode.userData!["vx"] = targetNode.userData!["vx"] as! CGFloat * -1.0 107 | } 108 | } 109 | 110 | override func touchesBegan(_ touches: Set, with event: UIEvent?) { 111 | createBall() 112 | } 113 | 114 | // MARK: - SKPhysicsContactDelegate 115 | 116 | func didBegin(_ contact: SKPhysicsContact) { 117 | let firstBody: SKPhysicsBody 118 | let secondBody: SKPhysicsBody 119 | if contact.bodyA.categoryBitMask < contact.bodyB.categoryBitMask { 120 | firstBody = contact.bodyA 121 | secondBody = contact.bodyB 122 | } else { 123 | firstBody = contact.bodyB 124 | secondBody = contact.bodyA 125 | } 126 | 127 | if firstBody.categoryBitMask & ContactCategory.target.rawValue > 0 && secondBody.categoryBitMask & ContactCategory.ball.rawValue > 0 { 128 | secondBody.node?.removeFromParent() 129 | } 130 | } 131 | } 132 | -------------------------------------------------------------------------------- /GameplayKitSandbox.xcodeproj/project.pbxproj: -------------------------------------------------------------------------------- 1 | // !$*UTF8*$! 2 | { 3 | archiveVersion = 1; 4 | classes = { 5 | }; 6 | objectVersion = 46; 7 | objects = { 8 | 9 | /* Begin PBXBuildFile section */ 10 | 9B484A5D1D96D6640051E037 /* NoiseViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9B484A5C1D96D6640051E037 /* NoiseViewController.swift */; }; 11 | 9B484A5F1D96D66F0051E037 /* NoiseScene.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9B484A5E1D96D66F0051E037 /* NoiseScene.swift */; }; 12 | 9B544D6F1BB80A8C00CE30AC /* PathfindingScene.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9B544D6E1BB80A8C00CE30AC /* PathfindingScene.swift */; }; 13 | 9B544D711BB9967000CE30AC /* AgentsScene.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9B544D701BB9967000CE30AC /* AgentsScene.swift */; }; 14 | 9B544D731BB99C0200CE30AC /* AgentNode.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9B544D721BB99C0200CE30AC /* AgentNode.swift */; }; 15 | 9B638A4C1BBC1D840043FFEC /* RuleScene.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9B638A4B1BBC1D830043FFEC /* RuleScene.swift */; }; 16 | 9B76DD001BAE839E00298642 /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9B76DCFF1BAE839E00298642 /* AppDelegate.swift */; }; 17 | 9B76DD071BAE839E00298642 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 9B76DD061BAE839E00298642 /* Assets.xcassets */; }; 18 | 9B76DD0A1BAE839E00298642 /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 9B76DD081BAE839E00298642 /* LaunchScreen.storyboard */; }; 19 | 9B76DD151BAE839E00298642 /* GameplayKitSandboxTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9B76DD141BAE839E00298642 /* GameplayKitSandboxTests.swift */; }; 20 | 9B76DD201BAE839E00298642 /* GameplayKitSandboxUITests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9B76DD1F1BAE839E00298642 /* GameplayKitSandboxUITests.swift */; }; 21 | 9B76DD2E1BAE83BD00298642 /* ExamplesViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9B76DD2D1BAE83BD00298642 /* ExamplesViewController.swift */; }; 22 | 9B76DD301BAE879400298642 /* ExampleViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9B76DD2F1BAE879400298642 /* ExampleViewController.swift */; }; 23 | 9B76DD321BAE8DD300298642 /* RandomizationViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9B76DD311BAE8DD300298642 /* RandomizationViewController.swift */; }; 24 | 9B76DD341BAE8F6400298642 /* RandomizationScene.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9B76DD331BAE8F6400298642 /* RandomizationScene.swift */; }; 25 | 9B76DD371BAE903F00298642 /* ExampleScene.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9B76DD361BAE903F00298642 /* ExampleScene.swift */; }; 26 | 9BAE52221BAEC8D000D2D85B /* EntitiesViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9BAE52211BAEC8D000D2D85B /* EntitiesViewController.swift */; }; 27 | 9BAE52291BAEC9E000D2D85B /* StateViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9BAE52281BAEC9E000D2D85B /* StateViewController.swift */; }; 28 | 9BAE522B1BAEC9E900D2D85B /* MinmaxViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9BAE522A1BAEC9E900D2D85B /* MinmaxViewController.swift */; }; 29 | 9BAE522D1BAEC9F100D2D85B /* PathfindingViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9BAE522C1BAEC9F100D2D85B /* PathfindingViewController.swift */; }; 30 | 9BAE522F1BAEC9F900D2D85B /* AgentsViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9BAE522E1BAEC9F900D2D85B /* AgentsViewController.swift */; }; 31 | 9BAE52321BAECA0700D2D85B /* RuleViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9BAE52311BAECA0700D2D85B /* RuleViewController.swift */; }; 32 | 9BAE52341BAEFF5700D2D85B /* EntitiesScene.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9BAE52331BAEFF5700D2D85B /* EntitiesScene.swift */; }; 33 | 9BAE52361BAF720500D2D85B /* VisualComponent.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9BAE52351BAF720500D2D85B /* VisualComponent.swift */; }; 34 | 9BAE52381BAF829800D2D85B /* AttackComponent.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9BAE52371BAF829800D2D85B /* AttackComponent.swift */; }; 35 | 9BAE523A1BAF8D5400D2D85B /* IntelligenceComponent.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9BAE52391BAF8D5400D2D85B /* IntelligenceComponent.swift */; }; 36 | 9BAE523C1BB0A71700D2D85B /* ControlComponent.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9BAE523B1BB0A71700D2D85B /* ControlComponent.swift */; }; 37 | 9BAE523E1BB113C700D2D85B /* StateScene.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9BAE523D1BB113C700D2D85B /* StateScene.swift */; }; 38 | 9BAE52411BB119CF00D2D85B /* fire.sks in Resources */ = {isa = PBXBuildFile; fileRef = 9BAE523F1BB119CF00D2D85B /* fire.sks */; }; 39 | 9BAE52421BB119CF00D2D85B /* spark.png in Resources */ = {isa = PBXBuildFile; fileRef = 9BAE52401BB119CF00D2D85B /* spark.png */; }; 40 | 9BAE52441BB119E800D2D85B /* rain.sks in Resources */ = {isa = PBXBuildFile; fileRef = 9BAE52431BB119E800D2D85B /* rain.sks */; }; 41 | 9BAE52461BB11BCB00D2D85B /* spark.sks in Resources */ = {isa = PBXBuildFile; fileRef = 9BAE52451BB11BCB00D2D85B /* spark.sks */; }; 42 | 9BAE52481BB11F4200D2D85B /* HouseState.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9BAE52471BB11F4200D2D85B /* HouseState.swift */; }; 43 | 9BAE524A1BB1204300D2D85B /* BurnableComponent.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9BAE52491BB1204300D2D85B /* BurnableComponent.swift */; }; 44 | 9BAE524C1BB120B500D2D85B /* HouseBurningState.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9BAE524B1BB120B500D2D85B /* HouseBurningState.swift */; }; 45 | 9BAE524E1BB120DD00D2D85B /* HouseWetState.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9BAE524D1BB120DD00D2D85B /* HouseWetState.swift */; }; 46 | 9BAE52501BB120F700D2D85B /* HouseDryState.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9BAE524F1BB120F700D2D85B /* HouseDryState.swift */; }; 47 | 9BAE52521BB19BD800D2D85B /* MinmaxScene.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9BAE52511BB19BD800D2D85B /* MinmaxScene.swift */; }; 48 | 9BAE52541BB26D5900D2D85B /* Board.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9BAE52531BB26D5900D2D85B /* Board.swift */; }; 49 | 9BAE52561BB26E0A00D2D85B /* Player.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9BAE52551BB26E0A00D2D85B /* Player.swift */; }; 50 | 9BDA16D41BB3AB6700192000 /* Mark.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9BDA16D31BB3AB6700192000 /* Mark.swift */; }; 51 | 9BDA16D81BB4493200192000 /* Move.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9BDA16D71BB4493200192000 /* Move.swift */; }; 52 | /* End PBXBuildFile section */ 53 | 54 | /* Begin PBXContainerItemProxy section */ 55 | 9B76DD111BAE839E00298642 /* PBXContainerItemProxy */ = { 56 | isa = PBXContainerItemProxy; 57 | containerPortal = 9B76DCF41BAE839E00298642 /* Project object */; 58 | proxyType = 1; 59 | remoteGlobalIDString = 9B76DCFB1BAE839E00298642; 60 | remoteInfo = GameplayKitSandbox; 61 | }; 62 | 9B76DD1C1BAE839E00298642 /* PBXContainerItemProxy */ = { 63 | isa = PBXContainerItemProxy; 64 | containerPortal = 9B76DCF41BAE839E00298642 /* Project object */; 65 | proxyType = 1; 66 | remoteGlobalIDString = 9B76DCFB1BAE839E00298642; 67 | remoteInfo = GameplayKitSandbox; 68 | }; 69 | /* End PBXContainerItemProxy section */ 70 | 71 | /* Begin PBXFileReference section */ 72 | 9B484A5C1D96D6640051E037 /* NoiseViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = NoiseViewController.swift; sourceTree = ""; }; 73 | 9B484A5E1D96D66F0051E037 /* NoiseScene.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = NoiseScene.swift; sourceTree = ""; }; 74 | 9B544D6E1BB80A8C00CE30AC /* PathfindingScene.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = PathfindingScene.swift; sourceTree = ""; }; 75 | 9B544D701BB9967000CE30AC /* AgentsScene.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = AgentsScene.swift; sourceTree = ""; }; 76 | 9B544D721BB99C0200CE30AC /* AgentNode.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = AgentNode.swift; sourceTree = ""; }; 77 | 9B638A4B1BBC1D830043FFEC /* RuleScene.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = RuleScene.swift; sourceTree = ""; }; 78 | 9B76DCFC1BAE839E00298642 /* GameplayKitSandbox.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = GameplayKitSandbox.app; sourceTree = BUILT_PRODUCTS_DIR; }; 79 | 9B76DCFF1BAE839E00298642 /* AppDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = ""; }; 80 | 9B76DD061BAE839E00298642 /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = ""; }; 81 | 9B76DD091BAE839E00298642 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/LaunchScreen.storyboard; sourceTree = ""; }; 82 | 9B76DD0B1BAE839E00298642 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 83 | 9B76DD101BAE839E00298642 /* GameplayKitSandboxTests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = GameplayKitSandboxTests.xctest; sourceTree = BUILT_PRODUCTS_DIR; }; 84 | 9B76DD141BAE839E00298642 /* GameplayKitSandboxTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = GameplayKitSandboxTests.swift; sourceTree = ""; }; 85 | 9B76DD161BAE839E00298642 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 86 | 9B76DD1B1BAE839E00298642 /* GameplayKitSandboxUITests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = GameplayKitSandboxUITests.xctest; sourceTree = BUILT_PRODUCTS_DIR; }; 87 | 9B76DD1F1BAE839E00298642 /* GameplayKitSandboxUITests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = GameplayKitSandboxUITests.swift; sourceTree = ""; }; 88 | 9B76DD211BAE839E00298642 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 89 | 9B76DD2D1BAE83BD00298642 /* ExamplesViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ExamplesViewController.swift; sourceTree = ""; }; 90 | 9B76DD2F1BAE879400298642 /* ExampleViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ExampleViewController.swift; sourceTree = ""; }; 91 | 9B76DD311BAE8DD300298642 /* RandomizationViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = RandomizationViewController.swift; sourceTree = ""; }; 92 | 9B76DD331BAE8F6400298642 /* RandomizationScene.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = RandomizationScene.swift; sourceTree = ""; }; 93 | 9B76DD361BAE903F00298642 /* ExampleScene.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ExampleScene.swift; sourceTree = ""; }; 94 | 9BAE52211BAEC8D000D2D85B /* EntitiesViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = EntitiesViewController.swift; sourceTree = ""; }; 95 | 9BAE52281BAEC9E000D2D85B /* StateViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = StateViewController.swift; sourceTree = ""; }; 96 | 9BAE522A1BAEC9E900D2D85B /* MinmaxViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = MinmaxViewController.swift; sourceTree = ""; }; 97 | 9BAE522C1BAEC9F100D2D85B /* PathfindingViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = PathfindingViewController.swift; sourceTree = ""; }; 98 | 9BAE522E1BAEC9F900D2D85B /* AgentsViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = AgentsViewController.swift; sourceTree = ""; }; 99 | 9BAE52311BAECA0700D2D85B /* RuleViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = RuleViewController.swift; sourceTree = ""; }; 100 | 9BAE52331BAEFF5700D2D85B /* EntitiesScene.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = EntitiesScene.swift; sourceTree = ""; }; 101 | 9BAE52351BAF720500D2D85B /* VisualComponent.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = VisualComponent.swift; sourceTree = ""; }; 102 | 9BAE52371BAF829800D2D85B /* AttackComponent.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = AttackComponent.swift; sourceTree = ""; }; 103 | 9BAE52391BAF8D5400D2D85B /* IntelligenceComponent.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = IntelligenceComponent.swift; sourceTree = ""; }; 104 | 9BAE523B1BB0A71700D2D85B /* ControlComponent.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ControlComponent.swift; sourceTree = ""; }; 105 | 9BAE523D1BB113C700D2D85B /* StateScene.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = StateScene.swift; sourceTree = ""; }; 106 | 9BAE523F1BB119CF00D2D85B /* fire.sks */ = {isa = PBXFileReference; lastKnownFileType = file.sks; path = fire.sks; sourceTree = ""; }; 107 | 9BAE52401BB119CF00D2D85B /* spark.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = spark.png; sourceTree = ""; }; 108 | 9BAE52431BB119E800D2D85B /* rain.sks */ = {isa = PBXFileReference; lastKnownFileType = file.sks; path = rain.sks; sourceTree = ""; }; 109 | 9BAE52451BB11BCB00D2D85B /* spark.sks */ = {isa = PBXFileReference; lastKnownFileType = file.sks; path = spark.sks; sourceTree = ""; }; 110 | 9BAE52471BB11F4200D2D85B /* HouseState.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = HouseState.swift; sourceTree = ""; }; 111 | 9BAE52491BB1204300D2D85B /* BurnableComponent.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = BurnableComponent.swift; sourceTree = ""; }; 112 | 9BAE524B1BB120B500D2D85B /* HouseBurningState.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = HouseBurningState.swift; sourceTree = ""; }; 113 | 9BAE524D1BB120DD00D2D85B /* HouseWetState.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = HouseWetState.swift; sourceTree = ""; }; 114 | 9BAE524F1BB120F700D2D85B /* HouseDryState.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = HouseDryState.swift; sourceTree = ""; }; 115 | 9BAE52511BB19BD800D2D85B /* MinmaxScene.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = MinmaxScene.swift; sourceTree = ""; }; 116 | 9BAE52531BB26D5900D2D85B /* Board.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Board.swift; sourceTree = ""; }; 117 | 9BAE52551BB26E0A00D2D85B /* Player.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Player.swift; sourceTree = ""; }; 118 | 9BDA16D31BB3AB6700192000 /* Mark.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Mark.swift; sourceTree = ""; }; 119 | 9BDA16D71BB4493200192000 /* Move.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Move.swift; sourceTree = ""; }; 120 | /* End PBXFileReference section */ 121 | 122 | /* Begin PBXFrameworksBuildPhase section */ 123 | 9B76DCF91BAE839E00298642 /* Frameworks */ = { 124 | isa = PBXFrameworksBuildPhase; 125 | buildActionMask = 2147483647; 126 | files = ( 127 | ); 128 | runOnlyForDeploymentPostprocessing = 0; 129 | }; 130 | 9B76DD0D1BAE839E00298642 /* Frameworks */ = { 131 | isa = PBXFrameworksBuildPhase; 132 | buildActionMask = 2147483647; 133 | files = ( 134 | ); 135 | runOnlyForDeploymentPostprocessing = 0; 136 | }; 137 | 9B76DD181BAE839E00298642 /* Frameworks */ = { 138 | isa = PBXFrameworksBuildPhase; 139 | buildActionMask = 2147483647; 140 | files = ( 141 | ); 142 | runOnlyForDeploymentPostprocessing = 0; 143 | }; 144 | /* End PBXFrameworksBuildPhase section */ 145 | 146 | /* Begin PBXGroup section */ 147 | 9B484A5B1D96D6360051E037 /* Noise */ = { 148 | isa = PBXGroup; 149 | children = ( 150 | 9B484A5C1D96D6640051E037 /* NoiseViewController.swift */, 151 | 9B484A5E1D96D66F0051E037 /* NoiseScene.swift */, 152 | ); 153 | name = Noise; 154 | sourceTree = ""; 155 | }; 156 | 9B76DCF31BAE839E00298642 = { 157 | isa = PBXGroup; 158 | children = ( 159 | 9B76DCFE1BAE839E00298642 /* GameplayKitSandbox */, 160 | 9B76DD131BAE839E00298642 /* GameplayKitSandboxTests */, 161 | 9B76DD1E1BAE839E00298642 /* GameplayKitSandboxUITests */, 162 | 9B76DCFD1BAE839E00298642 /* Products */, 163 | ); 164 | sourceTree = ""; 165 | }; 166 | 9B76DCFD1BAE839E00298642 /* Products */ = { 167 | isa = PBXGroup; 168 | children = ( 169 | 9B76DCFC1BAE839E00298642 /* GameplayKitSandbox.app */, 170 | 9B76DD101BAE839E00298642 /* GameplayKitSandboxTests.xctest */, 171 | 9B76DD1B1BAE839E00298642 /* GameplayKitSandboxUITests.xctest */, 172 | ); 173 | name = Products; 174 | sourceTree = ""; 175 | }; 176 | 9B76DCFE1BAE839E00298642 /* GameplayKitSandbox */ = { 177 | isa = PBXGroup; 178 | children = ( 179 | 9B76DCFF1BAE839E00298642 /* AppDelegate.swift */, 180 | 9B76DD061BAE839E00298642 /* Assets.xcassets */, 181 | 9B76DD081BAE839E00298642 /* LaunchScreen.storyboard */, 182 | 9B76DD0B1BAE839E00298642 /* Info.plist */, 183 | 9B76DD2D1BAE83BD00298642 /* ExamplesViewController.swift */, 184 | 9B76DD2F1BAE879400298642 /* ExampleViewController.swift */, 185 | 9B76DD361BAE903F00298642 /* ExampleScene.swift */, 186 | 9B76DD351BAE8F6D00298642 /* Randomization */, 187 | 9BAE52201BAEC8B600D2D85B /* Entities */, 188 | 9BAE52231BAEC99C00D2D85B /* State */, 189 | 9BAE52241BAEC9A100D2D85B /* Minmax */, 190 | 9BAE52251BAEC9B100D2D85B /* Pathfinding */, 191 | 9BAE52261BAEC9BF00D2D85B /* Agents */, 192 | 9BAE52271BAEC9CB00D2D85B /* Rule */, 193 | 9B484A5B1D96D6360051E037 /* Noise */, 194 | ); 195 | path = GameplayKitSandbox; 196 | sourceTree = ""; 197 | }; 198 | 9B76DD131BAE839E00298642 /* GameplayKitSandboxTests */ = { 199 | isa = PBXGroup; 200 | children = ( 201 | 9B76DD141BAE839E00298642 /* GameplayKitSandboxTests.swift */, 202 | 9B76DD161BAE839E00298642 /* Info.plist */, 203 | ); 204 | path = GameplayKitSandboxTests; 205 | sourceTree = ""; 206 | }; 207 | 9B76DD1E1BAE839E00298642 /* GameplayKitSandboxUITests */ = { 208 | isa = PBXGroup; 209 | children = ( 210 | 9B76DD1F1BAE839E00298642 /* GameplayKitSandboxUITests.swift */, 211 | 9B76DD211BAE839E00298642 /* Info.plist */, 212 | ); 213 | path = GameplayKitSandboxUITests; 214 | sourceTree = ""; 215 | }; 216 | 9B76DD351BAE8F6D00298642 /* Randomization */ = { 217 | isa = PBXGroup; 218 | children = ( 219 | 9B76DD311BAE8DD300298642 /* RandomizationViewController.swift */, 220 | 9B76DD331BAE8F6400298642 /* RandomizationScene.swift */, 221 | ); 222 | name = Randomization; 223 | sourceTree = ""; 224 | }; 225 | 9BAE52201BAEC8B600D2D85B /* Entities */ = { 226 | isa = PBXGroup; 227 | children = ( 228 | 9BAE52211BAEC8D000D2D85B /* EntitiesViewController.swift */, 229 | 9BAE52331BAEFF5700D2D85B /* EntitiesScene.swift */, 230 | 9BAE52351BAF720500D2D85B /* VisualComponent.swift */, 231 | 9BAE52371BAF829800D2D85B /* AttackComponent.swift */, 232 | 9BAE52391BAF8D5400D2D85B /* IntelligenceComponent.swift */, 233 | 9BAE523B1BB0A71700D2D85B /* ControlComponent.swift */, 234 | ); 235 | name = Entities; 236 | sourceTree = ""; 237 | }; 238 | 9BAE52231BAEC99C00D2D85B /* State */ = { 239 | isa = PBXGroup; 240 | children = ( 241 | 9BAE52281BAEC9E000D2D85B /* StateViewController.swift */, 242 | 9BAE523D1BB113C700D2D85B /* StateScene.swift */, 243 | 9BAE523F1BB119CF00D2D85B /* fire.sks */, 244 | 9BAE52401BB119CF00D2D85B /* spark.png */, 245 | 9BAE52431BB119E800D2D85B /* rain.sks */, 246 | 9BAE52451BB11BCB00D2D85B /* spark.sks */, 247 | 9BAE52471BB11F4200D2D85B /* HouseState.swift */, 248 | 9BAE52491BB1204300D2D85B /* BurnableComponent.swift */, 249 | 9BAE524B1BB120B500D2D85B /* HouseBurningState.swift */, 250 | 9BAE524D1BB120DD00D2D85B /* HouseWetState.swift */, 251 | 9BAE524F1BB120F700D2D85B /* HouseDryState.swift */, 252 | ); 253 | name = State; 254 | sourceTree = ""; 255 | }; 256 | 9BAE52241BAEC9A100D2D85B /* Minmax */ = { 257 | isa = PBXGroup; 258 | children = ( 259 | 9BAE522A1BAEC9E900D2D85B /* MinmaxViewController.swift */, 260 | 9BAE52511BB19BD800D2D85B /* MinmaxScene.swift */, 261 | 9BAE52531BB26D5900D2D85B /* Board.swift */, 262 | 9BAE52551BB26E0A00D2D85B /* Player.swift */, 263 | 9BDA16D31BB3AB6700192000 /* Mark.swift */, 264 | 9BDA16D71BB4493200192000 /* Move.swift */, 265 | ); 266 | name = Minmax; 267 | sourceTree = ""; 268 | }; 269 | 9BAE52251BAEC9B100D2D85B /* Pathfinding */ = { 270 | isa = PBXGroup; 271 | children = ( 272 | 9BAE522C1BAEC9F100D2D85B /* PathfindingViewController.swift */, 273 | 9B544D6E1BB80A8C00CE30AC /* PathfindingScene.swift */, 274 | ); 275 | name = Pathfinding; 276 | sourceTree = ""; 277 | }; 278 | 9BAE52261BAEC9BF00D2D85B /* Agents */ = { 279 | isa = PBXGroup; 280 | children = ( 281 | 9BAE522E1BAEC9F900D2D85B /* AgentsViewController.swift */, 282 | 9B544D701BB9967000CE30AC /* AgentsScene.swift */, 283 | 9B544D721BB99C0200CE30AC /* AgentNode.swift */, 284 | ); 285 | name = Agents; 286 | sourceTree = ""; 287 | }; 288 | 9BAE52271BAEC9CB00D2D85B /* Rule */ = { 289 | isa = PBXGroup; 290 | children = ( 291 | 9BAE52311BAECA0700D2D85B /* RuleViewController.swift */, 292 | 9B638A4B1BBC1D830043FFEC /* RuleScene.swift */, 293 | ); 294 | name = Rule; 295 | sourceTree = ""; 296 | }; 297 | /* End PBXGroup section */ 298 | 299 | /* Begin PBXNativeTarget section */ 300 | 9B76DCFB1BAE839E00298642 /* GameplayKitSandbox */ = { 301 | isa = PBXNativeTarget; 302 | buildConfigurationList = 9B76DD241BAE839E00298642 /* Build configuration list for PBXNativeTarget "GameplayKitSandbox" */; 303 | buildPhases = ( 304 | 9B76DCF81BAE839E00298642 /* Sources */, 305 | 9B76DCF91BAE839E00298642 /* Frameworks */, 306 | 9B76DCFA1BAE839E00298642 /* Resources */, 307 | ); 308 | buildRules = ( 309 | ); 310 | dependencies = ( 311 | ); 312 | name = GameplayKitSandbox; 313 | productName = GameplayKitSandbox; 314 | productReference = 9B76DCFC1BAE839E00298642 /* GameplayKitSandbox.app */; 315 | productType = "com.apple.product-type.application"; 316 | }; 317 | 9B76DD0F1BAE839E00298642 /* GameplayKitSandboxTests */ = { 318 | isa = PBXNativeTarget; 319 | buildConfigurationList = 9B76DD271BAE839E00298642 /* Build configuration list for PBXNativeTarget "GameplayKitSandboxTests" */; 320 | buildPhases = ( 321 | 9B76DD0C1BAE839E00298642 /* Sources */, 322 | 9B76DD0D1BAE839E00298642 /* Frameworks */, 323 | 9B76DD0E1BAE839E00298642 /* Resources */, 324 | ); 325 | buildRules = ( 326 | ); 327 | dependencies = ( 328 | 9B76DD121BAE839E00298642 /* PBXTargetDependency */, 329 | ); 330 | name = GameplayKitSandboxTests; 331 | productName = GameplayKitSandboxTests; 332 | productReference = 9B76DD101BAE839E00298642 /* GameplayKitSandboxTests.xctest */; 333 | productType = "com.apple.product-type.bundle.unit-test"; 334 | }; 335 | 9B76DD1A1BAE839E00298642 /* GameplayKitSandboxUITests */ = { 336 | isa = PBXNativeTarget; 337 | buildConfigurationList = 9B76DD2A1BAE839E00298642 /* Build configuration list for PBXNativeTarget "GameplayKitSandboxUITests" */; 338 | buildPhases = ( 339 | 9B76DD171BAE839E00298642 /* Sources */, 340 | 9B76DD181BAE839E00298642 /* Frameworks */, 341 | 9B76DD191BAE839E00298642 /* Resources */, 342 | ); 343 | buildRules = ( 344 | ); 345 | dependencies = ( 346 | 9B76DD1D1BAE839E00298642 /* PBXTargetDependency */, 347 | ); 348 | name = GameplayKitSandboxUITests; 349 | productName = GameplayKitSandboxUITests; 350 | productReference = 9B76DD1B1BAE839E00298642 /* GameplayKitSandboxUITests.xctest */; 351 | productType = "com.apple.product-type.bundle.ui-testing"; 352 | }; 353 | /* End PBXNativeTarget section */ 354 | 355 | /* Begin PBXProject section */ 356 | 9B76DCF41BAE839E00298642 /* Project object */ = { 357 | isa = PBXProject; 358 | attributes = { 359 | LastUpgradeCheck = 1100; 360 | ORGANIZATIONNAME = tnantoka; 361 | TargetAttributes = { 362 | 9B76DCFB1BAE839E00298642 = { 363 | CreatedOnToolsVersion = 7.0; 364 | LastSwiftMigration = 1100; 365 | }; 366 | 9B76DD0F1BAE839E00298642 = { 367 | CreatedOnToolsVersion = 7.0; 368 | LastSwiftMigration = 1100; 369 | TestTargetID = 9B76DCFB1BAE839E00298642; 370 | }; 371 | 9B76DD1A1BAE839E00298642 = { 372 | CreatedOnToolsVersion = 7.0; 373 | LastSwiftMigration = 1100; 374 | TestTargetID = 9B76DCFB1BAE839E00298642; 375 | }; 376 | }; 377 | }; 378 | buildConfigurationList = 9B76DCF71BAE839E00298642 /* Build configuration list for PBXProject "GameplayKitSandbox" */; 379 | compatibilityVersion = "Xcode 3.2"; 380 | developmentRegion = en; 381 | hasScannedForEncodings = 0; 382 | knownRegions = ( 383 | en, 384 | Base, 385 | ); 386 | mainGroup = 9B76DCF31BAE839E00298642; 387 | productRefGroup = 9B76DCFD1BAE839E00298642 /* Products */; 388 | projectDirPath = ""; 389 | projectRoot = ""; 390 | targets = ( 391 | 9B76DCFB1BAE839E00298642 /* GameplayKitSandbox */, 392 | 9B76DD0F1BAE839E00298642 /* GameplayKitSandboxTests */, 393 | 9B76DD1A1BAE839E00298642 /* GameplayKitSandboxUITests */, 394 | ); 395 | }; 396 | /* End PBXProject section */ 397 | 398 | /* Begin PBXResourcesBuildPhase section */ 399 | 9B76DCFA1BAE839E00298642 /* Resources */ = { 400 | isa = PBXResourcesBuildPhase; 401 | buildActionMask = 2147483647; 402 | files = ( 403 | 9B76DD0A1BAE839E00298642 /* LaunchScreen.storyboard in Resources */, 404 | 9BAE52461BB11BCB00D2D85B /* spark.sks in Resources */, 405 | 9BAE52421BB119CF00D2D85B /* spark.png in Resources */, 406 | 9BAE52441BB119E800D2D85B /* rain.sks in Resources */, 407 | 9B76DD071BAE839E00298642 /* Assets.xcassets in Resources */, 408 | 9BAE52411BB119CF00D2D85B /* fire.sks in Resources */, 409 | ); 410 | runOnlyForDeploymentPostprocessing = 0; 411 | }; 412 | 9B76DD0E1BAE839E00298642 /* Resources */ = { 413 | isa = PBXResourcesBuildPhase; 414 | buildActionMask = 2147483647; 415 | files = ( 416 | ); 417 | runOnlyForDeploymentPostprocessing = 0; 418 | }; 419 | 9B76DD191BAE839E00298642 /* Resources */ = { 420 | isa = PBXResourcesBuildPhase; 421 | buildActionMask = 2147483647; 422 | files = ( 423 | ); 424 | runOnlyForDeploymentPostprocessing = 0; 425 | }; 426 | /* End PBXResourcesBuildPhase section */ 427 | 428 | /* Begin PBXSourcesBuildPhase section */ 429 | 9B76DCF81BAE839E00298642 /* Sources */ = { 430 | isa = PBXSourcesBuildPhase; 431 | buildActionMask = 2147483647; 432 | files = ( 433 | 9BDA16D81BB4493200192000 /* Move.swift in Sources */, 434 | 9BAE522B1BAEC9E900D2D85B /* MinmaxViewController.swift in Sources */, 435 | 9B544D731BB99C0200CE30AC /* AgentNode.swift in Sources */, 436 | 9BAE522D1BAEC9F100D2D85B /* PathfindingViewController.swift in Sources */, 437 | 9BAE52321BAECA0700D2D85B /* RuleViewController.swift in Sources */, 438 | 9BAE52341BAEFF5700D2D85B /* EntitiesScene.swift in Sources */, 439 | 9BAE52521BB19BD800D2D85B /* MinmaxScene.swift in Sources */, 440 | 9BAE523E1BB113C700D2D85B /* StateScene.swift in Sources */, 441 | 9B76DD341BAE8F6400298642 /* RandomizationScene.swift in Sources */, 442 | 9B76DD2E1BAE83BD00298642 /* ExamplesViewController.swift in Sources */, 443 | 9BAE52381BAF829800D2D85B /* AttackComponent.swift in Sources */, 444 | 9B76DD001BAE839E00298642 /* AppDelegate.swift in Sources */, 445 | 9B76DD321BAE8DD300298642 /* RandomizationViewController.swift in Sources */, 446 | 9BDA16D41BB3AB6700192000 /* Mark.swift in Sources */, 447 | 9BAE52481BB11F4200D2D85B /* HouseState.swift in Sources */, 448 | 9BAE52291BAEC9E000D2D85B /* StateViewController.swift in Sources */, 449 | 9B638A4C1BBC1D840043FFEC /* RuleScene.swift in Sources */, 450 | 9BAE524A1BB1204300D2D85B /* BurnableComponent.swift in Sources */, 451 | 9BAE52221BAEC8D000D2D85B /* EntitiesViewController.swift in Sources */, 452 | 9B484A5F1D96D66F0051E037 /* NoiseScene.swift in Sources */, 453 | 9BAE524C1BB120B500D2D85B /* HouseBurningState.swift in Sources */, 454 | 9BAE522F1BAEC9F900D2D85B /* AgentsViewController.swift in Sources */, 455 | 9BAE52541BB26D5900D2D85B /* Board.swift in Sources */, 456 | 9BAE52561BB26E0A00D2D85B /* Player.swift in Sources */, 457 | 9BAE523A1BAF8D5400D2D85B /* IntelligenceComponent.swift in Sources */, 458 | 9B484A5D1D96D6640051E037 /* NoiseViewController.swift in Sources */, 459 | 9BAE52361BAF720500D2D85B /* VisualComponent.swift in Sources */, 460 | 9B76DD301BAE879400298642 /* ExampleViewController.swift in Sources */, 461 | 9B76DD371BAE903F00298642 /* ExampleScene.swift in Sources */, 462 | 9BAE52501BB120F700D2D85B /* HouseDryState.swift in Sources */, 463 | 9BAE523C1BB0A71700D2D85B /* ControlComponent.swift in Sources */, 464 | 9B544D6F1BB80A8C00CE30AC /* PathfindingScene.swift in Sources */, 465 | 9B544D711BB9967000CE30AC /* AgentsScene.swift in Sources */, 466 | 9BAE524E1BB120DD00D2D85B /* HouseWetState.swift in Sources */, 467 | ); 468 | runOnlyForDeploymentPostprocessing = 0; 469 | }; 470 | 9B76DD0C1BAE839E00298642 /* Sources */ = { 471 | isa = PBXSourcesBuildPhase; 472 | buildActionMask = 2147483647; 473 | files = ( 474 | 9B76DD151BAE839E00298642 /* GameplayKitSandboxTests.swift in Sources */, 475 | ); 476 | runOnlyForDeploymentPostprocessing = 0; 477 | }; 478 | 9B76DD171BAE839E00298642 /* Sources */ = { 479 | isa = PBXSourcesBuildPhase; 480 | buildActionMask = 2147483647; 481 | files = ( 482 | 9B76DD201BAE839E00298642 /* GameplayKitSandboxUITests.swift in Sources */, 483 | ); 484 | runOnlyForDeploymentPostprocessing = 0; 485 | }; 486 | /* End PBXSourcesBuildPhase section */ 487 | 488 | /* Begin PBXTargetDependency section */ 489 | 9B76DD121BAE839E00298642 /* PBXTargetDependency */ = { 490 | isa = PBXTargetDependency; 491 | target = 9B76DCFB1BAE839E00298642 /* GameplayKitSandbox */; 492 | targetProxy = 9B76DD111BAE839E00298642 /* PBXContainerItemProxy */; 493 | }; 494 | 9B76DD1D1BAE839E00298642 /* PBXTargetDependency */ = { 495 | isa = PBXTargetDependency; 496 | target = 9B76DCFB1BAE839E00298642 /* GameplayKitSandbox */; 497 | targetProxy = 9B76DD1C1BAE839E00298642 /* PBXContainerItemProxy */; 498 | }; 499 | /* End PBXTargetDependency section */ 500 | 501 | /* Begin PBXVariantGroup section */ 502 | 9B76DD081BAE839E00298642 /* LaunchScreen.storyboard */ = { 503 | isa = PBXVariantGroup; 504 | children = ( 505 | 9B76DD091BAE839E00298642 /* Base */, 506 | ); 507 | name = LaunchScreen.storyboard; 508 | sourceTree = ""; 509 | }; 510 | /* End PBXVariantGroup section */ 511 | 512 | /* Begin XCBuildConfiguration section */ 513 | 9B76DD221BAE839E00298642 /* Debug */ = { 514 | isa = XCBuildConfiguration; 515 | buildSettings = { 516 | ALWAYS_SEARCH_USER_PATHS = NO; 517 | CLANG_ANALYZER_LOCALIZABILITY_NONLOCALIZED = YES; 518 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; 519 | CLANG_CXX_LIBRARY = "libc++"; 520 | CLANG_ENABLE_MODULES = YES; 521 | CLANG_ENABLE_OBJC_ARC = YES; 522 | CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; 523 | CLANG_WARN_BOOL_CONVERSION = YES; 524 | CLANG_WARN_COMMA = YES; 525 | CLANG_WARN_CONSTANT_CONVERSION = YES; 526 | CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; 527 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 528 | CLANG_WARN_EMPTY_BODY = YES; 529 | CLANG_WARN_ENUM_CONVERSION = YES; 530 | CLANG_WARN_INFINITE_RECURSION = YES; 531 | CLANG_WARN_INT_CONVERSION = YES; 532 | CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; 533 | CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; 534 | CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; 535 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 536 | CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; 537 | CLANG_WARN_STRICT_PROTOTYPES = YES; 538 | CLANG_WARN_SUSPICIOUS_MOVE = YES; 539 | CLANG_WARN_UNREACHABLE_CODE = YES; 540 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 541 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; 542 | COPY_PHASE_STRIP = NO; 543 | DEBUG_INFORMATION_FORMAT = dwarf; 544 | ENABLE_STRICT_OBJC_MSGSEND = YES; 545 | ENABLE_TESTABILITY = YES; 546 | GCC_C_LANGUAGE_STANDARD = gnu99; 547 | GCC_DYNAMIC_NO_PIC = NO; 548 | GCC_NO_COMMON_BLOCKS = YES; 549 | GCC_OPTIMIZATION_LEVEL = 0; 550 | GCC_PREPROCESSOR_DEFINITIONS = ( 551 | "DEBUG=1", 552 | "$(inherited)", 553 | ); 554 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 555 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 556 | GCC_WARN_UNDECLARED_SELECTOR = YES; 557 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 558 | GCC_WARN_UNUSED_FUNCTION = YES; 559 | GCC_WARN_UNUSED_VARIABLE = YES; 560 | IPHONEOS_DEPLOYMENT_TARGET = 10.0; 561 | MTL_ENABLE_DEBUG_INFO = YES; 562 | ONLY_ACTIVE_ARCH = YES; 563 | OTHER_SWIFT_FLAGS = "-D DEBUG"; 564 | SDKROOT = iphoneos; 565 | SWIFT_OPTIMIZATION_LEVEL = "-Onone"; 566 | SWIFT_SWIFT3_OBJC_INFERENCE = Default; 567 | SWIFT_VERSION = 5.0; 568 | }; 569 | name = Debug; 570 | }; 571 | 9B76DD231BAE839E00298642 /* Release */ = { 572 | isa = XCBuildConfiguration; 573 | buildSettings = { 574 | ALWAYS_SEARCH_USER_PATHS = NO; 575 | CLANG_ANALYZER_LOCALIZABILITY_NONLOCALIZED = YES; 576 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; 577 | CLANG_CXX_LIBRARY = "libc++"; 578 | CLANG_ENABLE_MODULES = YES; 579 | CLANG_ENABLE_OBJC_ARC = YES; 580 | CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; 581 | CLANG_WARN_BOOL_CONVERSION = YES; 582 | CLANG_WARN_COMMA = YES; 583 | CLANG_WARN_CONSTANT_CONVERSION = YES; 584 | CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; 585 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 586 | CLANG_WARN_EMPTY_BODY = YES; 587 | CLANG_WARN_ENUM_CONVERSION = YES; 588 | CLANG_WARN_INFINITE_RECURSION = YES; 589 | CLANG_WARN_INT_CONVERSION = YES; 590 | CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; 591 | CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; 592 | CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; 593 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 594 | CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; 595 | CLANG_WARN_STRICT_PROTOTYPES = YES; 596 | CLANG_WARN_SUSPICIOUS_MOVE = YES; 597 | CLANG_WARN_UNREACHABLE_CODE = YES; 598 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 599 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; 600 | COPY_PHASE_STRIP = NO; 601 | DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; 602 | ENABLE_NS_ASSERTIONS = NO; 603 | ENABLE_STRICT_OBJC_MSGSEND = YES; 604 | GCC_C_LANGUAGE_STANDARD = gnu99; 605 | GCC_NO_COMMON_BLOCKS = YES; 606 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 607 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 608 | GCC_WARN_UNDECLARED_SELECTOR = YES; 609 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 610 | GCC_WARN_UNUSED_FUNCTION = YES; 611 | GCC_WARN_UNUSED_VARIABLE = YES; 612 | IPHONEOS_DEPLOYMENT_TARGET = 10.0; 613 | MTL_ENABLE_DEBUG_INFO = NO; 614 | SDKROOT = iphoneos; 615 | SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule"; 616 | SWIFT_SWIFT3_OBJC_INFERENCE = Default; 617 | SWIFT_VERSION = 5.0; 618 | VALIDATE_PRODUCT = YES; 619 | }; 620 | name = Release; 621 | }; 622 | 9B76DD251BAE839E00298642 /* Debug */ = { 623 | isa = XCBuildConfiguration; 624 | buildSettings = { 625 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 626 | INFOPLIST_FILE = GameplayKitSandbox/Info.plist; 627 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; 628 | PRODUCT_BUNDLE_IDENTIFIER = com.bornneet.GameplayKitSandbox; 629 | PRODUCT_NAME = "$(TARGET_NAME)"; 630 | SWIFT_SWIFT3_OBJC_INFERENCE = Default; 631 | SWIFT_VERSION = 5.0; 632 | }; 633 | name = Debug; 634 | }; 635 | 9B76DD261BAE839E00298642 /* Release */ = { 636 | isa = XCBuildConfiguration; 637 | buildSettings = { 638 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 639 | INFOPLIST_FILE = GameplayKitSandbox/Info.plist; 640 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; 641 | PRODUCT_BUNDLE_IDENTIFIER = com.bornneet.GameplayKitSandbox; 642 | PRODUCT_NAME = "$(TARGET_NAME)"; 643 | SWIFT_SWIFT3_OBJC_INFERENCE = Default; 644 | SWIFT_VERSION = 5.0; 645 | }; 646 | name = Release; 647 | }; 648 | 9B76DD281BAE839E00298642 /* Debug */ = { 649 | isa = XCBuildConfiguration; 650 | buildSettings = { 651 | BUNDLE_LOADER = "$(TEST_HOST)"; 652 | INFOPLIST_FILE = GameplayKitSandboxTests/Info.plist; 653 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; 654 | PRODUCT_BUNDLE_IDENTIFIER = com.bornneet.GameplayKitSandboxTests; 655 | PRODUCT_NAME = "$(TARGET_NAME)"; 656 | SWIFT_SWIFT3_OBJC_INFERENCE = On; 657 | SWIFT_VERSION = 5.0; 658 | TEST_HOST = "$(BUILT_PRODUCTS_DIR)/GameplayKitSandbox.app/GameplayKitSandbox"; 659 | }; 660 | name = Debug; 661 | }; 662 | 9B76DD291BAE839E00298642 /* Release */ = { 663 | isa = XCBuildConfiguration; 664 | buildSettings = { 665 | BUNDLE_LOADER = "$(TEST_HOST)"; 666 | INFOPLIST_FILE = GameplayKitSandboxTests/Info.plist; 667 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; 668 | PRODUCT_BUNDLE_IDENTIFIER = com.bornneet.GameplayKitSandboxTests; 669 | PRODUCT_NAME = "$(TARGET_NAME)"; 670 | SWIFT_SWIFT3_OBJC_INFERENCE = On; 671 | SWIFT_VERSION = 5.0; 672 | TEST_HOST = "$(BUILT_PRODUCTS_DIR)/GameplayKitSandbox.app/GameplayKitSandbox"; 673 | }; 674 | name = Release; 675 | }; 676 | 9B76DD2B1BAE839E00298642 /* Debug */ = { 677 | isa = XCBuildConfiguration; 678 | buildSettings = { 679 | INFOPLIST_FILE = GameplayKitSandboxUITests/Info.plist; 680 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; 681 | PRODUCT_BUNDLE_IDENTIFIER = com.bornneet.GameplayKitSandboxUITests; 682 | PRODUCT_NAME = "$(TARGET_NAME)"; 683 | SWIFT_SWIFT3_OBJC_INFERENCE = On; 684 | SWIFT_VERSION = 5.0; 685 | TEST_TARGET_NAME = GameplayKitSandbox; 686 | USES_XCTRUNNER = YES; 687 | }; 688 | name = Debug; 689 | }; 690 | 9B76DD2C1BAE839E00298642 /* Release */ = { 691 | isa = XCBuildConfiguration; 692 | buildSettings = { 693 | INFOPLIST_FILE = GameplayKitSandboxUITests/Info.plist; 694 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; 695 | PRODUCT_BUNDLE_IDENTIFIER = com.bornneet.GameplayKitSandboxUITests; 696 | PRODUCT_NAME = "$(TARGET_NAME)"; 697 | SWIFT_SWIFT3_OBJC_INFERENCE = On; 698 | SWIFT_VERSION = 5.0; 699 | TEST_TARGET_NAME = GameplayKitSandbox; 700 | USES_XCTRUNNER = YES; 701 | }; 702 | name = Release; 703 | }; 704 | /* End XCBuildConfiguration section */ 705 | 706 | /* Begin XCConfigurationList section */ 707 | 9B76DCF71BAE839E00298642 /* Build configuration list for PBXProject "GameplayKitSandbox" */ = { 708 | isa = XCConfigurationList; 709 | buildConfigurations = ( 710 | 9B76DD221BAE839E00298642 /* Debug */, 711 | 9B76DD231BAE839E00298642 /* Release */, 712 | ); 713 | defaultConfigurationIsVisible = 0; 714 | defaultConfigurationName = Release; 715 | }; 716 | 9B76DD241BAE839E00298642 /* Build configuration list for PBXNativeTarget "GameplayKitSandbox" */ = { 717 | isa = XCConfigurationList; 718 | buildConfigurations = ( 719 | 9B76DD251BAE839E00298642 /* Debug */, 720 | 9B76DD261BAE839E00298642 /* Release */, 721 | ); 722 | defaultConfigurationIsVisible = 0; 723 | defaultConfigurationName = Release; 724 | }; 725 | 9B76DD271BAE839E00298642 /* Build configuration list for PBXNativeTarget "GameplayKitSandboxTests" */ = { 726 | isa = XCConfigurationList; 727 | buildConfigurations = ( 728 | 9B76DD281BAE839E00298642 /* Debug */, 729 | 9B76DD291BAE839E00298642 /* Release */, 730 | ); 731 | defaultConfigurationIsVisible = 0; 732 | defaultConfigurationName = Release; 733 | }; 734 | 9B76DD2A1BAE839E00298642 /* Build configuration list for PBXNativeTarget "GameplayKitSandboxUITests" */ = { 735 | isa = XCConfigurationList; 736 | buildConfigurations = ( 737 | 9B76DD2B1BAE839E00298642 /* Debug */, 738 | 9B76DD2C1BAE839E00298642 /* Release */, 739 | ); 740 | defaultConfigurationIsVisible = 0; 741 | defaultConfigurationName = Release; 742 | }; 743 | /* End XCConfigurationList section */ 744 | }; 745 | rootObject = 9B76DCF41BAE839E00298642 /* Project object */; 746 | } 747 | --------------------------------------------------------------------------------