add label with 100000000 changes

This commit is contained in:
Niko Jochim 2020-05-21 17:59:19 +02:00
parent fbe8dbde9d
commit d16867f367
14 changed files with 114 additions and 5 deletions

View File

@ -23,9 +23,9 @@
3E6785442472CC27007B9DE4 /* DefaultWayComponent.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3E6785432472CC27007B9DE4 /* DefaultWayComponent.swift */; }; 3E6785442472CC27007B9DE4 /* DefaultWayComponent.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3E6785432472CC27007B9DE4 /* DefaultWayComponent.swift */; };
3EBD242C245D8044003CECE7 /* GameCenterHelper.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3EBD242B245D8044003CECE7 /* GameCenterHelper.swift */; }; 3EBD242C245D8044003CECE7 /* GameCenterHelper.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3EBD242B245D8044003CECE7 /* GameCenterHelper.swift */; };
3EBD242E245D9332003CECE7 /* Team.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3EBD242D245D9332003CECE7 /* Team.swift */; }; 3EBD242E245D9332003CECE7 /* Team.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3EBD242D245D9332003CECE7 /* Team.swift */; };
8BB6FF402472B8F000162BBD /* SkillButtonNode.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8BB6FF3F2472B8F000162BBD /* SkillButtonNode.swift */; };
3F745DF0246F48FC00CE7375 /* PlayerMoveType.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3F745DEF246F48FC00CE7375 /* PlayerMoveType.swift */; }; 3F745DF0246F48FC00CE7375 /* PlayerMoveType.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3F745DEF246F48FC00CE7375 /* PlayerMoveType.swift */; };
3FE19DB5246C7A22004827AB /* RoundCalculatorService.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3FE19DB4246C7A22004827AB /* RoundCalculatorService.swift */; }; 3FE19DB5246C7A22004827AB /* RoundCalculatorService.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3FE19DB4246C7A22004827AB /* RoundCalculatorService.swift */; };
8BB6FF402472B8F000162BBD /* SkillButtonNode.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8BB6FF3F2472B8F000162BBD /* SkillButtonNode.swift */; };
9E04AFAF245E2B73002D5CFC /* AttackActionComponent.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9E04AFAE245E2B73002D5CFC /* AttackActionComponent.swift */; }; 9E04AFAF245E2B73002D5CFC /* AttackActionComponent.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9E04AFAE245E2B73002D5CFC /* AttackActionComponent.swift */; };
9E11FF79245CD81100EED3BE /* Fire.sks in Resources */ = {isa = PBXBuildFile; fileRef = 9E11FF77245CD81100EED3BE /* Fire.sks */; }; 9E11FF79245CD81100EED3BE /* Fire.sks in Resources */ = {isa = PBXBuildFile; fileRef = 9E11FF77245CD81100EED3BE /* Fire.sks */; };
9E174C82245DD81D00209FF0 /* ButtonNode.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9E174C81245DD81D00209FF0 /* ButtonNode.swift */; }; 9E174C82245DD81D00209FF0 /* ButtonNode.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9E174C81245DD81D00209FF0 /* ButtonNode.swift */; };
@ -45,6 +45,7 @@
9EA3ABEF245C834B006BC61D /* ModalContentComponent.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9EA3ABEE245C834B006BC61D /* ModalContentComponent.swift */; }; 9EA3ABEF245C834B006BC61D /* ModalContentComponent.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9EA3ABEE245C834B006BC61D /* ModalContentComponent.swift */; };
9EBFD7552462CF5A00E1E219 /* SliderComponent.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9EBFD7542462CF5A00E1E219 /* SliderComponent.swift */; }; 9EBFD7552462CF5A00E1E219 /* SliderComponent.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9EBFD7542462CF5A00E1E219 /* SliderComponent.swift */; };
9EC239E1246878A900952F74 /* MultiplayerNetwork.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9EC239E0246878A900952F74 /* MultiplayerNetwork.swift */; }; 9EC239E1246878A900952F74 /* MultiplayerNetwork.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9EC239E0246878A900952F74 /* MultiplayerNetwork.swift */; };
9EC2FBA72476B1EC00ABF11F /* PlayerInfoComponent.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9EC2FBA62476B1EC00ABF11F /* PlayerInfoComponent.swift */; };
9EC7E48B2461FBF700396BCD /* SliderNode.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9EC7E48A2461FBF700396BCD /* SliderNode.swift */; }; 9EC7E48B2461FBF700396BCD /* SliderNode.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9EC7E48A2461FBF700396BCD /* SliderNode.swift */; };
9EC86B9F245C88A300796EF3 /* Modal.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9EC86B9E245C88A300796EF3 /* Modal.swift */; }; 9EC86B9F245C88A300796EF3 /* Modal.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9EC86B9E245C88A300796EF3 /* Modal.swift */; };
9EC86BA6245C8AD000796EF3 /* ModalType.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9EC86BA5245C8AD000796EF3 /* ModalType.swift */; }; 9EC86BA6245C8AD000796EF3 /* ModalType.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9EC86BA5245C8AD000796EF3 /* ModalType.swift */; };
@ -97,9 +98,9 @@
3E6785432472CC27007B9DE4 /* DefaultWayComponent.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DefaultWayComponent.swift; sourceTree = "<group>"; }; 3E6785432472CC27007B9DE4 /* DefaultWayComponent.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DefaultWayComponent.swift; sourceTree = "<group>"; };
3EBD242B245D8044003CECE7 /* GameCenterHelper.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = GameCenterHelper.swift; sourceTree = "<group>"; }; 3EBD242B245D8044003CECE7 /* GameCenterHelper.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = GameCenterHelper.swift; sourceTree = "<group>"; };
3EBD242D245D9332003CECE7 /* Team.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Team.swift; sourceTree = "<group>"; }; 3EBD242D245D9332003CECE7 /* Team.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Team.swift; sourceTree = "<group>"; };
8BB6FF3F2472B8F000162BBD /* SkillButtonNode.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SkillButtonNode.swift; sourceTree = "<group>"; };
3F745DEF246F48FC00CE7375 /* PlayerMoveType.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PlayerMoveType.swift; sourceTree = "<group>"; }; 3F745DEF246F48FC00CE7375 /* PlayerMoveType.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PlayerMoveType.swift; sourceTree = "<group>"; };
3FE19DB4246C7A22004827AB /* RoundCalculatorService.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = RoundCalculatorService.swift; sourceTree = "<group>"; }; 3FE19DB4246C7A22004827AB /* RoundCalculatorService.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = RoundCalculatorService.swift; sourceTree = "<group>"; };
8BB6FF3F2472B8F000162BBD /* SkillButtonNode.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SkillButtonNode.swift; sourceTree = "<group>"; };
9E04AFAE245E2B73002D5CFC /* AttackActionComponent.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AttackActionComponent.swift; sourceTree = "<group>"; }; 9E04AFAE245E2B73002D5CFC /* AttackActionComponent.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AttackActionComponent.swift; sourceTree = "<group>"; };
9E11FF77245CD81100EED3BE /* Fire.sks */ = {isa = PBXFileReference; lastKnownFileType = file.sks; path = Fire.sks; sourceTree = "<group>"; }; 9E11FF77245CD81100EED3BE /* Fire.sks */ = {isa = PBXFileReference; lastKnownFileType = file.sks; path = Fire.sks; sourceTree = "<group>"; };
9E174C81245DD81D00209FF0 /* ButtonNode.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ButtonNode.swift; sourceTree = "<group>"; }; 9E174C81245DD81D00209FF0 /* ButtonNode.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ButtonNode.swift; sourceTree = "<group>"; };
@ -119,6 +120,7 @@
9EA3ABEE245C834B006BC61D /* ModalContentComponent.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ModalContentComponent.swift; sourceTree = "<group>"; }; 9EA3ABEE245C834B006BC61D /* ModalContentComponent.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ModalContentComponent.swift; sourceTree = "<group>"; };
9EBFD7542462CF5A00E1E219 /* SliderComponent.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = SliderComponent.swift; sourceTree = "<group>"; }; 9EBFD7542462CF5A00E1E219 /* SliderComponent.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = SliderComponent.swift; sourceTree = "<group>"; };
9EC239E0246878A900952F74 /* MultiplayerNetwork.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MultiplayerNetwork.swift; sourceTree = "<group>"; }; 9EC239E0246878A900952F74 /* MultiplayerNetwork.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MultiplayerNetwork.swift; sourceTree = "<group>"; };
9EC2FBA62476B1EC00ABF11F /* PlayerInfoComponent.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PlayerInfoComponent.swift; sourceTree = "<group>"; };
9EC7E48A2461FBF700396BCD /* SliderNode.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SliderNode.swift; sourceTree = "<group>"; }; 9EC7E48A2461FBF700396BCD /* SliderNode.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SliderNode.swift; sourceTree = "<group>"; };
9EC86B9E245C88A300796EF3 /* Modal.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Modal.swift; sourceTree = "<group>"; }; 9EC86B9E245C88A300796EF3 /* Modal.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Modal.swift; sourceTree = "<group>"; };
9EC86BA5245C8AD000796EF3 /* ModalType.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ModalType.swift; sourceTree = "<group>"; }; 9EC86BA5245C8AD000796EF3 /* ModalType.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ModalType.swift; sourceTree = "<group>"; };
@ -241,6 +243,7 @@
9EC7E48A2461FBF700396BCD /* SliderNode.swift */, 9EC7E48A2461FBF700396BCD /* SliderNode.swift */,
3E6785432472CC27007B9DE4 /* DefaultWayComponent.swift */, 3E6785432472CC27007B9DE4 /* DefaultWayComponent.swift */,
8BB6FF3F2472B8F000162BBD /* SkillButtonNode.swift */, 8BB6FF3F2472B8F000162BBD /* SkillButtonNode.swift */,
9EC2FBA62476B1EC00ABF11F /* PlayerInfoComponent.swift */,
); );
path = Components; path = Components;
sourceTree = "<group>"; sourceTree = "<group>";
@ -436,6 +439,7 @@
3EBD242E245D9332003CECE7 /* Team.swift in Sources */, 3EBD242E245D9332003CECE7 /* Team.swift in Sources */,
9E174C88245DF1FF00209FF0 /* BackgroundComponent.swift in Sources */, 9E174C88245DF1FF00209FF0 /* BackgroundComponent.swift in Sources */,
9E78ACBA245CBDAF00526FF7 /* HUD.swift in Sources */, 9E78ACBA245CBDAF00526FF7 /* HUD.swift in Sources */,
9EC2FBA72476B1EC00ABF11F /* PlayerInfoComponent.swift in Sources */,
9EEDE02D246FCD770096C735 /* SpinningLogoEntity.swift in Sources */, 9EEDE02D246FCD770096C735 /* SpinningLogoEntity.swift in Sources */,
11738A3B24508F68004426F1 /* UnitType.swift in Sources */, 11738A3B24508F68004426F1 /* UnitType.swift in Sources */,
9E174C86245DD91500209FF0 /* ButtonComponent.swift in Sources */, 9E174C86245DD91500209FF0 /* ButtonComponent.swift in Sources */,

View File

@ -18,6 +18,7 @@ class CancelBtnComponent: GKComponent {
isEnabled: isEnabled, isEnabled: isEnabled,
position: position, position: position,
onButtonPress: onButtonPress) onButtonPress: onButtonPress)
cancelBtnNode.zPosition = 4
super.init() super.init()
} }

View File

@ -18,6 +18,7 @@ class ButtonComponent: GKComponent {
isEnabled: isEnabled, isEnabled: isEnabled,
position: position, position: position,
onButtonPress: onButtonPress) onButtonPress: onButtonPress)
buttonNode.zPosition = 4
super.init() super.init()
} }

View File

@ -8,14 +8,26 @@
import GameplayKit import GameplayKit
import SpriteKit import SpriteKit
import GameKit
class DefaultBaseComponent: GKComponent { class DefaultBaseComponent: GKComponent {
var spriteNode: BaseNode var spriteNode: BaseNode
var labelNode : SKLabelNode?
init(texture: SKTexture, position: CGPoint) { init(texture: SKTexture, position: CGPoint) {
spriteNode = BaseNode(texture: texture, size: CGSize(width: 80, height: 80)) spriteNode = BaseNode(texture: texture, size: CGSize(width: 80, height: 80))
spriteNode.position = position spriteNode.position = position
spriteNode.zPosition = 2
super.init() super.init()
labelNode = SKLabelNode(text: "")
labelNode?.fontColor = SKColor.black
labelNode?.horizontalAlignmentMode = .left
labelNode?.verticalAlignmentMode = .center
labelNode?.fontName = "AvenirNext-Bold"
labelNode?.fontSize = 15
labelNode?.position = CGPoint(x: position.x + 20 , y: position.y - 40 )
labelNode?.zPosition = spriteNode.zPosition - 1
} }
required init?(coder aDecoder: NSCoder) { required init?(coder aDecoder: NSCoder) {

View File

@ -18,7 +18,7 @@ class DefaultWayComponent: GKComponent {
shapeNode.path = pathToDraw shapeNode.path = pathToDraw
shapeNode.strokeColor = UIColor(red: 0.852, green: 0.649, blue: 0.123, alpha: 1) shapeNode.strokeColor = UIColor(red: 0.852, green: 0.649, blue: 0.123, alpha: 1)
shapeNode.lineWidth = 10 shapeNode.lineWidth = 10
shapeNode.zPosition = -1 shapeNode.zPosition = 0
super.init() super.init()
} }

View File

@ -17,6 +17,7 @@ class ModalBackgroundComponent: GKComponent {
spriteNode = SKSpriteNode(texture: texture, size: texture.size()) spriteNode = SKSpriteNode(texture: texture, size: texture.size())
spriteNode.setScale(2) spriteNode.setScale(2)
spriteNode.position = anchorPoint spriteNode.position = anchorPoint
spriteNode.zPosition = 3
super.init() super.init()
} }

View File

@ -20,6 +20,7 @@ class ModalContentComponent: GKComponent{
self.header.position = CGPoint(x: anchorPoint.x, y: anchorPoint.y + 125) self.header.position = CGPoint(x: anchorPoint.x, y: anchorPoint.y + 125)
self.header.fontName = "HelveticaNeue-Bold" self.header.fontName = "HelveticaNeue-Bold"
self.header.fontSize = 40 self.header.fontSize = 40
self.header.zPosition = 4
self.body = SKLabelNode(text: body) self.body = SKLabelNode(text: body)
self.body.position = CGPoint(x: anchorPoint.x, y: anchorPoint.y - 20) self.body.position = CGPoint(x: anchorPoint.x, y: anchorPoint.y - 20)
@ -28,11 +29,13 @@ class ModalContentComponent: GKComponent{
self.body.horizontalAlignmentMode = SKLabelHorizontalAlignmentMode.center self.body.horizontalAlignmentMode = SKLabelHorizontalAlignmentMode.center
self.body.fontName = "HelveticaNeue-Bold" self.body.fontName = "HelveticaNeue-Bold"
self.body.fontSize = 40 self.body.fontSize = 40
self.body.zPosition = 4
self.footer = SKLabelNode(text: footer) self.footer = SKLabelNode(text: footer)
self.footer.position = CGPoint(x: anchorPoint.x, y: anchorPoint.y - 40) self.footer.position = CGPoint(x: anchorPoint.x, y: anchorPoint.y - 40)
self.footer.fontName = "HelveticaNeue-Bold" self.footer.fontName = "HelveticaNeue-Bold"
self.footer.fontSize = 40 self.footer.fontSize = 40
self.footer.zPosition = 4
super.init() super.init()
} }

View File

@ -0,0 +1,70 @@
//
// PlayerInfoComponent.swift
// GoldWars
//
// Created by Niko Jochim on 21.05.20.
// Copyright © 2020 SP2. All rights reserved.
//
import Foundation
import GameplayKit
import GameKit
class PlayerInfoComponent: GKComponent {
var hostLabel:SKLabelNode
var hostUnitsLabel:SKLabelNode
var peerLabel:SKLabelNode
var peerUnitsLabel:SKLabelNode
init(size: CGSize) {
var host: String?
var peer: String?
if MatchmakingHelper.sharedInstance.isServer {
host = GKLocalPlayer.local.displayName
peer = MatchmakingHelper.sharedInstance.mpMatch?.players[0].displayName
} else {
host = MatchmakingHelper.sharedInstance.mpMatch?.players[0].displayName
peer = GKLocalPlayer.local.displayName
}
hostLabel = SKLabelNode(text: host)
hostUnitsLabel = SKLabelNode(text: "500")
peerLabel = SKLabelNode(text: peer)
peerUnitsLabel = SKLabelNode(text: "500")
super.init()
hostLabel.position = CGPoint(x: size.width * 0.02, y: size.height * 0.95)
hostLabel.horizontalAlignmentMode = .left
peerLabel.position = CGPoint(x: size.width * 0.98, y: size.height * 0.95)
peerLabel.horizontalAlignmentMode = .right
hostUnitsLabel.position = CGPoint(x: size.width * 0.05, y: size.height * 0.9)
peerUnitsLabel.position = CGPoint(x: size.width * 0.95, y: size.height * 0.9)
setColor(labelNodes: [hostLabel,hostUnitsLabel,peerLabel,peerUnitsLabel])
}
func setColor(labelNodes: [SKLabelNode]) -> Void {
for label in labelNodes {
label.fontColor = SKColor.black
}
}
required init?(coder: NSCoder) {
fatalError("init(coder:) has not been implemented")
}
}

View File

@ -14,6 +14,7 @@ class SliderComponent: GKComponent {
init(width: CGFloat, position: CGPoint) { init(width: CGFloat, position: CGPoint) {
sliderNode = SliderNode(width: width, position: position) sliderNode = SliderNode(width: width, position: position)
sliderNode.zPosition = 4
super.init() super.init()
} }

View File

@ -26,6 +26,7 @@ class SliderNode :SKNode {
sliderLine = SKShapeNode(rectOf: CGSize(width: width, height: 8)) sliderLine = SKShapeNode(rectOf: CGSize(width: width, height: 8))
sliderLine.position = position sliderLine.position = position
sliderLine.fillColor = SKColor.white sliderLine.fillColor = SKColor.white
sliderLine.zPosition = 4
sliderKnob = SliderKnob(circleOfRadius: 20) sliderKnob = SliderKnob(circleOfRadius: 20)
sliderKnob.min = position.x - width / 2 sliderKnob.min = position.x - width / 2
sliderKnob.max = position.x + width / 2 sliderKnob.max = position.x + width / 2

View File

@ -17,7 +17,7 @@ class TeamComponent: GKComponent {
init(team: Team, player: GKPlayer, position: CGPoint) { init(team: Team, player: GKPlayer, position: CGPoint) {
fire = SKEmitterNode(fileNamed: "Fire")! fire = SKEmitterNode(fileNamed: "Fire")!
fire.zPosition = -1 fire.zPosition = 1
fire.position = position fire.position = position
fire.name = "fire" fire.name = "fire"
fire.particleColorSequence = nil fire.particleColorSequence = nil

View File

@ -36,6 +36,8 @@ class Base: GKEntity{
addComponent(TeamComponent(team: team!, player: player!, position: position)) addComponent(TeamComponent(team: team!, player: player!, position: position))
self.unitCount = 500 self.unitCount = 500
} }
self.component(ofType: DefaultBaseComponent.self)?.labelNode?.text = "\(unitCount)"
} }
func doPlayerMoveTypeToBase(base: Base, playerMoveType: PlayerMoveType, units: Int) -> [GKEntity]{ func doPlayerMoveTypeToBase(base: Base, playerMoveType: PlayerMoveType, units: Int) -> [GKEntity]{
@ -43,6 +45,8 @@ class Base: GKEntity{
base.ownershipPlayer = self.ownershipPlayer base.ownershipPlayer = self.ownershipPlayer
self.unitCount -= units self.unitCount -= units
base.unitCount += units base.unitCount += units
self.component(ofType: DefaultBaseComponent.self)?.labelNode?.text = "\(self.unitCount)"
base.component(ofType: DefaultBaseComponent.self)?.labelNode?.text = "\(base.unitCount)"
DataService.sharedInstance.addMove(playerMove: PlayerMove(fromBase: self.baseID, DataService.sharedInstance.addMove(playerMove: PlayerMove(fromBase: self.baseID,
toBase: base.baseID, toBase: base.baseID,
unitCount: units * playerMoveType.rawValue)) unitCount: units * playerMoveType.rawValue))

View File

@ -33,6 +33,9 @@ class EntityManager {
if let spriteNode = entity.component(ofType: DefaultBaseComponent.self)?.spriteNode { if let spriteNode = entity.component(ofType: DefaultBaseComponent.self)?.spriteNode {
scene.addChild(spriteNode) scene.addChild(spriteNode)
} }
if let label = entity.component(ofType: DefaultBaseComponent.self)?.labelNode {
scene.addChild(label)
}
if let fire = entity.component(ofType: TeamComponent.self)?.fire{ if let fire = entity.component(ofType: TeamComponent.self)?.fire{
scene.addChild(fire) scene.addChild(fire)
} }
@ -84,6 +87,12 @@ class EntityManager {
if let wayNode = entity.component(ofType: DefaultWayComponent.self)?.shapeNode { if let wayNode = entity.component(ofType: DefaultWayComponent.self)?.shapeNode {
scene.addChild(wayNode) scene.addChild(wayNode)
} }
if let playerInfos = entity.component(ofType: PlayerInfoComponent.self) {
scene.addChild(playerInfos.hostLabel)
scene.addChild(playerInfos.hostUnitsLabel)
scene.addChild(playerInfos.peerLabel)
scene.addChild(playerInfos.peerUnitsLabel)
}
} }
func remove(_ entity: GKEntity) { func remove(_ entity: GKEntity) {
@ -143,7 +152,7 @@ class EntityManager {
let snapBase = self.getSnapshotBaseById(baseId: base.baseID, snapshotModel: snapshotModel) let snapBase = self.getSnapshotBaseById(baseId: base.baseID, snapshotModel: snapshotModel)
var getOwnerBySnapBase: GKPlayer? = nil var getOwnerBySnapBase: GKPlayer? = nil
base.unitCount = snapBase.unitCount base.unitCount = snapBase.unitCount
base.component(ofType: DefaultBaseComponent.self)?.labelNode?.text = "\(base.unitCount)"
if snapBase.ownership != nil { if snapBase.ownership != nil {
getOwnerBySnapBase = MatchmakingHelper.sharedInstance.getGKPlayerByUsername(displayName: snapBase.ownership!) getOwnerBySnapBase = MatchmakingHelper.sharedInstance.getGKPlayerByUsername(displayName: snapBase.ownership!)
} }

View File

@ -24,6 +24,8 @@ class HUD: GKEntity {
addComponent(TimerComponent(text: "", addComponent(TimerComponent(text: "",
anchorPoint: CGPoint(x: size.width * 0.5, y: size.height * 0.9), duration: 30)) anchorPoint: CGPoint(x: size.width * 0.5, y: size.height * 0.9), duration: 30))
addComponent(PlayerInfoComponent(size: size))
} }
required init?(coder: NSCoder) { required init?(coder: NSCoder) {