Revert "Merge branch '33-basisownership-anhand-des-gkplayers' into 'development'"
This reverts merge request !54
This commit is contained in:
parent
bd5d142a43
commit
4189d0f634
@ -10,24 +10,24 @@ import GameplayKit
|
||||
|
||||
class AtkBoostSkillComponent: GKComponent{
|
||||
|
||||
let shapeNode: SKShapeNode
|
||||
let labelNode: SKLabelNode
|
||||
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()
|
||||
}
|
||||
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")
|
||||
}
|
||||
required init?(coder: NSCoder) {
|
||||
fatalError("init(coder:) has not been implemented")
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -24,7 +24,7 @@ class BackgroundComponent: GKComponent{
|
||||
nodes.append(sky)
|
||||
}
|
||||
super.init()
|
||||
}
|
||||
}
|
||||
|
||||
func update(){
|
||||
for node in nodes{
|
||||
|
@ -10,25 +10,25 @@ import SpriteKit
|
||||
|
||||
class BaseNode: SKSpriteNode{
|
||||
|
||||
override func touchesBegan(_ touches: Set<UITouch>, with event: UIEvent?) {
|
||||
// TODO: PopUp Einheiten + Close PopUp
|
||||
self.run(
|
||||
SKAction.sequence(
|
||||
[
|
||||
SKAction.resize(byWidth: 20, height: 20, duration: 0.5),
|
||||
SKAction.resize(byWidth: -20, height: -20, duration: 0.5)
|
||||
]
|
||||
)
|
||||
)
|
||||
}
|
||||
override func touchesBegan(_ touches: Set<UITouch>, with event: UIEvent?) {
|
||||
// TODO: PopUp Einheiten + Close PopUp
|
||||
self.run(
|
||||
SKAction.sequence(
|
||||
[
|
||||
SKAction.resize(byWidth: 20, height: 20, duration: 0.5),
|
||||
SKAction.resize(byWidth: -20, height: -20, duration: 0.5)
|
||||
]
|
||||
)
|
||||
)
|
||||
}
|
||||
|
||||
override func touchesMoved(_ touches: Set<UITouch>, with event: UIEvent?) {
|
||||
// TODO: zeige Angirff Effect
|
||||
}
|
||||
override func touchesMoved(_ touches: Set<UITouch>, with event: UIEvent?) {
|
||||
// TODO: zeige Angirff Effect
|
||||
}
|
||||
|
||||
override func touchesEnded(_ touches: Set<UITouch>, with event: UIEvent?) {
|
||||
// TODO: Open Slider PopUp
|
||||
}
|
||||
override func touchesEnded(_ touches: Set<UITouch>, with event: UIEvent?) {
|
||||
// TODO: Open Slider PopUp
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
@ -18,7 +18,7 @@ class ButtonNode: SKSpriteNode {
|
||||
} else {
|
||||
self.alpha = 0.3
|
||||
self.childNode(withName: "label")?.alpha = 0.3
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -50,26 +50,26 @@ class ButtonNode: SKSpriteNode {
|
||||
}
|
||||
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)
|
||||
onButtonPress()
|
||||
}
|
||||
|
||||
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)
|
||||
onButtonPress()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
required init?(coder aDecoder: NSCoder) {
|
||||
fatalError("init(coder:) has not been implemented")
|
||||
}
|
||||
required init?(coder aDecoder: NSCoder) {
|
||||
fatalError("init(coder:) has not been implemented")
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -10,24 +10,24 @@ import GameplayKit
|
||||
|
||||
class DefBoostSkillComponent: GKComponent{
|
||||
|
||||
let shapeNode: SKShapeNode
|
||||
let labelNode: SKLabelNode
|
||||
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()
|
||||
}
|
||||
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")
|
||||
}
|
||||
required init?(coder: NSCoder) {
|
||||
fatalError("init(coder:) has not been implemented")
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -10,15 +10,15 @@ import GameplayKit
|
||||
import SpriteKit
|
||||
|
||||
class DefaultBaseComponent: GKComponent {
|
||||
var spriteNode: BaseNode
|
||||
var spriteNode: BaseNode
|
||||
|
||||
init(texture: SKTexture, position: CGPoint) {
|
||||
spriteNode = BaseNode(texture: texture, size: CGSize(width: 80, height: 80))
|
||||
spriteNode.position = position
|
||||
super.init()
|
||||
}
|
||||
init(texture: SKTexture, position: CGPoint) {
|
||||
spriteNode = BaseNode(texture: texture, size: CGSize(width: 80, height: 80))
|
||||
spriteNode.position = position
|
||||
super.init()
|
||||
}
|
||||
|
||||
required init?(coder aDecoder: NSCoder) {
|
||||
fatalError("init(coder:) has not been implemented")
|
||||
}
|
||||
required init?(coder aDecoder: NSCoder) {
|
||||
fatalError("init(coder:) has not been implemented")
|
||||
}
|
||||
}
|
||||
|
@ -10,17 +10,17 @@ import GameplayKit
|
||||
import SpriteKit
|
||||
|
||||
class ModalBackgroundComponent: GKComponent {
|
||||
let spriteNode: SKSpriteNode
|
||||
let spriteNode: SKSpriteNode
|
||||
|
||||
init(anchorPoint: CGPoint) {
|
||||
let texture = SKTexture(imageNamed:"ModalBackground")
|
||||
spriteNode = SKSpriteNode(texture: texture, size: texture.size())
|
||||
spriteNode.setScale(2)
|
||||
spriteNode.position = anchorPoint
|
||||
super.init()
|
||||
}
|
||||
init(anchorPoint: CGPoint) {
|
||||
let texture = SKTexture(imageNamed:"ModalBackground")
|
||||
spriteNode = SKSpriteNode(texture: texture, size: texture.size())
|
||||
spriteNode.setScale(2)
|
||||
spriteNode.position = anchorPoint
|
||||
super.init()
|
||||
}
|
||||
|
||||
required init?(coder aDecoder: NSCoder) {
|
||||
fatalError("init(coder:) has not been implemented")
|
||||
}
|
||||
required init?(coder aDecoder: NSCoder) {
|
||||
fatalError("init(coder:) has not been implemented")
|
||||
}
|
||||
}
|
||||
|
@ -11,32 +11,32 @@ import SpriteKit
|
||||
|
||||
class ModalContentComponent: GKComponent{
|
||||
|
||||
var header: SKLabelNode
|
||||
var body: SKLabelNode
|
||||
var footer: SKLabelNode
|
||||
var header: SKLabelNode
|
||||
var body: SKLabelNode
|
||||
var footer: SKLabelNode
|
||||
|
||||
init(header: String, body: String, footer: String , anchorPoint: CGPoint) {
|
||||
self.header = SKLabelNode(text: header)
|
||||
self.header.position = CGPoint(x: anchorPoint.x, y: anchorPoint.y + 125)
|
||||
self.header.fontName = "HelveticaNeue-Bold"
|
||||
self.header.fontSize = 40
|
||||
init(header: String, body: String, footer: String , anchorPoint: CGPoint) {
|
||||
self.header = SKLabelNode(text: header)
|
||||
self.header.position = CGPoint(x: anchorPoint.x, y: anchorPoint.y + 125)
|
||||
self.header.fontName = "HelveticaNeue-Bold"
|
||||
self.header.fontSize = 40
|
||||
|
||||
self.body = SKLabelNode(text: body)
|
||||
self.body.position = CGPoint(x: anchorPoint.x, y: anchorPoint.y - 20)
|
||||
self.body.numberOfLines = 2
|
||||
self.body.preferredMaxLayoutWidth = 390
|
||||
self.body.horizontalAlignmentMode = SKLabelHorizontalAlignmentMode.center
|
||||
self.body.fontName = "HelveticaNeue-Bold"
|
||||
self.body.fontSize = 40
|
||||
self.body = SKLabelNode(text: body)
|
||||
self.body.position = CGPoint(x: anchorPoint.x, y: anchorPoint.y - 20)
|
||||
self.body.numberOfLines = 2
|
||||
self.body.preferredMaxLayoutWidth = 390
|
||||
self.body.horizontalAlignmentMode = SKLabelHorizontalAlignmentMode.center
|
||||
self.body.fontName = "HelveticaNeue-Bold"
|
||||
self.body.fontSize = 40
|
||||
|
||||
self.footer = SKLabelNode(text: footer)
|
||||
self.footer.position = CGPoint(x: anchorPoint.x, y: anchorPoint.y - 40)
|
||||
self.footer.fontName = "HelveticaNeue-Bold"
|
||||
self.footer.fontSize = 40
|
||||
super.init()
|
||||
}
|
||||
self.footer = SKLabelNode(text: footer)
|
||||
self.footer.position = CGPoint(x: anchorPoint.x, y: anchorPoint.y - 40)
|
||||
self.footer.fontName = "HelveticaNeue-Bold"
|
||||
self.footer.fontSize = 40
|
||||
super.init()
|
||||
}
|
||||
|
||||
required init?(coder aDecoder: NSCoder) {
|
||||
fatalError("init(coder:) has not been implemented")
|
||||
}
|
||||
required init?(coder aDecoder: NSCoder) {
|
||||
fatalError("init(coder:) has not been implemented")
|
||||
}
|
||||
}
|
||||
|
@ -10,14 +10,14 @@ import GameplayKit
|
||||
|
||||
class SliderComponent: GKComponent {
|
||||
|
||||
var sliderNode: SliderNode
|
||||
var sliderNode: SliderNode
|
||||
|
||||
init(width: CGFloat, position: CGPoint) {
|
||||
sliderNode = SliderNode(width: width, position: position)
|
||||
super.init()
|
||||
}
|
||||
init(width: CGFloat, position: CGPoint) {
|
||||
sliderNode = SliderNode(width: width, position: position)
|
||||
super.init()
|
||||
}
|
||||
|
||||
required init?(coder: NSCoder) {
|
||||
fatalError("init(coder:) has not been implemented")
|
||||
}
|
||||
required init?(coder: NSCoder) {
|
||||
fatalError("init(coder:) has not been implemented")
|
||||
}
|
||||
}
|
||||
|
@ -11,56 +11,56 @@ import SpriteKit
|
||||
|
||||
class SliderNode :SKNode {
|
||||
|
||||
var sliderLine :SKShapeNode
|
||||
var sliderKnob :SliderKnob
|
||||
var width: CGFloat
|
||||
var sliderLine :SKShapeNode
|
||||
var sliderKnob :SliderKnob
|
||||
var width: CGFloat
|
||||
|
||||
var getValue: CGFloat{
|
||||
get{
|
||||
return ((sliderKnob.position.x.rounded() - sliderKnob.min) / width)
|
||||
}
|
||||
}
|
||||
var getValue: CGFloat{
|
||||
get{
|
||||
return ((sliderKnob.position.x.rounded() - sliderKnob.min) / width)
|
||||
}
|
||||
}
|
||||
|
||||
init(width: CGFloat, position: CGPoint) {
|
||||
self.width = width
|
||||
sliderLine = SKShapeNode(rectOf: CGSize(width: width, height: 8))
|
||||
sliderLine.position = position
|
||||
sliderLine.fillColor = SKColor.white
|
||||
sliderKnob = SliderKnob(circleOfRadius: 20)
|
||||
sliderKnob.min = position.x - width / 2
|
||||
sliderKnob.max = position.x + width / 2
|
||||
sliderKnob.fillColor = SKColor.red
|
||||
sliderKnob.zPosition = sliderLine.zPosition + 1
|
||||
sliderKnob.position = CGPoint(x: sliderLine.position.x, y: sliderLine.position.y + 1)
|
||||
super.init()
|
||||
init(width: CGFloat, position: CGPoint) {
|
||||
self.width = width
|
||||
sliderLine = SKShapeNode(rectOf: CGSize(width: width, height: 8))
|
||||
sliderLine.position = position
|
||||
sliderLine.fillColor = SKColor.white
|
||||
sliderKnob = SliderKnob(circleOfRadius: 20)
|
||||
sliderKnob.min = position.x - width / 2
|
||||
sliderKnob.max = position.x + width / 2
|
||||
sliderKnob.fillColor = SKColor.red
|
||||
sliderKnob.zPosition = sliderLine.zPosition + 1
|
||||
sliderKnob.position = CGPoint(x: sliderLine.position.x, y: sliderLine.position.y + 1)
|
||||
super.init()
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
required init?(coder aDecoder: NSCoder) {
|
||||
fatalError("init(coder:) has not been implemented")
|
||||
}
|
||||
required init?(coder aDecoder: NSCoder) {
|
||||
fatalError("init(coder:) has not been implemented")
|
||||
}
|
||||
}
|
||||
|
||||
class SliderKnob: SKShapeNode {
|
||||
var min = CGFloat()
|
||||
var max = CGFloat()
|
||||
var min = CGFloat()
|
||||
var max = CGFloat()
|
||||
|
||||
override func touchesMoved(_ touches: Set<UITouch>, with event: UIEvent?) {
|
||||
override func touchesMoved(_ touches: Set<UITouch>, with event: UIEvent?) {
|
||||
|
||||
for touch in touches {
|
||||
let touchLocation = touch.location(in: self.scene!)
|
||||
for touch in touches {
|
||||
let touchLocation = touch.location(in: self.scene!)
|
||||
|
||||
if self.position.x >= min - 1 && self.position.x <= max + 1{
|
||||
self.position.x = touchLocation.x
|
||||
}
|
||||
if self.position.x >= min - 1 && self.position.x <= max + 1{
|
||||
self.position.x = touchLocation.x
|
||||
}
|
||||
|
||||
if(self.position.x <= min){
|
||||
self.position.x = min
|
||||
}
|
||||
if(self.position.x >= max){
|
||||
self.position.x = max
|
||||
}
|
||||
}
|
||||
}
|
||||
if(self.position.x <= min){
|
||||
self.position.x = min
|
||||
}
|
||||
if(self.position.x >= max){
|
||||
self.position.x = max
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -10,25 +10,25 @@ import GameplayKit
|
||||
|
||||
class SpySkillComponent: GKComponent{
|
||||
|
||||
let shapeNode: SKShapeNode
|
||||
let labelNode: SKLabelNode
|
||||
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()
|
||||
}
|
||||
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")
|
||||
}
|
||||
required init?(coder: NSCoder) {
|
||||
fatalError("init(coder:) has not been implemented")
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
@ -24,11 +24,11 @@ class TeamComponent: GKComponent {
|
||||
fire.particleColorBlendFactor = 1.0
|
||||
|
||||
switch team {
|
||||
case .team1: fire.particleColor = SKColor.red
|
||||
case .team2: fire.particleColor = SKColor.purple
|
||||
case .team3: fire.particleColor = SKColor.green
|
||||
case .team4: fire.particleColor = SKColor.gray
|
||||
}
|
||||
case .team1: fire.particleColor = SKColor.red
|
||||
case .team2: fire.particleColor = SKColor.purple
|
||||
case .team3: fire.particleColor = SKColor.green
|
||||
case .team4: fire.particleColor = SKColor.gray
|
||||
}
|
||||
|
||||
self.team = team
|
||||
self.player = player
|
||||
|
@ -14,7 +14,7 @@ class TimerComponent: GKComponent {
|
||||
var endTime :Date!
|
||||
var duration :Double
|
||||
|
||||
init(text: String, anchorPoint: CGPoint, duration: TimeInterval) {
|
||||
init(text: String, anchorPoint: CGPoint, duration: TimeInterval) {
|
||||
self.labelNode = SKLabelNode(text: text)
|
||||
self.labelNode.fontColor = UIColor.black
|
||||
self.labelNode.fontSize = CGFloat(45)
|
||||
|
@ -16,7 +16,7 @@ class Background: GKEntity {
|
||||
}
|
||||
|
||||
override func update(deltaTime seconds: TimeInterval) {
|
||||
component(ofType: BackgroundComponent.self)?.update()
|
||||
component(ofType: BackgroundComponent.self)?.update()
|
||||
}
|
||||
|
||||
required init?(coder: NSCoder) {
|
||||
|
@ -8,7 +8,6 @@
|
||||
|
||||
import SpriteKit
|
||||
import GameplayKit
|
||||
import GameKit
|
||||
|
||||
class Base: GKEntity {
|
||||
|
||||
@ -17,7 +16,7 @@ class Base: GKEntity {
|
||||
var changeOwnership: Bool
|
||||
var ownershipPlayer: GKPlayer?
|
||||
|
||||
init(position: CGPoint, player: GKPlayer? = nil, team: Team? = nil) {
|
||||
init(position: CGPoint, team: Team! = nil) {
|
||||
self.unitCount = 0
|
||||
self.adjacencyList = [Base]()
|
||||
self.changeOwnership = false
|
||||
|
@ -14,42 +14,42 @@ class EntityManager {
|
||||
|
||||
var entities = Set<GKEntity>()
|
||||
let scene: SKScene
|
||||
var isModal: Bool
|
||||
var isModal: Bool
|
||||
|
||||
init(scene: SKScene) {
|
||||
self.scene = scene
|
||||
isModal = false
|
||||
isModal = false
|
||||
}
|
||||
|
||||
func add(_ entity: GKEntity) {
|
||||
entities.insert(entity)
|
||||
if let spriteNode = entity.component(ofType: DefaultBaseComponent.self)?.spriteNode {
|
||||
scene.addChild(spriteNode)
|
||||
}
|
||||
if let fire = entity.component(ofType: TeamComponent.self)?.fire{
|
||||
scene.addChild(fire)
|
||||
}
|
||||
if let spriteNode = entity.component(ofType: ModalBackgroundComponent.self)?.spriteNode {
|
||||
scene.addChild(spriteNode)
|
||||
isModal = true
|
||||
}
|
||||
if let modal = entity.component(ofType: ModalContentComponent.self) {
|
||||
scene.addChild(modal.header)
|
||||
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)
|
||||
}
|
||||
if let spriteNode = entity.component(ofType: DefaultBaseComponent.self)?.spriteNode {
|
||||
scene.addChild(spriteNode)
|
||||
}
|
||||
if let fire = entity.component(ofType: TeamComponent.self)?.fire{
|
||||
scene.addChild(fire)
|
||||
}
|
||||
if let spriteNode = entity.component(ofType: ModalBackgroundComponent.self)?.spriteNode {
|
||||
scene.addChild(spriteNode)
|
||||
isModal = true
|
||||
}
|
||||
if let modal = entity.component(ofType: ModalContentComponent.self) {
|
||||
scene.addChild(modal.header)
|
||||
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)
|
||||
}
|
||||
if let timer = entity.component(ofType: TimerComponent.self) {
|
||||
scene.addChild(timer.labelNode)
|
||||
}
|
||||
@ -61,29 +61,29 @@ class EntityManager {
|
||||
scene.addChild(node)
|
||||
}
|
||||
}
|
||||
if let sliderNode = entity.component(ofType: SliderComponent.self)?.sliderNode {
|
||||
scene.addChild(sliderNode.sliderKnob)
|
||||
scene.addChild(sliderNode.sliderLine)
|
||||
}
|
||||
if let sliderNode = entity.component(ofType: SliderComponent.self)?.sliderNode {
|
||||
scene.addChild(sliderNode.sliderKnob)
|
||||
scene.addChild(sliderNode.sliderLine)
|
||||
}
|
||||
}
|
||||
|
||||
func remove(_ entity: GKEntity) {
|
||||
if let spriteNode = entity.component(ofType: DefaultBaseComponent.self)?.spriteNode {
|
||||
spriteNode.removeFromParent()
|
||||
}
|
||||
if let spriteNode = entity.component(ofType: ModalBackgroundComponent.self)?.spriteNode {
|
||||
spriteNode.removeFromParent()
|
||||
isModal = false
|
||||
}
|
||||
if let modal = entity.component(ofType: ModalContentComponent.self) {
|
||||
modal.header.removeFromParent()
|
||||
modal.body.removeFromParent()
|
||||
modal.footer.removeFromParent()
|
||||
}
|
||||
if let sliderNode = entity.component(ofType: SliderComponent.self)?.sliderNode {
|
||||
sliderNode.sliderKnob.removeFromParent()
|
||||
sliderNode.sliderLine.removeFromParent()
|
||||
}
|
||||
if let spriteNode = entity.component(ofType: ModalBackgroundComponent.self)?.spriteNode {
|
||||
spriteNode.removeFromParent()
|
||||
isModal = false
|
||||
}
|
||||
if let modal = entity.component(ofType: ModalContentComponent.self) {
|
||||
modal.header.removeFromParent()
|
||||
modal.body.removeFromParent()
|
||||
modal.footer.removeFromParent()
|
||||
}
|
||||
if let sliderNode = entity.component(ofType: SliderComponent.self)?.sliderNode {
|
||||
sliderNode.sliderKnob.removeFromParent()
|
||||
sliderNode.sliderLine.removeFromParent()
|
||||
}
|
||||
entities.remove(entity)
|
||||
}
|
||||
|
||||
@ -115,36 +115,36 @@ class EntityManager {
|
||||
let _ = entity.component(ofType: DefaultBaseComponent.self) {
|
||||
if teamComponent.team == team {
|
||||
return entity
|
||||
}
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func getBasesByTeam(for team: Team) -> Set<Base> {
|
||||
return entities.filter{$0 is Base && ($0 as! Base).component(ofType: TeamComponent.self)?.team == team } as! Set<Base>
|
||||
}
|
||||
|
||||
func getTeamByBase(base: Base) -> Team? {
|
||||
for entity in entities {
|
||||
if entity is Base && entity == base{
|
||||
for component in entity.components{
|
||||
if component is TeamComponent {
|
||||
return entity.component(ofType: TeamComponent.self)!.team
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
func getTeamByBase(base: Base) -> Team? {
|
||||
for entity in entities {
|
||||
if entity is Base && entity == base{
|
||||
for component in entity.components{
|
||||
if component is TeamComponent {
|
||||
return entity.component(ofType: TeamComponent.self)!.team
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func getBackground() -> GKEntity? {
|
||||
return entities.filter{$0 is Background}[0]
|
||||
}
|
||||
|
||||
func getBaseNodeByTeam(for team: Team) -> SKSpriteNode? {
|
||||
return getBaseByTeam(for: team)?.component(ofType: DefaultBaseComponent.self)?.spriteNode
|
||||
}
|
||||
func getBaseNodeByTeam(for team: Team) -> SKSpriteNode? {
|
||||
return getBaseByTeam(for: team)?.component(ofType: DefaultBaseComponent.self)?.spriteNode
|
||||
}
|
||||
|
||||
func getButtonByName(buttonName:String) -> Button {
|
||||
return entities.filter{$0 is Button && ($0 as! Button).name == buttonName }[0] as! Button
|
||||
|
@ -10,28 +10,28 @@ 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)))
|
||||
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(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)))
|
||||
addComponent(DefBoostSkillComponent(text: "Def",
|
||||
texture: nil,
|
||||
anchorPoint: CGPoint(x: size.width * 0.95, y: size.height * 0.1)))
|
||||
|
||||
addComponent(TimerComponent(text: "",
|
||||
anchorPoint: CGPoint(x: size.width * 0.5, y: size.height * 0.9), duration: 30))
|
||||
}
|
||||
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")
|
||||
}
|
||||
required init?(coder: NSCoder) {
|
||||
fatalError("init(coder:) has not been implemented")
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -10,40 +10,30 @@ import GameplayKit
|
||||
|
||||
class Modal: GKEntity{
|
||||
|
||||
var unitCount:Int
|
||||
var unitCount:Int
|
||||
|
||||
init(modaltype: ModalType, base: Base, anchorPoint: CGPoint) {
|
||||
unitCount = base.unitCount
|
||||
super.init()
|
||||
switch modaltype{
|
||||
case .BaseDetails:
|
||||
addComponent(ModalBackgroundComponent(anchorPoint: anchorPoint))
|
||||
addComponent(ModalContentComponent(
|
||||
header: "Basis Information",
|
||||
body: "Diese Basis enthält \(base.unitCount) Einheiten",
|
||||
footer: "",
|
||||
anchorPoint: anchorPoint
|
||||
)
|
||||
)
|
||||
case .BaseAttack:
|
||||
addComponent(ModalBackgroundComponent(anchorPoint: anchorPoint))
|
||||
addComponent(SliderComponent(
|
||||
width: 300,
|
||||
position: CGPoint(x: anchorPoint.x , y: anchorPoint.y - 80)
|
||||
)
|
||||
)
|
||||
addComponent(ModalContentComponent(
|
||||
header: "Angriff",
|
||||
body: "Schicke \(unitCount / 2) Einheiten",
|
||||
footer: "",
|
||||
anchorPoint: anchorPoint
|
||||
)
|
||||
)
|
||||
}
|
||||
}
|
||||
init(modaltype: ModalType, base: Base, anchorPoint: CGPoint) {
|
||||
unitCount = base.unitCount
|
||||
super.init()
|
||||
switch modaltype{
|
||||
case .BaseDetails:
|
||||
addComponent(ModalBackgroundComponent(anchorPoint: anchorPoint))
|
||||
addComponent(ModalContentComponent(header: "Basis Information",
|
||||
body: "Diese Basis enthält \(base.unitCount) Einheiten",
|
||||
footer: "",
|
||||
anchorPoint: anchorPoint))
|
||||
case .BaseAttack:
|
||||
addComponent(ModalBackgroundComponent(anchorPoint: anchorPoint))
|
||||
addComponent(SliderComponent(width: 300, position: CGPoint(x: anchorPoint.x , y: anchorPoint.y - 80)))
|
||||
addComponent(ModalContentComponent(header: "Angriff",
|
||||
body: "Schicke \(unitCount / 2) Einheiten",
|
||||
footer: "",
|
||||
anchorPoint: anchorPoint))
|
||||
}
|
||||
}
|
||||
|
||||
required init?(coder: NSCoder) {
|
||||
fatalError("init(coder:) has not been implemented")
|
||||
}
|
||||
required init?(coder: NSCoder) {
|
||||
fatalError("init(coder:) has not been implemented")
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -7,6 +7,6 @@
|
||||
//
|
||||
|
||||
enum ModalType: String{
|
||||
case BaseDetails
|
||||
case BaseAttack
|
||||
case BaseDetails
|
||||
case BaseAttack
|
||||
}
|
||||
|
@ -16,7 +16,7 @@ final class GameCenterHelper: NSObject {
|
||||
var viewController: UIViewController?
|
||||
|
||||
static var isAuthenticated: Bool {
|
||||
return GKLocalPlayer.local.isAuthenticated
|
||||
return GKLocalPlayer.local.isAuthenticated
|
||||
}
|
||||
|
||||
override init() {
|
||||
@ -24,7 +24,7 @@ final class GameCenterHelper: NSObject {
|
||||
|
||||
GKLocalPlayer.local.authenticateHandler = { gcAuthVC, error in
|
||||
NotificationCenter.default
|
||||
.post(name: .authenticationChanged, object: GKLocalPlayer.local.isAuthenticated)
|
||||
.post(name: .authenticationChanged, object: GKLocalPlayer.local.isAuthenticated)
|
||||
|
||||
if GKLocalPlayer.local.isAuthenticated {
|
||||
print("Authenticated to Game Center!")
|
||||
|
@ -23,9 +23,9 @@ class GameViewController: UIViewController {
|
||||
view.showsFPS = true
|
||||
view.showsNodeCount = true
|
||||
|
||||
GameCenterHelper.helper.viewController = self
|
||||
MatchmakingHelper.sharedInstance.viewController = self
|
||||
}
|
||||
GameCenterHelper.helper.viewController = self
|
||||
MatchmakingHelper.sharedInstance.viewController = self
|
||||
}
|
||||
}
|
||||
|
||||
override var shouldAutorotate: Bool {
|
||||
|
@ -71,15 +71,15 @@ class MatchmakingHelper: NSObject, GKMatchmakerViewControllerDelegate, GKMatchDe
|
||||
|
||||
/*
|
||||
Der User hat die Verbindung mit "Abbrechen" unterbrochen. GameCenter MatchMaking wird beendet.
|
||||
*/
|
||||
*/
|
||||
func matchmakerViewControllerWasCancelled(_ viewController: GKMatchmakerViewController) {
|
||||
viewController.dismiss(animated: true, completion: nil)
|
||||
delegate?.matchEnded()
|
||||
}
|
||||
|
||||
/*
|
||||
Wenn GameCenter kein match erstellen kann, wird der viewcontroller dismissed.
|
||||
*/
|
||||
Wenn GameCenter kein match erstellen kann, wird der viewcontroller dismissed.
|
||||
*/
|
||||
func matchmakerViewController(_ viewController: GKMatchmakerViewController, didFailWithError error: Error) {
|
||||
viewController.dismiss(animated: true, completion: nil)
|
||||
print("Error finding match", error.localizedDescription)
|
||||
@ -90,7 +90,7 @@ class MatchmakingHelper: NSObject, GKMatchmakerViewControllerDelegate, GKMatchDe
|
||||
Gamecenter hat erfolgreich ein Match gefunden, das Spiel kann gestartet werden.
|
||||
expectedPlayerCount: Die verbleibende Anzahl von Spielern, die sich noch nicht mit dem Spiel verbunden haben
|
||||
z.B 0 gibt an, dass keine weiteren Spieler benötigt werden um das Match zu starten
|
||||
*/
|
||||
*/
|
||||
func matchmakerViewController(_ viewController: GKMatchmakerViewController, didFind match: GKMatch) {
|
||||
viewController.dismiss(animated: true, completion: nil)
|
||||
mpMatch = match
|
||||
@ -101,8 +101,8 @@ class MatchmakingHelper: NSObject, GKMatchmakerViewControllerDelegate, GKMatchDe
|
||||
}
|
||||
|
||||
/*
|
||||
Vom match erhaltene Spielerdaten
|
||||
*/
|
||||
Vom match erhaltene Spielerdaten
|
||||
*/
|
||||
private func match(match: GKMatch!, didReceiveData data: NSData!,fromPlayer playerID: String!) {
|
||||
if mpMatch != match { return }
|
||||
delegate?.matchReceivedData(match: match, data: data, fromPlayer: playerID)
|
||||
@ -142,8 +142,8 @@ class MatchmakingHelper: NSObject, GKMatchmakerViewControllerDelegate, GKMatchDe
|
||||
}
|
||||
|
||||
/*
|
||||
Ein Spieler wird als Host für das Match gewählt. Dieser ist Spieler 1. Im Anschluss wird die GameScene geladen.
|
||||
*/
|
||||
Ein Spieler wird als Host für das Match gewählt. Dieser ist Spieler 1. Im Anschluss wird die GameScene geladen.
|
||||
*/
|
||||
func startMatch() {
|
||||
|
||||
mpMatch!.chooseBestHostingPlayer(completionHandler: {
|
||||
|
@ -35,29 +35,29 @@ class GameScene: SKScene{
|
||||
|
||||
let touchLocation = touch.location(in: self)
|
||||
|
||||
if isMoveTouch{
|
||||
isMoveTouch = false
|
||||
if isMoveTouch{
|
||||
isMoveTouch = false
|
||||
currentDraggedBase!.component(ofType: DefaultBaseComponent.self)?.spriteNode.position = currentDraggedBasePos
|
||||
currentDraggedBase!.component(ofType: TeamComponent.self)?.fire.position = currentDraggedBasePos
|
||||
|
||||
for base in currentDraggedBase!.adjacencyList {
|
||||
if atPoint(touchLocation) == base.component(ofType: DefaultBaseComponent.self)?.spriteNode {
|
||||
// TODO: change interaction based on collision instead of touchlocation
|
||||
for base in currentDraggedBase!.adjacencyList {
|
||||
if atPoint(touchLocation) == base.component(ofType: DefaultBaseComponent.self)?.spriteNode {
|
||||
// TODO: change interaction based on collision instead of touchlocation
|
||||
|
||||
if !(entityManager.getTeamByBase(base: currentDraggedBase!) == entityManager.getTeamByBase(base: base)){
|
||||
entityManager.add(Modal(modaltype: .BaseAttack,
|
||||
base: currentDraggedBase!,
|
||||
anchorPoint: CGPoint(x: self.size.width / 2 , y: self.size.height / 2)))
|
||||
entityManager.update((currentDraggedBase?.attackBase(base: base, units: 100))!)
|
||||
}else {
|
||||
entityManager.add(Modal(modaltype: .BaseAttack,
|
||||
base: currentDraggedBase!,
|
||||
anchorPoint: CGPoint(x: self.size.width / 2 , y: self.size.height / 2)))
|
||||
}
|
||||
if !(entityManager.getTeamByBase(base: currentDraggedBase!) == entityManager.getTeamByBase(base: base)){
|
||||
entityManager.add(Modal(modaltype: .BaseAttack,
|
||||
base: currentDraggedBase!,
|
||||
anchorPoint: CGPoint(x: self.size.width / 2 , y: self.size.height / 2)))
|
||||
entityManager.update((currentDraggedBase?.attackBase(base: base, units: 100))!)
|
||||
}else {
|
||||
entityManager.add(Modal(modaltype: .BaseAttack,
|
||||
base: currentDraggedBase!,
|
||||
anchorPoint: CGPoint(x: self.size.width / 2 , y: self.size.height / 2)))
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
for entity in entityManager.entities {
|
||||
let spriteNode = entity.component(ofType: DefaultBaseComponent.self)?.spriteNode
|
||||
|
@ -24,16 +24,16 @@ class MenuScene: SKScene {
|
||||
if CommandLine.arguments.contains("--no-matchmaking") {
|
||||
self.loadScene(scene: GameScene(size: self.size))
|
||||
} else {
|
||||
MatchmakingHelper.sharedInstance.presentMatchmaker(scene: self)
|
||||
MatchmakingHelper.sharedInstance.presentMatchmaker(scene: self)
|
||||
}
|
||||
}))
|
||||
}))
|
||||
entityManager.add(Button(name: "settingsButton",
|
||||
iconName: "",
|
||||
text: "Settings",
|
||||
position: CGPoint(x: midX, y: midY - 80 ),
|
||||
onButtonPress: {
|
||||
//TODO: create Settings Scene
|
||||
}))
|
||||
}))
|
||||
entityManager.add(Background(size: self.size))
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user