diff --git a/GoldWars/GoldWars.xcodeproj/project.pbxproj b/GoldWars/GoldWars.xcodeproj/project.pbxproj index 0462ade..fcbd525 100644 --- a/GoldWars/GoldWars.xcodeproj/project.pbxproj +++ b/GoldWars/GoldWars.xcodeproj/project.pbxproj @@ -18,7 +18,7 @@ 116060F7245C57D2004E5A36 /* EntityManager.swift in Sources */ = {isa = PBXBuildFile; fileRef = 116060F6245C57D2004E5A36 /* EntityManager.swift */; }; 11738A3B24508F68004426F1 /* Unit.swift in Sources */ = {isa = PBXBuildFile; fileRef = 11738A3A24508F68004426F1 /* Unit.swift */; }; 2086465C2461B66200817C23 /* TimerComponent.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2086465B2461B66200817C23 /* TimerComponent.swift */; }; - 3E67854024728368007B9DE4 /* CElemente.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3E67853F24728368007B9DE4 /* CElemente.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 */; }; 3EBD242C245D8044003CECE7 /* GameCenterHelper.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3EBD242B245D8044003CECE7 /* GameCenterHelper.swift */; }; @@ -91,7 +91,7 @@ 116060F6245C57D2004E5A36 /* EntityManager.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = EntityManager.swift; sourceTree = ""; }; 11738A3A24508F68004426F1 /* Unit.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Unit.swift; sourceTree = ""; }; 2086465B2461B66200817C23 /* TimerComponent.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TimerComponent.swift; sourceTree = ""; }; - 3E67853F24728368007B9DE4 /* CElemente.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CElemente.swift; sourceTree = ""; }; + 3E67853F24728368007B9DE4 /* CElements.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CElements.swift; sourceTree = ""; }; 3E6785412472CBEC007B9DE4 /* Way.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Way.swift; sourceTree = ""; }; 3E6785432472CC27007B9DE4 /* DefaultWayComponent.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DefaultWayComponent.swift; sourceTree = ""; }; 3EBD242B245D8044003CECE7 /* GameCenterHelper.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = GameCenterHelper.swift; sourceTree = ""; }; @@ -305,7 +305,7 @@ AB1D759E245DD2EA00671525 /* Map */ = { isa = PBXGroup; children = ( - 3E67853F24728368007B9DE4 /* CElemente.swift */, + 3E67853F24728368007B9DE4 /* CElements.swift */, AB1D759F245DEC0500671525 /* MapFactory.swift */, AB1D759B245DD18100671525 /* TwoPlayerDefaultTestMap.swift */, AB21D7D4246C748A00B09CBA /* TwoPlayerMapGenerator.swift */, @@ -446,12 +446,11 @@ C064E9A8246C0EA50022B228 /* LabelNode.swift in Sources */, 3EBD242C245D8044003CECE7 /* GameCenterHelper.swift in Sources */, 3F745DF0246F48FC00CE7375 /* PlayerMoveType.swift in Sources */, - AB1D759C245DD18100671525 /* MapProtocol.swift in Sources */, AEBF3B01246EB187004F7CD5 /* CancelBtnComponent.swift in Sources */, AB1D75A0245DEC0500671525 /* MapFactory.swift in Sources */, AB1D759D245DD18100671525 /* TwoPlayerDefaultTestMap.swift in Sources */, 9EBFD7552462CF5A00E1E219 /* SliderComponent.swift in Sources */, - 3E67854024728368007B9DE4 /* CElemente.swift in Sources */, + 3E67854024728368007B9DE4 /* CElements.swift in Sources */, ABA03DA0244BD54F00A66916 /* Base.swift in Sources */, C064E9AC246C151F0022B228 /* Label.swift in Sources */, 9E174C82245DD81D00209FF0 /* ButtonNode.swift in Sources */, diff --git a/GoldWars/GoldWars/Map/CElemente.swift b/GoldWars/GoldWars/Map/CElements.swift similarity index 98% rename from GoldWars/GoldWars/Map/CElemente.swift rename to GoldWars/GoldWars/Map/CElements.swift index 409ed30..22fc4dc 100644 --- a/GoldWars/GoldWars/Map/CElemente.swift +++ b/GoldWars/GoldWars/Map/CElements.swift @@ -8,11 +8,12 @@ import SpriteKit -class CElement1: CenterElementProtocol { +class CElement0: CenterElementProtocol { var bases: [Base] = [] var centerBase: Base var ways: [Way] = [] + var id: Int = 0 required init(frame: CGRect) { self.centerBase = Base( @@ -49,11 +50,12 @@ class CElement1: CenterElementProtocol { } } -class CElement2: CenterElementProtocol { +class CElement1: CenterElementProtocol { var bases: [Base] = [] var leftBase: Base var rightBase: Base var ways: [Way] = [] + var id: Int = 1 required init(frame: CGRect) { self.leftBase = Base( @@ -110,73 +112,75 @@ class CElement2: CenterElementProtocol { } } +class CElement2: CenterElementProtocol { + var bases: [Base] = [] + var leftBase: Base + var rightBase: Base + var ways: [Way] = [] + var id: Int = 2 + + required init(frame: CGRect) { + self.leftBase = Base( + position: CGPoint( + x: frame.minX, + y: frame.midY + ) + ) + + self.rightBase = Base( + position: CGPoint( + x: frame.maxX, + y: frame.midY + ) + ) + self.bases.append(leftBase) + self.bases.append(rightBase) + + self.connectInnerBases() + self.createInternalWays() + } + + func connectInnerBases() { + self.leftBase.adjacencyList.append(self.rightBase) + self.rightBase.adjacencyList.append(self.leftBase) + } + + func createInternalWays() { + ways.append(Way(fromBase: self.leftBase, toBase: self.rightBase)) + } + + func getAllBases() -> [Base] { + return self.bases + } + + func getInternalWays() -> [Way] { + return self.ways + } + + func getTopConnection() -> Base? { + return self.rightBase + } + + func getRightConnection() -> Base? { + return self.rightBase + } + + func getBottomConnection() -> Base? { + return self.leftBase + } + + func getLeftConnection() -> Base? { + return self.leftBase + } +} + class CElement3: CenterElementProtocol { - var bases: [Base] = [] - var leftBase: Base - var rightBase: Base - var ways: [Way] = [] - - required init(frame: CGRect) { - self.leftBase = Base( - position: CGPoint( - x: frame.minX, - y: frame.midY - ) - ) - - self.rightBase = Base( - position: CGPoint( - x: frame.maxX, - y: frame.midY - ) - ) - self.bases.append(leftBase) - self.bases.append(rightBase) - - self.connectInnerBases() - self.createInternalWays() - } - - func connectInnerBases() { - self.leftBase.adjacencyList.append(self.rightBase) - self.rightBase.adjacencyList.append(self.leftBase) - } - - func createInternalWays() { - ways.append(Way(fromBase: self.leftBase, toBase: self.rightBase)) - } - - func getAllBases() -> [Base] { - return self.bases - } - - func getInternalWays() -> [Way] { - return self.ways - } - - func getTopConnection() -> Base? { - return self.rightBase - } - - func getRightConnection() -> Base? { - return self.rightBase - } - - func getBottomConnection() -> Base? { - return self.leftBase - } - - func getLeftConnection() -> Base? { - return self.leftBase - } -} - -class CElement4: CenterElementProtocol { var bases: [Base] = [] var centerBase: Base var leftBase: Base var rightBase: Base var ways: [Way] = [] + var id: Int = 3 required init(frame: CGRect) { self.centerBase = Base( @@ -247,32 +251,110 @@ class CElement4: CenterElementProtocol { } } +class CElement4: CenterElementProtocol { + var bases: [Base] = [] + var centerBase: Base + var leftBase: Base + var rightBase: Base + var ways: [Way] = [] + var id: Int = 4 + + required init(frame: CGRect) { + self.centerBase = Base( + position: CGPoint( + x: frame.midX, + y: frame.maxY + ) + ) + + self.leftBase = Base( + position: CGPoint( + x: frame.minX, + y: frame.minY + ) + ) + + self.rightBase = Base( + position: CGPoint( + x: frame.maxX, + y: frame.minY + ) + ) + self.bases.append(centerBase) + self.bases.append(leftBase) + self.bases.append(rightBase) + + self.connectInnerBases() + self.createInternalWays() + } + + func connectInnerBases() { + self.leftBase.adjacencyList.append(self.rightBase) + self.leftBase.adjacencyList.append(self.centerBase) + self.rightBase.adjacencyList.append(self.leftBase) + self.rightBase.adjacencyList.append(self.centerBase) + self.centerBase.adjacencyList.append(self.leftBase) + self.centerBase.adjacencyList.append(self.rightBase) + } + + func createInternalWays() { + ways.append(Way(fromBase: self.leftBase, toBase: self.rightBase)) + ways.append(Way(fromBase: self.centerBase, toBase: self.rightBase)) + ways.append(Way(fromBase: self.centerBase, toBase: self.leftBase)) + } + + func getAllBases() -> [Base] { + return self.bases + } + + func getInternalWays() -> [Way] { + return self.ways + } + + func getTopConnection() -> Base? { + return self.rightBase + } + + func getRightConnection() -> Base? { + return self.rightBase + } + + func getBottomConnection() -> Base? { + return self.centerBase + } + + func getLeftConnection() -> Base? { + return self.leftBase + } +} + class CElement5: CenterElementProtocol { var bases: [Base] = [] var centerBase: Base var leftBase: Base var rightBase: Base var ways: [Way] = [] + var id: Int = 5 required init(frame: CGRect) { self.centerBase = Base( position: CGPoint( x: frame.midX, - y: frame.maxY + y: frame.minY ) ) self.leftBase = Base( position: CGPoint( x: frame.minX, - y: frame.minY + y: frame.maxY ) ) self.rightBase = Base( position: CGPoint( x: frame.maxX, - y: frame.minY + y: frame.maxY ) ) self.bases.append(centerBase) @@ -307,7 +389,7 @@ class CElement5: CenterElementProtocol { } func getTopConnection() -> Base? { - return self.rightBase + return self.centerBase } func getRightConnection() -> Base? { @@ -315,7 +397,7 @@ class CElement5: CenterElementProtocol { } func getBottomConnection() -> Base? { - return self.centerBase + return self.leftBase } func getLeftConnection() -> Base? { @@ -329,6 +411,7 @@ class CElement6: CenterElementProtocol { var leftBase: Base var rightBase: Base var ways: [Way] = [] + var id: Int = 6 required init(frame: CGRect) { self.centerBase = Base( @@ -391,7 +474,7 @@ class CElement6: CenterElementProtocol { } func getBottomConnection() -> Base? { - return self.leftBase + return self.rightBase } func getLeftConnection() -> Base? { @@ -400,88 +483,13 @@ class CElement6: CenterElementProtocol { } class CElement7: CenterElementProtocol { - var bases: [Base] = [] - var centerBase: Base - var leftBase: Base - var rightBase: Base - var ways: [Way] = [] - - required init(frame: CGRect) { - self.centerBase = Base( - position: CGPoint( - x: frame.midX, - y: frame.minY - ) - ) - - self.leftBase = Base( - position: CGPoint( - x: frame.minX, - y: frame.maxY - ) - ) - - self.rightBase = Base( - position: CGPoint( - x: frame.maxX, - y: frame.maxY - ) - ) - self.bases.append(centerBase) - self.bases.append(leftBase) - self.bases.append(rightBase) - - self.connectInnerBases() - self.createInternalWays() - } - - func connectInnerBases() { - self.leftBase.adjacencyList.append(self.rightBase) - self.leftBase.adjacencyList.append(self.centerBase) - self.rightBase.adjacencyList.append(self.leftBase) - self.rightBase.adjacencyList.append(self.centerBase) - self.centerBase.adjacencyList.append(self.leftBase) - self.centerBase.adjacencyList.append(self.rightBase) - } - - func createInternalWays() { - ways.append(Way(fromBase: self.leftBase, toBase: self.rightBase)) - ways.append(Way(fromBase: self.centerBase, toBase: self.rightBase)) - ways.append(Way(fromBase: self.centerBase, toBase: self.leftBase)) - } - - func getAllBases() -> [Base] { - return self.bases - } - - func getInternalWays() -> [Way] { - return self.ways - } - - func getTopConnection() -> Base? { - return self.centerBase - } - - func getRightConnection() -> Base? { - return self.rightBase - } - - func getBottomConnection() -> Base? { - return self.rightBase - } - - func getLeftConnection() -> Base? { - return self.leftBase - } -} - -class CElement8: CenterElementProtocol { var bases: [Base] = [] var topBase: Base var bottomBase: Base var leftBase: Base var rightBase: Base var ways: [Way] = [] + var id: Int = 7 required init(frame: CGRect) { self.topBase = Base( @@ -567,11 +575,12 @@ class CElement8: CenterElementProtocol { } } -class CElement9: CenterElementProtocol { +class CElement8: CenterElementProtocol { var bases: [Base] = [] var leftBase: Base var rightBase: Base var ways: [Way] = [] + var id: Int = 8 required init(frame: CGRect) { self.leftBase = Base( @@ -628,11 +637,74 @@ class CElement9: CenterElementProtocol { } } +class CElement9: CenterElementProtocol { + var bases: [Base] = [] + var leftBase: Base + var rightBase: Base + var ways: [Way] = [] + var id: Int = 9 + + required init(frame: CGRect) { + self.leftBase = Base( + position: CGPoint( + x: frame.minX, + y: frame.midY + ) + ) + + self.rightBase = Base( + position: CGPoint( + x: frame.maxX, + y: frame.midY + ) + ) + self.bases.append(leftBase) + self.bases.append(rightBase) + + self.connectInnerBases() + self.createInternalWays() + } + + func connectInnerBases() { + self.leftBase.adjacencyList.append(self.rightBase) + self.rightBase.adjacencyList.append(self.leftBase) + } + + func createInternalWays() { + ways.append(Way(fromBase: self.leftBase, toBase: self.rightBase)) + } + + func getAllBases() -> [Base] { + return self.bases + } + + func getInternalWays() -> [Way] { + return self.ways + } + + func getTopConnection() -> Base? { + return nil + } + + func getRightConnection() -> Base? { + return self.rightBase + } + + func getBottomConnection() -> Base? { + return self.rightBase + } + + func getLeftConnection() -> Base? { + return self.leftBase + } +} + class CElement10: CenterElementProtocol { var bases: [Base] = [] var leftBase: Base var rightBase: Base var ways: [Way] = [] + var id: Int = 10 required init(frame: CGRect) { self.leftBase = Base( @@ -673,7 +745,7 @@ class CElement10: CenterElementProtocol { } func getTopConnection() -> Base? { - return nil + return self.rightBase } func getRightConnection() -> Base? { @@ -681,7 +753,7 @@ class CElement10: CenterElementProtocol { } func getBottomConnection() -> Base? { - return self.rightBase + return nil } func getLeftConnection() -> Base? { @@ -691,24 +763,34 @@ class CElement10: CenterElementProtocol { class CElement11: CenterElementProtocol { var bases: [Base] = [] + var centerBase: Base var leftBase: Base var rightBase: Base var ways: [Way] = [] + var id: Int = 11 required init(frame: CGRect) { + self.centerBase = Base( + position: CGPoint( + x: frame.midX, + y: frame.maxY + ) + ) + self.leftBase = Base( position: CGPoint( x: frame.minX, - y: frame.midY + y: frame.minY ) ) self.rightBase = Base( position: CGPoint( x: frame.maxX, - y: frame.midY + y: frame.minY ) ) + self.bases.append(centerBase) self.bases.append(leftBase) self.bases.append(rightBase) @@ -718,11 +800,17 @@ class CElement11: CenterElementProtocol { func connectInnerBases() { self.leftBase.adjacencyList.append(self.rightBase) + self.leftBase.adjacencyList.append(self.centerBase) self.rightBase.adjacencyList.append(self.leftBase) + self.rightBase.adjacencyList.append(self.centerBase) + self.centerBase.adjacencyList.append(self.leftBase) + self.centerBase.adjacencyList.append(self.rightBase) } func createInternalWays() { ways.append(Way(fromBase: self.leftBase, toBase: self.rightBase)) + ways.append(Way(fromBase: self.centerBase, toBase: self.leftBase)) + ways.append(Way(fromBase: self.centerBase, toBase: self.rightBase)) } func getAllBases() -> [Base] { @@ -734,7 +822,7 @@ class CElement11: CenterElementProtocol { } func getTopConnection() -> Base? { - return self.rightBase + return nil } func getRightConnection() -> Base? { @@ -742,7 +830,7 @@ class CElement11: CenterElementProtocol { } func getBottomConnection() -> Base? { - return nil + return self.centerBase } func getLeftConnection() -> Base? { @@ -756,6 +844,7 @@ class CElement12: CenterElementProtocol { var leftBase: Base var rightBase: Base var ways: [Way] = [] + var id: Int = 12 required init(frame: CGRect) { self.centerBase = Base( @@ -810,7 +899,7 @@ class CElement12: CenterElementProtocol { } func getTopConnection() -> Base? { - return nil + return self.rightBase } func getRightConnection() -> Base? { @@ -818,7 +907,7 @@ class CElement12: CenterElementProtocol { } func getBottomConnection() -> Base? { - return self.centerBase + return nil } func getLeftConnection() -> Base? { @@ -832,26 +921,27 @@ class CElement13: CenterElementProtocol { var leftBase: Base var rightBase: Base var ways: [Way] = [] + var id: Int = 13 required init(frame: CGRect) { self.centerBase = Base( position: CGPoint( x: frame.midX, - y: frame.maxY + y: frame.minY ) ) self.leftBase = Base( position: CGPoint( x: frame.minX, - y: frame.minY + y: frame.maxY ) ) self.rightBase = Base( position: CGPoint( x: frame.maxX, - y: frame.minY + y: frame.maxY ) ) self.bases.append(centerBase) @@ -886,7 +976,7 @@ class CElement13: CenterElementProtocol { } func getTopConnection() -> Base? { - return self.rightBase + return nil } func getRightConnection() -> Base? { @@ -894,7 +984,7 @@ class CElement13: CenterElementProtocol { } func getBottomConnection() -> Base? { - return nil + return self.leftBase } func getLeftConnection() -> Base? { @@ -908,82 +998,7 @@ class CElement14: CenterElementProtocol { var leftBase: Base var rightBase: Base var ways: [Way] = [] - - required init(frame: CGRect) { - self.centerBase = Base( - position: CGPoint( - x: frame.midX, - y: frame.minY - ) - ) - - self.leftBase = Base( - position: CGPoint( - x: frame.minX, - y: frame.maxY - ) - ) - - self.rightBase = Base( - position: CGPoint( - x: frame.maxX, - y: frame.maxY - ) - ) - self.bases.append(centerBase) - self.bases.append(leftBase) - self.bases.append(rightBase) - - self.connectInnerBases() - self.createInternalWays() - } - - func connectInnerBases() { - self.leftBase.adjacencyList.append(self.rightBase) - self.leftBase.adjacencyList.append(self.centerBase) - self.rightBase.adjacencyList.append(self.leftBase) - self.rightBase.adjacencyList.append(self.centerBase) - self.centerBase.adjacencyList.append(self.leftBase) - self.centerBase.adjacencyList.append(self.rightBase) - } - - func createInternalWays() { - ways.append(Way(fromBase: self.leftBase, toBase: self.rightBase)) - ways.append(Way(fromBase: self.centerBase, toBase: self.leftBase)) - ways.append(Way(fromBase: self.centerBase, toBase: self.rightBase)) - } - - func getAllBases() -> [Base] { - return self.bases - } - - func getInternalWays() -> [Way] { - return self.ways - } - - func getTopConnection() -> Base? { - return nil - } - - func getRightConnection() -> Base? { - return self.rightBase - } - - func getBottomConnection() -> Base? { - return self.leftBase - } - - func getLeftConnection() -> Base? { - return self.leftBase - } -} - -class CElement15: CenterElementProtocol { - var bases: [Base] = [] - var centerBase: Base - var leftBase: Base - var rightBase: Base - var ways: [Way] = [] + var id: Int = 14 required init(frame: CGRect) { self.centerBase = Base( @@ -1054,6 +1069,99 @@ class CElement15: CenterElementProtocol { } } +class CElement15: CenterElementProtocol { + var bases: [Base] = [] + var topBase: Base + var bottomBase: Base + var leftBase: Base + var rightBase: Base + var ways: [Way] = [] + var id: Int = 15 + + required init(frame: CGRect) { + self.topBase = Base( + position: CGPoint( + x: frame.midX, + y: frame.minY + ) + ) + + self.bottomBase = Base( + position: CGPoint( + x: frame.midX, + y: frame.maxY + ) + ) + + self.leftBase = Base( + position: CGPoint( + x: frame.minX, + y: frame.midY + ) + ) + + self.rightBase = Base( + position: CGPoint( + x: frame.maxX, + y: frame.midY + ) + ) + self.bases.append(topBase) + self.bases.append(bottomBase) + self.bases.append(leftBase) + self.bases.append(rightBase) + + self.connectInnerBases() + self.createInternalWays() + } + + func connectInnerBases() { + self.leftBase.adjacencyList.append(self.rightBase) + self.leftBase.adjacencyList.append(self.topBase) + self.leftBase.adjacencyList.append(self.bottomBase) + self.rightBase.adjacencyList.append(self.leftBase) + self.rightBase.adjacencyList.append(self.topBase) + self.rightBase.adjacencyList.append(self.bottomBase) + self.topBase.adjacencyList.append(self.leftBase) + self.topBase.adjacencyList.append(self.rightBase) + self.topBase.adjacencyList.append(self.bottomBase) + self.bottomBase.adjacencyList.append(self.topBase) + self.bottomBase.adjacencyList.append(self.rightBase) + self.bottomBase.adjacencyList.append(self.leftBase) + } + + func createInternalWays() { + ways.append(Way(fromBase: self.topBase, toBase: self.rightBase)) + ways.append(Way(fromBase: self.topBase, toBase: self.leftBase)) + ways.append(Way(fromBase: self.bottomBase, toBase: self.rightBase)) + ways.append(Way(fromBase: self.bottomBase, toBase: self.leftBase)) + } + + func getAllBases() -> [Base] { + return self.bases + } + + func getInternalWays() -> [Way] { + return self.ways + } + + func getTopConnection() -> Base? { + return self.topBase + } + + func getRightConnection() -> Base? { + return self.rightBase + } + + func getBottomConnection() -> Base? { + return nil + } + + func getLeftConnection() -> Base? { + return self.leftBase + } +} + class CElement16: CenterElementProtocol { var bases: [Base] = [] var topBase: Base @@ -1061,98 +1169,7 @@ class CElement16: CenterElementProtocol { var leftBase: Base var rightBase: Base var ways: [Way] = [] - - required init(frame: CGRect) { - self.topBase = Base( - position: CGPoint( - x: frame.midX, - y: frame.minY - ) - ) - - self.bottomBase = Base( - position: CGPoint( - x: frame.midX, - y: frame.maxY - ) - ) - - self.leftBase = Base( - position: CGPoint( - x: frame.minX, - y: frame.midY - ) - ) - - self.rightBase = Base( - position: CGPoint( - x: frame.maxX, - y: frame.midY - ) - ) - self.bases.append(topBase) - self.bases.append(bottomBase) - self.bases.append(leftBase) - self.bases.append(rightBase) - - self.connectInnerBases() - self.createInternalWays() - } - - func connectInnerBases() { - self.leftBase.adjacencyList.append(self.rightBase) - self.leftBase.adjacencyList.append(self.topBase) - self.leftBase.adjacencyList.append(self.bottomBase) - self.rightBase.adjacencyList.append(self.leftBase) - self.rightBase.adjacencyList.append(self.topBase) - self.rightBase.adjacencyList.append(self.bottomBase) - self.topBase.adjacencyList.append(self.leftBase) - self.topBase.adjacencyList.append(self.rightBase) - self.topBase.adjacencyList.append(self.bottomBase) - self.bottomBase.adjacencyList.append(self.topBase) - self.bottomBase.adjacencyList.append(self.rightBase) - self.bottomBase.adjacencyList.append(self.leftBase) - } - - func createInternalWays() { - ways.append(Way(fromBase: self.topBase, toBase: self.rightBase)) - ways.append(Way(fromBase: self.topBase, toBase: self.leftBase)) - ways.append(Way(fromBase: self.bottomBase, toBase: self.rightBase)) - ways.append(Way(fromBase: self.bottomBase, toBase: self.leftBase)) - } - - func getAllBases() -> [Base] { - return self.bases - } - - func getInternalWays() -> [Way] { - return self.ways - } - - func getTopConnection() -> Base? { - return self.topBase - } - - func getRightConnection() -> Base? { - return self.rightBase - } - - func getBottomConnection() -> Base? { - return nil - } - - func getLeftConnection() -> Base? { - return self.leftBase - } -} - -class CElement17: CenterElementProtocol { - var bases: [Base] = [] - var topBase: Base - var bottomBase: Base - var leftBase: Base - var rightBase: Base - var ways: [Way] = [] + var id: Int = 16 required init(frame: CGRect) { self.topBase = Base( @@ -1238,13 +1255,14 @@ class CElement17: CenterElementProtocol { } } -class CElement18: CenterElementProtocol { +class CElement17: CenterElementProtocol { var bases: [Base] = [] var topBase: Base var bottomBase: Base var leftBase: Base var rightBase: Base var ways: [Way] = [] + var id: Int = 17 required init(frame: CGRect) { self.topBase = Base( diff --git a/GoldWars/GoldWars/Map/MapFactory.swift b/GoldWars/GoldWars/Map/MapFactory.swift index 7da0ea5..0aab86f 100644 --- a/GoldWars/GoldWars/Map/MapFactory.swift +++ b/GoldWars/GoldWars/Map/MapFactory.swift @@ -23,6 +23,7 @@ protocol CenterElementProtocol { var bases: [Base] {get set} var ways: [Way] {get set} + var id: Int { get } init(frame: CGRect)