Merge branch '58-spy-boost-faehigkeit-implementieren' into 'development'

Resolve "Spy-Boost Faehigkeit implementieren"

Closes #58

See merge request marcel.schwarz/software-projekt-2!102
This commit is contained in:
Aldin Duraki 2020-06-02 21:47:18 +00:00
commit fbc6a63232
2 changed files with 18 additions and 6 deletions

View File

@ -217,6 +217,14 @@ class EntityManager {
return entities.filter{$0 is Base && ($0 as! Base).component(ofType: TeamComponent.self)?.team == team } as! Set<Base> return entities.filter{$0 is Base && ($0 as! Base).component(ofType: TeamComponent.self)?.team == team } as! Set<Base>
} }
func getOpponentBases(for team: Team) -> Set<Base> {
if(team == .team1){
return getBasesByTeam(for: .team2)
}else {
return getBasesByTeam(for: .team1)
}
}
func getBasesByPlayer(for player: GKPlayer) -> Set<Base> { func getBasesByPlayer(for player: GKPlayer) -> Set<Base> {
return entities.filter{$0 is Base && ($0 as! Base).component(ofType: TeamComponent.self)?.player == player } as! Set<Base> return entities.filter{$0 is Base && ($0 as! Base).component(ofType: TeamComponent.self)?.player == player } as! Set<Base>
} }
@ -238,6 +246,10 @@ class EntityManager {
return entities.filter { $0 is Base && ($0 as! Base).component(ofType: TeamComponent.self)?.player.displayName == playerName }[0].component(ofType: TeamComponent.self)!.team return entities.filter { $0 is Base && ($0 as! Base).component(ofType: TeamComponent.self)?.player.displayName == playerName }[0].component(ofType: TeamComponent.self)!.team
} }
func getTeam() -> Team {
return entities.filter { $0 is Base && ($0 as! Base).component(ofType: TeamComponent.self)?.player.displayName == GKLocalPlayer.local.displayName }[0].component(ofType: TeamComponent.self)!.team
}
func getBasebyID(id: Int) -> Base?{ func getBasebyID(id: Int) -> Base?{
for entity in entities { for entity in entities {
if entity is Base && (entity as! Base).baseID == id { if entity is Base && (entity as! Base).baseID == id {

View File

@ -56,7 +56,7 @@ class HUD: GKEntity {
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.75, y: EntityManager.gameEMInstance.scene.size.height * 0.1),
onButtonPress: { onButtonPress: {
print("Not implemented") EntityManager.gameEMInstance.getOpponentBases(for: EntityManager.gameEMInstance.getTeam()).forEach({base in base.component(ofType: DefaultBaseComponent.self)?.labelNode.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)
GameCenterManager.sharedInstance.addAchievementProgress(identifier: "de.hft.stuttgart.ip2.goldwars.skill.spy.ten", increasePercentComplete: 10) GameCenterManager.sharedInstance.addAchievementProgress(identifier: "de.hft.stuttgart.ip2.goldwars.skill.spy.ten", increasePercentComplete: 10)
} }
@ -70,7 +70,7 @@ class HUD: GKEntity {
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)
GameCenterManager.sharedInstance.addAchievementProgress(identifier: "de.hft.stuttgart.ip2.goldwars.skill.def.ten", increasePercentComplete: 10) GameCenterManager.sharedInstance.addAchievementProgress(identifier: "de.hft.stuttgart.ip2.goldwars.skill.def.ten", increasePercentComplete: 10)
} }
) )
atkSkill = SingeClickButtonNode( atkSkill = SingeClickButtonNode(
textureName: "yellow_circle", textureName: "yellow_circle",
@ -78,10 +78,10 @@ class HUD: GKEntity {
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.95, 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)
GameCenterManager.sharedInstance.addAchievementProgress(identifier: "de.hft.stuttgart.ip2.goldwars.skill.atk.ten", increasePercentComplete: 10) GameCenterManager.sharedInstance.addAchievementProgress(identifier: "de.hft.stuttgart.ip2.goldwars.skill.atk.ten", increasePercentComplete: 10)
} }
) )
finishButton = SingeClickButtonNode( finishButton = SingeClickButtonNode(