diff --git a/GoldWars/GoldWars.xcodeproj/project.pbxproj b/GoldWars/GoldWars.xcodeproj/project.pbxproj index 14ad1f2..d04b888 100644 --- a/GoldWars/GoldWars.xcodeproj/project.pbxproj +++ b/GoldWars/GoldWars.xcodeproj/project.pbxproj @@ -18,6 +18,7 @@ 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 */; }; + ABA03DA0244BD54F00A66916 /* Base.swift in Sources */ = {isa = PBXBuildFile; fileRef = ABA03D9F244BD54F00A66916 /* Base.swift */; }; /* End PBXBuildFile section */ /* Begin PBXContainerItemProxy section */ @@ -55,6 +56,7 @@ 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 = ""; }; + ABA03D9F244BD54F00A66916 /* Base.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Base.swift; sourceTree = ""; }; /* End PBXFileReference section */ /* Begin PBXFrameworksBuildPhase section */ @@ -105,6 +107,7 @@ 110360D1244B101A008610AF /* GoldWars */ = { isa = PBXGroup; children = ( + ABA03D9E244BD53D00A66916 /* Base */, 11036114244B3E8A008610AF /* Menu */, 1103610F244B3D48008610AF /* Game */, 110360D2244B101A008610AF /* AppDelegate.swift */, @@ -153,6 +156,14 @@ path = Menu; sourceTree = ""; }; + ABA03D9E244BD53D00A66916 /* Base */ = { + isa = PBXGroup; + children = ( + ABA03D9F244BD54F00A66916 /* Base.swift */, + ); + path = Base; + sourceTree = ""; + }; /* End PBXGroup section */ /* Begin PBXNativeTarget section */ @@ -288,6 +299,7 @@ files = ( 110360D9244B101A008610AF /* GameScene.swift in Sources */, 11036113244B3E30008610AF /* MenuScene.swift in Sources */, + ABA03DA0244BD54F00A66916 /* Base.swift in Sources */, 110360DB244B101A008610AF /* GameViewController.swift in Sources */, 110360D3244B101A008610AF /* AppDelegate.swift in Sources */, ); diff --git a/GoldWars/GoldWars/Assets.xcassets/BaseTexture/PlayerOne.imageset/Contents.json b/GoldWars/GoldWars/Assets.xcassets/Base.imageset/Contents.json similarity index 70% rename from GoldWars/GoldWars/Assets.xcassets/BaseTexture/PlayerOne.imageset/Contents.json rename to GoldWars/GoldWars/Assets.xcassets/Base.imageset/Contents.json index 90f6141..91f9bef 100644 --- a/GoldWars/GoldWars/Assets.xcassets/BaseTexture/PlayerOne.imageset/Contents.json +++ b/GoldWars/GoldWars/Assets.xcassets/Base.imageset/Contents.json @@ -1,17 +1,17 @@ { "images" : [ { - "filename" : "Blue-small.png", + "filename" : "base-small.png", "idiom" : "universal", "scale" : "1x" }, { - "filename" : "Blue-medium.png", + "filename" : "base-medium.png", "idiom" : "universal", "scale" : "2x" }, { - "filename" : "Blue-large.png", + "filename" : "base-large.png", "idiom" : "universal", "scale" : "3x" } diff --git a/GoldWars/GoldWars/Assets.xcassets/Base.imageset/base-large.png b/GoldWars/GoldWars/Assets.xcassets/Base.imageset/base-large.png new file mode 100644 index 0000000..b3b9ec4 Binary files /dev/null and b/GoldWars/GoldWars/Assets.xcassets/Base.imageset/base-large.png differ diff --git a/GoldWars/GoldWars/Assets.xcassets/Base.imageset/base-medium.png b/GoldWars/GoldWars/Assets.xcassets/Base.imageset/base-medium.png new file mode 100644 index 0000000..99710a1 Binary files /dev/null and b/GoldWars/GoldWars/Assets.xcassets/Base.imageset/base-medium.png differ diff --git a/GoldWars/GoldWars/Assets.xcassets/Base.imageset/base-small.png b/GoldWars/GoldWars/Assets.xcassets/Base.imageset/base-small.png new file mode 100644 index 0000000..dd7d356 Binary files /dev/null and b/GoldWars/GoldWars/Assets.xcassets/Base.imageset/base-small.png differ diff --git a/GoldWars/GoldWars/Assets.xcassets/BaseTexture/Contents.json b/GoldWars/GoldWars/Assets.xcassets/BaseTexture/Contents.json deleted file mode 100644 index 73c0059..0000000 --- a/GoldWars/GoldWars/Assets.xcassets/BaseTexture/Contents.json +++ /dev/null @@ -1,6 +0,0 @@ -{ - "info" : { - "author" : "xcode", - "version" : 1 - } -} diff --git a/GoldWars/GoldWars/Assets.xcassets/BaseTexture/PlayerOne.imageset/Blue-large.png b/GoldWars/GoldWars/Assets.xcassets/BaseTexture/PlayerOne.imageset/Blue-large.png deleted file mode 100644 index 36c39f3..0000000 Binary files a/GoldWars/GoldWars/Assets.xcassets/BaseTexture/PlayerOne.imageset/Blue-large.png and /dev/null differ diff --git a/GoldWars/GoldWars/Assets.xcassets/BaseTexture/PlayerOne.imageset/Blue-medium.png b/GoldWars/GoldWars/Assets.xcassets/BaseTexture/PlayerOne.imageset/Blue-medium.png deleted file mode 100644 index d46a821..0000000 Binary files a/GoldWars/GoldWars/Assets.xcassets/BaseTexture/PlayerOne.imageset/Blue-medium.png and /dev/null differ diff --git a/GoldWars/GoldWars/Assets.xcassets/BaseTexture/PlayerOne.imageset/Blue-small.png b/GoldWars/GoldWars/Assets.xcassets/BaseTexture/PlayerOne.imageset/Blue-small.png deleted file mode 100644 index 4138b79..0000000 Binary files a/GoldWars/GoldWars/Assets.xcassets/BaseTexture/PlayerOne.imageset/Blue-small.png and /dev/null differ diff --git a/GoldWars/GoldWars/Assets.xcassets/BaseTexture/PlayerTwo.imageset/Contents.json b/GoldWars/GoldWars/Assets.xcassets/BaseTexture/PlayerTwo.imageset/Contents.json deleted file mode 100644 index 3fda81f..0000000 --- a/GoldWars/GoldWars/Assets.xcassets/BaseTexture/PlayerTwo.imageset/Contents.json +++ /dev/null @@ -1,23 +0,0 @@ -{ - "images" : [ - { - "filename" : "Red-small.png", - "idiom" : "universal", - "scale" : "1x" - }, - { - "filename" : "Red-medium.png", - "idiom" : "universal", - "scale" : "2x" - }, - { - "filename" : "Red-large.png", - "idiom" : "universal", - "scale" : "3x" - } - ], - "info" : { - "author" : "xcode", - "version" : 1 - } -} diff --git a/GoldWars/GoldWars/Assets.xcassets/BaseTexture/PlayerTwo.imageset/Red-large.png b/GoldWars/GoldWars/Assets.xcassets/BaseTexture/PlayerTwo.imageset/Red-large.png deleted file mode 100644 index 61b4e99..0000000 Binary files a/GoldWars/GoldWars/Assets.xcassets/BaseTexture/PlayerTwo.imageset/Red-large.png and /dev/null differ diff --git a/GoldWars/GoldWars/Assets.xcassets/BaseTexture/PlayerTwo.imageset/Red-medium.png b/GoldWars/GoldWars/Assets.xcassets/BaseTexture/PlayerTwo.imageset/Red-medium.png deleted file mode 100644 index ca641a8..0000000 Binary files a/GoldWars/GoldWars/Assets.xcassets/BaseTexture/PlayerTwo.imageset/Red-medium.png and /dev/null differ diff --git a/GoldWars/GoldWars/Assets.xcassets/BaseTexture/PlayerTwo.imageset/Red-small.png b/GoldWars/GoldWars/Assets.xcassets/BaseTexture/PlayerTwo.imageset/Red-small.png deleted file mode 100644 index 68d96fc..0000000 Binary files a/GoldWars/GoldWars/Assets.xcassets/BaseTexture/PlayerTwo.imageset/Red-small.png and /dev/null differ diff --git a/GoldWars/GoldWars/Base/Base.swift b/GoldWars/GoldWars/Base/Base.swift new file mode 100644 index 0000000..393c427 --- /dev/null +++ b/GoldWars/GoldWars/Base/Base.swift @@ -0,0 +1,46 @@ +// +// Base.swift +// GoldWars +// +// Created by Marcel Schwarz on 18.04.20. +// Copyright © 2020 SP2. All rights reserved. +// + +import SpriteKit +import GameplayKit + +class Base { + var spriteNode: BaseNode! + + init(frame: CGRect, color: UIColor, position: CGPoint) { + spriteNode = BaseNode(texture: SKTexture(imageNamed: "Base"), color: color, size: CGSize(width: 50.0, height: 50.0)) + spriteNode.colorBlendFactor = 1 + spriteNode.name = "Base" + spriteNode.position = position + spriteNode.isUserInteractionEnabled = true + } +} + +class BaseNode: SKSpriteNode { + override func touchesBegan(_ touches: Set, with event: UIEvent?) { + print("\(self.name!) was touched and is located at \(self.position)") + self.run( + SKAction.sequence( + [ + SKAction.resize(byWidth: 20, height: 20, duration: 0.5), + SKAction.resize(byWidth: -20, height: -20, duration: 0.5) + ] + ) + ) + + } +} + +enum PlayerColors { + static let colors = [ + UIColor(red: 231/255, green: 76/255, blue: 60/255, alpha: 1.0), + UIColor(red: 241/255, green: 196/255, blue: 15/255, alpha: 1.0), + UIColor(red: 46/255, green: 204/255, blue: 113/255, alpha: 1.0), + UIColor(red: 52/255, green: 152/255, blue: 219/255, alpha: 1.0), + ] +} diff --git a/GoldWars/GoldWars/Game/GameScene.sks b/GoldWars/GoldWars/Game/GameScene.sks index 693e11d..ebf306a 100644 Binary files a/GoldWars/GoldWars/Game/GameScene.sks and b/GoldWars/GoldWars/Game/GameScene.sks differ diff --git a/GoldWars/GoldWars/Game/GameScene.swift b/GoldWars/GoldWars/Game/GameScene.swift index 413eb79..df15181 100644 --- a/GoldWars/GoldWars/Game/GameScene.swift +++ b/GoldWars/GoldWars/Game/GameScene.swift @@ -13,9 +13,28 @@ class GameScene: SKScene { var entities = [GKEntity]() var graphs = [String : GKGraph]() + var bases = [Base]() override func sceneDidLoad() { + // Spawn bases + for _ in 1...15 { + let color = PlayerColors.colors.randomElement() + let xRange = Int(frame.minX + frame.width * 0.07)...Int(frame.maxX - frame.width * 0.07) + let yRange = Int(frame.minY + frame.height * 0.07)...Int(frame.maxY - frame.width * 0.07) + let position = CGPoint( + x: Int.random(in: xRange), + y: Int.random(in: yRange) + ) + + print("Generating Base at \(position)") + + let base = Base(frame: frame, color: color!, position: position) + + addChild(base.spriteNode) + bases.append(base) + } + } func touchDown(atPoint pos : CGPoint) { @@ -31,7 +50,7 @@ class GameScene: SKScene { } override func touchesBegan(_ touches: Set, with event: UIEvent?) { - + } override func touchesMoved(_ touches: Set, with event: UIEvent?) {