clean Code
This commit is contained in:
parent
e2c08b51a2
commit
e76f86b126
@ -130,12 +130,10 @@ class GameScene: SKScene{
|
||||
func gameEnd(){
|
||||
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 n = 0
|
||||
var actionAdded = false
|
||||
for nodeChild in children {
|
||||
if nodeChild.name == "peerLabel" || nodeChild.name == "hostLabel"{
|
||||
continue
|
||||
@ -146,18 +144,15 @@ class GameScene: SKScene{
|
||||
}
|
||||
if nodeChild.name != "clouds"{
|
||||
nodeChild.run(sequence,completion: {
|
||||
if n < 1 {
|
||||
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()
|
||||
})
|
||||
@ -165,9 +160,8 @@ class GameScene: SKScene{
|
||||
self.addChild(node)
|
||||
}
|
||||
explosion.run(action)
|
||||
n += 1
|
||||
actionAdded = true
|
||||
}
|
||||
|
||||
})
|
||||
}
|
||||
}
|
||||
@ -177,14 +171,11 @@ class GameScene: SKScene{
|
||||
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()
|
||||
@ -193,14 +184,12 @@ class GameScene: SKScene{
|
||||
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)
|
||||
@ -217,28 +206,6 @@ class GameScene: SKScene{
|
||||
return explosion
|
||||
}
|
||||
|
||||
func goldWarsCoin() -> SK3DNode {
|
||||
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
|
||||
}()
|
||||
let node = SK3DNode(viewportSize: CGSize(width: 250, height: 250))
|
||||
node.scnScene = scnScene
|
||||
return node
|
||||
}
|
||||
|
||||
func backToMenuAction() {
|
||||
GameCenterManager.sharedInstance.reset()
|
||||
self.gameEndEffects = false
|
||||
@ -247,7 +214,6 @@ class GameScene: SKScene{
|
||||
self.view?.presentScene(MenuScene(size: self.size))
|
||||
entityManager.entities.removeAll()
|
||||
self.removeFromParent()
|
||||
|
||||
}
|
||||
|
||||
func checkBases(bases: Set<Base>, touchLocation: CGPoint){
|
||||
|
Loading…
Reference in New Issue
Block a user