Merge branch '66-game-over-scene-2' into 'development'
Resolve "Game-Over Scene" Closes #66 See merge request marcel.schwarz/software-projekt-2!115
This commit is contained in:
commit
875524d170
@ -31,6 +31,8 @@
|
||||
9E174C86245DD91500209FF0 /* ButtonComponent.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9E174C85245DD91500209FF0 /* ButtonComponent.swift */; };
|
||||
9E174C88245DF1FF00209FF0 /* BackgroundComponent.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9E174C87245DF1FF00209FF0 /* BackgroundComponent.swift */; };
|
||||
9E174C8A245E1A0A00209FF0 /* Background.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9E174C89245E1A0A00209FF0 /* Background.swift */; };
|
||||
9E61EAC4249BAC9100334DDE /* LoserFire.sks in Resources */ = {isa = PBXBuildFile; fileRef = 9E61EAC2249BAC9100334DDE /* LoserFire.sks */; };
|
||||
9E61EAC7249BB61A00334DDE /* SpinningLogo3DNode.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9E61EAC6249BB61A00334DDE /* SpinningLogo3DNode.swift */; };
|
||||
9E78ACB6245C9A5300526FF7 /* GameKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 9E78ACB5245C9A5300526FF7 /* GameKit.framework */; };
|
||||
9E78ACB8245CB75B00526FF7 /* TeamComponent.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9E78ACB7245CB75B00526FF7 /* TeamComponent.swift */; };
|
||||
9E78ACBA245CBDAF00526FF7 /* HUD.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9E78ACB9245CBDAF00526FF7 /* HUD.swift */; };
|
||||
@ -41,7 +43,6 @@
|
||||
9EC7E48B2461FBF700396BCD /* SliderNode.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9EC7E48A2461FBF700396BCD /* SliderNode.swift */; };
|
||||
9EC86B9F245C88A300796EF3 /* Modal.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9EC86B9E245C88A300796EF3 /* Modal.swift */; };
|
||||
9EEDE02D246FCD770096C735 /* SpinningLogoEntity.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9EEDE02C246FCD770096C735 /* SpinningLogoEntity.swift */; };
|
||||
9EEDE02F246FCD800096C735 /* SpinningLogoComponent.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9EEDE02E246FCD800096C735 /* SpinningLogoComponent.swift */; };
|
||||
AB21D7D5246C748A00B09CBA /* MapFactory.swift in Sources */ = {isa = PBXBuildFile; fileRef = AB21D7D4246C748A00B09CBA /* MapFactory.swift */; };
|
||||
ABA03DA0244BD54F00A66916 /* Base.swift in Sources */ = {isa = PBXBuildFile; fileRef = ABA03D9F244BD54F00A66916 /* Base.swift */; };
|
||||
ABC0C3732481509300387B8F /* MapUtils.swift in Sources */ = {isa = PBXBuildFile; fileRef = ABC0C3722481509300387B8F /* MapUtils.swift */; };
|
||||
@ -94,6 +95,8 @@
|
||||
9E174C85245DD91500209FF0 /* ButtonComponent.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ButtonComponent.swift; sourceTree = "<group>"; };
|
||||
9E174C87245DF1FF00209FF0 /* BackgroundComponent.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = BackgroundComponent.swift; sourceTree = "<group>"; };
|
||||
9E174C89245E1A0A00209FF0 /* Background.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Background.swift; sourceTree = "<group>"; };
|
||||
9E61EAC2249BAC9100334DDE /* LoserFire.sks */ = {isa = PBXFileReference; lastKnownFileType = file.sks; path = LoserFire.sks; sourceTree = "<group>"; };
|
||||
9E61EAC6249BB61A00334DDE /* SpinningLogo3DNode.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SpinningLogo3DNode.swift; sourceTree = "<group>"; };
|
||||
9E78ACB5245C9A5300526FF7 /* GameKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = GameKit.framework; path = System/Library/Frameworks/GameKit.framework; sourceTree = SDKROOT; };
|
||||
9E78ACB7245CB75B00526FF7 /* TeamComponent.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TeamComponent.swift; sourceTree = "<group>"; };
|
||||
9E78ACB9245CBDAF00526FF7 /* HUD.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = HUD.swift; sourceTree = "<group>"; };
|
||||
@ -105,7 +108,6 @@
|
||||
9EC86B9E245C88A300796EF3 /* Modal.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Modal.swift; sourceTree = "<group>"; };
|
||||
9ECD3699245C91F7008DEEBD /* GoldWars.entitlements */ = {isa = PBXFileReference; lastKnownFileType = text.plist.entitlements; path = GoldWars.entitlements; sourceTree = "<group>"; };
|
||||
9EEDE02C246FCD770096C735 /* SpinningLogoEntity.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = SpinningLogoEntity.swift; sourceTree = "<group>"; };
|
||||
9EEDE02E246FCD800096C735 /* SpinningLogoComponent.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = SpinningLogoComponent.swift; sourceTree = "<group>"; };
|
||||
AB21D7D4246C748A00B09CBA /* MapFactory.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MapFactory.swift; sourceTree = "<group>"; };
|
||||
ABA03D9F244BD54F00A66916 /* Base.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Base.swift; sourceTree = "<group>"; };
|
||||
ABC0C3722481509300387B8F /* MapUtils.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MapUtils.swift; sourceTree = "<group>"; };
|
||||
@ -207,8 +209,8 @@
|
||||
8BB6FF3F2472B8F000162BBD /* SingeClickButtonNode.swift */,
|
||||
C05BB9C3247D890C00411249 /* SliderComponent.swift */,
|
||||
9EC7E48A2461FBF700396BCD /* SliderNode.swift */,
|
||||
9EEDE02E246FCD800096C735 /* SpinningLogoComponent.swift */,
|
||||
9E78ACB7245CB75B00526FF7 /* TeamComponent.swift */,
|
||||
9E61EAC6249BB61A00334DDE /* SpinningLogo3DNode.swift */,
|
||||
);
|
||||
path = Components;
|
||||
sourceTree = "<group>";
|
||||
@ -234,6 +236,7 @@
|
||||
children = (
|
||||
3F79FFDF2486F7CD003F79C3 /* Explosion.sks */,
|
||||
9E11FF77245CD81100EED3BE /* Fire.sks */,
|
||||
9E61EAC2249BAC9100334DDE /* LoserFire.sks */,
|
||||
);
|
||||
path = Partikels;
|
||||
sourceTree = "<group>";
|
||||
@ -368,6 +371,7 @@
|
||||
9E11FF79245CD81100EED3BE /* Fire.sks in Resources */,
|
||||
110360E0244B101B008610AF /* Assets.xcassets in Resources */,
|
||||
110360E3244B101B008610AF /* LaunchScreen.storyboard in Resources */,
|
||||
9E61EAC4249BAC9100334DDE /* LoserFire.sks in Resources */,
|
||||
C04783EE2468583F004961FB /* intro-music.mp3 in Resources */,
|
||||
3F79FFE02486F7CD003F79C3 /* Explosion.sks in Resources */,
|
||||
);
|
||||
@ -418,7 +422,7 @@
|
||||
ABC0C3732481509300387B8F /* MapUtils.swift in Sources */,
|
||||
9E174C82245DD81D00209FF0 /* ButtonNode.swift in Sources */,
|
||||
9EC7E48B2461FBF700396BCD /* SliderNode.swift in Sources */,
|
||||
9EEDE02F246FCD800096C735 /* SpinningLogoComponent.swift in Sources */,
|
||||
9E61EAC7249BB61A00334DDE /* SpinningLogo3DNode.swift in Sources */,
|
||||
9E174C84245DD8CE00209FF0 /* Button.swift in Sources */,
|
||||
110360DB244B101A008610AF /* GameViewController.swift in Sources */,
|
||||
C05BB9C4247D890C00411249 /* SliderComponent.swift in Sources */,
|
||||
|
23
GoldWars/GoldWars/Assets.xcassets/winner.imageset/Contents.json
vendored
Normal file
23
GoldWars/GoldWars/Assets.xcassets/winner.imageset/Contents.json
vendored
Normal file
@ -0,0 +1,23 @@
|
||||
{
|
||||
"images" : [
|
||||
{
|
||||
"filename" : "winner.png",
|
||||
"idiom" : "universal",
|
||||
"scale" : "1x"
|
||||
},
|
||||
{
|
||||
"filename" : "winner-1.png",
|
||||
"idiom" : "universal",
|
||||
"scale" : "2x"
|
||||
},
|
||||
{
|
||||
"filename" : "winner-2.png",
|
||||
"idiom" : "universal",
|
||||
"scale" : "3x"
|
||||
}
|
||||
],
|
||||
"info" : {
|
||||
"author" : "xcode",
|
||||
"version" : 1
|
||||
}
|
||||
}
|
BIN
GoldWars/GoldWars/Assets.xcassets/winner.imageset/winner-1.png
vendored
Normal file
BIN
GoldWars/GoldWars/Assets.xcassets/winner.imageset/winner-1.png
vendored
Normal file
Binary file not shown.
After Width: | Height: | Size: 448 KiB |
BIN
GoldWars/GoldWars/Assets.xcassets/winner.imageset/winner-2.png
vendored
Normal file
BIN
GoldWars/GoldWars/Assets.xcassets/winner.imageset/winner-2.png
vendored
Normal file
Binary file not shown.
After Width: | Height: | Size: 448 KiB |
BIN
GoldWars/GoldWars/Assets.xcassets/winner.imageset/winner.png
vendored
Normal file
BIN
GoldWars/GoldWars/Assets.xcassets/winner.imageset/winner.png
vendored
Normal file
Binary file not shown.
After Width: | Height: | Size: 448 KiB |
40
GoldWars/GoldWars/Components/SpinningLogo3DNode.swift
Normal file
40
GoldWars/GoldWars/Components/SpinningLogo3DNode.swift
Normal file
@ -0,0 +1,40 @@
|
||||
//
|
||||
// SpinningLogo3DNode.swift
|
||||
// GoldWars
|
||||
//
|
||||
// Created by Niko Jochim on 18.06.20.
|
||||
// Copyright © 2020 SP2. All rights reserved.
|
||||
//
|
||||
|
||||
import Foundation
|
||||
import SpriteKit
|
||||
import GameKit
|
||||
class SpinningLogo3DNode : SK3DNode {
|
||||
|
||||
init() {
|
||||
super.init(viewportSize: CGSize(width: 250, height: 250))
|
||||
let scnScene: SCNScene = {
|
||||
let scnScene = SCNScene()
|
||||
let cylinder = SCNCylinder(radius: 250, height: 50)
|
||||
let logoMaterial = SCNMaterial()
|
||||
let colorMaterial = SCNMaterial()
|
||||
logoMaterial.diffuse.contents = UIImage(named: "logo_no_background")
|
||||
colorMaterial.diffuse.contents = UIColor(red: 0.852, green: 0.649, blue: 0.123, alpha: 1)
|
||||
cylinder.materials = [colorMaterial,logoMaterial,logoMaterial]
|
||||
let cylinderNode = SCNNode(geometry: cylinder)
|
||||
cylinderNode.eulerAngles = SCNVector3(x: Float(CGFloat.pi / 2), y: 0, z: Float(CGFloat.pi / 2))
|
||||
let action = SCNAction.rotateBy(x: CGFloat(GLKMathDegreesToRadians(360)), y:0 , z: 0, duration: 8)
|
||||
let forever = SCNAction.repeatForever(action)
|
||||
cylinderNode.runAction(forever)
|
||||
scnScene.rootNode.addChildNode(cylinderNode)
|
||||
return scnScene
|
||||
}()
|
||||
self.scnScene = scnScene
|
||||
self.position = position
|
||||
}
|
||||
|
||||
required init?(coder: NSCoder) {
|
||||
fatalError("init(coder:) has not been implemented")
|
||||
}
|
||||
}
|
||||
|
@ -1,45 +0,0 @@
|
||||
//
|
||||
// SpinningLogoComponent.swift
|
||||
// GoldWars
|
||||
//
|
||||
// Created by Niko Jochim on 15.05.20.
|
||||
// Copyright © 2020 SP2. All rights reserved.
|
||||
//
|
||||
|
||||
import Foundation
|
||||
import GameKit
|
||||
|
||||
class SpinningLogoComponent: GKComponent{
|
||||
|
||||
var node : SK3DNode
|
||||
|
||||
init(position: CGPoint) {
|
||||
|
||||
let scnScene: SCNScene = {
|
||||
let scnScene = SCNScene()
|
||||
let cylinder = SCNCylinder(radius: 250, height: 50)
|
||||
let logoMaterial = SCNMaterial()
|
||||
let colorMaterial = SCNMaterial()
|
||||
logoMaterial.diffuse.contents = UIImage(named: "logo_no_background")
|
||||
colorMaterial.diffuse.contents = UIColor(red: 0.852, green: 0.649, blue: 0.123, alpha: 1)
|
||||
cylinder.materials = [colorMaterial,logoMaterial,logoMaterial]
|
||||
let cylinderNode = SCNNode(geometry: cylinder)
|
||||
cylinderNode.eulerAngles = SCNVector3(x: Float(CGFloat.pi / 2), y: 0, z: Float(CGFloat.pi / 2))
|
||||
let action = SCNAction.rotateBy(x: CGFloat(GLKMathDegreesToRadians(360)), y:0 , z: 0, duration: 8)
|
||||
let forever = SCNAction.repeatForever(action)
|
||||
cylinderNode.runAction(forever)
|
||||
scnScene.rootNode.addChildNode(cylinderNode)
|
||||
return scnScene
|
||||
}()
|
||||
|
||||
self.node = SK3DNode(viewportSize: CGSize(width: 250, height: 250))
|
||||
node.scnScene = scnScene
|
||||
node.position = position
|
||||
super.init()
|
||||
}
|
||||
|
||||
required init?(coder: NSCoder) {
|
||||
fatalError("init(coder:) has not been implemented")
|
||||
}
|
||||
|
||||
}
|
@ -60,6 +60,10 @@ class EntityManager {
|
||||
scene.addChild(hudEntitiy.blockWholeScreenPane)
|
||||
}
|
||||
|
||||
if let spinningLogoEntity = entity as? SpinningLogoEntity {
|
||||
scene.addChild(spinningLogoEntity.spinningLogoNode)
|
||||
}
|
||||
|
||||
if let wayEntity = entity as? Way {
|
||||
scene.addChild(wayEntity.localWayComponent)
|
||||
}
|
||||
@ -88,9 +92,7 @@ class EntityManager {
|
||||
if let labelNode = entity.component(ofType: LabelComponent.self)?.labelNode {
|
||||
scene.addChild(labelNode)
|
||||
}
|
||||
if let node = entity.component(ofType: SpinningLogoComponent.self)?.node {
|
||||
scene.addChild(node)
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
func remove(_ entity: GKEntity) {
|
||||
@ -275,7 +277,7 @@ class EntityManager {
|
||||
}
|
||||
|
||||
func getBackground() -> GKEntity? {
|
||||
return entities.filter{$0 is Background}[0]
|
||||
return entities.filter{$0 is Background}.first
|
||||
}
|
||||
|
||||
func getBaseNodeByTeam(for team: Team) -> SKSpriteNode? {
|
||||
@ -287,7 +289,7 @@ class EntityManager {
|
||||
}
|
||||
|
||||
func getHUD() -> HUD? {
|
||||
return entities.filter{$0 is HUD}[0] as? HUD
|
||||
return entities.filter{$0 is HUD}.first as? HUD
|
||||
}
|
||||
|
||||
func getSnapshotModel() -> SnapshotModel {
|
||||
|
@ -35,8 +35,10 @@ class HUD: GKEntity {
|
||||
|
||||
init(size: CGSize) {
|
||||
hostLabel = SKLabelNode(text: GameCenterManager.sharedInstance.hostingPlayer?.displayName)
|
||||
hostLabel.name = "hostLabel"
|
||||
hostUnitsLabel = SKLabelNode(text: "500" )
|
||||
peerLabel = SKLabelNode(text: GameCenterManager.sharedInstance.peerPlayer?.displayName)
|
||||
peerLabel.name = "peerLabel"
|
||||
peerUnitsLabel = SKLabelNode(text: "500")
|
||||
|
||||
roundTimerLabel = SKLabelNode(text: "")
|
||||
|
@ -11,9 +11,12 @@ import GameplayKit
|
||||
|
||||
class SpinningLogoEntity: GKEntity {
|
||||
|
||||
let spinningLogoNode : SpinningLogo3DNode
|
||||
|
||||
init(position: CGPoint) {
|
||||
spinningLogoNode = SpinningLogo3DNode()
|
||||
spinningLogoNode.position = position
|
||||
super.init()
|
||||
self.addComponent(SpinningLogoComponent(position: position))
|
||||
}
|
||||
|
||||
required init?(coder: NSCoder) {
|
||||
|
@ -39,7 +39,7 @@ class Way: GKEntity {
|
||||
self.localWayComponent.strokeColor = UIColor(red: 0.852, green: 0.649, blue: 0.123, alpha: 1)
|
||||
self.localWayComponent.lineWidth = 10
|
||||
self.localWayComponent.zPosition = 0
|
||||
|
||||
self.localWayComponent.name = "way"
|
||||
super.init()
|
||||
}
|
||||
|
||||
|
@ -29,7 +29,7 @@ struct State: Codable {
|
||||
|
||||
final class GameCenterManager: NSObject, GKMatchmakerViewControllerDelegate, GKGameCenterControllerDelegate ,GKMatchDelegate,GKLocalPlayerListener{
|
||||
|
||||
static let sharedInstance = GameCenterManager()
|
||||
static var sharedInstance = GameCenterManager()
|
||||
|
||||
let LOG = OSLog.init(subsystem: "GameCenterManager", category: "GameCenterManager")
|
||||
|
||||
@ -44,6 +44,8 @@ final class GameCenterManager: NSObject, GKMatchmakerViewControllerDelegate, GKG
|
||||
var entityManager = EntityManager.gameEMInstance
|
||||
var localPlayerRandomNumber: RandomNumber?
|
||||
var initIsFinish = false
|
||||
var gameEnded = false
|
||||
var winner: String?
|
||||
var gameScene: GameScene?
|
||||
static var isAuthenticated: Bool {
|
||||
return GKLocalPlayer.local.isAuthenticated
|
||||
@ -56,6 +58,16 @@ final class GameCenterManager: NSObject, GKMatchmakerViewControllerDelegate, GKG
|
||||
localPlayerRandomNumber = RandomNumber()
|
||||
}
|
||||
|
||||
func reset() {
|
||||
isMatchStarted = false
|
||||
isServer = false
|
||||
localPlayerRandomNumber = RandomNumber()
|
||||
initIsFinish = false
|
||||
gameEnded = false
|
||||
winner = nil
|
||||
gameScene = nil
|
||||
}
|
||||
|
||||
func authUser() -> Void {
|
||||
GKLocalPlayer.local.authenticateHandler = { gcAuthVC, error in
|
||||
NotificationCenter.default
|
||||
@ -225,10 +237,12 @@ final class GameCenterManager: NSObject, GKMatchmakerViewControllerDelegate, GKG
|
||||
os_log("Spiel startet", log: LOG, type: .info)
|
||||
case 4:
|
||||
os_log("State 4 erhalten, Peer hat verloren", log: LOG, type: .info)
|
||||
// TODO: Trigger Loser Scene
|
||||
winner = hostingPlayer?.displayName
|
||||
gameEnded = true
|
||||
case 5:
|
||||
os_log("State 5 erhalten, Peer hat gewonnen", log: LOG, type: .info)
|
||||
// TODO: Trigger Winner Scene
|
||||
winner = peerPlayer?.displayName
|
||||
gameEnded = true
|
||||
default:
|
||||
break
|
||||
}
|
||||
|
@ -11,7 +11,6 @@ import SpriteKit
|
||||
import GameplayKit
|
||||
|
||||
class GameViewController: UIViewController {
|
||||
public static let sharedInstance = GameViewController();
|
||||
var currentScene: SKView?
|
||||
|
||||
override func viewDidLoad() {
|
||||
@ -44,4 +43,5 @@ class GameViewController: UIViewController {
|
||||
override var prefersStatusBarHidden: Bool {
|
||||
return true
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -38,7 +38,6 @@ class MultiplayerNetwork{
|
||||
|
||||
func sendPlayerMoves(localRoundData: LocalRoundData) {
|
||||
if GameCenterManager.sharedInstance.isServer == false {
|
||||
print("I am client")
|
||||
self.isSending = true
|
||||
let encoder = JSONEncoder()
|
||||
let encoded = (try? encoder.encode(localRoundData))!
|
||||
|
Binary file not shown.
Binary file not shown.
BIN
GoldWars/GoldWars/Partikels/LoserFire.sks
Normal file
BIN
GoldWars/GoldWars/Partikels/LoserFire.sks
Normal file
Binary file not shown.
@ -158,7 +158,8 @@ class RoundCalculatorService {
|
||||
winner = determineWinner(by: "capture")
|
||||
}
|
||||
winner == GameCenterManager.sharedInstance.hostingPlayer?.displayName ? GameCenterManager.sharedInstance.sendStateToPeers(state: State(state: 4)) : GameCenterManager.sharedInstance.sendStateToPeers(state: State(state: 5))
|
||||
//TODO: Trigger Winner/Loser-Scene for Server
|
||||
GameCenterManager.sharedInstance.winner = winner
|
||||
GameCenterManager.sharedInstance.gameEnded = true
|
||||
return
|
||||
}
|
||||
currentRound += 1
|
||||
|
@ -30,7 +30,9 @@ class RoundTimer: Timer {
|
||||
}
|
||||
|
||||
func stopTimer() {
|
||||
guard timer != nil else { return }
|
||||
timer?.invalidate()
|
||||
timer = nil
|
||||
}
|
||||
|
||||
func resumeTimer() {
|
||||
@ -46,7 +48,6 @@ class RoundTimer: Timer {
|
||||
@objc func onTimerFires()
|
||||
{
|
||||
timeLeft -= 1
|
||||
|
||||
EntityManager.gameEMInstance.updateTime(time: (timeLeft > 0 ? String(timeLeft) : roundEnded))
|
||||
|
||||
if timeLeft == 0 {
|
||||
@ -57,6 +58,7 @@ class RoundTimer: Timer {
|
||||
}
|
||||
calculate = true
|
||||
}
|
||||
|
||||
if timeLeft <= 0 {
|
||||
if calculate
|
||||
&& !RoundCalculatorService.sharedInstance.isCalculating
|
||||
@ -66,5 +68,7 @@ class RoundTimer: Timer {
|
||||
calculate = false
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -18,6 +18,7 @@ class GameScene: SKScene{
|
||||
var currentDraggedBase : Base?
|
||||
static var sendUnits: Int = 0
|
||||
var collisionBase: Base?
|
||||
var gameEndEffects = false
|
||||
|
||||
override func sceneDidLoad() {
|
||||
entityManager.setScene(scene: self)
|
||||
@ -25,8 +26,8 @@ class GameScene: SKScene{
|
||||
entityManager.add(Background(size: self.size))
|
||||
if CommandLine.arguments.contains("--no-matchmaking") {
|
||||
_ = MapFactory(scene: self, entityManager: entityManager).load()
|
||||
return
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
override func didMove(to view: SKView) {
|
||||
@ -77,6 +78,9 @@ class GameScene: SKScene{
|
||||
|
||||
override func update(_ currentTime: TimeInterval) {
|
||||
entityManager.getBackground()?.update(deltaTime: currentTime)
|
||||
if GameCenterManager.sharedInstance.gameEnded && !gameEndEffects {
|
||||
gameEnd()
|
||||
}
|
||||
}
|
||||
|
||||
func addAttackDetails(touchLocation: CGPoint){
|
||||
@ -121,6 +125,96 @@ class GameScene: SKScene{
|
||||
}
|
||||
}
|
||||
|
||||
func gameEnd(){
|
||||
entityManager.getHUD()?.blockWholeScreenPane.isHidden = true
|
||||
gameEndEffects = true
|
||||
GameCenterManager.sharedInstance.gameEnded = false
|
||||
let move = SKAction.move(to: CGPoint(x: self.size.width / 2, y: self.size.height / 2), duration: 1)
|
||||
let removeParticle = SKAction.removeFromParent()
|
||||
let sequence = SKAction.sequence([move, removeParticle])
|
||||
var actionAdded = false
|
||||
for nodeChild in children {
|
||||
if nodeChild.name == "peerLabel" || nodeChild.name == "hostLabel"{
|
||||
continue
|
||||
}
|
||||
if nodeChild.name == "way" {
|
||||
nodeChild.run(SKAction.removeFromParent())
|
||||
continue
|
||||
}
|
||||
if nodeChild.name != "clouds"{
|
||||
nodeChild.run(sequence) {
|
||||
if !actionAdded {
|
||||
let explosion = self.getFinalExplosion()
|
||||
self.addChild(explosion)
|
||||
let action = SKAction.afterDelay(2) {
|
||||
(self.childNode(withName: "hostLabel") as! SKLabelNode).horizontalAlignmentMode = .center
|
||||
(self.childNode(withName: "peerLabel") as! SKLabelNode).horizontalAlignmentMode = .center
|
||||
self.childNode(withName: "hostLabel")?.run(SKAction.move(to: CGPoint(x: self.size.width * 0.25, y: self.size.height * 0.3), duration: 1))
|
||||
self.childNode(withName: "peerLabel")?.run(SKAction.move(to: CGPoint(x: self.size.width * 0.75, y: self.size.height * 0.3), duration: 1))
|
||||
self.initGameEndIcons()
|
||||
let node = ButtonNode(textureName: "yellow_button05", text: "Menu", isEnabled: true, position: CGPoint(x: self.size.width / 2, y: self.size.height / 2 - 300), onButtonPress: {
|
||||
self.backToMenuAction()
|
||||
})
|
||||
node.name = "BackButton"
|
||||
self.addChild(node)
|
||||
}
|
||||
explosion.run(action)
|
||||
actionAdded = true
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func initGameEndIcons() {
|
||||
let iclonSize = CGSize(width: 400, height: 400)
|
||||
let winnerIcon = SKSpriteNode(texture: SKTexture(imageNamed: "winner"));
|
||||
winnerIcon.size = iclonSize
|
||||
let loserIcon = SKSpriteNode(texture: SKTexture(imageNamed: "BaseTexture"))
|
||||
loserIcon.size = iclonSize
|
||||
let loserFire = SKEmitterNode(fileNamed: "LoserFire")
|
||||
loserFire?.zPosition = loserIcon.zPosition - 1
|
||||
loserFire?.run(SKAction.scale(by: 4, duration: 8))
|
||||
let iconPosition1 = CGPoint(x: self.size.width * 0.25, y: self.size.height * 0.55)
|
||||
let iconPosition2 = CGPoint(x: self.size.width * 0.75, y: self.size.height * 0.55)
|
||||
let coin = SpinningLogo3DNode()
|
||||
if GameCenterManager.sharedInstance.winner == GameCenterManager.sharedInstance.hostingPlayer?.displayName {
|
||||
winnerIcon.position = iconPosition1
|
||||
coin.position = iconPosition1
|
||||
loserIcon.position = iconPosition2
|
||||
loserFire?.position = iconPosition2
|
||||
} else {
|
||||
winnerIcon.position = iconPosition2
|
||||
coin.position = iconPosition2
|
||||
loserIcon.position = iconPosition1
|
||||
loserFire?.position = iconPosition1
|
||||
}
|
||||
self.addChild(winnerIcon)
|
||||
self.addChild(coin)
|
||||
self.addChild(loserIcon)
|
||||
self.addChild(loserFire!)
|
||||
}
|
||||
|
||||
func getFinalExplosion() -> SKEmitterNode {
|
||||
let explosion = SKEmitterNode(fileNamed: "Explosion")!
|
||||
explosion.zPosition = 2
|
||||
explosion.position = CGPoint(x: self.size.width / 2, y: self.size.height / 2)
|
||||
explosion.name = "explosion"
|
||||
explosion.particleColorSequence = nil
|
||||
explosion.particleColorBlendFactor = 1.0
|
||||
return explosion
|
||||
}
|
||||
|
||||
func backToMenuAction() {
|
||||
GameCenterManager.sharedInstance.reset()
|
||||
self.gameEndEffects = false
|
||||
entityManager.getTimer()?.stopTimer()
|
||||
RoundCalculatorService.sharedInstance.currentRound = 1
|
||||
self.view?.presentScene(MenuScene(size: self.size))
|
||||
entityManager.entities.removeAll()
|
||||
self.removeFromParent()
|
||||
}
|
||||
|
||||
func checkBases(bases: Set<Base>, touchLocation: CGPoint){
|
||||
for base in bases {
|
||||
if atPoint(touchLocation) == base.component(ofType: DefaultBaseComponent.self)?.spriteNode {
|
||||
@ -173,6 +267,8 @@ class GameScene: SKScene{
|
||||
}
|
||||
|
||||
@objc func pauseGame() -> Void {
|
||||
entityManager.removeModal()
|
||||
entityManager.getHUD()?.roundTimer.stopTimer()
|
||||
entityManager.add(Modal(modaltype: .PauseGame,
|
||||
base: nil,
|
||||
anchorPoint: CGPoint(x: self.size.width / 2 , y: self.size.height / 2),
|
||||
@ -181,7 +277,6 @@ class GameScene: SKScene{
|
||||
touchLocation: nil,
|
||||
collisionBase: nil
|
||||
))
|
||||
entityManager.getHUD()?.roundTimer.stopTimer()
|
||||
}
|
||||
@objc func resumeGame() -> Void {
|
||||
entityManager.removeModal()
|
||||
|
Loading…
Reference in New Issue
Block a user