Merge branch '87-vektorisierte-wege' into 'development'
Resolve "Vektorisierte Wege" Closes #87 See merge request marcel.schwarz/software-projekt-2!113
This commit is contained in:
commit
1a9c075dce
@ -18,7 +18,6 @@
|
||||
116060F7245C57D2004E5A36 /* EntityManager.swift in Sources */ = {isa = PBXBuildFile; fileRef = 116060F6245C57D2004E5A36 /* EntityManager.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 */; };
|
||||
3EAD889524801B6A0048A10A /* RoundTimer.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3EAD889424801B6A0048A10A /* RoundTimer.swift */; };
|
||||
3EBD242E245D9332003CECE7 /* Team.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3EBD242D245D9332003CECE7 /* Team.swift */; };
|
||||
3F745DF0246F48FC00CE7375 /* PlayerMoveType.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3F745DEF246F48FC00CE7375 /* PlayerMoveType.swift */; };
|
||||
@ -82,7 +81,6 @@
|
||||
116060F6245C57D2004E5A36 /* EntityManager.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = EntityManager.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>"; };
|
||||
3EAD889424801B6A0048A10A /* RoundTimer.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = RoundTimer.swift; sourceTree = "<group>"; };
|
||||
3EBD242D245D9332003CECE7 /* Team.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Team.swift; sourceTree = "<group>"; };
|
||||
3F745DEF246F48FC00CE7375 /* PlayerMoveType.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PlayerMoveType.swift; sourceTree = "<group>"; };
|
||||
@ -203,7 +201,6 @@
|
||||
9E174C85245DD91500209FF0 /* ButtonComponent.swift */,
|
||||
9E174C81245DD81D00209FF0 /* ButtonNode.swift */,
|
||||
9EA3ABE8245C6DAA006BC61D /* DefaultBaseComponent.swift */,
|
||||
3E6785432472CC27007B9DE4 /* DefaultWayComponent.swift */,
|
||||
C064E9A9246C114C0022B228 /* LabelComponent.swift */,
|
||||
C064E9A7246C0EA50022B228 /* LabelNode.swift */,
|
||||
9EC2FBA62476B1EC00ABF11F /* PlayerInfoComponent.swift */,
|
||||
@ -424,7 +421,6 @@
|
||||
9EEDE02F246FCD800096C735 /* SpinningLogoComponent.swift in Sources */,
|
||||
9E174C84245DD8CE00209FF0 /* Button.swift in Sources */,
|
||||
110360DB244B101A008610AF /* GameViewController.swift in Sources */,
|
||||
3E6785442472CC27007B9DE4 /* DefaultWayComponent.swift in Sources */,
|
||||
C05BB9C4247D890C00411249 /* SliderComponent.swift in Sources */,
|
||||
110360D3244B101A008610AF /* AppDelegate.swift in Sources */,
|
||||
9EC86B9F245C88A300796EF3 /* Modal.swift in Sources */,
|
||||
|
@ -1,27 +0,0 @@
|
||||
//
|
||||
// AttackActionComponent.swift
|
||||
// GoldWars
|
||||
//
|
||||
// Created by Niko Jochim on 03.05.20.
|
||||
// Copyright © 2020 SP2. All rights reserved.
|
||||
//
|
||||
|
||||
import GameplayKit
|
||||
|
||||
class AttackActionComponent: GKComponent {
|
||||
|
||||
|
||||
init(unitCount: Int, adjacencyList: Array<Base>, position: CGPoint) {
|
||||
super.init()
|
||||
}
|
||||
|
||||
required init?(coder: NSCoder) {
|
||||
fatalError("init(coder:) has not been implemented")
|
||||
}
|
||||
|
||||
|
||||
func action() {
|
||||
// Not implemented yet
|
||||
}
|
||||
|
||||
}
|
@ -1,28 +0,0 @@
|
||||
//
|
||||
// DefaultWayComponent.swift
|
||||
// GoldWars
|
||||
//
|
||||
// Created by Jakob Haag on 18.05.20.
|
||||
// Copyright © 2020 SP2. All rights reserved.
|
||||
//
|
||||
|
||||
import Foundation
|
||||
import GameplayKit
|
||||
import SpriteKit
|
||||
|
||||
class DefaultWayComponent: GKComponent {
|
||||
var shapeNode: SKShapeNode
|
||||
|
||||
init(pathToDraw: CGMutablePath) {
|
||||
self.shapeNode = SKShapeNode()
|
||||
shapeNode.path = pathToDraw
|
||||
shapeNode.strokeColor = UIColor(red: 0.852, green: 0.649, blue: 0.123, alpha: 1)
|
||||
shapeNode.lineWidth = 10
|
||||
shapeNode.zPosition = 0
|
||||
super.init()
|
||||
}
|
||||
|
||||
required init?(coder aDecoder: NSCoder) {
|
||||
fatalError("init(coder:) has not been implemented")
|
||||
}
|
||||
}
|
@ -1,25 +0,0 @@
|
||||
//
|
||||
// SkillComponent.swift
|
||||
// GoldWars
|
||||
//
|
||||
// Created by Marcel Schwarz on 24.05.20.
|
||||
// Copyright © 2020 SP2. All rights reserved.
|
||||
//
|
||||
|
||||
import Foundation
|
||||
import GameKit
|
||||
import GameplayKit
|
||||
|
||||
class SkillComponent: GKComponent {
|
||||
var skillButtonNode: SingeClickButtonNode
|
||||
|
||||
init(textureName: String, text: String, position: CGPoint, isEnabled: Bool, onButtonPress: @escaping () -> ()) {
|
||||
skillButtonNode = SingeClickButtonNode(textureName: textureName, text: text, isEnabled: isEnabled, position: position, onButtonPress: onButtonPress)
|
||||
super.init()
|
||||
}
|
||||
|
||||
required init?(coder: NSCoder) {
|
||||
fatalError("init(coder:) has not been implemented")
|
||||
}
|
||||
}
|
||||
|
@ -59,6 +59,10 @@ class EntityManager {
|
||||
scene.addChild(hudEntitiy.roundLabel)
|
||||
}
|
||||
|
||||
if let wayEntity = entity as? Way {
|
||||
scene.addChild(wayEntity.localWayComponent)
|
||||
}
|
||||
|
||||
if let spriteNode = entity.component(ofType: DefaultBaseComponent.self) {
|
||||
scene.addChild(spriteNode.labelNode)
|
||||
scene.addChild(spriteNode.spriteNode)
|
||||
@ -84,9 +88,6 @@ class EntityManager {
|
||||
if let node = entity.component(ofType: SpinningLogoComponent.self)?.node {
|
||||
scene.addChild(node)
|
||||
}
|
||||
if let wayNode = entity.component(ofType: DefaultWayComponent.self)?.shapeNode {
|
||||
scene.addChild(wayNode)
|
||||
}
|
||||
}
|
||||
|
||||
func remove(_ entity: GKEntity) {
|
||||
|
@ -12,19 +12,52 @@ import GameplayKit
|
||||
|
||||
class Way: GKEntity {
|
||||
|
||||
var localWayComponent: SKShapeNode
|
||||
|
||||
required init(fromBase: Base, toBase: Base) {
|
||||
super.init()
|
||||
|
||||
let fromBaseX = fromBase.position.x
|
||||
let fromBaseY = fromBase.position.y
|
||||
let toBaseX = toBase.position.x
|
||||
let toBaseY = toBase.position.y
|
||||
|
||||
let xControll1 = Way.computeX(x1: fromBaseX, x2: toBaseX, y1: fromBaseY, y2: toBaseY, factor: 2/5)
|
||||
let yControll1 = Way.computeY(x1: fromBaseX, x2: toBaseX, y1: fromBaseY, y2: toBaseY, factor: 2/5)
|
||||
let xControll2 = Way.computeX(x1: fromBaseX, x2: toBaseX, y1: fromBaseY, y2: toBaseY, factor: 3/5)
|
||||
let yControll2 = Way.computeY(x1: fromBaseX, x2: toBaseX, y1: fromBaseY, y2: toBaseY, factor: 3/5)
|
||||
|
||||
let pathToDraw = CGMutablePath()
|
||||
pathToDraw.move(to: fromBase.position)
|
||||
pathToDraw.addLine(to: toBase.position)
|
||||
pathToDraw.addCurve(
|
||||
to: toBase.position,
|
||||
control1: CGPoint(x: xControll1, y: yControll1),
|
||||
control2: CGPoint(x: xControll2, y: yControll2)
|
||||
)
|
||||
|
||||
self.localWayComponent = SKShapeNode()
|
||||
self.localWayComponent.path = pathToDraw
|
||||
self.localWayComponent.strokeColor = UIColor(red: 0.852, green: 0.649, blue: 0.123, alpha: 1)
|
||||
self.localWayComponent.lineWidth = 10
|
||||
self.localWayComponent.zPosition = 0
|
||||
|
||||
addComponent(DefaultWayComponent(pathToDraw: pathToDraw))
|
||||
super.init()
|
||||
}
|
||||
|
||||
required init?(coder: NSCoder) {
|
||||
fatalError("init(coder:) has not been implemented")
|
||||
}
|
||||
|
||||
static var wayDelta: CGFloat = 5
|
||||
|
||||
static func computeX(x1: CGFloat, x2: CGFloat, y1: CGFloat, y2: CGFloat, factor: CGFloat) -> CGFloat {
|
||||
let mix:CGFloat = Bool.random() ? -1/wayDelta : 1/wayDelta
|
||||
let x = x1 + factor * (x2 - x1) + mix * -(y2-y1)
|
||||
return x
|
||||
}
|
||||
|
||||
static func computeY(x1: CGFloat, x2: CGFloat, y1: CGFloat, y2: CGFloat, factor: CGFloat) -> CGFloat {
|
||||
let mix:CGFloat = Bool.random() ? -1/wayDelta : 1/wayDelta
|
||||
let y = y1 + factor * (y2 - y1) + mix * (x2-x1)
|
||||
return y
|
||||
}
|
||||
}
|
||||
|
@ -183,24 +183,25 @@ class CElement3: CenterElementProtocol {
|
||||
var id: Int = 3
|
||||
|
||||
required init(frame: CGRect) {
|
||||
let delta = (frame.maxY - frame.minY) * 0.15
|
||||
self.centerBase = Base(
|
||||
position: CGPoint(
|
||||
x: frame.midX,
|
||||
y: frame.maxY
|
||||
y: frame.maxY - delta
|
||||
)
|
||||
)
|
||||
|
||||
self.leftBase = Base(
|
||||
position: CGPoint(
|
||||
x: frame.minX,
|
||||
y: frame.minY
|
||||
y: frame.minY + delta
|
||||
)
|
||||
)
|
||||
|
||||
self.rightBase = Base(
|
||||
position: CGPoint(
|
||||
x: frame.maxX,
|
||||
y: frame.minY
|
||||
y: frame.minY + delta
|
||||
)
|
||||
)
|
||||
self.bases.append(centerBase)
|
||||
@ -260,24 +261,25 @@ class CElement4: CenterElementProtocol {
|
||||
var id: Int = 4
|
||||
|
||||
required init(frame: CGRect) {
|
||||
let delta = (frame.maxY - frame.minY) * 0.15
|
||||
self.centerBase = Base(
|
||||
position: CGPoint(
|
||||
x: frame.midX,
|
||||
y: frame.maxY
|
||||
y: frame.maxY - delta
|
||||
)
|
||||
)
|
||||
|
||||
self.leftBase = Base(
|
||||
position: CGPoint(
|
||||
x: frame.minX,
|
||||
y: frame.minY
|
||||
y: frame.minY + delta
|
||||
)
|
||||
)
|
||||
|
||||
self.rightBase = Base(
|
||||
position: CGPoint(
|
||||
x: frame.maxX,
|
||||
y: frame.minY
|
||||
y: frame.minY + delta
|
||||
)
|
||||
)
|
||||
self.bases.append(centerBase)
|
||||
@ -337,24 +339,25 @@ class CElement5: CenterElementProtocol {
|
||||
var id: Int = 5
|
||||
|
||||
required init(frame: CGRect) {
|
||||
let delta = (frame.maxY - frame.minY) * 0.15
|
||||
self.centerBase = Base(
|
||||
position: CGPoint(
|
||||
x: frame.midX,
|
||||
y: frame.minY
|
||||
y: frame.minY + delta
|
||||
)
|
||||
)
|
||||
|
||||
self.leftBase = Base(
|
||||
position: CGPoint(
|
||||
x: frame.minX,
|
||||
y: frame.maxY
|
||||
y: frame.maxY - delta
|
||||
)
|
||||
)
|
||||
|
||||
self.rightBase = Base(
|
||||
position: CGPoint(
|
||||
x: frame.maxX,
|
||||
y: frame.maxY
|
||||
y: frame.maxY - delta
|
||||
)
|
||||
)
|
||||
self.bases.append(centerBase)
|
||||
@ -414,24 +417,25 @@ class CElement6: CenterElementProtocol {
|
||||
var id: Int = 6
|
||||
|
||||
required init(frame: CGRect) {
|
||||
let delta = (frame.maxY - frame.minY) * 0.15
|
||||
self.centerBase = Base(
|
||||
position: CGPoint(
|
||||
x: frame.midX,
|
||||
y: frame.minY
|
||||
y: frame.minY + delta
|
||||
)
|
||||
)
|
||||
|
||||
self.leftBase = Base(
|
||||
position: CGPoint(
|
||||
x: frame.minX,
|
||||
y: frame.maxY
|
||||
y: frame.maxY - delta
|
||||
)
|
||||
)
|
||||
|
||||
self.rightBase = Base(
|
||||
position: CGPoint(
|
||||
x: frame.maxX,
|
||||
y: frame.maxY
|
||||
y: frame.maxY - delta
|
||||
)
|
||||
)
|
||||
self.bases.append(centerBase)
|
||||
@ -766,24 +770,25 @@ class CElement11: CenterElementProtocol {
|
||||
var id: Int = 11
|
||||
|
||||
required init(frame: CGRect) {
|
||||
let delta = (frame.maxY - frame.minY) * 0.15
|
||||
self.centerBase = Base(
|
||||
position: CGPoint(
|
||||
x: frame.midX,
|
||||
y: frame.maxY
|
||||
y: frame.maxY - delta
|
||||
)
|
||||
)
|
||||
|
||||
self.leftBase = Base(
|
||||
position: CGPoint(
|
||||
x: frame.minX,
|
||||
y: frame.minY
|
||||
y: frame.minY + delta
|
||||
)
|
||||
)
|
||||
|
||||
self.rightBase = Base(
|
||||
position: CGPoint(
|
||||
x: frame.maxX,
|
||||
y: frame.minY
|
||||
y: frame.minY + delta
|
||||
)
|
||||
)
|
||||
self.bases.append(centerBase)
|
||||
@ -843,24 +848,25 @@ class CElement12: CenterElementProtocol {
|
||||
var id: Int = 12
|
||||
|
||||
required init(frame: CGRect) {
|
||||
let delta = (frame.maxY - frame.minY) * 0.15
|
||||
self.centerBase = Base(
|
||||
position: CGPoint(
|
||||
x: frame.midX,
|
||||
y: frame.maxY
|
||||
y: frame.maxY - delta
|
||||
)
|
||||
)
|
||||
|
||||
self.leftBase = Base(
|
||||
position: CGPoint(
|
||||
x: frame.minX,
|
||||
y: frame.minY
|
||||
y: frame.minY + delta
|
||||
)
|
||||
)
|
||||
|
||||
self.rightBase = Base(
|
||||
position: CGPoint(
|
||||
x: frame.maxX,
|
||||
y: frame.minY
|
||||
y: frame.minY + delta
|
||||
)
|
||||
)
|
||||
self.bases.append(centerBase)
|
||||
@ -920,24 +926,25 @@ class CElement13: CenterElementProtocol {
|
||||
var id: Int = 13
|
||||
|
||||
required init(frame: CGRect) {
|
||||
let delta = (frame.maxY - frame.minY) * 0.15
|
||||
self.centerBase = Base(
|
||||
position: CGPoint(
|
||||
x: frame.midX,
|
||||
y: frame.minY
|
||||
y: frame.minY + delta
|
||||
)
|
||||
)
|
||||
|
||||
self.leftBase = Base(
|
||||
position: CGPoint(
|
||||
x: frame.minX,
|
||||
y: frame.maxY
|
||||
y: frame.maxY - delta
|
||||
)
|
||||
)
|
||||
|
||||
self.rightBase = Base(
|
||||
position: CGPoint(
|
||||
x: frame.maxX,
|
||||
y: frame.maxY
|
||||
y: frame.maxY - delta
|
||||
)
|
||||
)
|
||||
self.bases.append(centerBase)
|
||||
@ -997,24 +1004,25 @@ class CElement14: CenterElementProtocol {
|
||||
var id: Int = 14
|
||||
|
||||
required init(frame: CGRect) {
|
||||
let delta = (frame.maxY - frame.minY) * 0.15
|
||||
self.centerBase = Base(
|
||||
position: CGPoint(
|
||||
x: frame.midX,
|
||||
y: frame.minY
|
||||
y: frame.minY + delta
|
||||
)
|
||||
)
|
||||
|
||||
self.leftBase = Base(
|
||||
position: CGPoint(
|
||||
x: frame.minX,
|
||||
y: frame.maxY
|
||||
y: frame.maxY - delta
|
||||
)
|
||||
)
|
||||
|
||||
self.rightBase = Base(
|
||||
position: CGPoint(
|
||||
x: frame.maxX,
|
||||
y: frame.maxY
|
||||
y: frame.maxY - delta
|
||||
)
|
||||
)
|
||||
self.bases.append(centerBase)
|
||||
|
@ -86,7 +86,7 @@ class GameScene: SKScene{
|
||||
if let baseEntity = entity as? Base {
|
||||
if baseEntity.ownershipPlayer == GKLocalPlayer.local {
|
||||
entityManager.add(Modal(modaltype: .BaseDetails,
|
||||
base: entity as! Base,
|
||||
base: entity as? Base,
|
||||
anchorPoint: CGPoint(x: self.size.width / 2 , y: self.size.height / 2),
|
||||
gameScene: self,
|
||||
currentDraggedBase: currentDraggedBase, touchLocation: touchLocation, collisionBase: collisionBase))
|
||||
|
Loading…
Reference in New Issue
Block a user