Prints und Kommentare entfernt
This commit is contained in:
parent
25c57ceb74
commit
8fabdda718
@ -29,11 +29,7 @@ class GameScene: SKScene{
|
|||||||
MapFactory(scene: self, entityManager: self.entityManager).loadMap(playerCount: 2)
|
MapFactory(scene: self, entityManager: self.entityManager).loadMap(playerCount: 2)
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
Aufgerufen: wenn Prozess beendet: Basis auf eine andere gezogen
|
|
||||||
*/
|
|
||||||
override func touchesEnded(_ touches: Set<UITouch>, with event: UIEvent?) {
|
override func touchesEnded(_ touches: Set<UITouch>, with event: UIEvent?) {
|
||||||
print("touchesEnded")
|
|
||||||
guard let touch = touches.first else {
|
guard let touch = touches.first else {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
@ -41,57 +37,29 @@ class GameScene: SKScene{
|
|||||||
let touchLocation = touch.location(in: self)
|
let touchLocation = touch.location(in: self)
|
||||||
|
|
||||||
if isMoveTouch{
|
if isMoveTouch{
|
||||||
/*
|
|
||||||
Aufgerufen: wenn Prozess beendet: Basis auf eine andere gezogen
|
|
||||||
sendet 0 Einheiten, weil noch nicht slider betätugt wurde
|
|
||||||
*/
|
|
||||||
isMoveTouch = false
|
isMoveTouch = false
|
||||||
print("isMoveTouch false")
|
|
||||||
currentDraggedBase!.component(ofType: DefaultBaseComponent.self)?.spriteNode.position = currentDraggedBasePos //currentdraggedbase position gespeichert
|
currentDraggedBase!.component(ofType: DefaultBaseComponent.self)?.spriteNode.position = currentDraggedBasePos //currentdraggedbase position gespeichert
|
||||||
currentDraggedBase!.component(ofType: TeamComponent.self)?.fire.position = currentDraggedBasePos
|
currentDraggedBase!.component(ofType: TeamComponent.self)?.fire.position = currentDraggedBasePos
|
||||||
//currentDraggedBase bekommt Feuerposition?: wenn auskommentiert verliert nur die alte Position das Feuer, 2 Feuer sind dann auf der neusten Position
|
|
||||||
|
|
||||||
for base in currentDraggedBase!.adjacencyList {
|
for base in currentDraggedBase!.adjacencyList {
|
||||||
//basis wurde berührt
|
|
||||||
if atPoint(touchLocation) == base.component(ofType: DefaultBaseComponent.self)?.spriteNode {
|
if atPoint(touchLocation) == base.component(ofType: DefaultBaseComponent.self)?.spriteNode {
|
||||||
// TODO: change interaction based on collision instead of touchlocation
|
// TODO: change interaction based on collision instead of touchlocation
|
||||||
if !(entityManager.getTeamByBase(base: currentDraggedBase!) == entityManager.getTeamByBase(base: base)){
|
if !(entityManager.getTeamByBase(base: currentDraggedBase!) == entityManager.getTeamByBase(base: base)){
|
||||||
|
|
||||||
entityManager.add(Modal(modaltype: .BaseAttack,
|
entityManager.add(Modal(modaltype: .BaseAttack,
|
||||||
base: currentDraggedBase!,
|
base: currentDraggedBase!,
|
||||||
anchorPoint: CGPoint(x: self.size.width / 2 , y: self.size.height / 2),
|
anchorPoint: CGPoint(x: self.size.width / 2 , y: self.size.height / 2),
|
||||||
entityManager: entityManager, gameScene: self, currentDraggedBase: currentDraggedBase, touchLocation: touchLocation))
|
entityManager: entityManager, gameScene: self, currentDraggedBase: currentDraggedBase, touchLocation: touchLocation))
|
||||||
/* print("if")
|
|
||||||
print("sendUnits \(Int(self.sendUnits))")
|
|
||||||
entityManager.update((currentDraggedBase?.attackBase(base: base, units: Int(self.sendUnits)))!)*/
|
|
||||||
}else {
|
}else {
|
||||||
entityManager.add(Modal(modaltype: .BaseAttack,
|
entityManager.add(Modal(modaltype: .BaseAttack,
|
||||||
base: currentDraggedBase!,
|
base: currentDraggedBase!,
|
||||||
anchorPoint: CGPoint(x: self.size.width / 2 , y: self.size.height / 2),
|
anchorPoint: CGPoint(x: self.size.width / 2 , y: self.size.height / 2),
|
||||||
entityManager: entityManager, gameScene: self, currentDraggedBase: currentDraggedBase, touchLocation: touchLocation))
|
entityManager: entityManager, gameScene: self, currentDraggedBase: currentDraggedBase, touchLocation: touchLocation))
|
||||||
print("else")
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
print("else ismoveTouch is false")
|
|
||||||
/*
|
|
||||||
for base in currentDraggedBase!.adjacencyList {
|
|
||||||
print("in here")
|
|
||||||
if atPoint(touchLocation) == base.component(ofType: DefaultBaseComponent.self)?.spriteNode {
|
|
||||||
print("in here 2")
|
|
||||||
// if !(entityManager.getTeamByBase(base: currentDraggedBase!) == entityManager.getTeamByBase(base: base)){
|
|
||||||
print("sendUnits \(Int(self.sendUnits))")
|
|
||||||
entityManager.update((currentDraggedBase?.attackBase(base: base, units: Int(self.sendUnits)))!)
|
|
||||||
// print("in here 3")
|
|
||||||
self.sendUnits = 0
|
|
||||||
// }
|
|
||||||
}
|
|
||||||
}*/
|
|
||||||
//add Base Details
|
|
||||||
|
|
||||||
for entity in entityManager.entities {
|
for entity in entityManager.entities {
|
||||||
let spriteNode = entity.component(ofType: DefaultBaseComponent.self)?.spriteNode
|
let spriteNode = entity.component(ofType: DefaultBaseComponent.self)?.spriteNode
|
||||||
|
|
||||||
@ -107,7 +75,6 @@ class GameScene: SKScene{
|
|||||||
base: entity as! Base,
|
base: entity as! Base,
|
||||||
anchorPoint: CGPoint(x: self.size.width / 2 , y: self.size.height / 2),
|
anchorPoint: CGPoint(x: self.size.width / 2 , y: self.size.height / 2),
|
||||||
entityManager: entityManager, gameScene: self, currentDraggedBase: currentDraggedBase, touchLocation: touchLocation))
|
entityManager: entityManager, gameScene: self, currentDraggedBase: currentDraggedBase, touchLocation: touchLocation))
|
||||||
print("Added Base Details")
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -115,11 +82,7 @@ class GameScene: SKScene{
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
Dauernd aufgerufen beim Prozess: Eine Basis auf eine andere zu ziehen.
|
|
||||||
*/
|
|
||||||
override func touchesMoved(_ touches: Set<UITouch>, with event: UIEvent?) {
|
override func touchesMoved(_ touches: Set<UITouch>, with event: UIEvent?) {
|
||||||
print("touchesMoved")
|
|
||||||
guard let touch = touches.first else {
|
guard let touch = touches.first else {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
@ -130,33 +93,27 @@ class GameScene: SKScene{
|
|||||||
child.touchesMoved(touches, with: event)
|
child.touchesMoved(touches, with: event)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
//checken des Modals/slider des Modals, anzeigen der ausgewählten Units
|
|
||||||
for e in entityManager.entities{
|
for e in entityManager.entities{
|
||||||
if let body = e.component(ofType: ModalContentComponent.self)?.body{
|
if let body = e.component(ofType: ModalContentComponent.self)?.body{
|
||||||
GameScene.sendUnits = ((e.component(ofType: SliderComponent.self)?.sliderNode.getValue ?? 0) * CGFloat((e as! Modal).unitCount)).rounded(.up)
|
GameScene.sendUnits = ((e.component(ofType: SliderComponent.self)?.sliderNode.getValue ?? 0) * CGFloat((e as! Modal).unitCount)).rounded(.up)
|
||||||
print("slider unit \(GameScene.sendUnits)")
|
|
||||||
body.text = "Schicke \(GameScene.sendUnits) Einheiten "
|
body.text = "Schicke \(GameScene.sendUnits) Einheiten "
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// alle Basen eines Players
|
|
||||||
let bases = entityManager.getBasesByPlayer(for: GKLocalPlayer.local)
|
let bases = entityManager.getBasesByPlayer(for: GKLocalPlayer.local)
|
||||||
|
|
||||||
for base in bases {
|
for base in bases {
|
||||||
//wenn die Touchlocation die position der Basis trifft
|
|
||||||
if atPoint(touchLocation) == base.component(ofType: DefaultBaseComponent.self)?.spriteNode{
|
if atPoint(touchLocation) == base.component(ofType: DefaultBaseComponent.self)?.spriteNode{
|
||||||
if !isMoveTouch {
|
if !isMoveTouch {
|
||||||
print("neue currentdraggedbase + position")
|
|
||||||
currentDraggedBasePos = base.component(ofType: DefaultBaseComponent.self)!.spriteNode.position
|
currentDraggedBasePos = base.component(ofType: DefaultBaseComponent.self)!.spriteNode.position
|
||||||
currentDraggedBase = base
|
currentDraggedBase = base
|
||||||
}
|
}
|
||||||
isMoveTouch = true
|
isMoveTouch = true
|
||||||
print("isMoveTouch true")
|
|
||||||
|
|
||||||
//Feuer & Basis müssen sich mitbewegen können
|
|
||||||
base.component(ofType: DefaultBaseComponent.self)?.spriteNode.position = touchLocation
|
base.component(ofType: DefaultBaseComponent.self)?.spriteNode.position = touchLocation
|
||||||
base.component(ofType: TeamComponent.self)?.fire.position = touchLocation
|
base.component(ofType: TeamComponent.self)?.fire.position = touchLocation
|
||||||
|
|
||||||
// jede basis die in der Nähe ist soll vergrößert werden.
|
|
||||||
for adjacencyBase in base.adjacencyList {
|
for adjacencyBase in base.adjacencyList {
|
||||||
let node = adjacencyBase.component(ofType: DefaultBaseComponent.self)?.spriteNode
|
let node = adjacencyBase.component(ofType: DefaultBaseComponent.self)?.spriteNode
|
||||||
node?.run(SKAction.sequence([
|
node?.run(SKAction.sequence([
|
||||||
|
Loading…
Reference in New Issue
Block a user