remove SkillComponents and PlayerInfoComponent and implement them in the HUD class. Adjust the EntityManager
This commit is contained in:
parent
0b09180f83
commit
915d726160
@ -24,7 +24,6 @@
|
|||||||
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 /* SingeClickButtonNode.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8BB6FF3F2472B8F000162BBD /* SingeClickButtonNode.swift */; };
|
8BB6FF402472B8F000162BBD /* SingeClickButtonNode.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8BB6FF3F2472B8F000162BBD /* SingeClickButtonNode.swift */; };
|
||||||
9E04AFAF245E2B73002D5CFC /* AttackActionComponent.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9E04AFAE245E2B73002D5CFC /* AttackActionComponent.swift */; };
|
|
||||||
9E0E459724796262009817A6 /* GameCenterManager.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9E0E459624796262009817A6 /* GameCenterManager.swift */; };
|
9E0E459724796262009817A6 /* GameCenterManager.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9E0E459624796262009817A6 /* GameCenterManager.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 */; };
|
||||||
@ -43,7 +42,6 @@
|
|||||||
9EC86B9F245C88A300796EF3 /* Modal.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9EC86B9E245C88A300796EF3 /* Modal.swift */; };
|
9EC86B9F245C88A300796EF3 /* Modal.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9EC86B9E245C88A300796EF3 /* Modal.swift */; };
|
||||||
9EEDE02D246FCD770096C735 /* SpinningLogoEntity.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9EEDE02C246FCD770096C735 /* SpinningLogoEntity.swift */; };
|
9EEDE02D246FCD770096C735 /* SpinningLogoEntity.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9EEDE02C246FCD770096C735 /* SpinningLogoEntity.swift */; };
|
||||||
9EEDE02F246FCD800096C735 /* SpinningLogoComponent.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9EEDE02E246FCD800096C735 /* SpinningLogoComponent.swift */; };
|
9EEDE02F246FCD800096C735 /* SpinningLogoComponent.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9EEDE02E246FCD800096C735 /* SpinningLogoComponent.swift */; };
|
||||||
AB0B88F6247AD89200C8DF66 /* SkillComponent.swift in Sources */ = {isa = PBXBuildFile; fileRef = AB0B88F5247AD89200C8DF66 /* SkillComponent.swift */; };
|
|
||||||
AB21D7D5246C748A00B09CBA /* MapFactory.swift in Sources */ = {isa = PBXBuildFile; fileRef = AB21D7D4246C748A00B09CBA /* MapFactory.swift */; };
|
AB21D7D5246C748A00B09CBA /* MapFactory.swift in Sources */ = {isa = PBXBuildFile; fileRef = AB21D7D4246C748A00B09CBA /* MapFactory.swift */; };
|
||||||
ABA03DA0244BD54F00A66916 /* Base.swift in Sources */ = {isa = PBXBuildFile; fileRef = ABA03D9F244BD54F00A66916 /* Base.swift */; };
|
ABA03DA0244BD54F00A66916 /* Base.swift in Sources */ = {isa = PBXBuildFile; fileRef = ABA03D9F244BD54F00A66916 /* Base.swift */; };
|
||||||
ABC0C3732481509300387B8F /* MapUtils.swift in Sources */ = {isa = PBXBuildFile; fileRef = ABC0C3722481509300387B8F /* MapUtils.swift */; };
|
ABC0C3732481509300387B8F /* MapUtils.swift in Sources */ = {isa = PBXBuildFile; fileRef = ABC0C3722481509300387B8F /* MapUtils.swift */; };
|
||||||
@ -89,7 +87,6 @@
|
|||||||
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 /* SingeClickButtonNode.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SingeClickButtonNode.swift; sourceTree = "<group>"; };
|
8BB6FF3F2472B8F000162BBD /* SingeClickButtonNode.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SingeClickButtonNode.swift; sourceTree = "<group>"; };
|
||||||
9E04AFAE245E2B73002D5CFC /* AttackActionComponent.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AttackActionComponent.swift; sourceTree = "<group>"; };
|
|
||||||
9E0E459624796262009817A6 /* GameCenterManager.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = GameCenterManager.swift; sourceTree = "<group>"; };
|
9E0E459624796262009817A6 /* GameCenterManager.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = GameCenterManager.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>"; };
|
||||||
@ -109,7 +106,6 @@
|
|||||||
9ECD3699245C91F7008DEEBD /* GoldWars.entitlements */ = {isa = PBXFileReference; lastKnownFileType = text.plist.entitlements; path = GoldWars.entitlements; 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>"; };
|
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>"; };
|
9EEDE02E246FCD800096C735 /* SpinningLogoComponent.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = SpinningLogoComponent.swift; sourceTree = "<group>"; };
|
||||||
AB0B88F5247AD89200C8DF66 /* SkillComponent.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SkillComponent.swift; sourceTree = "<group>"; };
|
|
||||||
AB21D7D4246C748A00B09CBA /* MapFactory.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MapFactory.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>"; };
|
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>"; };
|
ABC0C3722481509300387B8F /* MapUtils.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MapUtils.swift; sourceTree = "<group>"; };
|
||||||
@ -199,7 +195,6 @@
|
|||||||
116060F4245C56EA004E5A36 /* Components */ = {
|
116060F4245C56EA004E5A36 /* Components */ = {
|
||||||
isa = PBXGroup;
|
isa = PBXGroup;
|
||||||
children = (
|
children = (
|
||||||
9E04AFAE245E2B73002D5CFC /* AttackActionComponent.swift */,
|
|
||||||
9E174C87245DF1FF00209FF0 /* BackgroundComponent.swift */,
|
9E174C87245DF1FF00209FF0 /* BackgroundComponent.swift */,
|
||||||
9EA3ABEA245C6DFA006BC61D /* BaseNode.swift */,
|
9EA3ABEA245C6DFA006BC61D /* BaseNode.swift */,
|
||||||
9E174C85245DD91500209FF0 /* ButtonComponent.swift */,
|
9E174C85245DD91500209FF0 /* ButtonComponent.swift */,
|
||||||
@ -210,7 +205,6 @@
|
|||||||
C064E9A7246C0EA50022B228 /* LabelNode.swift */,
|
C064E9A7246C0EA50022B228 /* LabelNode.swift */,
|
||||||
9EC2FBA62476B1EC00ABF11F /* PlayerInfoComponent.swift */,
|
9EC2FBA62476B1EC00ABF11F /* PlayerInfoComponent.swift */,
|
||||||
8BB6FF3F2472B8F000162BBD /* SingeClickButtonNode.swift */,
|
8BB6FF3F2472B8F000162BBD /* SingeClickButtonNode.swift */,
|
||||||
AB0B88F5247AD89200C8DF66 /* SkillComponent.swift */,
|
|
||||||
C05BB9C3247D890C00411249 /* SliderComponent.swift */,
|
C05BB9C3247D890C00411249 /* SliderComponent.swift */,
|
||||||
9EC7E48A2461FBF700396BCD /* SliderNode.swift */,
|
9EC7E48A2461FBF700396BCD /* SliderNode.swift */,
|
||||||
9EEDE02E246FCD800096C735 /* SpinningLogoComponent.swift */,
|
9EEDE02E246FCD800096C735 /* SpinningLogoComponent.swift */,
|
||||||
@ -397,7 +391,6 @@
|
|||||||
3FE19DB5246C7A22004827AB /* RoundCalculatorService.swift in Sources */,
|
3FE19DB5246C7A22004827AB /* RoundCalculatorService.swift in Sources */,
|
||||||
9EC239E1246878A900952F74 /* MultiplayerNetwork.swift in Sources */,
|
9EC239E1246878A900952F74 /* MultiplayerNetwork.swift in Sources */,
|
||||||
9EA3ABEB245C6DFA006BC61D /* BaseNode.swift in Sources */,
|
9EA3ABEB245C6DFA006BC61D /* BaseNode.swift in Sources */,
|
||||||
9E04AFAF245E2B73002D5CFC /* AttackActionComponent.swift in Sources */,
|
|
||||||
3E6785422472CBEC007B9DE4 /* Way.swift in Sources */,
|
3E6785422472CBEC007B9DE4 /* Way.swift in Sources */,
|
||||||
110360D9244B101A008610AF /* GameScene.swift in Sources */,
|
110360D9244B101A008610AF /* GameScene.swift in Sources */,
|
||||||
C04783F024685995004961FB /* SettingsScene.swift in Sources */,
|
C04783F024685995004961FB /* SettingsScene.swift in Sources */,
|
||||||
@ -415,7 +408,6 @@
|
|||||||
9EA3ABE9245C6DAA006BC61D /* DefaultBaseComponent.swift in Sources */,
|
9EA3ABE9245C6DAA006BC61D /* DefaultBaseComponent.swift in Sources */,
|
||||||
9E174C8A245E1A0A00209FF0 /* Background.swift in Sources */,
|
9E174C8A245E1A0A00209FF0 /* Background.swift in Sources */,
|
||||||
8BB6FF402472B8F000162BBD /* SingeClickButtonNode.swift in Sources */,
|
8BB6FF402472B8F000162BBD /* SingeClickButtonNode.swift in Sources */,
|
||||||
AB0B88F6247AD89200C8DF66 /* SkillComponent.swift in Sources */,
|
|
||||||
C064E9A8246C0EA50022B228 /* LabelNode.swift in Sources */,
|
C064E9A8246C0EA50022B228 /* LabelNode.swift in Sources */,
|
||||||
3F745DF0246F48FC00CE7375 /* PlayerMoveType.swift in Sources */,
|
3F745DF0246F48FC00CE7375 /* PlayerMoveType.swift in Sources */,
|
||||||
3E67854024728368007B9DE4 /* CElements.swift in Sources */,
|
3E67854024728368007B9DE4 /* CElements.swift in Sources */,
|
||||||
|
@ -10,48 +10,3 @@ import Foundation
|
|||||||
import GameplayKit
|
import GameplayKit
|
||||||
import GameKit
|
import GameKit
|
||||||
|
|
||||||
|
|
||||||
class PlayerInfoComponent: GKComponent {
|
|
||||||
|
|
||||||
var entityManager = EntityManager.gameEMInstance
|
|
||||||
var hostLabel:SKLabelNode
|
|
||||||
var hostUnitsLabel:SKLabelNode
|
|
||||||
|
|
||||||
var peerLabel:SKLabelNode
|
|
||||||
var peerUnitsLabel:SKLabelNode
|
|
||||||
var host: GKPlayer?
|
|
||||||
var peer: GKPlayer?
|
|
||||||
|
|
||||||
init(size: CGSize) {
|
|
||||||
host = GameCenterManager.sharedInstance.hostingPlayer
|
|
||||||
peer = GameCenterManager.sharedInstance.peerPlayer
|
|
||||||
hostLabel = SKLabelNode(text: host?.displayName)
|
|
||||||
hostUnitsLabel = SKLabelNode(text: "500" )
|
|
||||||
peerLabel = SKLabelNode(text: peer?.displayName)
|
|
||||||
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 update(){
|
|
||||||
hostUnitsLabel.text = "\(entityManager.getUnitSum(by: host!))"
|
|
||||||
peerUnitsLabel.text = "\(entityManager.getUnitSum(by: peer!))"
|
|
||||||
}
|
|
||||||
|
|
||||||
func setColor(labelNodes: [SKLabelNode]) -> Void {
|
|
||||||
for label in labelNodes {
|
|
||||||
label.fontColor = SKColor.black
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
required init?(coder: NSCoder) {
|
|
||||||
fatalError("init(coder:) has not been implemented")
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
@ -21,51 +21,5 @@ class SkillComponent: GKComponent {
|
|||||||
required init?(coder: NSCoder) {
|
required init?(coder: NSCoder) {
|
||||||
fatalError("init(coder:) has not been implemented")
|
fatalError("init(coder:) has not been implemented")
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
class AtkSkillComponent: SkillComponent {
|
|
||||||
|
|
||||||
init() {
|
|
||||||
super.init(textureName: "yellow_circle",
|
|
||||||
text: "Atk",
|
|
||||||
position: CGPoint(x: EntityManager.gameEMInstance.scene.size.width * 0.95, y: EntityManager.gameEMInstance.scene.size.height * 0.1),
|
|
||||||
isEnabled: true,
|
|
||||||
onButtonPress: {EntityManager.gameEMInstance.getBasesByTeam(for: .team2).forEach({base in base.hasAttackBoost = true})})
|
|
||||||
}
|
|
||||||
|
|
||||||
required init?(coder: NSCoder) {
|
|
||||||
fatalError("init(coder:) has not been implemented")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
class DefSkillComponent: SkillComponent {
|
|
||||||
|
|
||||||
init() {
|
|
||||||
super.init(textureName: "yellow_circle",
|
|
||||||
text: "Def",
|
|
||||||
position: CGPoint(x: EntityManager.gameEMInstance.scene.size.width * 0.85, y: EntityManager.gameEMInstance.scene.size.height * 0.1),
|
|
||||||
isEnabled: true,
|
|
||||||
onButtonPress: {EntityManager.gameEMInstance.getBasesByTeam(for: .team2).forEach({base in base.hasDefenseBoost = true})})
|
|
||||||
}
|
|
||||||
|
|
||||||
required init?(coder: NSCoder) {
|
|
||||||
fatalError("init(coder:) has not been implemented")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
class SpySkillComponent: SkillComponent {
|
|
||||||
|
|
||||||
init() {
|
|
||||||
super.init(textureName: "yellow_circle",
|
|
||||||
text: "Spy",
|
|
||||||
position: CGPoint(x: EntityManager.gameEMInstance.scene.size.width * 0.75, y: EntityManager.gameEMInstance.scene.size.height * 0.1),
|
|
||||||
isEnabled: true,
|
|
||||||
onButtonPress: { print("Not implemented") }
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
required init?(coder: NSCoder) {
|
|
||||||
fatalError("init(coder:) has not been implemented")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
@ -42,6 +42,17 @@ class EntityManager {
|
|||||||
isModal = true
|
isModal = true
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if let hudEnitity = entity as? HUD {
|
||||||
|
scene.addChild(hudEnitity.hostLabel)
|
||||||
|
scene.addChild(hudEnitity.hostUnitsLabel)
|
||||||
|
scene.addChild(hudEnitity.peerLabel)
|
||||||
|
scene.addChild(hudEnitity.peerUnitsLabel)
|
||||||
|
scene.addChild(hudEnitity.defSkill)
|
||||||
|
scene.addChild(hudEnitity.atkSkill)
|
||||||
|
scene.addChild(hudEnitity.spySkill)
|
||||||
|
isModal = true
|
||||||
|
}
|
||||||
|
|
||||||
if let spriteNode = entity.component(ofType: DefaultBaseComponent.self) {
|
if let spriteNode = entity.component(ofType: DefaultBaseComponent.self) {
|
||||||
scene.addChild(spriteNode.labelNode)
|
scene.addChild(spriteNode.labelNode)
|
||||||
scene.addChild(spriteNode.spriteNode)
|
scene.addChild(spriteNode.spriteNode)
|
||||||
@ -49,15 +60,6 @@ class EntityManager {
|
|||||||
if let fire = entity.component(ofType: TeamComponent.self)?.fire{
|
if let fire = entity.component(ofType: TeamComponent.self)?.fire{
|
||||||
scene.addChild(fire)
|
scene.addChild(fire)
|
||||||
}
|
}
|
||||||
if let skillButtonNode = entity.component(ofType: AtkSkillComponent.self)?.skillButtonNode {
|
|
||||||
scene.addChild(skillButtonNode)
|
|
||||||
}
|
|
||||||
if let skillButtonNode = entity.component(ofType: DefSkillComponent.self)?.skillButtonNode {
|
|
||||||
scene.addChild(skillButtonNode)
|
|
||||||
}
|
|
||||||
if let skillButtonNode = entity.component(ofType: SpySkillComponent.self)?.skillButtonNode {
|
|
||||||
scene.addChild(skillButtonNode)
|
|
||||||
}
|
|
||||||
if let timer = entity.component(ofType: TimerComponent.self) {
|
if let timer = entity.component(ofType: TimerComponent.self) {
|
||||||
scene.addChild(timer.labelNode)
|
scene.addChild(timer.labelNode)
|
||||||
}
|
}
|
||||||
@ -82,12 +84,6 @@ 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) {
|
||||||
@ -165,7 +161,7 @@ class EntityManager {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
getHUD()?.component(ofType: PlayerInfoComponent.self)?.update()
|
getHUD()!.updateUnitSum()
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -243,8 +239,8 @@ class EntityManager {
|
|||||||
return entities.filter{$0 is Button && ($0 as! Button).name == buttonName }[0] as! Button
|
return entities.filter{$0 is Button && ($0 as! Button).name == buttonName }[0] as! Button
|
||||||
}
|
}
|
||||||
|
|
||||||
func getHUD() -> GKEntity? {
|
func getHUD() -> HUD? {
|
||||||
return entities.filter{$0 is HUD}[0]
|
return entities.filter{$0 is HUD}[0] as! HUD
|
||||||
}
|
}
|
||||||
|
|
||||||
func getSnapshotModel() -> SnapshotModel {
|
func getSnapshotModel() -> SnapshotModel {
|
||||||
|
@ -7,20 +7,73 @@
|
|||||||
//
|
//
|
||||||
|
|
||||||
import GameplayKit
|
import GameplayKit
|
||||||
|
import GameKit
|
||||||
|
|
||||||
class HUD: GKEntity {
|
class HUD: GKEntity {
|
||||||
|
|
||||||
|
var entityManager = EntityManager.gameEMInstance
|
||||||
|
var hostLabel:SKLabelNode
|
||||||
|
var hostUnitsLabel:SKLabelNode
|
||||||
|
|
||||||
|
var peerLabel:SKLabelNode
|
||||||
|
var peerUnitsLabel:SKLabelNode
|
||||||
|
var host: GKPlayer?
|
||||||
|
var peer: GKPlayer?
|
||||||
|
|
||||||
|
var spySkill: SingeClickButtonNode
|
||||||
|
var defSkill: SingeClickButtonNode
|
||||||
|
var atkSkill: SingeClickButtonNode
|
||||||
|
|
||||||
init(size: CGSize) {
|
init(size: CGSize) {
|
||||||
super.init()
|
host = GameCenterManager.sharedInstance.hostingPlayer
|
||||||
|
peer = GameCenterManager.sharedInstance.peerPlayer
|
||||||
|
hostLabel = SKLabelNode(text: host?.displayName)
|
||||||
|
hostUnitsLabel = SKLabelNode(text: "500" )
|
||||||
|
peerLabel = SKLabelNode(text: peer?.displayName)
|
||||||
|
peerUnitsLabel = SKLabelNode(text: "500")
|
||||||
|
|
||||||
addComponent(DefSkillComponent())
|
spySkill = SingeClickButtonNode(
|
||||||
addComponent(AtkSkillComponent())
|
textureName: "yellow_circle",
|
||||||
addComponent(SpySkillComponent())
|
text: "Spy",
|
||||||
|
isEnabled: true,
|
||||||
|
position: CGPoint(x: EntityManager.gameEMInstance.scene.size.width * 0.75, y: EntityManager.gameEMInstance.scene.size.height * 0.1),
|
||||||
|
onButtonPress: { print("Not implemented") }
|
||||||
|
)
|
||||||
|
defSkill = SingeClickButtonNode(
|
||||||
|
textureName: "yellow_circle",
|
||||||
|
text: "Def",
|
||||||
|
isEnabled: true,
|
||||||
|
position: CGPoint(x: EntityManager.gameEMInstance.scene.size.width * 0.85, y: EntityManager.gameEMInstance.scene.size.height * 0.1),
|
||||||
|
onButtonPress: {EntityManager.gameEMInstance.getBasesByTeam(for: .team2).forEach({base in base.hasDefenseBoost = true})}
|
||||||
|
)
|
||||||
|
atkSkill = SingeClickButtonNode(
|
||||||
|
textureName: "yellow_circle",
|
||||||
|
text: "Atk",
|
||||||
|
isEnabled: true,
|
||||||
|
position: CGPoint(x: EntityManager.gameEMInstance.scene.size.width * 0.95, y: EntityManager.gameEMInstance.scene.size.height * 0.1),
|
||||||
|
onButtonPress: {EntityManager.gameEMInstance.getBasesByTeam(for: .team2).forEach({base in base.hasAttackBoost = true})}
|
||||||
|
)
|
||||||
|
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])
|
||||||
|
|
||||||
addComponent(TimerComponent(text: "", anchorPoint: CGPoint(x: size.width * 0.5, y: size.height * 0.9), duration: 30))
|
addComponent(TimerComponent(text: "", anchorPoint: CGPoint(x: size.width * 0.5, y: size.height * 0.9), duration: 30))
|
||||||
|
}
|
||||||
addComponent(PlayerInfoComponent(size: size))
|
|
||||||
|
func updateUnitSum(){
|
||||||
|
hostUnitsLabel.text = "\(entityManager.getUnitSum(by: host!))"
|
||||||
|
peerUnitsLabel.text = "\(entityManager.getUnitSum(by: peer!))"
|
||||||
|
}
|
||||||
|
|
||||||
|
func setColor(labelNodes: [SKLabelNode]) -> Void {
|
||||||
|
for label in labelNodes {
|
||||||
|
label.fontColor = SKColor.black
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
required init?(coder: NSCoder) {
|
required init?(coder: NSCoder) {
|
||||||
|
Loading…
Reference in New Issue
Block a user