Merge branch '16-einheiten-der-basis-hinzufugen' into 'development'

Resolve "Einheiten der Basis hinzufügen"

Closes #16

See merge request marcel.schwarz/software-projekt-2!14
This commit is contained in:
Aldin Duraki 2020-04-22 17:42:27 +00:00
commit f5f45af111
3 changed files with 12 additions and 9 deletions

View File

@ -13,8 +13,10 @@ 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) {
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)
@ -26,6 +28,8 @@ class Base : SKSpriteNode{
self.position = position
self.zPosition = 2
self.isUserInteractionEnabled = true
self.unitCount = unitCount
self.unitType = unitType
}
required init?(coder aDecoder: NSCoder) {
@ -45,7 +49,6 @@ class Base : SKSpriteNode{
]
)
)
}
override func touchesMoved(_ touches: Set<UITouch>, with event: UIEvent?) {

View File

@ -34,8 +34,8 @@ class GameScene: SKScene, SKPhysicsContactDelegate {
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" )
let basePlayer2 = Base(color: SKColor.blue, position: CGPoint(x: maxX * 0.9, y: midY), name: "Player2" )
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

View File

@ -6,8 +6,8 @@
// Copyright © 2020 SP2. All rights reserved.
//
struct Unit{
var strength: Float
var health: Float
var defence: Float
enum Unit{
case General
case Defence
case Attack
}