Merge branch '88-cooldown-fur-skills' into 'development'
Resolve "Cooldown für Skills" Closes #88 See merge request marcel.schwarz/software-projekt-2!123
This commit is contained in:
commit
49c6017d8a
@ -25,6 +25,7 @@
|
|||||||
3EBD242E245D9332003CECE7 /* Team.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3EBD242D245D9332003CECE7 /* Team.swift */; };
|
3EBD242E245D9332003CECE7 /* Team.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3EBD242D245D9332003CECE7 /* Team.swift */; };
|
||||||
3F79FFE02486F7CD003F79C3 /* Explosion.sks in Resources */ = {isa = PBXBuildFile; fileRef = 3F79FFDF2486F7CD003F79C3 /* Explosion.sks */; };
|
3F79FFE02486F7CD003F79C3 /* Explosion.sks in Resources */ = {isa = PBXBuildFile; fileRef = 3F79FFDF2486F7CD003F79C3 /* Explosion.sks */; };
|
||||||
3FE19DB5246C7A22004827AB /* RoundCalculatorService.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3FE19DB4246C7A22004827AB /* RoundCalculatorService.swift */; };
|
3FE19DB5246C7A22004827AB /* RoundCalculatorService.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3FE19DB4246C7A22004827AB /* RoundCalculatorService.swift */; };
|
||||||
|
8B9CA5F1249A3C2E00561704 /* SkillButtonNode.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8B9CA5F0249A3C2E00561704 /* SkillButtonNode.swift */; };
|
||||||
8BB6FF402472B8F000162BBD /* SingeClickButtonNode.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8BB6FF3F2472B8F000162BBD /* SingeClickButtonNode.swift */; };
|
8BB6FF402472B8F000162BBD /* SingeClickButtonNode.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8BB6FF3F2472B8F000162BBD /* SingeClickButtonNode.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 */; };
|
||||||
@ -92,6 +93,7 @@
|
|||||||
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>"; };
|
||||||
3F79FFDF2486F7CD003F79C3 /* Explosion.sks */ = {isa = PBXFileReference; lastKnownFileType = file.sks; path = Explosion.sks; sourceTree = "<group>"; };
|
3F79FFDF2486F7CD003F79C3 /* Explosion.sks */ = {isa = PBXFileReference; lastKnownFileType = file.sks; path = Explosion.sks; 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>"; };
|
||||||
|
8B9CA5F0249A3C2E00561704 /* SkillButtonNode.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SkillButtonNode.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>"; };
|
||||||
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>"; };
|
||||||
@ -217,6 +219,7 @@
|
|||||||
C064E9A7246C0EA50022B228 /* LabelNode.swift */,
|
C064E9A7246C0EA50022B228 /* LabelNode.swift */,
|
||||||
9EC2FBA62476B1EC00ABF11F /* PlayerInfoComponent.swift */,
|
9EC2FBA62476B1EC00ABF11F /* PlayerInfoComponent.swift */,
|
||||||
8BB6FF3F2472B8F000162BBD /* SingeClickButtonNode.swift */,
|
8BB6FF3F2472B8F000162BBD /* SingeClickButtonNode.swift */,
|
||||||
|
8B9CA5F0249A3C2E00561704 /* SkillButtonNode.swift */,
|
||||||
C05BB9C3247D890C00411249 /* SliderComponent.swift */,
|
C05BB9C3247D890C00411249 /* SliderComponent.swift */,
|
||||||
9EC7E48A2461FBF700396BCD /* SliderNode.swift */,
|
9EC7E48A2461FBF700396BCD /* SliderNode.swift */,
|
||||||
9E78ACB7245CB75B00526FF7 /* TeamComponent.swift */,
|
9E78ACB7245CB75B00526FF7 /* TeamComponent.swift */,
|
||||||
@ -427,6 +430,7 @@
|
|||||||
9E174C8A245E1A0A00209FF0 /* Background.swift in Sources */,
|
9E174C8A245E1A0A00209FF0 /* Background.swift in Sources */,
|
||||||
8BB6FF402472B8F000162BBD /* SingeClickButtonNode.swift in Sources */,
|
8BB6FF402472B8F000162BBD /* SingeClickButtonNode.swift in Sources */,
|
||||||
C064E9A8246C0EA50022B228 /* LabelNode.swift in Sources */,
|
C064E9A8246C0EA50022B228 /* LabelNode.swift in Sources */,
|
||||||
|
8B9CA5F1249A3C2E00561704 /* SkillButtonNode.swift in Sources */,
|
||||||
3EAD889524801B6A0048A10A /* RoundTimer.swift in Sources */,
|
3EAD889524801B6A0048A10A /* RoundTimer.swift in Sources */,
|
||||||
3E67854024728368007B9DE4 /* CElements.swift in Sources */,
|
3E67854024728368007B9DE4 /* CElements.swift in Sources */,
|
||||||
ABA03DA0244BD54F00A66916 /* Base.swift in Sources */,
|
ABA03DA0244BD54F00A66916 /* Base.swift in Sources */,
|
||||||
|
21
GoldWars/GoldWars/Assets.xcassets/atk_button.imageset/Contents.json
vendored
Normal file
21
GoldWars/GoldWars/Assets.xcassets/atk_button.imageset/Contents.json
vendored
Normal file
@ -0,0 +1,21 @@
|
|||||||
|
{
|
||||||
|
"images" : [
|
||||||
|
{
|
||||||
|
"filename" : "atk_button.png",
|
||||||
|
"idiom" : "universal",
|
||||||
|
"scale" : "1x"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"idiom" : "universal",
|
||||||
|
"scale" : "2x"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"idiom" : "universal",
|
||||||
|
"scale" : "3x"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"info" : {
|
||||||
|
"author" : "xcode",
|
||||||
|
"version" : 1
|
||||||
|
}
|
||||||
|
}
|
BIN
GoldWars/GoldWars/Assets.xcassets/atk_button.imageset/atk_button.png
vendored
Normal file
BIN
GoldWars/GoldWars/Assets.xcassets/atk_button.imageset/atk_button.png
vendored
Normal file
Binary file not shown.
After Width: | Height: | Size: 6.9 KiB |
21
GoldWars/GoldWars/Assets.xcassets/def_button.imageset/Contents.json
vendored
Normal file
21
GoldWars/GoldWars/Assets.xcassets/def_button.imageset/Contents.json
vendored
Normal file
@ -0,0 +1,21 @@
|
|||||||
|
{
|
||||||
|
"images" : [
|
||||||
|
{
|
||||||
|
"filename" : "def_button.png",
|
||||||
|
"idiom" : "universal",
|
||||||
|
"scale" : "1x"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"idiom" : "universal",
|
||||||
|
"scale" : "2x"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"idiom" : "universal",
|
||||||
|
"scale" : "3x"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"info" : {
|
||||||
|
"author" : "xcode",
|
||||||
|
"version" : 1
|
||||||
|
}
|
||||||
|
}
|
BIN
GoldWars/GoldWars/Assets.xcassets/def_button.imageset/def_button.png
vendored
Normal file
BIN
GoldWars/GoldWars/Assets.xcassets/def_button.imageset/def_button.png
vendored
Normal file
Binary file not shown.
After Width: | Height: | Size: 6.8 KiB |
21
GoldWars/GoldWars/Assets.xcassets/spy_button.imageset/Contents.json
vendored
Normal file
21
GoldWars/GoldWars/Assets.xcassets/spy_button.imageset/Contents.json
vendored
Normal file
@ -0,0 +1,21 @@
|
|||||||
|
{
|
||||||
|
"images" : [
|
||||||
|
{
|
||||||
|
"filename" : "spy_button.png",
|
||||||
|
"idiom" : "universal",
|
||||||
|
"scale" : "1x"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"idiom" : "universal",
|
||||||
|
"scale" : "2x"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"idiom" : "universal",
|
||||||
|
"scale" : "3x"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"info" : {
|
||||||
|
"author" : "xcode",
|
||||||
|
"version" : 1
|
||||||
|
}
|
||||||
|
}
|
BIN
GoldWars/GoldWars/Assets.xcassets/spy_button.imageset/spy_button.png
vendored
Normal file
BIN
GoldWars/GoldWars/Assets.xcassets/spy_button.imageset/spy_button.png
vendored
Normal file
Binary file not shown.
After Width: | Height: | Size: 7.7 KiB |
56
GoldWars/GoldWars/Components/SkillButtonNode.swift
Normal file
56
GoldWars/GoldWars/Components/SkillButtonNode.swift
Normal file
@ -0,0 +1,56 @@
|
|||||||
|
//
|
||||||
|
// SkillButtonNode.swift
|
||||||
|
// GoldWars
|
||||||
|
//
|
||||||
|
// Created by Simon Kellner on 17.06.20.
|
||||||
|
// Copyright © 2020 SP2. All rights reserved.
|
||||||
|
//
|
||||||
|
|
||||||
|
import SpriteKit
|
||||||
|
|
||||||
|
class SkillButtonNode: ButtonNode {
|
||||||
|
|
||||||
|
|
||||||
|
var cooldownCounter = 0
|
||||||
|
var hasCooled: Bool = false
|
||||||
|
let cooldown: Int
|
||||||
|
let displayText: String
|
||||||
|
|
||||||
|
init(textureName: String, text: String, isEnabled: Bool, cooldown: Int, position: CGPoint, onButtonPress: @escaping () -> ()) {
|
||||||
|
self.cooldown = cooldown
|
||||||
|
self.displayText = text
|
||||||
|
super.init(textureName: textureName, text: text, isEnabled: isEnabled, position: position, onButtonPress: onButtonPress)
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
override func touchesBegan(_ touches: Set<UITouch>, with event: UIEvent?) {
|
||||||
|
super.touchesBegan(touches, with: event)
|
||||||
|
super.isEnabled = false
|
||||||
|
self.cooldownCounter = self.cooldown
|
||||||
|
self.hasCooled = true
|
||||||
|
}
|
||||||
|
|
||||||
|
func decreaseCooldown() {
|
||||||
|
if self.cooldownCounter <= 1 {
|
||||||
|
super.isEnabled = true
|
||||||
|
super.label.text = self.displayText
|
||||||
|
let newRoundAction = SKAction.sequence([
|
||||||
|
SKAction.scale(by: 1.5, duration: 1),
|
||||||
|
SKAction.scale(by: 1/1.5, duration: 1),
|
||||||
|
])
|
||||||
|
if hasCooled {
|
||||||
|
self.run(newRoundAction)
|
||||||
|
self.hasCooled = false
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
super.isEnabled = false
|
||||||
|
self.cooldownCounter -= 1
|
||||||
|
super.label.text = self.cooldownCounter.description
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
required init?(coder aDecoder: NSCoder) {
|
||||||
|
fatalError("init(coder:) has not been implemented")
|
||||||
|
}
|
||||||
|
}
|
@ -352,13 +352,6 @@ class EntityManager {
|
|||||||
button.buttonNode.removeFromParent()
|
button.buttonNode.removeFromParent()
|
||||||
}
|
}
|
||||||
self.remove(modal)
|
self.remove(modal)
|
||||||
|
|
||||||
for child in scene.children {
|
|
||||||
if(child.name != "fire"){
|
|
||||||
child.alpha = 1
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
isModal = false
|
isModal = false
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
@ -18,9 +18,9 @@ class HUD: GKEntity {
|
|||||||
var peerLabel:SKLabelNode
|
var peerLabel:SKLabelNode
|
||||||
var peerUnitsLabel:SKLabelNode
|
var peerUnitsLabel:SKLabelNode
|
||||||
|
|
||||||
var spySkill: SingeClickButtonNode
|
var spySkill: SkillButtonNode
|
||||||
var defSkill: SingeClickButtonNode
|
var defSkill: SkillButtonNode
|
||||||
var atkSkill: SingeClickButtonNode
|
var atkSkill: SkillButtonNode
|
||||||
|
|
||||||
var roundTimerLabel: SKLabelNode
|
var roundTimerLabel: SKLabelNode
|
||||||
let roundTimer: RoundTimer
|
let roundTimer: RoundTimer
|
||||||
@ -50,11 +50,12 @@ class HUD: GKEntity {
|
|||||||
|
|
||||||
self.roundTimer = RoundTimer()
|
self.roundTimer = RoundTimer()
|
||||||
|
|
||||||
spySkill = SingeClickButtonNode(
|
spySkill = SkillButtonNode(
|
||||||
textureName: "yellow_circle",
|
textureName: "spy_button",
|
||||||
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),
|
cooldown: 3,
|
||||||
|
position: CGPoint(x: EntityManager.gameEMInstance.scene.size.width * 0.80, y: EntityManager.gameEMInstance.scene.size.height * 0.1),
|
||||||
onButtonPress: {
|
onButtonPress: {
|
||||||
EntityManager.gameEMInstance.getOpponentBases(for: EntityManager.gameEMInstance.getTeam()).forEach({base in base.component(ofType: TeamComponent.self)?.unitcountLabel.text = "\(base.unitCount)"})
|
EntityManager.gameEMInstance.getOpponentBases(for: EntityManager.gameEMInstance.getTeam()).forEach({base in base.component(ofType: TeamComponent.self)?.unitcountLabel.text = "\(base.unitCount)"})
|
||||||
GameCenterManager.sharedInstance.addAchievementProgress(identifier: "de.hft.stuttgart.ip2.goldwars.skill.first.time", increasePercentComplete: 100)
|
GameCenterManager.sharedInstance.addAchievementProgress(identifier: "de.hft.stuttgart.ip2.goldwars.skill.first.time", increasePercentComplete: 100)
|
||||||
@ -62,11 +63,12 @@ class HUD: GKEntity {
|
|||||||
SoundManager.sharedInstance.playSoundEffect(pathToFile: "use_boost",fileExtension: "wav", volumeLevel: 0.0)
|
SoundManager.sharedInstance.playSoundEffect(pathToFile: "use_boost",fileExtension: "wav", volumeLevel: 0.0)
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
defSkill = SingeClickButtonNode(
|
defSkill = SkillButtonNode(
|
||||||
textureName: "yellow_circle",
|
textureName: "def_button",
|
||||||
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),
|
cooldown: 4,
|
||||||
|
position: CGPoint(x: EntityManager.gameEMInstance.scene.size.width * 0.90, y: EntityManager.gameEMInstance.scene.size.height * 0.1),
|
||||||
onButtonPress: {
|
onButtonPress: {
|
||||||
DataService.sharedInstance.localRoundData.hasDefenceBoost = true
|
DataService.sharedInstance.localRoundData.hasDefenceBoost = true
|
||||||
GameCenterManager.sharedInstance.addAchievementProgress(identifier: "de.hft.stuttgart.ip2.goldwars.skill.first.time", increasePercentComplete: 100)
|
GameCenterManager.sharedInstance.addAchievementProgress(identifier: "de.hft.stuttgart.ip2.goldwars.skill.first.time", increasePercentComplete: 100)
|
||||||
@ -74,11 +76,12 @@ class HUD: GKEntity {
|
|||||||
SoundManager.sharedInstance.playSoundEffect(pathToFile: "use_boost",fileExtension: "wav",volumeLevel: 0.0)
|
SoundManager.sharedInstance.playSoundEffect(pathToFile: "use_boost",fileExtension: "wav",volumeLevel: 0.0)
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
atkSkill = SingeClickButtonNode(
|
atkSkill = SkillButtonNode(
|
||||||
textureName: "yellow_circle",
|
textureName: "atk_button",
|
||||||
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),
|
cooldown: 4,
|
||||||
|
position: CGPoint(x: EntityManager.gameEMInstance.scene.size.width * 0.70, y: EntityManager.gameEMInstance.scene.size.height * 0.1),
|
||||||
onButtonPress: {
|
onButtonPress: {
|
||||||
DataService.sharedInstance.localRoundData.hasAttackBoost = true
|
DataService.sharedInstance.localRoundData.hasAttackBoost = true
|
||||||
GameCenterManager.sharedInstance.addAchievementProgress(identifier: "de.hft.stuttgart.ip2.goldwars.skill.first.time", increasePercentComplete: 100)
|
GameCenterManager.sharedInstance.addAchievementProgress(identifier: "de.hft.stuttgart.ip2.goldwars.skill.first.time", increasePercentComplete: 100)
|
||||||
@ -190,5 +193,12 @@ class HUD: GKEntity {
|
|||||||
])
|
])
|
||||||
currentRoundLabel.run(newRoundAction)
|
currentRoundLabel.run(newRoundAction)
|
||||||
SoundManager.sharedInstance.playSoundEffect(pathToFile: "new_round", fileExtension: "wav", volumeLevel: 0.0)
|
SoundManager.sharedInstance.playSoundEffect(pathToFile: "new_round", fileExtension: "wav", volumeLevel: 0.0)
|
||||||
|
self.decreaseSkillRoundCooldownCounter()
|
||||||
|
}
|
||||||
|
|
||||||
|
func decreaseSkillRoundCooldownCounter() {
|
||||||
|
self.spySkill.decreaseCooldown()
|
||||||
|
self.atkSkill.decreaseCooldown()
|
||||||
|
self.defSkill.decreaseCooldown()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -100,7 +100,6 @@ final class GameCenterManager: NSObject, GKMatchmakerViewControllerDelegate, GKG
|
|||||||
GKAchievement.loadAchievements { (achievements: [GKAchievement]?, err: Error?) in
|
GKAchievement.loadAchievements { (achievements: [GKAchievement]?, err: Error?) in
|
||||||
var achievementExists: Bool = false
|
var achievementExists: Bool = false
|
||||||
achievements?.forEach({ (achievement: GKAchievement) in
|
achievements?.forEach({ (achievement: GKAchievement) in
|
||||||
print(achievement.identifier)
|
|
||||||
if achievement.identifier == identifier {
|
if achievement.identifier == identifier {
|
||||||
achievementExists = true
|
achievementExists = true
|
||||||
achievement.percentComplete += increasePercentComplete
|
achievement.percentComplete += increasePercentComplete
|
||||||
|
Loading…
Reference in New Issue
Block a user