diff --git a/GoldWars/GoldWars.xcodeproj/project.pbxproj b/GoldWars/GoldWars.xcodeproj/project.pbxproj index 22753a8..41c82b9 100644 --- a/GoldWars/GoldWars.xcodeproj/project.pbxproj +++ b/GoldWars/GoldWars.xcodeproj/project.pbxproj @@ -22,6 +22,10 @@ 11738A3B24508F68004426F1 /* Unit.swift in Sources */ = {isa = PBXBuildFile; fileRef = 11738A3A24508F68004426F1 /* Unit.swift */; }; 9E78ACB6245C9A5300526FF7 /* GameKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 9E78ACB5245C9A5300526FF7 /* GameKit.framework */; }; 9E78ACB8245CB75B00526FF7 /* TeamComponent.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9E78ACB7245CB75B00526FF7 /* TeamComponent.swift */; }; + 9E78ACBA245CBDAF00526FF7 /* HUD.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9E78ACB9245CBDAF00526FF7 /* HUD.swift */; }; + 9E78ACBE245CC9C000526FF7 /* AtkBoostSkillComponent.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9E78ACBD245CC9C000526FF7 /* AtkBoostSkillComponent.swift */; }; + 9E78ACC2245CC9EE00526FF7 /* DefBoostSkillComponent.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9E78ACC1245CC9EE00526FF7 /* DefBoostSkillComponent.swift */; }; + 9E78ACC4245CCA3600526FF7 /* SpySkillComponent.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9E78ACC3245CCA3600526FF7 /* SpySkillComponent.swift */; }; 9EA3ABE9245C6DAA006BC61D /* DefaultBaseComponent.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9EA3ABE8245C6DAA006BC61D /* DefaultBaseComponent.swift */; }; 9EA3ABEB245C6DFA006BC61D /* BaseNode.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9EA3ABEA245C6DFA006BC61D /* BaseNode.swift */; }; 9EA3ABED245C8143006BC61D /* ModalBackgroundComponent.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9EA3ABEC245C8143006BC61D /* ModalBackgroundComponent.swift */; }; @@ -70,6 +74,10 @@ 11738A3A24508F68004426F1 /* Unit.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Unit.swift; sourceTree = ""; }; 9E78ACB5245C9A5300526FF7 /* GameKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = GameKit.framework; path = System/Library/Frameworks/GameKit.framework; sourceTree = SDKROOT; }; 9E78ACB7245CB75B00526FF7 /* TeamComponent.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TeamComponent.swift; sourceTree = ""; }; + 9E78ACB9245CBDAF00526FF7 /* HUD.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = HUD.swift; sourceTree = ""; }; + 9E78ACBD245CC9C000526FF7 /* AtkBoostSkillComponent.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AtkBoostSkillComponent.swift; sourceTree = ""; }; + 9E78ACC1245CC9EE00526FF7 /* DefBoostSkillComponent.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DefBoostSkillComponent.swift; sourceTree = ""; }; + 9E78ACC3245CCA3600526FF7 /* SpySkillComponent.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SpySkillComponent.swift; sourceTree = ""; }; 9EA3ABE8245C6DAA006BC61D /* DefaultBaseComponent.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DefaultBaseComponent.swift; sourceTree = ""; }; 9EA3ABEA245C6DFA006BC61D /* BaseNode.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = BaseNode.swift; sourceTree = ""; }; 9EA3ABEC245C8143006BC61D /* ModalBackgroundComponent.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ModalBackgroundComponent.swift; sourceTree = ""; }; @@ -170,6 +178,9 @@ 9EA3ABEE245C834B006BC61D /* ModalContentComponent.swift */, 9EA3ABEA245C6DFA006BC61D /* BaseNode.swift */, 9E78ACB7245CB75B00526FF7 /* TeamComponent.swift */, + 9E78ACBD245CC9C000526FF7 /* AtkBoostSkillComponent.swift */, + 9E78ACC3245CCA3600526FF7 /* SpySkillComponent.swift */, + 9E78ACC1245CC9EE00526FF7 /* DefBoostSkillComponent.swift */, ); path = Components; sourceTree = ""; @@ -180,6 +191,7 @@ ABA03D9F244BD54F00A66916 /* Base.swift */, 9EC86B9E245C88A300796EF3 /* Modal.swift */, 116060F6245C57D2004E5A36 /* EntityManager.swift */, + 9E78ACB9245CBDAF00526FF7 /* HUD.swift */, ); path = Entities; sourceTree = ""; @@ -357,9 +369,12 @@ 9E78ACB8245CB75B00526FF7 /* TeamComponent.swift in Sources */, 9EA3ABEF245C834B006BC61D /* ModalContentComponent.swift in Sources */, 9EC86BA6245C8AD000796EF3 /* ModalType.swift in Sources */, + 9E78ACBE245CC9C000526FF7 /* AtkBoostSkillComponent.swift in Sources */, + 9E78ACC4245CCA3600526FF7 /* SpySkillComponent.swift in Sources */, 9EA3ABEB245C6DFA006BC61D /* BaseNode.swift in Sources */, 110360D9244B101A008610AF /* GameScene.swift in Sources */, 116060F7245C57D2004E5A36 /* EntityManager.swift in Sources */, + 9E78ACBA245CBDAF00526FF7 /* HUD.swift in Sources */, 11738A3B24508F68004426F1 /* Unit.swift in Sources */, 11036113244B3E30008610AF /* MenuScene.swift in Sources */, 9EA3ABE9245C6DAA006BC61D /* DefaultBaseComponent.swift in Sources */, @@ -368,6 +383,7 @@ 110360DB244B101A008610AF /* GameViewController.swift in Sources */, 110360D3244B101A008610AF /* AppDelegate.swift in Sources */, 9EC86B9F245C88A300796EF3 /* Modal.swift in Sources */, + 9E78ACC2245CC9EE00526FF7 /* DefBoostSkillComponent.swift in Sources */, ); runOnlyForDeploymentPostprocessing = 0; }; diff --git a/GoldWars/GoldWars/Components/AtkBoostSkillComponent.swift b/GoldWars/GoldWars/Components/AtkBoostSkillComponent.swift new file mode 100644 index 0000000..febccec --- /dev/null +++ b/GoldWars/GoldWars/Components/AtkBoostSkillComponent.swift @@ -0,0 +1,34 @@ +// +// AtkBoostSkillComponent.swift +// GoldWars +// +// Created by Niko Jochim on 01.05.20. +// Copyright © 2020 SP2. All rights reserved. +// + +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") + } + +} diff --git a/GoldWars/GoldWars/Components/DefBoostSkillComponent.swift b/GoldWars/GoldWars/Components/DefBoostSkillComponent.swift new file mode 100644 index 0000000..62b9b23 --- /dev/null +++ b/GoldWars/GoldWars/Components/DefBoostSkillComponent.swift @@ -0,0 +1,34 @@ +// +// DefBoostSkillComponent.swift +// GoldWars +// +// Created by Niko Jochim on 01.05.20. +// Copyright © 2020 SP2. All rights reserved. +// + +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") + } + +} diff --git a/GoldWars/GoldWars/Components/SpySkillComponent.swift b/GoldWars/GoldWars/Components/SpySkillComponent.swift new file mode 100644 index 0000000..d4fb374 --- /dev/null +++ b/GoldWars/GoldWars/Components/SpySkillComponent.swift @@ -0,0 +1,35 @@ +// +// SpySkillComponent.swift +// GoldWars +// +// Created by Niko Jochim on 01.05.20. +// Copyright © 2020 SP2. All rights reserved. +// + +import GameplayKit + +class SpySkillComponent: 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") + } + +} + diff --git a/GoldWars/GoldWars/Entities/EntityManager.swift b/GoldWars/GoldWars/Entities/EntityManager.swift index 1d9b79d..0ef959e 100644 --- a/GoldWars/GoldWars/Entities/EntityManager.swift +++ b/GoldWars/GoldWars/Entities/EntityManager.swift @@ -35,6 +35,18 @@ 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 skill = entity.component(ofType: DefBoostSkillComponent.self) { + scene.addChild(skill.shapeNode) + scene.addChild(skill.labelNode) + } + if let skill = entity.component(ofType: SpySkillComponent.self) { + scene.addChild(skill.shapeNode) + scene.addChild(skill.labelNode) + } } diff --git a/GoldWars/GoldWars/Entities/HUD.swift b/GoldWars/GoldWars/Entities/HUD.swift new file mode 100644 index 0000000..8c31654 --- /dev/null +++ b/GoldWars/GoldWars/Entities/HUD.swift @@ -0,0 +1,35 @@ +// +// HUD.swift +// GoldWars +// +// Created by Niko Jochim on 01.05.20. +// Copyright © 2020 SP2. All rights reserved. +// + +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))) + + } + + required init?(coder: NSCoder) { + fatalError("init(coder:) has not been implemented") + } + +} diff --git a/GoldWars/GoldWars/Entities/Modal.swift b/GoldWars/GoldWars/Entities/Modal.swift index fbe6a02..0d96a15 100644 --- a/GoldWars/GoldWars/Entities/Modal.swift +++ b/GoldWars/GoldWars/Entities/Modal.swift @@ -19,10 +19,11 @@ class Modal:GKEntity{ case .BaseDetails: addComponent(ModalBackgroundComponent(anchorPoint: anchorPoint)) addComponent(ModalContentComponent(header: "Basis Information", - body: "Diese Basis enthält \(base.unitCount) Einheiten", - footer: "",anchorPoint: anchorPoint)) + body: "Diese Basis enthält \(base.unitCount) Einheiten", + footer: "", + anchorPoint: anchorPoint)) default: - print("Bisch du dumm") + break } } diff --git a/GoldWars/GoldWars/Scenes/GameScene.swift b/GoldWars/GoldWars/Scenes/GameScene.swift index fc059b3..b941b7d 100644 --- a/GoldWars/GoldWars/Scenes/GameScene.swift +++ b/GoldWars/GoldWars/Scenes/GameScene.swift @@ -17,7 +17,7 @@ class GameScene: SKScene{ entityManager = EntityManager(scene: self) entityManager.add(Base(textureName: "Base", team: .team1)) entityManager.add(Base(textureName: "Base", team: .team2)) - + entityManager.add(HUD(size: self.size)) initMap() } @@ -83,7 +83,6 @@ class GameScene: SKScene{ } - override func touchesBegan(_ touches: Set, with event: UIEvent?) { guard let touch = touches.first else { return @@ -112,15 +111,9 @@ class GameScene: SKScene{ entityManager.add(Modal(modaltype: .BaseDetails, base: entity as! Base, anchorPoint: CGPoint(x: self.size.width / 2 , y: self.size.height / 2))) - } - } - - - } - } }