diff --git a/GoldWars/GoldWars.xcodeproj/project.pbxproj b/GoldWars/GoldWars.xcodeproj/project.pbxproj index 837e018..199af2e 100644 --- a/GoldWars/GoldWars.xcodeproj/project.pbxproj +++ b/GoldWars/GoldWars.xcodeproj/project.pbxproj @@ -3,23 +3,49 @@ archiveVersion = 1; classes = { }; - objectVersion = 50; + objectVersion = 53; objects = { /* Begin PBXBuildFile section */ 110360D3244B101A008610AF /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 110360D2244B101A008610AF /* AppDelegate.swift */; }; - 110360D5244B101A008610AF /* GameScene.sks in Resources */ = {isa = PBXBuildFile; fileRef = 110360D4244B101A008610AF /* GameScene.sks */; }; 110360D9244B101A008610AF /* GameScene.swift in Sources */ = {isa = PBXBuildFile; fileRef = 110360D8244B101A008610AF /* GameScene.swift */; }; 110360DB244B101A008610AF /* GameViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 110360DA244B101A008610AF /* GameViewController.swift */; }; 110360DE244B101A008610AF /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 110360DC244B101A008610AF /* Main.storyboard */; }; 110360E0244B101B008610AF /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 110360DF244B101B008610AF /* Assets.xcassets */; }; 110360E3244B101B008610AF /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 110360E1244B101B008610AF /* LaunchScreen.storyboard */; }; 110360EE244B101B008610AF /* GoldWarsTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 110360ED244B101B008610AF /* GoldWarsTests.swift */; }; - 110360F9244B101B008610AF /* GoldWarsUITests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 110360F8244B101B008610AF /* GoldWarsUITests.swift */; }; - 11036111244B3D6A008610AF /* MenuScene.sks in Resources */ = {isa = PBXBuildFile; fileRef = 11036110244B3D6A008610AF /* MenuScene.sks */; }; 11036113244B3E30008610AF /* MenuScene.swift in Sources */ = {isa = PBXBuildFile; fileRef = 11036112244B3E30008610AF /* MenuScene.swift */; }; + 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 */; }; + 3EBD242C245D8044003CECE7 /* GameCenterHelper.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3EBD242B245D8044003CECE7 /* GameCenterHelper.swift */; }; + 3EBD242E245D9332003CECE7 /* Team.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3EBD242D245D9332003CECE7 /* Team.swift */; }; + 9E04AFAF245E2B73002D5CFC /* AttackActionComponent.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9E04AFAE245E2B73002D5CFC /* AttackActionComponent.swift */; }; + 9E11FF79245CD81100EED3BE /* Fire.sks in Resources */ = {isa = PBXBuildFile; fileRef = 9E11FF77245CD81100EED3BE /* Fire.sks */; }; + 9E174C82245DD81D00209FF0 /* ButtonNode.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9E174C81245DD81D00209FF0 /* ButtonNode.swift */; }; + 9E174C84245DD8CE00209FF0 /* Button.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9E174C83245DD8CE00209FF0 /* Button.swift */; }; + 9E174C86245DD91500209FF0 /* ButtonComponent.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9E174C85245DD91500209FF0 /* ButtonComponent.swift */; }; + 9E174C88245DF1FF00209FF0 /* BackgroundComponent.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9E174C87245DF1FF00209FF0 /* BackgroundComponent.swift */; }; + 9E174C8A245E1A0A00209FF0 /* Background.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9E174C89245E1A0A00209FF0 /* Background.swift */; }; + 9E78ACB6245C9A5300526FF7 /* GameKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 9E78ACB5245C9A5300526FF7 /* GameKit.framework */; }; + 9E78ACB8245CB75B00526FF7 /* TeamComponent.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9E78ACB7245CB75B00526FF7 /* TeamComponent.swift */; }; + 9E78ACBA245CBDAF00526FF7 /* HUD.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9E78ACB9245CBDAF00526FF7 /* HUD.swift */; }; + 9E78ACBE245CC9C000526FF7 /* AtkBoostSkillComponent.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9E78ACBD245CC9C000526FF7 /* AtkBoostSkillComponent.swift */; }; + 9E78ACC2245CC9EE00526FF7 /* DefBoostSkillComponent.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9E78ACC1245CC9EE00526FF7 /* DefBoostSkillComponent.swift */; }; + 9E78ACC4245CCA3600526FF7 /* SpySkillComponent.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9E78ACC3245CCA3600526FF7 /* SpySkillComponent.swift */; }; + 9EA3ABE9245C6DAA006BC61D /* DefaultBaseComponent.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9EA3ABE8245C6DAA006BC61D /* DefaultBaseComponent.swift */; }; + 9EA3ABEB245C6DFA006BC61D /* BaseNode.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9EA3ABEA245C6DFA006BC61D /* BaseNode.swift */; }; + 9EA3ABED245C8143006BC61D /* ModalBackgroundComponent.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9EA3ABEC245C8143006BC61D /* ModalBackgroundComponent.swift */; }; + 9EA3ABEF245C834B006BC61D /* ModalContentComponent.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9EA3ABEE245C834B006BC61D /* ModalContentComponent.swift */; }; + 9EBFD7552462CF5A00E1E219 /* SliderComponent.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9EBFD7542462CF5A00E1E219 /* SliderComponent.swift */; }; + 9EC7E48B2461FBF700396BCD /* SliderNode.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9EC7E48A2461FBF700396BCD /* SliderNode.swift */; }; + 9EC86B9F245C88A300796EF3 /* Modal.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9EC86B9E245C88A300796EF3 /* Modal.swift */; }; + 9EC86BA6245C8AD000796EF3 /* ModalType.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9EC86BA5245C8AD000796EF3 /* ModalType.swift */; }; + AB1D759C245DD18100671525 /* MapProtocol.swift in Sources */ = {isa = PBXBuildFile; fileRef = AB1D759A245DD18100671525 /* MapProtocol.swift */; }; + AB1D759D245DD18100671525 /* TwoPlayerDefaultTestMap.swift in Sources */ = {isa = PBXBuildFile; fileRef = AB1D759B245DD18100671525 /* TwoPlayerDefaultTestMap.swift */; }; + AB1D75A0245DEC0500671525 /* MapFactory.swift in Sources */ = {isa = PBXBuildFile; fileRef = AB1D759F245DEC0500671525 /* MapFactory.swift */; }; ABA03DA0244BD54F00A66916 /* Base.swift in Sources */ = {isa = PBXBuildFile; fileRef = ABA03D9F244BD54F00A66916 /* Base.swift */; }; + AE151589245F18EF001D363E /* MatchmakingHelper.swift in Sources */ = {isa = PBXBuildFile; fileRef = AE151588245F18EF001D363E /* MatchmakingHelper.swift */; }; /* End PBXBuildFile section */ /* Begin PBXContainerItemProxy section */ @@ -30,19 +56,11 @@ remoteGlobalIDString = 110360CE244B101A008610AF; remoteInfo = GoldWars; }; - 110360F5244B101B008610AF /* PBXContainerItemProxy */ = { - isa = PBXContainerItemProxy; - containerPortal = 110360C7244B101A008610AF /* Project object */; - proxyType = 1; - remoteGlobalIDString = 110360CE244B101A008610AF; - remoteInfo = GoldWars; - }; /* End PBXContainerItemProxy section */ /* Begin PBXFileReference section */ 110360CF244B101A008610AF /* GoldWars.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = GoldWars.app; sourceTree = BUILT_PRODUCTS_DIR; }; 110360D2244B101A008610AF /* AppDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = ""; }; - 110360D4244B101A008610AF /* GameScene.sks */ = {isa = PBXFileReference; lastKnownFileType = file.sks; path = GameScene.sks; sourceTree = ""; }; 110360D8244B101A008610AF /* GameScene.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = GameScene.swift; sourceTree = ""; }; 110360DA244B101A008610AF /* GameViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = GameViewController.swift; sourceTree = ""; }; 110360DD244B101A008610AF /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/Main.storyboard; sourceTree = ""; }; @@ -52,13 +70,39 @@ 110360E9244B101B008610AF /* GoldWarsTests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = GoldWarsTests.xctest; sourceTree = BUILT_PRODUCTS_DIR; }; 110360ED244B101B008610AF /* GoldWarsTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = GoldWarsTests.swift; sourceTree = ""; }; 110360EF244B101B008610AF /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; - 110360F4244B101B008610AF /* GoldWarsUITests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = GoldWarsUITests.xctest; sourceTree = BUILT_PRODUCTS_DIR; }; - 110360F8244B101B008610AF /* GoldWarsUITests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = GoldWarsUITests.swift; sourceTree = ""; }; - 110360FA244B101B008610AF /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; - 11036110244B3D6A008610AF /* MenuScene.sks */ = {isa = PBXFileReference; lastKnownFileType = file.sks; path = MenuScene.sks; sourceTree = ""; }; 11036112244B3E30008610AF /* MenuScene.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MenuScene.swift; sourceTree = ""; }; + 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 = ""; }; + 3EBD242B245D8044003CECE7 /* GameCenterHelper.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = GameCenterHelper.swift; sourceTree = ""; }; + 3EBD242D245D9332003CECE7 /* Team.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Team.swift; sourceTree = ""; }; + 9E04AFAE245E2B73002D5CFC /* AttackActionComponent.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AttackActionComponent.swift; sourceTree = ""; }; + 9E11FF77245CD81100EED3BE /* Fire.sks */ = {isa = PBXFileReference; lastKnownFileType = file.sks; path = Fire.sks; sourceTree = ""; }; + 9E174C81245DD81D00209FF0 /* ButtonNode.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ButtonNode.swift; sourceTree = ""; }; + 9E174C83245DD8CE00209FF0 /* Button.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Button.swift; sourceTree = ""; }; + 9E174C85245DD91500209FF0 /* ButtonComponent.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ButtonComponent.swift; sourceTree = ""; }; + 9E174C87245DF1FF00209FF0 /* BackgroundComponent.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = BackgroundComponent.swift; sourceTree = ""; }; + 9E174C89245E1A0A00209FF0 /* Background.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Background.swift; sourceTree = ""; }; + 9E78ACB5245C9A5300526FF7 /* GameKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = GameKit.framework; path = System/Library/Frameworks/GameKit.framework; sourceTree = SDKROOT; }; + 9E78ACB7245CB75B00526FF7 /* TeamComponent.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TeamComponent.swift; sourceTree = ""; }; + 9E78ACB9245CBDAF00526FF7 /* HUD.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = HUD.swift; sourceTree = ""; }; + 9E78ACBD245CC9C000526FF7 /* AtkBoostSkillComponent.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AtkBoostSkillComponent.swift; sourceTree = ""; }; + 9E78ACC1245CC9EE00526FF7 /* DefBoostSkillComponent.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DefBoostSkillComponent.swift; sourceTree = ""; }; + 9E78ACC3245CCA3600526FF7 /* SpySkillComponent.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SpySkillComponent.swift; sourceTree = ""; }; + 9EA3ABE8245C6DAA006BC61D /* DefaultBaseComponent.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DefaultBaseComponent.swift; sourceTree = ""; }; + 9EA3ABEA245C6DFA006BC61D /* BaseNode.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = BaseNode.swift; sourceTree = ""; }; + 9EA3ABEC245C8143006BC61D /* ModalBackgroundComponent.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ModalBackgroundComponent.swift; sourceTree = ""; }; + 9EA3ABEE245C834B006BC61D /* ModalContentComponent.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ModalContentComponent.swift; sourceTree = ""; }; + 9EBFD7542462CF5A00E1E219 /* SliderComponent.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = SliderComponent.swift; sourceTree = ""; }; + 9EC7E48A2461FBF700396BCD /* SliderNode.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SliderNode.swift; sourceTree = ""; }; + 9EC86B9E245C88A300796EF3 /* Modal.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Modal.swift; sourceTree = ""; }; + 9EC86BA5245C8AD000796EF3 /* ModalType.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ModalType.swift; sourceTree = ""; }; + 9ECD3699245C91F7008DEEBD /* GoldWars.entitlements */ = {isa = PBXFileReference; lastKnownFileType = text.plist.entitlements; path = GoldWars.entitlements; sourceTree = ""; }; + AB1D759A245DD18100671525 /* MapProtocol.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = MapProtocol.swift; sourceTree = ""; }; + AB1D759B245DD18100671525 /* TwoPlayerDefaultTestMap.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = TwoPlayerDefaultTestMap.swift; sourceTree = ""; }; + AB1D759F245DEC0500671525 /* MapFactory.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MapFactory.swift; sourceTree = ""; }; ABA03D9F244BD54F00A66916 /* Base.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Base.swift; sourceTree = ""; }; + AE151588245F18EF001D363E /* MatchmakingHelper.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MatchmakingHelper.swift; sourceTree = ""; }; /* End PBXFileReference section */ /* Begin PBXFrameworksBuildPhase section */ @@ -66,6 +110,7 @@ isa = PBXFrameworksBuildPhase; buildActionMask = 2147483647; files = ( + 9E78ACB6245C9A5300526FF7 /* GameKit.framework in Frameworks */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -76,13 +121,6 @@ ); runOnlyForDeploymentPostprocessing = 0; }; - 110360F1244B101B008610AF /* Frameworks */ = { - isa = PBXFrameworksBuildPhase; - buildActionMask = 2147483647; - files = ( - ); - runOnlyForDeploymentPostprocessing = 0; - }; /* End PBXFrameworksBuildPhase section */ /* Begin PBXGroup section */ @@ -91,8 +129,8 @@ children = ( 110360D1244B101A008610AF /* GoldWars */, 110360EC244B101B008610AF /* GoldWarsTests */, - 110360F7244B101B008610AF /* GoldWarsUITests */, 110360D0244B101A008610AF /* Products */, + 9E78ACB4245C9A5300526FF7 /* Frameworks */, ); sourceTree = ""; }; @@ -101,7 +139,6 @@ children = ( 110360CF244B101A008610AF /* GoldWars.app */, 110360E9244B101B008610AF /* GoldWarsTests.xctest */, - 110360F4244B101B008610AF /* GoldWarsUITests.xctest */, ); name = Products; sourceTree = ""; @@ -109,16 +146,20 @@ 110360D1244B101A008610AF /* GoldWars */ = { isa = PBXGroup; children = ( - 11738A3C24508F8C004426F1 /* Unit */, - ABA03D9E244BD53D00A66916 /* Base */, - 11036114244B3E8A008610AF /* Menu */, - 1103610F244B3D48008610AF /* Game */, + 9ECD3699245C91F7008DEEBD /* GoldWars.entitlements */, + 9E11FF74245CD79100EED3BE /* Partikels */, + 116060F5245C5709004E5A36 /* Entities */, + AB1D759E245DD2EA00671525 /* Map */, + 116060F4245C56EA004E5A36 /* Components */, + 9EC86BA2245C89B200796EF3 /* Enums */, + 9EC86BA4245C8A1E00796EF3 /* Scenes */, + 9EC86BA3245C89F400796EF3 /* Storyboards */, 110360D2244B101A008610AF /* AppDelegate.swift */, 110360DA244B101A008610AF /* GameViewController.swift */, - 110360DC244B101A008610AF /* Main.storyboard */, 110360DF244B101B008610AF /* Assets.xcassets */, - 110360E1244B101B008610AF /* LaunchScreen.storyboard */, 110360E4244B101B008610AF /* Info.plist */, + AE151588245F18EF001D363E /* MatchmakingHelper.swift */, + 3EBD242B245D8044003CECE7 /* GameCenterHelper.swift */, ); path = GoldWars; sourceTree = ""; @@ -132,47 +173,93 @@ path = GoldWarsTests; sourceTree = ""; }; - 110360F7244B101B008610AF /* GoldWarsUITests */ = { + 116060F4245C56EA004E5A36 /* Components */ = { isa = PBXGroup; children = ( - 110360F8244B101B008610AF /* GoldWarsUITests.swift */, - 110360FA244B101B008610AF /* Info.plist */, + 9E174C81245DD81D00209FF0 /* ButtonNode.swift */, + 9EA3ABE8245C6DAA006BC61D /* DefaultBaseComponent.swift */, + 9EA3ABEC245C8143006BC61D /* ModalBackgroundComponent.swift */, + 9EA3ABEE245C834B006BC61D /* ModalContentComponent.swift */, + 9EA3ABEA245C6DFA006BC61D /* BaseNode.swift */, + 9E78ACB7245CB75B00526FF7 /* TeamComponent.swift */, + 9E78ACBD245CC9C000526FF7 /* AtkBoostSkillComponent.swift */, + 9E78ACC3245CCA3600526FF7 /* SpySkillComponent.swift */, + 9E78ACC1245CC9EE00526FF7 /* DefBoostSkillComponent.swift */, + 9E174C85245DD91500209FF0 /* ButtonComponent.swift */, + 9E174C87245DF1FF00209FF0 /* BackgroundComponent.swift */, + 9E04AFAE245E2B73002D5CFC /* AttackActionComponent.swift */, + 2086465B2461B66200817C23 /* TimerComponent.swift */, + 9EBFD7542462CF5A00E1E219 /* SliderComponent.swift */, + 9EC7E48A2461FBF700396BCD /* SliderNode.swift */, ); - path = GoldWarsUITests; + path = Components; sourceTree = ""; }; - 1103610F244B3D48008610AF /* Game */ = { - isa = PBXGroup; - children = ( - 110360D4244B101A008610AF /* GameScene.sks */, - 110360D8244B101A008610AF /* GameScene.swift */, - ); - path = Game; - sourceTree = ""; - }; - 11036114244B3E8A008610AF /* Menu */ = { - isa = PBXGroup; - children = ( - 11036110244B3D6A008610AF /* MenuScene.sks */, - 11036112244B3E30008610AF /* MenuScene.swift */, - ); - path = Menu; - sourceTree = ""; - }; - 11738A3C24508F8C004426F1 /* Unit */ = { - isa = PBXGroup; - children = ( - 11738A3A24508F68004426F1 /* Unit.swift */, - ); - path = Unit; - sourceTree = ""; - }; - ABA03D9E244BD53D00A66916 /* Base */ = { + 116060F5245C5709004E5A36 /* Entities */ = { isa = PBXGroup; children = ( ABA03D9F244BD54F00A66916 /* Base.swift */, + 9EC86B9E245C88A300796EF3 /* Modal.swift */, + 116060F6245C57D2004E5A36 /* EntityManager.swift */, + 9E78ACB9245CBDAF00526FF7 /* HUD.swift */, + 9E174C83245DD8CE00209FF0 /* Button.swift */, + 9E174C89245E1A0A00209FF0 /* Background.swift */, ); - path = Base; + path = Entities; + sourceTree = ""; + }; + 9E11FF74245CD79100EED3BE /* Partikels */ = { + isa = PBXGroup; + children = ( + 9E11FF77245CD81100EED3BE /* Fire.sks */, + ); + path = Partikels; + sourceTree = ""; + }; + 9E78ACB4245C9A5300526FF7 /* Frameworks */ = { + isa = PBXGroup; + children = ( + 9E78ACB5245C9A5300526FF7 /* GameKit.framework */, + ); + name = Frameworks; + sourceTree = ""; + }; + 9EC86BA2245C89B200796EF3 /* Enums */ = { + isa = PBXGroup; + children = ( + 11738A3A24508F68004426F1 /* Unit.swift */, + 9EC86BA5245C8AD000796EF3 /* ModalType.swift */, + 3EBD242D245D9332003CECE7 /* Team.swift */, + ); + path = Enums; + sourceTree = ""; + }; + 9EC86BA3245C89F400796EF3 /* Storyboards */ = { + isa = PBXGroup; + children = ( + 110360DC244B101A008610AF /* Main.storyboard */, + 110360E1244B101B008610AF /* LaunchScreen.storyboard */, + ); + path = Storyboards; + sourceTree = ""; + }; + 9EC86BA4245C8A1E00796EF3 /* Scenes */ = { + isa = PBXGroup; + children = ( + 11036112244B3E30008610AF /* MenuScene.swift */, + 110360D8244B101A008610AF /* GameScene.swift */, + ); + path = Scenes; + sourceTree = ""; + }; + AB1D759E245DD2EA00671525 /* Map */ = { + isa = PBXGroup; + children = ( + AB1D759A245DD18100671525 /* MapProtocol.swift */, + AB1D759F245DEC0500671525 /* MapFactory.swift */, + AB1D759B245DD18100671525 /* TwoPlayerDefaultTestMap.swift */, + ); + path = Map; sourceTree = ""; }; /* End PBXGroup section */ @@ -213,24 +300,6 @@ productReference = 110360E9244B101B008610AF /* GoldWarsTests.xctest */; productType = "com.apple.product-type.bundle.unit-test"; }; - 110360F3244B101B008610AF /* GoldWarsUITests */ = { - isa = PBXNativeTarget; - buildConfigurationList = 11036103244B101B008610AF /* Build configuration list for PBXNativeTarget "GoldWarsUITests" */; - buildPhases = ( - 110360F0244B101B008610AF /* Sources */, - 110360F1244B101B008610AF /* Frameworks */, - 110360F2244B101B008610AF /* Resources */, - ); - buildRules = ( - ); - dependencies = ( - 110360F6244B101B008610AF /* PBXTargetDependency */, - ); - name = GoldWarsUITests; - productName = GoldWarsUITests; - productReference = 110360F4244B101B008610AF /* GoldWarsUITests.xctest */; - productType = "com.apple.product-type.bundle.ui-testing"; - }; /* End PBXNativeTarget section */ /* Begin PBXProject section */ @@ -248,14 +317,10 @@ CreatedOnToolsVersion = 11.3.1; TestTargetID = 110360CE244B101A008610AF; }; - 110360F3244B101B008610AF = { - CreatedOnToolsVersion = 11.3.1; - TestTargetID = 110360CE244B101A008610AF; - }; }; }; buildConfigurationList = 110360CA244B101A008610AF /* Build configuration list for PBXProject "GoldWars" */; - compatibilityVersion = "Xcode 9.3"; + compatibilityVersion = "Xcode 11.4"; developmentRegion = en; hasScannedForEncodings = 0; knownRegions = ( @@ -269,7 +334,6 @@ targets = ( 110360CE244B101A008610AF /* GoldWars */, 110360E8244B101B008610AF /* GoldWarsTests */, - 110360F3244B101B008610AF /* GoldWarsUITests */, ); }; /* End PBXProject section */ @@ -280,8 +344,7 @@ buildActionMask = 2147483647; files = ( 110360DE244B101A008610AF /* Main.storyboard in Resources */, - 11036111244B3D6A008610AF /* MenuScene.sks in Resources */, - 110360D5244B101A008610AF /* GameScene.sks in Resources */, + 9E11FF79245CD81100EED3BE /* Fire.sks in Resources */, 110360E0244B101B008610AF /* Assets.xcassets in Resources */, 110360E3244B101B008610AF /* LaunchScreen.storyboard in Resources */, ); @@ -294,13 +357,6 @@ ); runOnlyForDeploymentPostprocessing = 0; }; - 110360F2244B101B008610AF /* Resources */ = { - isa = PBXResourcesBuildPhase; - buildActionMask = 2147483647; - files = ( - ); - runOnlyForDeploymentPostprocessing = 0; - }; /* End PBXResourcesBuildPhase section */ /* Begin PBXSourcesBuildPhase section */ @@ -308,12 +364,39 @@ isa = PBXSourcesBuildPhase; buildActionMask = 2147483647; files = ( + 9E78ACB8245CB75B00526FF7 /* TeamComponent.swift in Sources */, + 9EA3ABEF245C834B006BC61D /* ModalContentComponent.swift in Sources */, + 9EC86BA6245C8AD000796EF3 /* ModalType.swift in Sources */, + 9E78ACBE245CC9C000526FF7 /* AtkBoostSkillComponent.swift in Sources */, + 9E78ACC4245CCA3600526FF7 /* SpySkillComponent.swift in Sources */, + 9EA3ABEB245C6DFA006BC61D /* BaseNode.swift in Sources */, + 9E04AFAF245E2B73002D5CFC /* AttackActionComponent.swift in Sources */, 110360D9244B101A008610AF /* GameScene.swift in Sources */, + 116060F7245C57D2004E5A36 /* EntityManager.swift in Sources */, + 3EBD242E245D9332003CECE7 /* Team.swift in Sources */, + 9E174C88245DF1FF00209FF0 /* BackgroundComponent.swift in Sources */, + 9E78ACBA245CBDAF00526FF7 /* HUD.swift in Sources */, 11738A3B24508F68004426F1 /* Unit.swift in Sources */, + 9E174C86245DD91500209FF0 /* ButtonComponent.swift in Sources */, + AE151589245F18EF001D363E /* MatchmakingHelper.swift in Sources */, 11036113244B3E30008610AF /* MenuScene.swift in Sources */, + 9EA3ABE9245C6DAA006BC61D /* DefaultBaseComponent.swift in Sources */, + 9E174C8A245E1A0A00209FF0 /* Background.swift in Sources */, + 9EA3ABED245C8143006BC61D /* ModalBackgroundComponent.swift in Sources */, + 3EBD242C245D8044003CECE7 /* GameCenterHelper.swift in Sources */, + AB1D759C245DD18100671525 /* MapProtocol.swift in Sources */, + AB1D75A0245DEC0500671525 /* MapFactory.swift in Sources */, + AB1D759D245DD18100671525 /* TwoPlayerDefaultTestMap.swift in Sources */, + 9EBFD7552462CF5A00E1E219 /* SliderComponent.swift in Sources */, ABA03DA0244BD54F00A66916 /* Base.swift in Sources */, + 9E174C82245DD81D00209FF0 /* ButtonNode.swift in Sources */, + 9EC7E48B2461FBF700396BCD /* SliderNode.swift in Sources */, + 9E174C84245DD8CE00209FF0 /* Button.swift in Sources */, 110360DB244B101A008610AF /* GameViewController.swift in Sources */, + 2086465C2461B66200817C23 /* TimerComponent.swift in Sources */, 110360D3244B101A008610AF /* AppDelegate.swift in Sources */, + 9EC86B9F245C88A300796EF3 /* Modal.swift in Sources */, + 9E78ACC2245CC9EE00526FF7 /* DefBoostSkillComponent.swift in Sources */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -325,14 +408,6 @@ ); runOnlyForDeploymentPostprocessing = 0; }; - 110360F0244B101B008610AF /* Sources */ = { - isa = PBXSourcesBuildPhase; - buildActionMask = 2147483647; - files = ( - 110360F9244B101B008610AF /* GoldWarsUITests.swift in Sources */, - ); - runOnlyForDeploymentPostprocessing = 0; - }; /* End PBXSourcesBuildPhase section */ /* Begin PBXTargetDependency section */ @@ -341,11 +416,6 @@ target = 110360CE244B101A008610AF /* GoldWars */; targetProxy = 110360EA244B101B008610AF /* PBXContainerItemProxy */; }; - 110360F6244B101B008610AF /* PBXTargetDependency */ = { - isa = PBXTargetDependency; - target = 110360CE244B101A008610AF /* GoldWars */; - targetProxy = 110360F5244B101B008610AF /* PBXContainerItemProxy */; - }; /* End PBXTargetDependency section */ /* Begin PBXVariantGroup section */ @@ -486,14 +556,20 @@ isa = XCBuildConfiguration; buildSettings = { ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; - CODE_SIGN_STYLE = Automatic; + CODE_SIGN_ENTITLEMENTS = GoldWars/GoldWars.entitlements; + CODE_SIGN_IDENTITY = "iPhone Developer"; + CODE_SIGN_STYLE = Manual; + CURRENT_PROJECT_VERSION = 2; + DEVELOPMENT_TEAM = DDKFQG46BQ; INFOPLIST_FILE = GoldWars/Info.plist; LD_RUNPATH_SEARCH_PATHS = ( "$(inherited)", "@executable_path/Frameworks", ); - PRODUCT_BUNDLE_IDENTIFIER = com.hft.stuttgart.GoldWars; + MARKETING_VERSION = 1.0; + PRODUCT_BUNDLE_IDENTIFIER = de.hft.stuttgart.ip2.goldwars; PRODUCT_NAME = "$(TARGET_NAME)"; + PROVISIONING_PROFILE_SPECIFIER = "Developer Profile"; SWIFT_VERSION = 5.0; TARGETED_DEVICE_FAMILY = 2; }; @@ -503,14 +579,20 @@ isa = XCBuildConfiguration; buildSettings = { ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; - CODE_SIGN_STYLE = Automatic; + CODE_SIGN_ENTITLEMENTS = GoldWars/GoldWars.entitlements; + CODE_SIGN_IDENTITY = "iPhone Developer"; + CODE_SIGN_STYLE = Manual; + CURRENT_PROJECT_VERSION = 2; + DEVELOPMENT_TEAM = DDKFQG46BQ; INFOPLIST_FILE = GoldWars/Info.plist; LD_RUNPATH_SEARCH_PATHS = ( "$(inherited)", "@executable_path/Frameworks", ); - PRODUCT_BUNDLE_IDENTIFIER = com.hft.stuttgart.GoldWars; + MARKETING_VERSION = 1.0; + PRODUCT_BUNDLE_IDENTIFIER = de.hft.stuttgart.ip2.goldwars; PRODUCT_NAME = "$(TARGET_NAME)"; + PROVISIONING_PROFILE_SPECIFIER = "Developer Profile"; SWIFT_VERSION = 5.0; TARGETED_DEVICE_FAMILY = 2; }; @@ -521,7 +603,9 @@ buildSettings = { ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = YES; BUNDLE_LOADER = "$(TEST_HOST)"; + "CODE_SIGN_IDENTITY[sdk=macosx*]" = "Apple Development"; CODE_SIGN_STYLE = Automatic; + DEVELOPMENT_TEAM = DDKFQG46BQ; INFOPLIST_FILE = GoldWarsTests/Info.plist; IPHONEOS_DEPLOYMENT_TARGET = 13.2; LD_RUNPATH_SEARCH_PATHS = ( @@ -542,7 +626,9 @@ buildSettings = { ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = YES; BUNDLE_LOADER = "$(TEST_HOST)"; + "CODE_SIGN_IDENTITY[sdk=macosx*]" = "Apple Development"; CODE_SIGN_STYLE = Automatic; + DEVELOPMENT_TEAM = DDKFQG46BQ; INFOPLIST_FILE = GoldWarsTests/Info.plist; IPHONEOS_DEPLOYMENT_TARGET = 13.2; LD_RUNPATH_SEARCH_PATHS = ( @@ -558,44 +644,6 @@ }; name = Release; }; - 11036104244B101B008610AF /* Debug */ = { - isa = XCBuildConfiguration; - buildSettings = { - ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = YES; - CODE_SIGN_STYLE = Automatic; - INFOPLIST_FILE = GoldWarsUITests/Info.plist; - LD_RUNPATH_SEARCH_PATHS = ( - "$(inherited)", - "@executable_path/Frameworks", - "@loader_path/Frameworks", - ); - PRODUCT_BUNDLE_IDENTIFIER = com.hft.stuttgart.GoldWarsUITests; - PRODUCT_NAME = "$(TARGET_NAME)"; - SWIFT_VERSION = 5.0; - TARGETED_DEVICE_FAMILY = "1,2"; - TEST_TARGET_NAME = GoldWars; - }; - name = Debug; - }; - 11036105244B101B008610AF /* Release */ = { - isa = XCBuildConfiguration; - buildSettings = { - ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = YES; - CODE_SIGN_STYLE = Automatic; - INFOPLIST_FILE = GoldWarsUITests/Info.plist; - LD_RUNPATH_SEARCH_PATHS = ( - "$(inherited)", - "@executable_path/Frameworks", - "@loader_path/Frameworks", - ); - PRODUCT_BUNDLE_IDENTIFIER = com.hft.stuttgart.GoldWarsUITests; - PRODUCT_NAME = "$(TARGET_NAME)"; - SWIFT_VERSION = 5.0; - TARGETED_DEVICE_FAMILY = "1,2"; - TEST_TARGET_NAME = GoldWars; - }; - name = Release; - }; /* End XCBuildConfiguration section */ /* Begin XCConfigurationList section */ @@ -626,15 +674,6 @@ defaultConfigurationIsVisible = 0; defaultConfigurationName = Release; }; - 11036103244B101B008610AF /* Build configuration list for PBXNativeTarget "GoldWarsUITests" */ = { - isa = XCConfigurationList; - buildConfigurations = ( - 11036104244B101B008610AF /* Debug */, - 11036105244B101B008610AF /* Release */, - ); - defaultConfigurationIsVisible = 0; - defaultConfigurationName = Release; - }; /* End XCConfigurationList section */ }; rootObject = 110360C7244B101A008610AF /* Project object */; diff --git a/GoldWars/GoldWars/Assets.xcassets/Base.imageset/Contents.json b/GoldWars/GoldWars/Assets.xcassets/Base.imageset/Contents.json index 91f9bef..721f4c4 100644 --- a/GoldWars/GoldWars/Assets.xcassets/Base.imageset/Contents.json +++ b/GoldWars/GoldWars/Assets.xcassets/Base.imageset/Contents.json @@ -1,17 +1,17 @@ { "images" : [ { - "filename" : "base-small.png", + "filename" : "base.png", "idiom" : "universal", "scale" : "1x" }, { - "filename" : "base-medium.png", + "filename" : "base-1.png", "idiom" : "universal", "scale" : "2x" }, { - "filename" : "base-large.png", + "filename" : "base-2.png", "idiom" : "universal", "scale" : "3x" } diff --git a/GoldWars/GoldWars/Assets.xcassets/Base.imageset/base-1.png b/GoldWars/GoldWars/Assets.xcassets/Base.imageset/base-1.png new file mode 100644 index 0000000..b9ffa3f Binary files /dev/null and b/GoldWars/GoldWars/Assets.xcassets/Base.imageset/base-1.png differ diff --git a/GoldWars/GoldWars/Assets.xcassets/Base.imageset/base-2.png b/GoldWars/GoldWars/Assets.xcassets/Base.imageset/base-2.png new file mode 100644 index 0000000..b9ffa3f Binary files /dev/null and b/GoldWars/GoldWars/Assets.xcassets/Base.imageset/base-2.png differ diff --git a/GoldWars/GoldWars/Assets.xcassets/Base.imageset/base-large.png b/GoldWars/GoldWars/Assets.xcassets/Base.imageset/base-large.png deleted file mode 100644 index b3b9ec4..0000000 Binary files a/GoldWars/GoldWars/Assets.xcassets/Base.imageset/base-large.png and /dev/null differ diff --git a/GoldWars/GoldWars/Assets.xcassets/Base.imageset/base-medium.png b/GoldWars/GoldWars/Assets.xcassets/Base.imageset/base-medium.png deleted file mode 100644 index 99710a1..0000000 Binary files a/GoldWars/GoldWars/Assets.xcassets/Base.imageset/base-medium.png and /dev/null differ diff --git a/GoldWars/GoldWars/Assets.xcassets/Base.imageset/base-small.png b/GoldWars/GoldWars/Assets.xcassets/Base.imageset/base-small.png deleted file mode 100644 index dd7d356..0000000 Binary files a/GoldWars/GoldWars/Assets.xcassets/Base.imageset/base-small.png and /dev/null differ diff --git a/GoldWars/GoldWars/Assets.xcassets/Base.imageset/base.png b/GoldWars/GoldWars/Assets.xcassets/Base.imageset/base.png new file mode 100644 index 0000000..b9ffa3f Binary files /dev/null and b/GoldWars/GoldWars/Assets.xcassets/Base.imageset/base.png differ diff --git a/GoldWars/GoldWars/Assets.xcassets/ModalBackground.imageset/Contents.json b/GoldWars/GoldWars/Assets.xcassets/ModalBackground.imageset/Contents.json new file mode 100644 index 0000000..a9bd99c --- /dev/null +++ b/GoldWars/GoldWars/Assets.xcassets/ModalBackground.imageset/Contents.json @@ -0,0 +1,23 @@ +{ + "images" : [ + { + "filename" : "PopUpBackground.png", + "idiom" : "universal", + "scale" : "1x" + }, + { + "filename" : "PopUpBackground-1.png", + "idiom" : "universal", + "scale" : "2x" + }, + { + "filename" : "PopUpBackground-2.png", + "idiom" : "universal", + "scale" : "3x" + } + ], + "info" : { + "author" : "xcode", + "version" : 1 + } +} diff --git a/GoldWars/GoldWars/Assets.xcassets/ModalBackground.imageset/PopUpBackground-1.png b/GoldWars/GoldWars/Assets.xcassets/ModalBackground.imageset/PopUpBackground-1.png new file mode 100644 index 0000000..5236731 Binary files /dev/null and b/GoldWars/GoldWars/Assets.xcassets/ModalBackground.imageset/PopUpBackground-1.png differ diff --git a/GoldWars/GoldWars/Assets.xcassets/ModalBackground.imageset/PopUpBackground-2.png b/GoldWars/GoldWars/Assets.xcassets/ModalBackground.imageset/PopUpBackground-2.png new file mode 100644 index 0000000..5236731 Binary files /dev/null and b/GoldWars/GoldWars/Assets.xcassets/ModalBackground.imageset/PopUpBackground-2.png differ diff --git a/GoldWars/GoldWars/Assets.xcassets/ModalBackground.imageset/PopUpBackground.png b/GoldWars/GoldWars/Assets.xcassets/ModalBackground.imageset/PopUpBackground.png new file mode 100644 index 0000000..5236731 Binary files /dev/null and b/GoldWars/GoldWars/Assets.xcassets/ModalBackground.imageset/PopUpBackground.png differ diff --git a/GoldWars/GoldWars/Assets.xcassets/SkyBackground.imageset/Contents.json b/GoldWars/GoldWars/Assets.xcassets/SkyBackground.imageset/Contents.json new file mode 100644 index 0000000..231694f --- /dev/null +++ b/GoldWars/GoldWars/Assets.xcassets/SkyBackground.imageset/Contents.json @@ -0,0 +1,21 @@ +{ + "images" : [ + { + "filename" : "SkyBackground.jpg", + "idiom" : "universal", + "scale" : "1x" + }, + { + "idiom" : "universal", + "scale" : "2x" + }, + { + "idiom" : "universal", + "scale" : "3x" + } + ], + "info" : { + "author" : "xcode", + "version" : 1 + } +} diff --git a/GoldWars/GoldWars/Assets.xcassets/SkyBackground.imageset/SkyBackground.jpg b/GoldWars/GoldWars/Assets.xcassets/SkyBackground.imageset/SkyBackground.jpg new file mode 100644 index 0000000..8b499d5 Binary files /dev/null and b/GoldWars/GoldWars/Assets.xcassets/SkyBackground.imageset/SkyBackground.jpg differ diff --git a/GoldWars/GoldWars/Assets.xcassets/spark.imageset/Contents.json b/GoldWars/GoldWars/Assets.xcassets/spark.imageset/Contents.json new file mode 100644 index 0000000..5fdc9ea --- /dev/null +++ b/GoldWars/GoldWars/Assets.xcassets/spark.imageset/Contents.json @@ -0,0 +1,21 @@ +{ + "images" : [ + { + "filename" : "spark.png", + "idiom" : "universal", + "scale" : "1x" + }, + { + "idiom" : "universal", + "scale" : "2x" + }, + { + "idiom" : "universal", + "scale" : "3x" + } + ], + "info" : { + "author" : "xcode", + "version" : 1 + } +} diff --git a/GoldWars/GoldWars/Assets.xcassets/spark.imageset/spark.png b/GoldWars/GoldWars/Assets.xcassets/spark.imageset/spark.png new file mode 100644 index 0000000..3383a21 Binary files /dev/null and b/GoldWars/GoldWars/Assets.xcassets/spark.imageset/spark.png differ diff --git a/GoldWars/GoldWars/Base/Base.swift b/GoldWars/GoldWars/Base/Base.swift deleted file mode 100644 index 06d7071..0000000 --- a/GoldWars/GoldWars/Base/Base.swift +++ /dev/null @@ -1,71 +0,0 @@ -// -// Base.swift -// GoldWars -// -// Created by Marcel Schwarz on 18.04.20. -// Copyright © 2020 SP2. All rights reserved. -// - -import SpriteKit -import GameplayKit - -class Base : SKSpriteNode{ - public static let colorSelected = SKColor.yellow - var availableBases = [Base]() - var defaultColor = SKColor.green - var unitType: Unit = Unit.General; - var unitCount: Int = 0; - - init(color: UIColor, position: CGPoint, name: String, unitCount: Int = 0, unitType: Unit = Unit.General) { - super.init(texture: SKTexture(imageNamed: "Base"), - color: color, - size: CGSize(width: 50.0, height: 50.0) - ) - - defaultColor = color - self.colorBlendFactor = 1 - self.name = name - self.position = position - self.zPosition = 2 - self.isUserInteractionEnabled = true - self.unitCount = unitCount - self.unitType = unitType - } - - required init?(coder aDecoder: NSCoder) { - fatalError("init(coder:) has not been implemented") - } - - func addAvailableBase(base: Base) { - availableBases.append(base) - } - - override func touchesBegan(_ touches: Set, with event: UIEvent?) { - 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, with event: UIEvent?) { - self.color = SKColor.yellow - - for base in availableBases { - base.color = Base.colorSelected - base.size = CGSize(width: 60, height: 60) - } - } - - override func touchesEnded(_ touches: Set, with event: UIEvent?) { - self.color = defaultColor - for base in availableBases { - base.color = base.defaultColor - base.size = CGSize(width: 50, height: 50) - } - } - -} diff --git a/GoldWars/GoldWars/Components/AtkBoostSkillComponent.swift b/GoldWars/GoldWars/Components/AtkBoostSkillComponent.swift new file mode 100644 index 0000000..a2d36b3 --- /dev/null +++ b/GoldWars/GoldWars/Components/AtkBoostSkillComponent.swift @@ -0,0 +1,33 @@ +// +// AtkBoostSkillComponent.swift +// GoldWars +// +// Created by Niko Jochim on 01.05.20. +// Copyright © 2020 SP2. All rights reserved. +// + +import GameplayKit + +class AtkBoostSkillComponent: GKComponent{ + + 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() + } + + required init?(coder: NSCoder) { + fatalError("init(coder:) has not been implemented") + } + +} diff --git a/GoldWars/GoldWars/Components/AttackActionComponent.swift b/GoldWars/GoldWars/Components/AttackActionComponent.swift new file mode 100644 index 0000000..ba46e1a --- /dev/null +++ b/GoldWars/GoldWars/Components/AttackActionComponent.swift @@ -0,0 +1,27 @@ +// +// 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, position: CGPoint) { + super.init() + } + + required init?(coder: NSCoder) { + fatalError("init(coder:) has not been implemented") + } + + + func action() { + // Not implemented yet + } + +} diff --git a/GoldWars/GoldWars/Components/BackgroundComponent.swift b/GoldWars/GoldWars/Components/BackgroundComponent.swift new file mode 100644 index 0000000..7239741 --- /dev/null +++ b/GoldWars/GoldWars/Components/BackgroundComponent.swift @@ -0,0 +1,42 @@ +// +// BackgroundComponent.swift +// GoldWars +// +// Created by Niko Jochim on 02.05.20. +// Copyright © 2020 SP2. All rights reserved. +// + +import GameplayKit + +class BackgroundComponent: GKComponent{ + + var nodes = [SKSpriteNode]() + let size: CGSize + + init(size: CGSize) { + self.size = size + for i in 0...2 { + let sky = SKSpriteNode(imageNamed: "SkyBackground") + sky.name = "clouds" + sky.zPosition = -1 + sky.size = CGSize(width: size.width, height: size.height) + sky.position = CGPoint(x: CGFloat(i) * sky.size.width, y: (size.height / 2)) + nodes.append(sky) + } + super.init() + } + + func update(){ + for node in nodes{ + node.position.x -= 2 + if node.position.x < -(size.width) { + node.position.x += (size.width) * 3 + } + } + } + + required init?(coder: NSCoder) { + fatalError("init(coder:) has not been implemented") + } + +} diff --git a/GoldWars/GoldWars/Components/BaseNode.swift b/GoldWars/GoldWars/Components/BaseNode.swift new file mode 100644 index 0000000..00da238 --- /dev/null +++ b/GoldWars/GoldWars/Components/BaseNode.swift @@ -0,0 +1,34 @@ +// +// BaseNode.swift +// GoldWars +// +// Created by Niko Jochim on 01.05.20. +// Copyright © 2020 SP2. All rights reserved. +// + +import SpriteKit + +class BaseNode: SKSpriteNode{ + + override func touchesBegan(_ touches: Set, 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, with event: UIEvent?) { + // TODO: zeige Angirff Effect + } + + override func touchesEnded(_ touches: Set, with event: UIEvent?) { + // TODO: Open Slider PopUp + } + + +} diff --git a/GoldWars/GoldWars/Components/ButtonComponent.swift b/GoldWars/GoldWars/Components/ButtonComponent.swift new file mode 100644 index 0000000..0fe059f --- /dev/null +++ b/GoldWars/GoldWars/Components/ButtonComponent.swift @@ -0,0 +1,27 @@ +// +// ButtonComponent.swift +// GoldWars +// +// Created by Niko Jochim on 02.05.20. +// Copyright © 2020 SP2. All rights reserved. +// + +import GameplayKit + +class ButtonComponent: GKComponent { + + var buttonNode: ButtonNode + + init(iconName: String, text: String, position: CGPoint, isEnabled:Bool, onButtonPress: @escaping () -> ()) { + buttonNode = ButtonNode(iconName: iconName, + text: text, + isEnabled: isEnabled, + position: position, + onButtonPress: onButtonPress) + super.init() + } + + required init?(coder: NSCoder) { + fatalError("init(coder:) has not been implemented") + } +} diff --git a/GoldWars/GoldWars/Components/ButtonNode.swift b/GoldWars/GoldWars/Components/ButtonNode.swift new file mode 100644 index 0000000..2ebd012 --- /dev/null +++ b/GoldWars/GoldWars/Components/ButtonNode.swift @@ -0,0 +1,75 @@ +// +// ButtonNode.swift +// GoldWars +// +// Created by Niko Jochim on 01.05.20. +// Copyright © 2020 SP2. All rights reserved. +// + +import SpriteKit + +class ButtonNode: SKSpriteNode { + + var isEnabled: Bool{ + didSet{ + if isEnabled { + self.alpha = 1 + self.childNode(withName: "label")?.alpha = 1 + } else { + self.alpha = 0.3 + self.childNode(withName: "label")?.alpha = 0.3 + } + } + } + + let onButtonPress: () -> () + + init(iconName: String, text: String, isEnabled: Bool, position: CGPoint, onButtonPress: @escaping () -> ()) { + self.onButtonPress = onButtonPress + self.isEnabled = isEnabled + let texture = SKTexture(imageNamed: "yellow_button04") + super.init(texture: texture, color: SKColor.white, size: texture.size()) + self.position = position + + let label = SKLabelNode(fontNamed: "Courier-Bold") + label.fontSize = 30 + label.fontColor = SKColor.black + label.zPosition = 1 + label.verticalAlignmentMode = .center + label.text = text + label.name = "label" + + if iconName.isEmpty { + label.position = CGPoint(x: 0, y: 0) + } else { + label.position = CGPoint(x: size.width * 0.25, y: 0) + let icon = SKSpriteNode(imageNamed: iconName) + icon.position = CGPoint(x: -size.width * 0.25, y: 0) + icon.zPosition = 1 + self.addChild(icon) + } + self.addChild(label) + isUserInteractionEnabled = true + } + + override func touchesBegan(_ touches: Set, 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") + } + +} diff --git a/GoldWars/GoldWars/Components/DefBoostSkillComponent.swift b/GoldWars/GoldWars/Components/DefBoostSkillComponent.swift new file mode 100644 index 0000000..01c0aef --- /dev/null +++ b/GoldWars/GoldWars/Components/DefBoostSkillComponent.swift @@ -0,0 +1,33 @@ +// +// DefBoostSkillComponent.swift +// GoldWars +// +// Created by Niko Jochim on 01.05.20. +// Copyright © 2020 SP2. All rights reserved. +// + +import GameplayKit + +class DefBoostSkillComponent: GKComponent{ + + 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() + } + + required init?(coder: NSCoder) { + fatalError("init(coder:) has not been implemented") + } + +} diff --git a/GoldWars/GoldWars/Components/DefaultBaseComponent.swift b/GoldWars/GoldWars/Components/DefaultBaseComponent.swift new file mode 100644 index 0000000..715840b --- /dev/null +++ b/GoldWars/GoldWars/Components/DefaultBaseComponent.swift @@ -0,0 +1,24 @@ +// +// DefaultBaseComponent.swift +// GoldWars +// +// Created by Niko Jochim on 01.05.20. +// Copyright © 2020 SP2. All rights reserved. +// + +import GameplayKit +import SpriteKit + +class DefaultBaseComponent: GKComponent { + var spriteNode: BaseNode + + 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") + } +} diff --git a/GoldWars/GoldWars/Components/ModalBackgroundComponent.swift b/GoldWars/GoldWars/Components/ModalBackgroundComponent.swift new file mode 100644 index 0000000..e81fcf9 --- /dev/null +++ b/GoldWars/GoldWars/Components/ModalBackgroundComponent.swift @@ -0,0 +1,26 @@ +// +// ModalBackgroundComponent.swift +// GoldWars +// +// Created by Niko Jochim on 01.05.20. +// Copyright © 2020 SP2. All rights reserved. +// + +import GameplayKit +import SpriteKit + +class ModalBackgroundComponent: GKComponent { + 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() + } + + required init?(coder aDecoder: NSCoder) { + fatalError("init(coder:) has not been implemented") + } +} diff --git a/GoldWars/GoldWars/Components/ModalContentComponent.swift b/GoldWars/GoldWars/Components/ModalContentComponent.swift new file mode 100644 index 0000000..df004a3 --- /dev/null +++ b/GoldWars/GoldWars/Components/ModalContentComponent.swift @@ -0,0 +1,42 @@ +// +// ModalComponent.swift +// GoldWars +// +// Created by Niko Jochim on 01.05.20. +// Copyright © 2020 SP2. All rights reserved. +// + +import GameplayKit +import SpriteKit + +class ModalContentComponent: GKComponent{ + + 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 + + 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() + } + + required init?(coder aDecoder: NSCoder) { + fatalError("init(coder:) has not been implemented") + } +} diff --git a/GoldWars/GoldWars/Components/SliderComponent.swift b/GoldWars/GoldWars/Components/SliderComponent.swift new file mode 100644 index 0000000..dc46145 --- /dev/null +++ b/GoldWars/GoldWars/Components/SliderComponent.swift @@ -0,0 +1,23 @@ +// +// SliderComponent.swift +// GoldWars +// +// Created by Niko Jochim on 05.05.20. +// Copyright © 2020 SP2. All rights reserved. +// + +import GameplayKit + +class SliderComponent: GKComponent { + + var sliderNode: SliderNode + + init(width: CGFloat, position: CGPoint) { + sliderNode = SliderNode(width: width, position: position) + super.init() + } + + required init?(coder: NSCoder) { + fatalError("init(coder:) has not been implemented") + } +} diff --git a/GoldWars/GoldWars/Components/SliderNode.swift b/GoldWars/GoldWars/Components/SliderNode.swift new file mode 100644 index 0000000..93f42d2 --- /dev/null +++ b/GoldWars/GoldWars/Components/SliderNode.swift @@ -0,0 +1,66 @@ +// +// SliderNode.swift +// GoldWars +// +// Created by Niko Jochim on 05.05.20. +// Copyright © 2020 SP2. All rights reserved. +// + +import SpriteKit + + +class SliderNode :SKNode { + + var sliderLine :SKShapeNode + var sliderKnob :SliderKnob + var width: CGFloat + + 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() + + } + + required init?(coder aDecoder: NSCoder) { + fatalError("init(coder:) has not been implemented") + } +} + +class SliderKnob: SKShapeNode { + var min = CGFloat() + var max = CGFloat() + + override func touchesMoved(_ touches: Set, with event: UIEvent?) { + + 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){ + self.position.x = min + } + if(self.position.x >= max){ + self.position.x = max + } + } + } +} + diff --git a/GoldWars/GoldWars/Components/SpySkillComponent.swift b/GoldWars/GoldWars/Components/SpySkillComponent.swift new file mode 100644 index 0000000..b193de5 --- /dev/null +++ b/GoldWars/GoldWars/Components/SpySkillComponent.swift @@ -0,0 +1,34 @@ +// +// SpySkillComponent.swift +// GoldWars +// +// Created by Niko Jochim on 01.05.20. +// Copyright © 2020 SP2. All rights reserved. +// + +import GameplayKit + +class SpySkillComponent: GKComponent{ + + 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() + } + + required init?(coder: NSCoder) { + fatalError("init(coder:) has not been implemented") + } + +} + diff --git a/GoldWars/GoldWars/Components/TeamComponent.swift b/GoldWars/GoldWars/Components/TeamComponent.swift new file mode 100644 index 0000000..379a1cc --- /dev/null +++ b/GoldWars/GoldWars/Components/TeamComponent.swift @@ -0,0 +1,39 @@ +// +// TeamComponent.swift +// GoldWars +// +// Created by Niko Jochim on 01.05.20. +// Copyright © 2020 SP2. All rights reserved. +// + +import SpriteKit +import GameplayKit + +class TeamComponent: GKComponent { + let team: Team + let fire: SKEmitterNode + + init(team: Team, position: CGPoint) { + fire = SKEmitterNode(fileNamed: "Fire")! + fire.zPosition = -1 + fire.position = position + fire.name = "fire" + fire.particleColorSequence = nil + 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 + } + + self.team = team + super.init() + } + + required init?(coder aDecoder: NSCoder) { + fatalError("init(coder:) has not been implemented") + } +} + diff --git a/GoldWars/GoldWars/Components/TimerComponent.swift b/GoldWars/GoldWars/Components/TimerComponent.swift new file mode 100644 index 0000000..816ca04 --- /dev/null +++ b/GoldWars/GoldWars/Components/TimerComponent.swift @@ -0,0 +1,56 @@ +// +// TimerComponent.swift +// GoldWars +// +// Created by Daniel Steckert on 05.05.20. +// Copyright © 2020 SP2. All rights reserved. +// + +import GameplayKit + +class TimerComponent: GKComponent { + + let labelNode :SKLabelNode + var endTime :Date! + var duration :Double + + init(text: String, anchorPoint: CGPoint, duration: TimeInterval) { + self.labelNode = SKLabelNode(text: text) + self.labelNode.fontColor = UIColor.black + self.labelNode.fontSize = CGFloat(45) + self.labelNode.position = CGPoint(x: anchorPoint.x, y: anchorPoint.y - 15) + self.duration = duration + 1 + super.init() + startWithDuration(duration: self.duration) + } + + func startWithDuration(duration: TimeInterval){ + endTime = Date().addingTimeInterval(duration) + } + + func timeLeft() -> Int { + let remainingSeconds = Int(endTime.timeIntervalSince(Date())) + if(remainingSeconds < 0 ){ + startWithDuration(duration: duration) + } + return remainingSeconds + } + + func isFinished() -> Bool { + return timeLeft() == 0 + } + + func update() { + self.labelNode.text = String(timeLeft()) + + if(isFinished()){ + self.labelNode.text = "Synching" + } + } + + required init?(coder: NSCoder) { + fatalError("init(coder:) has not been implemented") + } + +} + diff --git a/GoldWars/GoldWars/Entities/Background.swift b/GoldWars/GoldWars/Entities/Background.swift new file mode 100644 index 0000000..6cc1b74 --- /dev/null +++ b/GoldWars/GoldWars/Entities/Background.swift @@ -0,0 +1,25 @@ +// +// Background.swift +// GoldWars +// +// Created by Niko Jochim on 02.05.20. +// Copyright © 2020 SP2. All rights reserved. +// + +import GameplayKit + +class Background: GKEntity { + + init(size: CGSize) { + super.init() + addComponent(BackgroundComponent(size: size)) + } + + override func update(deltaTime seconds: TimeInterval) { + component(ofType: BackgroundComponent.self)?.update() + } + + required init?(coder: NSCoder) { + fatalError("init(coder:) has not been implemented") + } +} diff --git a/GoldWars/GoldWars/Entities/Base.swift b/GoldWars/GoldWars/Entities/Base.swift new file mode 100644 index 0000000..70fe75d --- /dev/null +++ b/GoldWars/GoldWars/Entities/Base.swift @@ -0,0 +1,42 @@ +// +// Base.swift +// GoldWars +// +// Created by Marcel Schwarz on 18.04.20. +// Copyright © 2020 SP2. All rights reserved. +// + +import SpriteKit +import GameplayKit + +class Base: GKEntity { + + var unitCount: Int + var adjacencyList: Array + var changeOwnerShip: Bool + + init(position: CGPoint, team: Team! = nil) { + self.unitCount = 0 + self.adjacencyList = [Base]() + self.changeOwnerShip = false + super.init() + + addComponent(DefaultBaseComponent(texture: SKTexture(imageNamed: "Base"), position: position)) + if(team != nil){ + addComponent(TeamComponent(team: team!, position: position)) + self.unitCount = 500 + } + } + + func attackBase(base: Base, units:Int) -> [GKEntity]{ + base.changeOwnerShip = true + self.unitCount -= units + base.unitCount += units + return [self, base] + } + + required init?(coder: NSCoder) { + fatalError("init(coder:) has not been implemented") + } + +} diff --git a/GoldWars/GoldWars/Entities/Button.swift b/GoldWars/GoldWars/Entities/Button.swift new file mode 100644 index 0000000..8ac174d --- /dev/null +++ b/GoldWars/GoldWars/Entities/Button.swift @@ -0,0 +1,25 @@ +// +// Button.swift +// GoldWars +// +// Created by Niko Jochim on 02.05.20. +// Copyright © 2020 SP2. All rights reserved. +// + +import GameKit + +class Button: GKEntity{ + + let name: String + var isEnabled = true + + init(name: String, iconName: String, text: String, position: CGPoint, onButtonPress: @escaping () -> ()) { + self.name = name + super.init() + self.addComponent(ButtonComponent(iconName: iconName, text: text, position: position, isEnabled: isEnabled, onButtonPress: onButtonPress)) + } + + required init?(coder: NSCoder) { + fatalError("init(coder:) has not been implemented") + } +} diff --git a/GoldWars/GoldWars/Entities/EntityManager.swift b/GoldWars/GoldWars/Entities/EntityManager.swift new file mode 100644 index 0000000..0f7166c --- /dev/null +++ b/GoldWars/GoldWars/Entities/EntityManager.swift @@ -0,0 +1,146 @@ +// +// EntityManager.swift +// GoldWars +// +// Created by Aldin Duraki on 01.05.20. +// Copyright © 2020 SP2. All rights reserved. +// + +import SpriteKit +import GameplayKit + +class EntityManager { + + var entities = Set() + let scene: SKScene + var isModal: Bool + + init(scene: SKScene) { + self.scene = scene + 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 timer = entity.component(ofType: TimerComponent.self) { + scene.addChild(timer.labelNode) + } + if let buttonNode = entity.component(ofType: ButtonComponent.self)?.buttonNode { + scene.addChild(buttonNode) + } + if let nodes = entity.component(ofType: BackgroundComponent.self)?.nodes { + for node in nodes { + scene.addChild(node) + } + } + 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() + } + entities.remove(entity) + } + + func update(_ entities: [GKEntity]){ + for entity in entities { + self.entities.update(with: entity) + let base = (entity as! Base) + + if base.changeOwnerShip { + base.addComponent(TeamComponent(team: (entities[0] as! Base).component(ofType: TeamComponent.self)!.team, position: (base.component(ofType: DefaultBaseComponent.self)?.spriteNode.position)!)) + base.changeOwnerShip = false + scene.addChild(base.component(ofType: TeamComponent.self)!.fire) + } + } + + } + func getBaseByTeam(for team: Team) -> GKEntity? { + for entity in entities { + if let teamComponent = entity.component(ofType: TeamComponent.self), + let _ = entity.component(ofType: DefaultBaseComponent.self) { + if teamComponent.team == team { + return entity + } + } + } + return nil + } + + func getBasesByTeam(for team: Team) -> Set { + return entities.filter{$0 is Base && ($0 as! Base).component(ofType: TeamComponent.self)?.team == team } as! Set + } + + 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 getButtonByName(buttonName:String) -> Button { + return entities.filter{$0 is Button && ($0 as! Button).name == buttonName }[0] as! Button + } + + func getHUD() -> GKEntity? { + return entities.filter{$0 is HUD}[0] + } +} diff --git a/GoldWars/GoldWars/Entities/HUD.swift b/GoldWars/GoldWars/Entities/HUD.swift new file mode 100644 index 0000000..a161285 --- /dev/null +++ b/GoldWars/GoldWars/Entities/HUD.swift @@ -0,0 +1,37 @@ +// +// HUD.swift +// GoldWars +// +// Created by Niko Jochim on 01.05.20. +// Copyright © 2020 SP2. All rights reserved. +// + +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))) + + + 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(TimerComponent(text: "", + 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") + } + +} diff --git a/GoldWars/GoldWars/Entities/Modal.swift b/GoldWars/GoldWars/Entities/Modal.swift new file mode 100644 index 0000000..cdafa53 --- /dev/null +++ b/GoldWars/GoldWars/Entities/Modal.swift @@ -0,0 +1,39 @@ +// +// Modal.swift +// GoldWars +// +// Created by Niko Jochim on 01.05.20. +// Copyright © 2020 SP2. All rights reserved. +// + +import GameplayKit + +class Modal: GKEntity{ + + 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)) + } + } + + required init?(coder: NSCoder) { + fatalError("init(coder:) has not been implemented") + } + +} diff --git a/GoldWars/GoldWars/Enums/ModalType.swift b/GoldWars/GoldWars/Enums/ModalType.swift new file mode 100644 index 0000000..40bcedf --- /dev/null +++ b/GoldWars/GoldWars/Enums/ModalType.swift @@ -0,0 +1,12 @@ +// +// ModalType.swift +// GoldWars +// +// Created by Niko Jochim on 01.05.20. +// Copyright © 2020 SP2. All rights reserved. +// + +enum ModalType: String{ + case BaseDetails + case BaseAttack +} diff --git a/GoldWars/GoldWars/Enums/Team.swift b/GoldWars/GoldWars/Enums/Team.swift new file mode 100644 index 0000000..15115fa --- /dev/null +++ b/GoldWars/GoldWars/Enums/Team.swift @@ -0,0 +1,16 @@ +// +// Team.swift +// GoldWars +// +// Created by Jakob Haag on 02.05.20. +// Copyright © 2020 SP2. All rights reserved. +// + +enum Team: Int { + case team1 = 1 + case team2 = 2 + case team3 = 3 + case team4 = 4 + + static let allValues = [team1, team2,team3,team4] +} diff --git a/GoldWars/GoldWars/Unit/Unit.swift b/GoldWars/GoldWars/Enums/Unit.swift similarity index 100% rename from GoldWars/GoldWars/Unit/Unit.swift rename to GoldWars/GoldWars/Enums/Unit.swift diff --git a/GoldWars/GoldWars/Game/GameScene.sks b/GoldWars/GoldWars/Game/GameScene.sks deleted file mode 100644 index ebf306a..0000000 Binary files a/GoldWars/GoldWars/Game/GameScene.sks and /dev/null differ diff --git a/GoldWars/GoldWars/Game/GameScene.swift b/GoldWars/GoldWars/Game/GameScene.swift deleted file mode 100644 index c8de31f..0000000 --- a/GoldWars/GoldWars/Game/GameScene.swift +++ /dev/null @@ -1,254 +0,0 @@ -// -// GameScene.swift -// GoldWars -// -// Created by Aldin Duraki on 18.04.20. -// Copyright © 2020 SP2. All rights reserved. -// - -import SpriteKit -import GameplayKit - -class GameScene: SKScene, SKPhysicsContactDelegate { - - var entities = [GKEntity]() - var graphs = [String : GKGraph]() - var bases = [Base]() - var player = [Base]() - var popUpOnBaseCollision = SKSpriteNode() - - // TODO: Refactoring following as Components in Sprint 2 - var timer = SKLabelNode() - var backBtn = SKShapeNode(circleOfRadius: 40) - var backLabel = SKLabelNode() - var atkBoostSkill = SKShapeNode(circleOfRadius: 30) - var defBoostSkill = SKShapeNode(circleOfRadius: 30) - var spySkill = SKShapeNode(circleOfRadius: 30) - var atkBoostLabel = SKLabelNode() - var defBoostLabel = SKLabelNode() - var spyLabel = SKLabelNode() - // TODO: END - - struct physicsBodyNumber { - static let basePlayer1Number: UInt32 = 0b1 - static let basePlayer2Number: UInt32 = 0b10 - static let base5Number: UInt32 = 0b101 - static let base6Number: UInt32 = 0b110 - static let base7Number: UInt32 = 0b111 - static let emptyNumber: UInt32 = 0b100 - } - - override func sceneDidLoad() { - - self.physicsWorld.gravity = CGVector(dx: 0, dy: 0) - self.physicsWorld.contactDelegate = self - - let maxX = self.size.width - let midY = self.size.height / 2 - - let basePlayer1 = Base(color: SKColor.red, position: CGPoint(x: maxX * 0.1, y: midY), name: "Player1", unitCount: 100, unitType: Unit.General) - let basePlayer2 = Base(color: SKColor.blue, position: CGPoint(x: maxX * 0.9, y: midY), name: "Player2", unitCount: 100, unitType: Unit.General) - basePlayer2.physicsBody = SKPhysicsBody(circleOfRadius: 50) - basePlayer2.physicsBody?.categoryBitMask = physicsBodyNumber.basePlayer2Number - basePlayer2.physicsBody?.collisionBitMask = physicsBodyNumber.emptyNumber - basePlayer2.physicsBody?.contactTestBitMask = physicsBodyNumber.base5Number & physicsBodyNumber.base6Number & physicsBodyNumber.base7Number - - popUpOnBaseCollision = SKSpriteNode(color: SKColor.blue , size: CGSize(width: self.size.width * 0.4, height: self.size.height * 0.4)) - popUpOnBaseCollision.position = CGPoint(x: self.size.width * 0.5, y: self.size.height * 0.5) - popUpOnBaseCollision.zPosition = 2 - - self.addChild(basePlayer1) - self.addChild(basePlayer2) - player.append(basePlayer1) - player.append(basePlayer2) - createVirginBases() - connectBases() - addPhysicsBodyToBase() - } - override func didMove(to view: SKView) { - let background = SKSpriteNode(imageNamed: "Background") - background.position = CGPoint(x: self.size.width / 2, y: self.size.height / 2) - background.zPosition = -1 - background.size = self.size - self.addChild(background) - - // TODO: Refactor following as Components in Sprint 2 - timer.text = "Roundtime: 30 Seconds left" - timer.fontColor = SKColor.black - timer.fontSize = 40 - timer.position = CGPoint(x: self.size.width/2, y: self.size.height * 0.9) - backBtn.position = CGPoint(x: 40, y: self.size.height * 0.9) - backBtn.fillColor = SKColor.gray - backLabel.text = "Back" - backLabel.position = CGPoint(x: backBtn.position.x, y: backBtn.position.y - 15) - spySkill.position = CGPoint(x: self.size.width * 0.75, y: 40) - spySkill.fillColor = SKColor.gray - spyLabel.text = "Spy" - spyLabel.position = CGPoint(x: spySkill.position.x, y: spySkill.position.y - 15); - atkBoostSkill.position = CGPoint(x: self.size.width * 0.85, y: 40) - atkBoostSkill.fillColor = SKColor.gray - atkBoostLabel.text = "Atk" - atkBoostLabel.position = CGPoint(x: atkBoostSkill.position.x, y: atkBoostSkill.position.y - 15) - defBoostSkill.position = CGPoint(x: self.size.width * 0.95, y: 40) - defBoostSkill.fillColor = SKColor.gray - defBoostLabel.text = "Def" - defBoostLabel.position = CGPoint(x: defBoostSkill.position.x, y: defBoostSkill.position.y - 15) - self.addChild(timer) - self.addChild(backBtn) - self.addChild(backLabel) - self.addChild(atkBoostSkill) - self.addChild(defBoostSkill) - self.addChild(spySkill) - self.addChild(atkBoostLabel) - self.addChild(defBoostLabel) - self.addChild(spyLabel) - // TODO: END - } - - - func addPhysicsBodyToBase() { - bases[5].physicsBody = SKPhysicsBody(circleOfRadius: 20) - bases[5].physicsBody?.categoryBitMask = physicsBodyNumber.base5Number - bases[5].physicsBody?.collisionBitMask = physicsBodyNumber.emptyNumber - bases[5].physicsBody?.contactTestBitMask = physicsBodyNumber.basePlayer2Number - - bases[6].physicsBody = SKPhysicsBody(circleOfRadius: 20) - bases[6].physicsBody?.categoryBitMask = physicsBodyNumber.base6Number - bases[6].physicsBody?.collisionBitMask = physicsBodyNumber.emptyNumber - bases[6].physicsBody?.contactTestBitMask = physicsBodyNumber.basePlayer2Number - - bases[7].physicsBody = SKPhysicsBody(circleOfRadius: 20) - bases[7].physicsBody?.categoryBitMask = physicsBodyNumber.base7Number - bases[7].physicsBody?.collisionBitMask = physicsBodyNumber.emptyNumber - bases[7].physicsBody?.contactTestBitMask = physicsBodyNumber.basePlayer2Number - } - - func createVirginBases() { - for i in 0...7 { - let base:Base - let color = SKColor.green - - var position = CGPoint(x: 0, y: 0) - switch i { - case 0...2: - let width = self.size.width * 0.25 - - if i == 0 { - position = CGPoint(x: width, y: self.size.height * 0.25) - } - if i == 1 { - position = CGPoint(x: width, y: self.size.height * 0.5) - } - if i == 2{ - position = CGPoint(x: width, y: self.size.height * 0.75) - } - - case 3...4: - let width = self.size.width * 0.5 - - if i == 3{ - position = CGPoint(x: width, y: self.size.height * 0.333) - } - if i == 4{ - position = CGPoint(x: width, y: self.size.height * 0.666) - } - - case 5...7: - let width = self.size.width * 0.75 - - if i == 5{ - position = CGPoint(x: width, y: self.size.height * 0.25) - } - if i == 6{ - position = CGPoint(x: width, y: self.size.height * 0.5) - } - if i == 7{ - position = CGPoint(x: width, y: self.size.height * 0.75) - } - - default: - break - } - - base = Base(color: color, position: position, name: "Base\(i)") - bases.append(base) - 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) - } - } - - } - - override func touchesBegan(_ touches: Set, with event: UIEvent?) { - for touch in touches { - let locationUser = touch.location(in: self) - if atPoint(locationUser) == popUpOnBaseCollision { - popUpOnBaseCollision.removeFromParent() - } - } - } - - override func touchesMoved(_ touches: Set, with event: UIEvent?) { - for touch in touches { - let locationUser = touch.location(in: self) - if atPoint(locationUser) == player[1]{ - player[1].position = locationUser - } - } - } - - override func touchesEnded(_ touches: Set, with event: UIEvent?) { - let maxX = self.size.width - let midY = self.size.height / 2 - - player[1].position = CGPoint(x: maxX * 0.9, y: midY) - } - - func didBegin(_ contact: SKPhysicsContact) { - self.addChild(popUpOnBaseCollision) - } -} diff --git a/GoldWars/GoldWars/GameCenterHelper.swift b/GoldWars/GoldWars/GameCenterHelper.swift new file mode 100644 index 0000000..abf9578 --- /dev/null +++ b/GoldWars/GoldWars/GameCenterHelper.swift @@ -0,0 +1,45 @@ +// +// GameCenterHelper.swift +// GoldWars +// +// Created by Jakob Haag on 02.05.20. +// Copyright © 2020 SP2. All rights reserved. +// + +import GameKit + +final class GameCenterHelper: NSObject { + typealias CompletionBlock = (Error?) -> Void + + static let helper = GameCenterHelper() + + var viewController: UIViewController? + + static var isAuthenticated: Bool { + return GKLocalPlayer.local.isAuthenticated + } + + override init() { + super.init() + + GKLocalPlayer.local.authenticateHandler = { gcAuthVC, error in + NotificationCenter.default + .post(name: .authenticationChanged, object: GKLocalPlayer.local.isAuthenticated) + + if GKLocalPlayer.local.isAuthenticated { + print("Authenticated to Game Center!") + } else if let vc = gcAuthVC { + self.viewController?.present(vc, animated: true) + } + else { + print("Error authentication to GameCenter: " + + "\(error?.localizedDescription ?? "none")") + } + } + } +} + +extension Notification.Name { + static let presentGame = Notification.Name(rawValue: "presentGame") + static let authenticationChanged = Notification.Name(rawValue: "authenticationChanged") +} diff --git a/GoldWars/GoldWars/GameViewController.swift b/GoldWars/GoldWars/GameViewController.swift index 2f7d3d6..e4a2f43 100644 --- a/GoldWars/GoldWars/GameViewController.swift +++ b/GoldWars/GoldWars/GameViewController.swift @@ -16,14 +16,16 @@ class GameViewController: UIViewController { super.viewDidLoad() if let view = self.view as! SKView? { - if let scene = SKScene(fileNamed: "MenuScene") { - //scene.scaleMode = .aspectFill - view.presentScene(scene) - //TODO: create dev profile or remove on delivery - view.showsFPS = true - view.showsNodeCount = true - } - } + let scene = MenuScene(size: self.view.bounds.size) + scene.scaleMode = .aspectFill + view.presentScene(scene) + //TODO: create dev profile or remove on delivery + view.showsFPS = true + view.showsNodeCount = true + + GameCenterHelper.helper.viewController = self + MatchmakingHelper.sharedInstance.viewController = self + } } override var shouldAutorotate: Bool { diff --git a/GoldWars/GoldWars/GoldWars.entitlements b/GoldWars/GoldWars/GoldWars.entitlements new file mode 100644 index 0000000..903def2 --- /dev/null +++ b/GoldWars/GoldWars/GoldWars.entitlements @@ -0,0 +1,8 @@ + + + + + aps-environment + development + + diff --git a/GoldWars/GoldWars/Info.plist b/GoldWars/GoldWars/Info.plist index 53cfd47..13fe48d 100644 --- a/GoldWars/GoldWars/Info.plist +++ b/GoldWars/GoldWars/Info.plist @@ -15,9 +15,9 @@ CFBundlePackageType $(PRODUCT_BUNDLE_PACKAGE_TYPE) CFBundleShortVersionString - 1.0 + $(MARKETING_VERSION) CFBundleVersion - 1 + $(CURRENT_PROJECT_VERSION) LSRequiresIPhoneOS UILaunchStoryboardName @@ -27,7 +27,10 @@ UIRequiredDeviceCapabilities armv7 + gamekit + UIRequiresFullScreen + UIStatusBarHidden UISupportedInterfaceOrientations diff --git a/GoldWars/GoldWars/Map/MapFactory.swift b/GoldWars/GoldWars/Map/MapFactory.swift new file mode 100644 index 0000000..ab4321a --- /dev/null +++ b/GoldWars/GoldWars/Map/MapFactory.swift @@ -0,0 +1,36 @@ +// +// MapFactory.swift +// GoldWars +// +// Created by Marcel Schwarz on 02.05.20. +// Copyright © 2020 SP2. All rights reserved. +// + +import Foundation +import SpriteKit + +class MapFactory { + + var twoPlayerMaps: [MapProtocol]! + var threePlayerMaps: [MapProtocol]! + var fourPlayerMaps: [MapProtocol]! + + init(scene: SKScene, entityManager: EntityManager) { + self.twoPlayerMaps = [ + TwoPlayerDefaultTestMap(scene: scene, entityManager: entityManager) + ] + + self.threePlayerMaps = [MapProtocol]() + self.fourPlayerMaps = [MapProtocol]() + } + + func loadMap(playerCount: Int) { + if playerCount == 2 { + twoPlayerMaps.randomElement()?.load() + } else if playerCount == 3 { + threePlayerMaps.randomElement()?.load() + } else { + fourPlayerMaps.randomElement()?.load() + } + } +} diff --git a/GoldWars/GoldWars/Map/MapProtocol.swift b/GoldWars/GoldWars/Map/MapProtocol.swift new file mode 100644 index 0000000..2560d39 --- /dev/null +++ b/GoldWars/GoldWars/Map/MapProtocol.swift @@ -0,0 +1,20 @@ +// +// MapProtocoll.swift +// GoldWars +// +// Created by Marcel Schwarz on 02.05.20. +// Copyright © 2020 SP2. All rights reserved. +// + +import Foundation +import SpriteKit + +protocol MapProtocol { + + var size: CGSize! {get set} + var entityManager: EntityManager! {get set} + + init(scene: SKScene, entityManager: EntityManager) + + func load() +} diff --git a/GoldWars/GoldWars/Map/TwoPlayerDefaultTestMap.swift b/GoldWars/GoldWars/Map/TwoPlayerDefaultTestMap.swift new file mode 100644 index 0000000..beff433 --- /dev/null +++ b/GoldWars/GoldWars/Map/TwoPlayerDefaultTestMap.swift @@ -0,0 +1,81 @@ +// +// DefaultTestMap.swift +// GoldWars +// +// Created by Marcel Schwarz on 02.05.20. +// Copyright © 2020 SP2. All rights reserved. +// + +import Foundation +import SpriteKit + +class TwoPlayerDefaultTestMap: MapProtocol { + + var entityManager: EntityManager! + var size: CGSize! + + required init(scene: SKScene, entityManager: EntityManager) { + self.entityManager = entityManager; + self.size = scene.size + } + + func load() { + + // Create Bases + let basePlayerOne = Base( + position: CGPoint(x: self.size.width * 0.1, y: self.size.height / 2), + team: .team1 + ) + + let column1 = [ + Base(position: CGPoint(x: self.size.width * 0.25, y: self.size.height * 0.25)), + Base(position: CGPoint(x: self.size.width * 0.25, y: self.size.height * 0.5)), + Base(position: CGPoint(x: self.size.width * 0.25, y: self.size.height * 0.75)) + ] + + let column2 = [ + Base(position: CGPoint(x: self.size.width * 0.5, y: self.size.height * 0.333)), + Base(position: CGPoint(x: self.size.width * 0.5, y: self.size.height * 0.666)) + ] + + let column3 = [ + Base(position: CGPoint(x: self.size.width * 0.75, y: self.size.height * 0.25)), + Base(position: CGPoint(x: self.size.width * 0.75, y: self.size.height * 0.5)), + Base(position: CGPoint(x: self.size.width * 0.75, y: self.size.height * 0.75)) + ] + + let basePlayerTwo = Base( + position: CGPoint(x: self.size.width * 0.9, y: self.size.height / 2), + team: .team2 + ) + + // Create adjacency Mapping + basePlayerOne.adjacencyList.append(contentsOf: column1) + + column1.forEach({currBase in + currBase.adjacencyList.append(contentsOf: column2) + currBase.adjacencyList.append(basePlayerOne) + }) + + column2.forEach({currBase in + currBase.adjacencyList.append(contentsOf: column3) + currBase.adjacencyList.append(contentsOf: column1) + }) + + column3.forEach({currBase in + currBase.adjacencyList.append(basePlayerTwo) + currBase.adjacencyList.append(contentsOf: column3) + }) + + basePlayerTwo.adjacencyList.append(contentsOf: column3) + + // Register bases with the EntityManager + entityManager.add(basePlayerOne) + + column1.forEach({base in entityManager.add(base)}) + column2.forEach({base in entityManager.add(base)}) + column3.forEach({base in entityManager.add(base)}) + + entityManager.add(basePlayerTwo) + } +} diff --git a/GoldWars/GoldWars/MatchmakingHelper.swift b/GoldWars/GoldWars/MatchmakingHelper.swift new file mode 100644 index 0000000..48628ce --- /dev/null +++ b/GoldWars/GoldWars/MatchmakingHelper.swift @@ -0,0 +1,178 @@ +// +// MatchmakingHelper.swift +// GoldWars +// +// Created by Chauntalle Schüle, Ömer Özel, Eray Kör on 03.05.20. +// Copyright © 2020 SP2. All rights reserved. +// + +import GameKit + +protocol GameKitHelperDelegate { + func matchStarted() + func matchEnded() + func matchReceivedData(match: GKMatch, data: NSData, + fromPlayer player: String) + +} +/* + Diese Klasse wird für das Matchmaking über das Gamecenter gebraucht + @param: delegate: erhält alle Multiplayerevents + @param: mpMatch: repräsentiert das Netzwerk, alle Mitspieler besitzen ein gemeinsames Spiel + @param: viewController: ist nicht der ViewController des Gamecenters, sondern des Spiels + @param: mpMatchStarted: gibt an, ob ein Match schon gestartet wurde + @param: isServer: gibt an, ob der local player, als der Server fungiert + @param: spieler1: ist immer der Spieler, der der Server ist + @param: spieler2: ist immer der Spieler, der der Client ist + @param: sharedInstance: ist eine geteilte Instanz für alle Spieler + */ +class MatchmakingHelper: NSObject, GKMatchmakerViewControllerDelegate, GKMatchDelegate { + + var delegate: GameKitHelperDelegate? + var mpMatch: GKMatch? + var viewController: UIViewController? + var mpMatchStarted: Bool + var isServer: Bool + var spieler1: GKPlayer? + var nameSpieler1 = "" + var menusc: MenuScene? + let localPlayer: GKLocalPlayer = GKLocalPlayer.local + + static let sharedInstance = MatchmakingHelper() + + + static var isAuthenticated: Bool{ + return GKLocalPlayer.local.isAuthenticated + } + + override init() { + mpMatchStarted = false + isServer = false + super.init() + } + + /* + Diese Methode wechselt von der MenuScene zum GameCenter ViewController. Die Spieler werden hier gesucht und gematcht. Mit minplayers/maxplayers kann bestimmt werden, wie viele Spieler insgesamt zusammen miteinander spielen. + */ + func presentMatchmaker(scene: MenuScene) { + menusc = scene + guard GKLocalPlayer.local.isAuthenticated else { + return + } + let request = GKMatchRequest() + + request.minPlayers = 2 + request.maxPlayers = 2 + request.inviteMessage = "Willst du GoldWars spielen?" + + let matchmakerVC = GKMatchmakerViewController.init(matchRequest: request) + matchmakerVC!.matchmakerDelegate = self + viewController?.present(matchmakerVC!, animated: true, completion: nil) + } + + /* + 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. + */ + func matchmakerViewController(_ viewController: GKMatchmakerViewController, didFailWithError error: Error) { + viewController.dismiss(animated: true, completion: nil) + print("Error finding match", error.localizedDescription) + delegate?.matchEnded() + } + + /* + 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 + match.delegate = self + if !mpMatchStarted && match.expectedPlayerCount == 0 { + startMatch() + } + } + + /* + 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) + + } + + /* + Verbindung/Matchmaking ist fehlgeschlagen + */ + private func match(match: GKMatch!, didFailWithError error: NSError!) { + if mpMatch != match { + return + } + mpMatchStarted = false + delegate?.matchEnded() + } + + /* + Wird beim ändern des States/Zustands des Spielers aufgerufen udn gibt dessen Zustand zurück. + */ + func match(_ match: GKMatch, player: GKPlayer, didChange state: GKPlayerConnectionState) { + if mpMatch != match { + return + } + + switch (state) { + case GKPlayerConnectionState.connected: + if (!mpMatchStarted && match.expectedPlayerCount == 0) { + startMatch() + } + case GKPlayerConnectionState.disconnected: + mpMatchStarted = false + delegate?.matchEnded() + default: + delegate?.matchEnded() + } + } + + /* + 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: { + (player) in + + self.mpMatchStarted = true + + if player == GKLocalPlayer.local { + self.isServer = true + self.spieler1 = player + self.nameSpieler1 = self.spieler1!.displayName + + } else { + self.isServer = false + } + + self.delegate?.matchStarted() + self.menusc!.loadScene(scene: GameScene(size: self.menusc!.size)) + }) + } + + + /* + Trennt die Verbindung vom Match + */ + func disconnect() { + if mpMatch != nil { + mpMatch?.disconnect() + } + } +} diff --git a/GoldWars/GoldWars/Menu/MenuScene.sks b/GoldWars/GoldWars/Menu/MenuScene.sks deleted file mode 100644 index 4eb9991..0000000 Binary files a/GoldWars/GoldWars/Menu/MenuScene.sks and /dev/null differ diff --git a/GoldWars/GoldWars/Menu/MenuScene.swift b/GoldWars/GoldWars/Menu/MenuScene.swift deleted file mode 100644 index 733d788..0000000 --- a/GoldWars/GoldWars/Menu/MenuScene.swift +++ /dev/null @@ -1,36 +0,0 @@ -// -// MenuScene.swift -// GoldWars -// -// Created by Aldin Duraki on 18.04.20. -// Copyright © 2020 SP2. All rights reserved. -// - -import SpriteKit - -class MenuScene: SKScene { - - var startGameButtonNode:SKSpriteNode! - var settingsButtonNode:SKSpriteNode! - - - override func touchesBegan(_ touches: Set, with event: UIEvent?) { - guard let touch = touches.first else { - return - } - let gameScene = GameScene(size: self.size) - let location = touch.location(in: self) - let frontTouchedNode = atPoint(location).name - - let transition = SKTransition.moveIn(with: .right, duration: 1) - - if frontTouchedNode == "startGameBtn" || frontTouchedNode == "tmpStartGameLbl"{ - self.view?.presentScene(gameScene, transition: transition) - } - - if frontTouchedNode == "settingsBtn" || frontTouchedNode == "tmpSettingsLbl"{ - //TODO: Implement settings functionality - } - } - -} diff --git a/GoldWars/GoldWars/Partikels/Fire.sks b/GoldWars/GoldWars/Partikels/Fire.sks new file mode 100644 index 0000000..f25e78f Binary files /dev/null and b/GoldWars/GoldWars/Partikels/Fire.sks differ diff --git a/GoldWars/GoldWars/Scenes/GameScene.swift b/GoldWars/GoldWars/Scenes/GameScene.swift new file mode 100644 index 0000000..b306854 --- /dev/null +++ b/GoldWars/GoldWars/Scenes/GameScene.swift @@ -0,0 +1,135 @@ +// +// GameScene.swift +// GoldWars +// +// Created by Aldin Duraki on 18.04.20. +// Copyright © 2020 SP2. All rights reserved. +// + +import SpriteKit +import GameplayKit + +class GameScene: SKScene{ + + var entityManager: EntityManager! + var isMoveTouch = false + var currentDraggedBasePos = CGPoint() + var currentDraggedBase : Base? + + override func sceneDidLoad() { + entityManager = EntityManager(scene: self) + entityManager.add(HUD(size: self.size)) + entityManager.add(Background(size: self.size)) + initMap() + } + + func initMap() { + MapFactory(scene: self, entityManager: self.entityManager).loadMap(playerCount: 2) + } + + override func touchesEnded(_ touches: Set, with event: UIEvent?) { + guard let touch = touches.first else { + return + } + + let touchLocation = touch.location(in: self) + + 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 + + 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 + + if entityManager.isModal && entity.isMember(of: Modal.self) { + entityManager.remove(entity) + for child in self.children { + if(child.name != "fire"){ + child.alpha = 1 + } + } + } + + if atPoint(touchLocation) == spriteNode && !entityManager.isModal { + spriteNode?.touchesBegan(touches, with: event) + if !entityManager.isModal { + for child in self.children { + if(child.name != "fire"){ + child.alpha = 0.3 + } + } + entityManager.add(Modal(modaltype: .BaseDetails, + base: entity as! Base, + anchorPoint: CGPoint(x: self.size.width / 2 , y: self.size.height / 2))) + } + } + } + } + + } + + override func touchesMoved(_ touches: Set, with event: UIEvent?) { + guard let touch = touches.first else { + return + } + let touchLocation = touch.location(in: self) + + for child in children { + if atPoint(touchLocation) == child { + child.touchesMoved(touches, with: event) + } + } + + for e in entityManager.entities{ + if let body = e.component(ofType: ModalContentComponent.self)?.body{ + body.text = "Schicke \( ((e.component(ofType: SliderComponent.self)?.sliderNode.getValue ?? 0) * CGFloat((e as! Modal).unitCount)).rounded(.up)) Einheiten " + } } + + let bases = entityManager.getBasesByTeam(for: .team1) + + for base in bases { + if atPoint(touchLocation) == base.component(ofType: DefaultBaseComponent.self)?.spriteNode{ + if !isMoveTouch { + currentDraggedBasePos = base.component(ofType: DefaultBaseComponent.self)!.spriteNode.position + currentDraggedBase = base + } + isMoveTouch = true + + base.component(ofType: DefaultBaseComponent.self)?.spriteNode.position = touchLocation + base.component(ofType: TeamComponent.self)?.fire.position = touchLocation + for adjacencyBase in base.adjacencyList { + let node = adjacencyBase.component(ofType: DefaultBaseComponent.self)?.spriteNode + node?.run(SKAction.sequence([ + SKAction.resize(byWidth: 2, height: 2, duration: 0.5), + SKAction.resize(byWidth: -2, height: -2, duration: 0.5) + ])) + } + } + } + } + + override func update(_ currentTime: TimeInterval) { + entityManager.getBackground()?.update(deltaTime: currentTime) + entityManager.getHUD()?.component(ofType: TimerComponent.self)?.update() + } +} diff --git a/GoldWars/GoldWars/Scenes/MenuScene.swift b/GoldWars/GoldWars/Scenes/MenuScene.swift new file mode 100644 index 0000000..edf6bb9 --- /dev/null +++ b/GoldWars/GoldWars/Scenes/MenuScene.swift @@ -0,0 +1,49 @@ +// +// MenuScene.swift +// GoldWars +// +// Created by Aldin Duraki on 18.04.20. +// Copyright © 2020 SP2. All rights reserved. +// + +import SpriteKit + +class MenuScene: SKScene { + + var entityManager: EntityManager! + + override func sceneDidLoad() { + entityManager = EntityManager(scene: self) + let midX = self.size.width / 2 + let midY = self.size.height / 2 + entityManager.add(Button(name: "startGameButton", + iconName: "", + text: "Start Game", + position: CGPoint(x: midX, y: midY), + onButtonPress: { + if CommandLine.arguments.contains("--no-matchmaking") { + self.loadScene(scene: GameScene(size: self.size)) + } else { + 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)) + } + + func loadScene(scene: SKScene) { + let transition = SKTransition.flipVertical(withDuration: 0.5) + self.view?.presentScene(scene, transition: transition) + } + + override func update(_ currentTime: TimeInterval) { + entityManager.getBackground()!.update(deltaTime: currentTime) + entityManager.getButtonByName(buttonName: "startGameButton").component(ofType: ButtonComponent.self)?.buttonNode.isEnabled = GameCenterHelper.isAuthenticated + } +} diff --git a/GoldWars/GoldWars/Base.lproj/LaunchScreen.storyboard b/GoldWars/GoldWars/Storyboards/Base.lproj/LaunchScreen.storyboard similarity index 100% rename from GoldWars/GoldWars/Base.lproj/LaunchScreen.storyboard rename to GoldWars/GoldWars/Storyboards/Base.lproj/LaunchScreen.storyboard diff --git a/GoldWars/GoldWars/Base.lproj/Main.storyboard b/GoldWars/GoldWars/Storyboards/Base.lproj/Main.storyboard similarity index 100% rename from GoldWars/GoldWars/Base.lproj/Main.storyboard rename to GoldWars/GoldWars/Storyboards/Base.lproj/Main.storyboard diff --git a/GoldWars/GoldWarsUITests/GoldWarsUITests.swift b/GoldWars/GoldWarsUITests/GoldWarsUITests.swift deleted file mode 100644 index f296a38..0000000 --- a/GoldWars/GoldWarsUITests/GoldWarsUITests.swift +++ /dev/null @@ -1,43 +0,0 @@ -// -// GoldWarsUITests.swift -// GoldWarsUITests -// -// Created by Aldin Duraki on 18.04.20. -// Copyright © 2020 SP2. All rights reserved. -// - -import XCTest - -class GoldWarsUITests: XCTestCase { - - override func setUp() { - // Put setup code here. This method is called before the invocation of each test method in the class. - - // In UI tests it is usually best to stop immediately when a failure occurs. - continueAfterFailure = false - - // In UI tests it’s important to set the initial state - such as interface orientation - required for your tests before they run. The setUp method is a good place to do this. - } - - override func tearDown() { - // Put teardown code here. This method is called after the invocation of each test method in the class. - } - - func testExample() { - // UI tests must launch the application that they test. - let app = XCUIApplication() - app.launch() - - // Use recording to get started writing UI tests. - // Use XCTAssert and related functions to verify your tests produce the correct results. - } - - func testLaunchPerformance() { - if #available(macOS 10.15, iOS 13.0, tvOS 13.0, *) { - // This measures how long it takes to launch your application. - measure(metrics: [XCTOSSignpostMetric.applicationLaunch]) { - XCUIApplication().launch() - } - } - } -} diff --git a/GoldWars/GoldWarsUITests/Info.plist b/GoldWars/GoldWarsUITests/Info.plist deleted file mode 100644 index 64d65ca..0000000 --- a/GoldWars/GoldWarsUITests/Info.plist +++ /dev/null @@ -1,22 +0,0 @@ - - - - - CFBundleDevelopmentRegion - $(DEVELOPMENT_LANGUAGE) - CFBundleExecutable - $(EXECUTABLE_NAME) - CFBundleIdentifier - $(PRODUCT_BUNDLE_IDENTIFIER) - CFBundleInfoDictionaryVersion - 6.0 - CFBundleName - $(PRODUCT_NAME) - CFBundlePackageType - $(PRODUCT_BUNDLE_PACKAGE_TYPE) - CFBundleShortVersionString - 1.0 - CFBundleVersion - 1 - -