Merge branch '70-anzahl-zuege-pro-runde' into 'development'
Resolve "Anzahl Zuege pro Runde" Closes #70 See merge request marcel.schwarz/software-projekt-2!80
This commit is contained in:
commit
23707cb1d9
@ -55,6 +55,7 @@ class TimerComponent: GKComponent {
|
||||
|
||||
if(isFinished()){
|
||||
self.labelNode.text = "Synching"
|
||||
RoundCalculatorService.sharedInstance.resetNumberOfAttacksAndFormats()
|
||||
if !MultiplayerNetwork.sharedInstance.isSending {
|
||||
MultiplayerNetwork.sharedInstance.sendPlayerMoves(playerMoves: DataService.sharedInstance.localPlayerMoves)
|
||||
}
|
||||
|
@ -23,7 +23,6 @@ class Modal: GKEntity{
|
||||
var body: SKLabelNode
|
||||
var footer: SKLabelNode
|
||||
|
||||
|
||||
init(modaltype: ModalType, base: Base, anchorPoint: CGPoint, gameScene: GameScene, currentDraggedBase: Base?, touchLocation: CGPoint, collisionBase: Base?) {
|
||||
unitCount = base.unitCount
|
||||
|
||||
@ -105,6 +104,7 @@ class Modal: GKEntity{
|
||||
func sendUnits(currentDraggedBase: Base?, touchLocation: CGPoint, gameScene: GameScene, collisionBase: Base?){
|
||||
for base in currentDraggedBase!.adjacencyList {
|
||||
if base == collisionBase {
|
||||
RoundCalculatorService.sharedInstance.increaseMoveCounter(ownBase: currentDraggedBase?.ownershipPlayer == base.ownershipPlayer)
|
||||
entityManager.update((currentDraggedBase?.doPlayerMoveTypeToBase(base: base, playerMoveType: PlayerMoveType.AtkMove, units: Int(GameScene.sendUnits)))!)
|
||||
GameScene.sendUnits = 0
|
||||
}
|
||||
|
@ -19,6 +19,9 @@ class RoundCalculatorService {
|
||||
|
||||
var isCalculating = false
|
||||
|
||||
var numberOfAttacks = 0
|
||||
var numberOfOwnUnitMoves = 0
|
||||
|
||||
func calculateRound() {
|
||||
os_log("Started calculating Round", log: RoundCalculatorService.LOG, type: .info)
|
||||
isCalculating = true
|
||||
@ -137,4 +140,16 @@ class RoundCalculatorService {
|
||||
//TODO: outsource playermoves
|
||||
}
|
||||
|
||||
func resetNumberOfAttacksAndFormats() {
|
||||
self.numberOfAttacks = 0;
|
||||
self.numberOfOwnUnitMoves = 0;
|
||||
}
|
||||
|
||||
func increaseMoveCounter(ownBase: Bool!) {
|
||||
if ownBase {
|
||||
self.numberOfOwnUnitMoves = self.numberOfOwnUnitMoves + 1
|
||||
} else {
|
||||
self.numberOfAttacks = self.numberOfAttacks + 1
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -115,6 +115,9 @@ class GameScene: SKScene{
|
||||
collisionBase = base
|
||||
// TODO: change interaction based on collision instead of touchlocation
|
||||
if currentDraggedBase!.unitCount > 1 {
|
||||
if !checkIfMoveIsAble() {
|
||||
return
|
||||
}
|
||||
entityManager.add(Modal(modaltype: .BaseAttack,
|
||||
base: currentDraggedBase!,
|
||||
anchorPoint: CGPoint(x: self.size.width / 2 , y: self.size.height / 2),
|
||||
@ -173,4 +176,12 @@ class GameScene: SKScene{
|
||||
]))
|
||||
}
|
||||
}
|
||||
|
||||
func checkIfMoveIsAble() -> Bool{
|
||||
if collisionBase?.ownershipPlayer == currentDraggedBase?.ownershipPlayer {
|
||||
return RoundCalculatorService.sharedInstance.numberOfOwnUnitMoves < 5
|
||||
} else {
|
||||
return RoundCalculatorService.sharedInstance.numberOfAttacks < 2
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -13,10 +13,10 @@ class SettingsScene: SKScene {
|
||||
var entityManager = EntityManager.settingsEMInstance
|
||||
|
||||
override func sceneDidLoad() {
|
||||
|
||||
entityManager.setScene(scene: self)
|
||||
let positionX = self.size.width * 0.1
|
||||
let positionY = self.size.height * 0.05
|
||||
print("SceneDidLoad Setting")
|
||||
entityManager.add(Button(name: "backToMenuScene",
|
||||
textureName: "yellow_button04",
|
||||
text: "Back",
|
||||
|
Loading…
Reference in New Issue
Block a user