Merge branch '56-attack-boost-faehigkeit-implementieren' into 'development'

Resolve "Attack/Defence Boost Faehigkeit implementieren"

Closes #57 and #56

See merge request marcel.schwarz/software-projekt-2!61
This commit is contained in:
Aldin Duraki 2020-05-20 19:04:41 +00:00
commit fbe8dbde9d
8 changed files with 164 additions and 76 deletions

View File

@ -16,13 +16,14 @@
110360EE244B101B008610AF /* GoldWarsTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 110360ED244B101B008610AF /* GoldWarsTests.swift */; };
11036113244B3E30008610AF /* MenuScene.swift in Sources */ = {isa = PBXBuildFile; fileRef = 11036112244B3E30008610AF /* MenuScene.swift */; };
116060F7245C57D2004E5A36 /* EntityManager.swift in Sources */ = {isa = PBXBuildFile; fileRef = 116060F6245C57D2004E5A36 /* EntityManager.swift */; };
11738A3B24508F68004426F1 /* Unit.swift in Sources */ = {isa = PBXBuildFile; fileRef = 11738A3A24508F68004426F1 /* Unit.swift */; };
11738A3B24508F68004426F1 /* UnitType.swift in Sources */ = {isa = PBXBuildFile; fileRef = 11738A3A24508F68004426F1 /* UnitType.swift */; };
2086465C2461B66200817C23 /* TimerComponent.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2086465B2461B66200817C23 /* TimerComponent.swift */; };
3E67854024728368007B9DE4 /* CElements.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3E67853F24728368007B9DE4 /* CElements.swift */; };
3E6785422472CBEC007B9DE4 /* Way.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3E6785412472CBEC007B9DE4 /* Way.swift */; };
3E6785442472CC27007B9DE4 /* DefaultWayComponent.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3E6785432472CC27007B9DE4 /* DefaultWayComponent.swift */; };
3EBD242C245D8044003CECE7 /* GameCenterHelper.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3EBD242B245D8044003CECE7 /* GameCenterHelper.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 */; };
3FE19DB5246C7A22004827AB /* RoundCalculatorService.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3FE19DB4246C7A22004827AB /* RoundCalculatorService.swift */; };
9E04AFAF245E2B73002D5CFC /* AttackActionComponent.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9E04AFAE245E2B73002D5CFC /* AttackActionComponent.swift */; };
@ -89,13 +90,14 @@
110360EF244B101B008610AF /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
11036112244B3E30008610AF /* MenuScene.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MenuScene.swift; sourceTree = "<group>"; };
116060F6245C57D2004E5A36 /* EntityManager.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = EntityManager.swift; sourceTree = "<group>"; };
11738A3A24508F68004426F1 /* Unit.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Unit.swift; sourceTree = "<group>"; };
11738A3A24508F68004426F1 /* UnitType.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = UnitType.swift; sourceTree = "<group>"; };
2086465B2461B66200817C23 /* TimerComponent.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TimerComponent.swift; sourceTree = "<group>"; };
3E67853F24728368007B9DE4 /* CElements.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CElements.swift; sourceTree = "<group>"; };
3E6785412472CBEC007B9DE4 /* Way.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Way.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>"; };
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>"; };
3FE19DB4246C7A22004827AB /* RoundCalculatorService.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = RoundCalculatorService.swift; sourceTree = "<group>"; };
9E04AFAE245E2B73002D5CFC /* AttackActionComponent.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AttackActionComponent.swift; sourceTree = "<group>"; };
@ -238,6 +240,7 @@
9EBFD7542462CF5A00E1E219 /* SliderComponent.swift */,
9EC7E48A2461FBF700396BCD /* SliderNode.swift */,
3E6785432472CC27007B9DE4 /* DefaultWayComponent.swift */,
8BB6FF3F2472B8F000162BBD /* SkillButtonNode.swift */,
);
path = Components;
sourceTree = "<group>";
@ -276,7 +279,7 @@
9EC86BA2245C89B200796EF3 /* Enums */ = {
isa = PBXGroup;
children = (
11738A3A24508F68004426F1 /* Unit.swift */,
11738A3A24508F68004426F1 /* UnitType.swift */,
9EC86BA5245C8AD000796EF3 /* ModalType.swift */,
3EBD242D245D9332003CECE7 /* Team.swift */,
3F745DEF246F48FC00CE7375 /* PlayerMoveType.swift */,
@ -434,7 +437,7 @@
9E174C88245DF1FF00209FF0 /* BackgroundComponent.swift in Sources */,
9E78ACBA245CBDAF00526FF7 /* HUD.swift in Sources */,
9EEDE02D246FCD770096C735 /* SpinningLogoEntity.swift in Sources */,
11738A3B24508F68004426F1 /* Unit.swift in Sources */,
11738A3B24508F68004426F1 /* UnitType.swift in Sources */,
9E174C86245DD91500209FF0 /* ButtonComponent.swift in Sources */,
AE151589245F18EF001D363E /* MatchmakingHelper.swift in Sources */,
11036113244B3E30008610AF /* MenuScene.swift in Sources */,
@ -442,6 +445,7 @@
AB21D7D5246C748A00B09CBA /* TwoPlayerMapGenerator.swift in Sources */,
9EA3ABE9245C6DAA006BC61D /* DefaultBaseComponent.swift in Sources */,
9E174C8A245E1A0A00209FF0 /* Background.swift in Sources */,
8BB6FF402472B8F000162BBD /* SkillButtonNode.swift in Sources */,
9EA3ABED245C8143006BC61D /* ModalBackgroundComponent.swift in Sources */,
C064E9A8246C0EA50022B228 /* LabelNode.swift in Sources */,
3EBD242C245D8044003CECE7 /* GameCenterHelper.swift in Sources */,

View File

@ -9,25 +9,31 @@
import GameplayKit
class AtkBoostSkillComponent: GKComponent{
let shapeNode: SKShapeNode
let labelNode: SKLabelNode
init(text: String, texture: SKTexture?, anchorPoint: CGPoint) {
self.labelNode = SKLabelNode(text: text)
self.shapeNode = SKShapeNode(circleOfRadius: 30)
self.shapeNode.position = anchorPoint
self.labelNode.position = CGPoint(x: anchorPoint.x, y: anchorPoint.y - 15)
if texture != nil {
shapeNode.fillTexture = texture
}else {
shapeNode.fillColor = SKColor.gray
}
super.init()
}
required init?(coder: NSCoder) {
fatalError("init(coder:) has not been implemented")
}
var skillButtonNode: SkillButtonNode
init(iconName: String, text: String, position: CGPoint, isEnabled:Bool) {
skillButtonNode = SkillButtonNode(iconName: iconName,
text: text,
isEnabled: isEnabled,
position: position,
onButtonPress: {
var bases: Set<Base> = EntityManager.sharedInstance.getBasesByTeam(for: .team2)
bases.forEach{ base in
if(base.unitType == .Defence){
base.unitType = .AttackDefence
}else {
base.unitType = .Attack
}
}
})
super.init()
}
required init?(coder: NSCoder) {
fatalError("init(coder:) has not been implemented")
}
}

View File

@ -9,25 +9,29 @@
import GameplayKit
class DefBoostSkillComponent: GKComponent{
let shapeNode: SKShapeNode
let labelNode: SKLabelNode
init(text: String, texture: SKTexture?, anchorPoint: CGPoint) {
self.labelNode = SKLabelNode(text: text)
self.shapeNode = SKShapeNode(circleOfRadius: 30)
self.shapeNode.position = anchorPoint
self.labelNode.position = CGPoint(x: anchorPoint.x, y: anchorPoint.y - 15)
if texture != nil {
shapeNode.fillTexture = texture
}else {
shapeNode.fillColor = SKColor.gray
}
super.init()
}
required init?(coder: NSCoder) {
fatalError("init(coder:) has not been implemented")
}
var skillButtonNode: SkillButtonNode
init(iconName: String, text: String, position: CGPoint, isEnabled:Bool) {
skillButtonNode = SkillButtonNode(iconName: iconName,
text: text,
isEnabled: isEnabled,
position: position,
onButtonPress: {
var bases: Set<Base> = EntityManager.sharedInstance.getBasesByTeam(for: .team2)
bases.forEach{ base in
if(base.unitType == .Attack){
base.unitType = .AttackDefence
}else {
base.unitType = .Defence
}
}
})
super.init()
}
required init?(coder: NSCoder) {
fatalError("init(coder:) has not been implemented")
}
}

View File

@ -0,0 +1,76 @@
//
// SkillButtonNode.swift
// GoldWars
//
// Created by Simon Kellner on 18.05.20.
// Copyright © 2020 SP2. All rights reserved.
//
import SpriteKit
class SkillButtonNode: SKSpriteNode {
var isEnabled: Bool{
didSet{
if isEnabled {
self.alpha = 1
self.childNode(withName: "label")?.alpha = 1
} else {
self.alpha = 0.3
self.childNode(withName: "label")?.alpha = 0.3
}
}
}
let onButtonPress: () -> ()
init(iconName: String, text: String, isEnabled: Bool, position: CGPoint, onButtonPress: @escaping () -> ()) {
self.onButtonPress = onButtonPress
self.isEnabled = isEnabled
let texture = SKTexture(imageNamed: "yellow_circle")
super.init(texture: texture, color: SKColor.white, size: texture.size())
self.position = position
let label = SKLabelNode(fontNamed: "Courier-Bold")
label.fontSize = 30
label.fontColor = SKColor.black
label.zPosition = 1
label.verticalAlignmentMode = .center
label.text = text
label.name = "label"
if iconName.isEmpty {
label.position = CGPoint(x: 0, y: 0)
} else {
label.position = CGPoint(x: size.width * 0.5, y: 0)
let icon = SKSpriteNode(imageNamed: iconName)
icon.position = CGPoint(x: -size.width * 0.5, y: 0)
icon.zPosition = 1
self.addChild(icon)
}
self.addChild(label)
isUserInteractionEnabled = true
}
override func touchesBegan(_ touches: Set<UITouch>, with event: UIEvent?) {
if isEnabled {
let action = SKAction.sequence(
[
SKAction.scale(by: (3/4), duration: 0.3),
SKAction.scale(by: (4/3), duration: 0.3),
]
)
self.childNode(withName: "label")?.run(action)
self.run(action)
self.isEnabled = false
onButtonPress()
}
}
required init?(coder aDecoder: NSCoder) {
fatalError("init(coder:) has not been implemented")
}
}

View File

@ -13,6 +13,7 @@ import GameKit
class Base: GKEntity{
static var BASE_ID_COUNT: Int = 0
var unitCount: Int
var unitType: UnitType
var adjacencyList: Array<Base>
var changeOwnership: Bool
var ownershipPlayer: GKPlayer?
@ -21,6 +22,7 @@ class Base: GKEntity{
init(position: CGPoint, player: GKPlayer! = nil, team: Team! = nil) {
self.unitCount = 0
self.unitType = .General
self.adjacencyList = [Base]()
self.changeOwnership = false
self.ownershipPlayer = player

View File

@ -44,13 +44,12 @@ class EntityManager {
scene.addChild(modal.body)
scene.addChild(modal.footer)
}
if let skill = entity.component(ofType: AtkBoostSkillComponent.self) {
scene.addChild(skill.shapeNode)
scene.addChild(skill.labelNode)
if let skillButtonNode = entity.component(ofType: AtkBoostSkillComponent.self)?.skillButtonNode {
scene.addChild(skillButtonNode)
isModal = true
}
if let skill = entity.component(ofType: DefBoostSkillComponent.self) {
scene.addChild(skill.shapeNode)
scene.addChild(skill.labelNode)
if let skillButtonNode = entity.component(ofType: DefBoostSkillComponent.self)?.skillButtonNode {
scene.addChild(skillButtonNode)
}
if let skill = entity.component(ofType: SpySkillComponent.self) {
scene.addChild(skill.shapeNode)

View File

@ -9,29 +9,25 @@
import GameplayKit
class HUD: GKEntity {
init(size: CGSize) {
super.init()
addComponent(SpySkillComponent(text: "Spy",
texture: nil,
anchorPoint: CGPoint(x: size.width * 0.75, y: size.height * 0.1)))
addComponent(AtkBoostSkillComponent(text: "Atk",
texture: nil,
anchorPoint: CGPoint(x: size.width * 0.85, y: size.height * 0.1)))
addComponent(DefBoostSkillComponent(text: "Def",
texture: nil,
anchorPoint: CGPoint(x: size.width * 0.95, y: size.height * 0.1)))
init(size: CGSize) {
super.init()
addComponent(SpySkillComponent(text: "Spy",
texture: nil,
anchorPoint: CGPoint(x: size.width * 0.75, y: size.height * 0.1)))
addComponent(AtkBoostSkillComponent(iconName: "", text: "Atk", position: CGPoint(x: size.width * 0.85, y: size.height * 0.1), isEnabled: true))
addComponent(DefBoostSkillComponent(iconName: "", text: "Def", position: CGPoint(x: size.width * 0.95, y: size.height * 0.1), isEnabled: true))
addComponent(TimerComponent(text: "",
anchorPoint: CGPoint(x: size.width * 0.5, y: size.height * 0.9), duration: 30))
}
required init?(coder: NSCoder) {
fatalError("init(coder:) has not been implemented")
}
anchorPoint: CGPoint(x: size.width * 0.5, y: size.height * 0.9), duration: 30))
}
required init?(coder: NSCoder) {
fatalError("init(coder:) has not been implemented")
}
}

View File

@ -6,8 +6,9 @@
// Copyright © 2020 SP2. All rights reserved.
//
enum Unit{
enum UnitType{
case General
case Defence
case Attack
case AttackDefence
}