From dace2364da5629043e722377c14dfc322dbde6e6 Mon Sep 17 00:00:00 2001 From: 127-Z3R0 <81heti1bif@hft-stuttgart.de> Date: Mon, 20 Apr 2020 12:58:47 +0200 Subject: [PATCH] add addLines, connectBases --- GoldWars/GoldWars/Game/GameScene.swift | 47 ++++++++++++++++++++++++++ 1 file changed, 47 insertions(+) diff --git a/GoldWars/GoldWars/Game/GameScene.swift b/GoldWars/GoldWars/Game/GameScene.swift index 164f324..d8db3a2 100644 --- a/GoldWars/GoldWars/Game/GameScene.swift +++ b/GoldWars/GoldWars/Game/GameScene.swift @@ -103,6 +103,53 @@ class GameScene: SKScene { self.addChild(base) } } + + func addLine(base1: Base , base2: Base){ + let line = SKShapeNode() + let linePath = CGMutablePath() + linePath.move(to: base1.position) + linePath.addLine(to: base2.position) + line.path = linePath + line.strokeColor = SKColor.white + addChild(line) + + } + + func connectBases(){ + player[0].addAvailableBase(base: bases[0]) + player[0].addAvailableBase(base: bases[1]) + player[0].addAvailableBase(base: bases[2]) + + bases[0].addAvailableBase(base: bases[3]) + + bases[1].addAvailableBase(base: bases[3]) + bases[1].addAvailableBase(base: bases[4]) + + bases[2].addAvailableBase(base: bases[4]) + + bases[3].addAvailableBase(base: bases[5]) + bases[3].addAvailableBase(base: bases[6]) + + bases[4].addAvailableBase(base: bases[7]) + bases[4].addAvailableBase(base: bases[6]) + + player[1].addAvailableBase(base: bases[5]) + player[1].addAvailableBase(base: bases[6]) + player[1].addAvailableBase(base: bases[7]) + + for base in player{ + for availableBase in base.availableBases{ + addLine(base1: base, base2: availableBase) + } + } + + for base in bases{ + for availableBase in base.availableBases{ + addLine(base1: base, base2: availableBase) + } + } + + } func touchDown(atPoint pos : CGPoint) {