Compare commits

...

1 Commits

Author SHA1 Message Date
Aldin Duraki
1074d244b1 HUD v1 2020-06-02 13:43:19 +02:00
6 changed files with 78 additions and 6 deletions

View File

@ -0,0 +1,21 @@
{
"images" : [
{
"filename" : "HostInfoWrapper.png",
"idiom" : "universal",
"scale" : "1x"
},
{
"idiom" : "universal",
"scale" : "2x"
},
{
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 139 KiB

View File

@ -0,0 +1,21 @@
{
"images" : [
{
"filename" : "PeerInfoWrapper.png",
"idiom" : "universal",
"scale" : "1x"
},
{
"idiom" : "universal",
"scale" : "2x"
},
{
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 144 KiB

View File

@ -48,6 +48,10 @@ class EntityManager {
scene.addChild(hudEntitiy.hostUnitsLabel) scene.addChild(hudEntitiy.hostUnitsLabel)
scene.addChild(hudEntitiy.peerLabel) scene.addChild(hudEntitiy.peerLabel)
scene.addChild(hudEntitiy.peerUnitsLabel) scene.addChild(hudEntitiy.peerUnitsLabel)
scene.addChild(hudEntitiy.skillWrapper)
scene.addChild(hudEntitiy.timerWrapper)
scene.addChild(hudEntitiy.hostInfoWrapper)
scene.addChild(hudEntitiy.peerInfoWrapper)
scene.addChild(hudEntitiy.defSkill) scene.addChild(hudEntitiy.defSkill)
scene.addChild(hudEntitiy.atkSkill) scene.addChild(hudEntitiy.atkSkill)
scene.addChild(hudEntitiy.spySkill) scene.addChild(hudEntitiy.spySkill)

View File

@ -20,6 +20,11 @@ class HUD: GKEntity {
var host: GKPlayer? var host: GKPlayer?
var peer: GKPlayer? var peer: GKPlayer?
var skillWrapper: SKShapeNode
var timerWrapper: SKShapeNode
var hostInfoWrapper: SKSpriteNode
var peerInfoWrapper: SKSpriteNode
var spySkill: SingeClickButtonNode var spySkill: SingeClickButtonNode
var defSkill: SingeClickButtonNode var defSkill: SingeClickButtonNode
var atkSkill: SingeClickButtonNode var atkSkill: SingeClickButtonNode
@ -38,32 +43,52 @@ class HUD: GKEntity {
peerUnitsLabel = SKLabelNode(text: "500") peerUnitsLabel = SKLabelNode(text: "500")
roundTimerLabel = SKLabelNode(text: "") roundTimerLabel = SKLabelNode(text: "")
roundTimerLabel.fontColor = UIColor.black roundTimerLabel.fontColor = UIColor.white
roundTimerLabel.fontSize = CGFloat(45) roundTimerLabel.fontSize = CGFloat(45)
roundTimerLabel.position = CGPoint(x: size.width * 0.5, y: size.height * 0.9) roundTimerLabel.position = CGPoint(x: size.width * 0.5, y: size.height * 0.94)
roundTimerLabel.horizontalAlignmentMode = .center roundTimerLabel.horizontalAlignmentMode = .center
self.roundTimer = RoundTimer() self.roundTimer = RoundTimer()
timerWrapper = SKShapeNode(rectOf: CGSize(width: 200, height: 60), cornerRadius: 6)
timerWrapper.position = CGPoint(x: size.width / 2, y: size.height - 27)
timerWrapper.fillColor = SKColor.lightGray
hostInfoWrapper = SKSpriteNode(imageNamed: "HostInfoWrapper")
hostInfoWrapper.scale(to: CGSize(width: hostInfoWrapper.frame.width * 0.4, height: hostInfoWrapper.frame.height * 0.4))
hostInfoWrapper.position = CGPoint(x: hostInfoWrapper.frame.width / 2, y: size.height - hostInfoWrapper.frame.height / 2)
hostInfoWrapper.alpha = 0.8
peerInfoWrapper = SKSpriteNode(imageNamed: "PeerInfoWrapper")
peerInfoWrapper.scale(to: CGSize(width: peerInfoWrapper.frame.width * 0.4 , height: peerInfoWrapper.frame.height * 0.4))
peerInfoWrapper.position = CGPoint(x: size.width - peerInfoWrapper.frame.width / 2, y: size.height - peerInfoWrapper.frame.height / 2)
peerInfoWrapper.alpha = 0.7
skillWrapper = SKShapeNode(circleOfRadius: 150)
skillWrapper.position = CGPoint(x: size.width, y: 0)
skillWrapper.fillColor = SKColor(white: 0, alpha: 0)
skillWrapper.strokeColor = SKColor.darkGray
spySkill = SingeClickButtonNode( spySkill = SingeClickButtonNode(
textureName: "yellow_circle", textureName: "yellow_circle",
text: "Spy", text: "Spy",
isEnabled: true, isEnabled: true,
position: CGPoint(x: EntityManager.gameEMInstance.scene.size.width * 0.75, y: EntityManager.gameEMInstance.scene.size.height * 0.1), position: CGPoint(x: EntityManager.gameEMInstance.scene.size.width * 0.86, y: EntityManager.gameEMInstance.scene.size.height * 0.05),
onButtonPress: { print("Not implemented") } onButtonPress: { print("Not implemented") }
) )
defSkill = SingeClickButtonNode( defSkill = SingeClickButtonNode(
textureName: "yellow_circle", textureName: "yellow_circle",
text: "Def", text: "Def",
isEnabled: true, isEnabled: true,
position: CGPoint(x: EntityManager.gameEMInstance.scene.size.width * 0.85, y: EntityManager.gameEMInstance.scene.size.height * 0.1), position: CGPoint(x: EntityManager.gameEMInstance.scene.size.width * 0.9, y: EntityManager.gameEMInstance.scene.size.height * 0.133),
onButtonPress: {DataService.sharedInstance.localRoundData.hasDefenceBoost = true} onButtonPress: {DataService.sharedInstance.localRoundData.hasDefenceBoost = true}
) )
atkSkill = SingeClickButtonNode( atkSkill = SingeClickButtonNode(
textureName: "yellow_circle", textureName: "yellow_circle",
text: "Atk", text: "Atk",
isEnabled: true, isEnabled: true,
position: CGPoint(x: EntityManager.gameEMInstance.scene.size.width * 0.95, y: EntityManager.gameEMInstance.scene.size.height * 0.1), position: CGPoint(x: EntityManager.gameEMInstance.scene.size.width * 0.96, y: EntityManager.gameEMInstance.scene.size.height * 0.186),
onButtonPress: {DataService.sharedInstance.localRoundData.hasAttackBoost = true} onButtonPress: {DataService.sharedInstance.localRoundData.hasAttackBoost = true}
) )
@ -104,6 +129,7 @@ class HUD: GKEntity {
func setColor(labelNodes: [SKLabelNode]) -> Void { func setColor(labelNodes: [SKLabelNode]) -> Void {
for label in labelNodes { for label in labelNodes {
label.fontColor = SKColor.black label.fontColor = SKColor.black
label.zPosition = 1
} }
} }
@ -120,6 +146,6 @@ class HUD: GKEntity {
func finishRound() -> () { func finishRound() -> () {
self.roundTimer.timeLeft = 1; self.roundTimer.timeLeft = 1;
self.roundTimer.roundEnded = "Waiting for other player..." self.roundTimer.roundEnded = "Waiting..."
} }
} }