Merge branch '38-verschiedene-modals-fuer-angriff-und-verschieben' into 'development'

Resolve "Verschiedene Modals fuer Angriff und Verschieben"

Closes #38

See merge request marcel.schwarz/software-projekt-2!81
This commit is contained in:
Marcel Schwarz 2020-05-29 13:58:06 +00:00
commit 02c7903705
4 changed files with 40 additions and 34 deletions

View File

@ -41,7 +41,6 @@
9EC2FBA72476B1EC00ABF11F /* PlayerInfoComponent.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9EC2FBA62476B1EC00ABF11F /* PlayerInfoComponent.swift */; }; 9EC2FBA72476B1EC00ABF11F /* PlayerInfoComponent.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9EC2FBA62476B1EC00ABF11F /* PlayerInfoComponent.swift */; };
9EC7E48B2461FBF700396BCD /* SliderNode.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9EC7E48A2461FBF700396BCD /* SliderNode.swift */; }; 9EC7E48B2461FBF700396BCD /* SliderNode.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9EC7E48A2461FBF700396BCD /* SliderNode.swift */; };
9EC86B9F245C88A300796EF3 /* Modal.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9EC86B9E245C88A300796EF3 /* Modal.swift */; }; 9EC86B9F245C88A300796EF3 /* Modal.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9EC86B9E245C88A300796EF3 /* Modal.swift */; };
9EC86BA6245C8AD000796EF3 /* ModalType.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9EC86BA5245C8AD000796EF3 /* ModalType.swift */; };
9EEDE02D246FCD770096C735 /* SpinningLogoEntity.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9EEDE02C246FCD770096C735 /* SpinningLogoEntity.swift */; }; 9EEDE02D246FCD770096C735 /* SpinningLogoEntity.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9EEDE02C246FCD770096C735 /* SpinningLogoEntity.swift */; };
9EEDE02F246FCD800096C735 /* SpinningLogoComponent.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9EEDE02E246FCD800096C735 /* SpinningLogoComponent.swift */; }; 9EEDE02F246FCD800096C735 /* SpinningLogoComponent.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9EEDE02E246FCD800096C735 /* SpinningLogoComponent.swift */; };
AB0B88F6247AD89200C8DF66 /* SkillComponent.swift in Sources */ = {isa = PBXBuildFile; fileRef = AB0B88F5247AD89200C8DF66 /* SkillComponent.swift */; }; AB0B88F6247AD89200C8DF66 /* SkillComponent.swift in Sources */ = {isa = PBXBuildFile; fileRef = AB0B88F5247AD89200C8DF66 /* SkillComponent.swift */; };
@ -108,7 +107,6 @@
9EC2FBA62476B1EC00ABF11F /* PlayerInfoComponent.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PlayerInfoComponent.swift; sourceTree = "<group>"; }; 9EC2FBA62476B1EC00ABF11F /* PlayerInfoComponent.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PlayerInfoComponent.swift; sourceTree = "<group>"; };
9EC7E48A2461FBF700396BCD /* SliderNode.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SliderNode.swift; sourceTree = "<group>"; }; 9EC7E48A2461FBF700396BCD /* SliderNode.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SliderNode.swift; sourceTree = "<group>"; };
9EC86B9E245C88A300796EF3 /* Modal.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Modal.swift; sourceTree = "<group>"; }; 9EC86B9E245C88A300796EF3 /* Modal.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Modal.swift; sourceTree = "<group>"; };
9EC86BA5245C8AD000796EF3 /* ModalType.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ModalType.swift; sourceTree = "<group>"; };
9ECD3699245C91F7008DEEBD /* GoldWars.entitlements */ = {isa = PBXFileReference; lastKnownFileType = text.plist.entitlements; path = GoldWars.entitlements; sourceTree = "<group>"; }; 9ECD3699245C91F7008DEEBD /* GoldWars.entitlements */ = {isa = PBXFileReference; lastKnownFileType = text.plist.entitlements; path = GoldWars.entitlements; sourceTree = "<group>"; };
9EEDE02C246FCD770096C735 /* SpinningLogoEntity.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = SpinningLogoEntity.swift; sourceTree = "<group>"; }; 9EEDE02C246FCD770096C735 /* SpinningLogoEntity.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = SpinningLogoEntity.swift; sourceTree = "<group>"; };
9EEDE02E246FCD800096C735 /* SpinningLogoComponent.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = SpinningLogoComponent.swift; sourceTree = "<group>"; }; 9EEDE02E246FCD800096C735 /* SpinningLogoComponent.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = SpinningLogoComponent.swift; sourceTree = "<group>"; };
@ -203,23 +201,23 @@
116060F4245C56EA004E5A36 /* Components */ = { 116060F4245C56EA004E5A36 /* Components */ = {
isa = PBXGroup; isa = PBXGroup;
children = ( children = (
C05BB9C3247D890C00411249 /* SliderComponent.swift */,
C064E9A7246C0EA50022B228 /* LabelNode.swift */,
9E174C81245DD81D00209FF0 /* ButtonNode.swift */,
8BB6FF3F2472B8F000162BBD /* SingeClickButtonNode.swift */,
9EA3ABEA245C6DFA006BC61D /* BaseNode.swift */,
9EC7E48A2461FBF700396BCD /* SliderNode.swift */,
C064E9A9246C114C0022B228 /* LabelComponent.swift */,
AB0B88F5247AD89200C8DF66 /* SkillComponent.swift */,
9EEDE02E246FCD800096C735 /* SpinningLogoComponent.swift */,
9E174C85245DD91500209FF0 /* ButtonComponent.swift */,
9EA3ABE8245C6DAA006BC61D /* DefaultBaseComponent.swift */,
9E78ACB7245CB75B00526FF7 /* TeamComponent.swift */,
9E174C87245DF1FF00209FF0 /* BackgroundComponent.swift */,
9E04AFAE245E2B73002D5CFC /* AttackActionComponent.swift */, 9E04AFAE245E2B73002D5CFC /* AttackActionComponent.swift */,
2086465B2461B66200817C23 /* TimerComponent.swift */, 9E174C87245DF1FF00209FF0 /* BackgroundComponent.swift */,
9EA3ABEA245C6DFA006BC61D /* BaseNode.swift */,
9E174C85245DD91500209FF0 /* ButtonComponent.swift */,
9E174C81245DD81D00209FF0 /* ButtonNode.swift */,
9EA3ABE8245C6DAA006BC61D /* DefaultBaseComponent.swift */,
3E6785432472CC27007B9DE4 /* DefaultWayComponent.swift */, 3E6785432472CC27007B9DE4 /* DefaultWayComponent.swift */,
C064E9A9246C114C0022B228 /* LabelComponent.swift */,
C064E9A7246C0EA50022B228 /* LabelNode.swift */,
9EC2FBA62476B1EC00ABF11F /* PlayerInfoComponent.swift */, 9EC2FBA62476B1EC00ABF11F /* PlayerInfoComponent.swift */,
8BB6FF3F2472B8F000162BBD /* SingeClickButtonNode.swift */,
AB0B88F5247AD89200C8DF66 /* SkillComponent.swift */,
C05BB9C3247D890C00411249 /* SliderComponent.swift */,
9EC7E48A2461FBF700396BCD /* SliderNode.swift */,
9EEDE02E246FCD800096C735 /* SpinningLogoComponent.swift */,
9E78ACB7245CB75B00526FF7 /* TeamComponent.swift */,
2086465B2461B66200817C23 /* TimerComponent.swift */,
); );
path = Components; path = Components;
sourceTree = "<group>"; sourceTree = "<group>";
@ -259,7 +257,6 @@
9EC86BA2245C89B200796EF3 /* Enums */ = { 9EC86BA2245C89B200796EF3 /* Enums */ = {
isa = PBXGroup; isa = PBXGroup;
children = ( children = (
9EC86BA5245C8AD000796EF3 /* ModalType.swift */,
3EBD242D245D9332003CECE7 /* Team.swift */, 3EBD242D245D9332003CECE7 /* Team.swift */,
3F745DEF246F48FC00CE7375 /* PlayerMoveType.swift */, 3F745DEF246F48FC00CE7375 /* PlayerMoveType.swift */,
); );
@ -401,7 +398,6 @@
9E78ACB8245CB75B00526FF7 /* TeamComponent.swift in Sources */, 9E78ACB8245CB75B00526FF7 /* TeamComponent.swift in Sources */,
9E0E459724796262009817A6 /* GameCenterManager.swift in Sources */, 9E0E459724796262009817A6 /* GameCenterManager.swift in Sources */,
3FE19DB5246C7A22004827AB /* RoundCalculatorService.swift in Sources */, 3FE19DB5246C7A22004827AB /* RoundCalculatorService.swift in Sources */,
9EC86BA6245C8AD000796EF3 /* ModalType.swift in Sources */,
9EC239E1246878A900952F74 /* MultiplayerNetwork.swift in Sources */, 9EC239E1246878A900952F74 /* MultiplayerNetwork.swift in Sources */,
9EA3ABEB245C6DFA006BC61D /* BaseNode.swift in Sources */, 9EA3ABEB245C6DFA006BC61D /* BaseNode.swift in Sources */,
9E04AFAF245E2B73002D5CFC /* AttackActionComponent.swift in Sources */, 9E04AFAF245E2B73002D5CFC /* AttackActionComponent.swift in Sources */,

View File

@ -11,6 +11,7 @@ import GameplayKit
enum ModalType: String{ enum ModalType: String{
case BaseDetails case BaseDetails
case BaseAttack case BaseAttack
case BaseMoveOwnUnits
} }
class Modal: GKEntity{ class Modal: GKEntity{
@ -46,7 +47,11 @@ class Modal: GKEntity{
footer = SKLabelNode() footer = SKLabelNode()
case .BaseAttack: case .BaseAttack:
header = SKLabelNode(text: "Angriff") header = SKLabelNode(text: "Angriff")
body = SKLabelNode(text: "Schicke \(unitCount / 2) Einheiten") body = SKLabelNode(text: "Schicke \(unitCount / 2)\nEinheiten")
footer = SKLabelNode()
case .BaseMoveOwnUnits:
header = SKLabelNode(text: "Formation")
body = SKLabelNode(text: "Sende \(unitCount / 2)\nEinheiten")
footer = SKLabelNode() footer = SKLabelNode()
} }
@ -75,9 +80,10 @@ class Modal: GKEntity{
addComponent(ButtonComponent(textureName: "yellow_button04", text: "Zurück", position: CGPoint(x: anchorPoint.x , y: anchorPoint.y - 105), isEnabled: true, onButtonPress: { addComponent(ButtonComponent(textureName: "yellow_button04", text: "Zurück", position: CGPoint(x: anchorPoint.x , y: anchorPoint.y - 105), isEnabled: true, onButtonPress: {
EntityManager.gameEMInstance.removeModal() EntityManager.gameEMInstance.removeModal()
})) }))
case .BaseAttack: case .BaseAttack, .BaseMoveOwnUnits:
let text = (modaltype == .BaseAttack) ? "Angriff" : "Senden"
addComponent(SliderComponent(width: 300, position: CGPoint(x: anchorPoint.x , y: anchorPoint.y - 50))) addComponent(SliderComponent(width: 300, position: CGPoint(x: anchorPoint.x , y: anchorPoint.y - 50)))
addComponent(ButtonComponent(textureName: "yellow_button04", text: "Senden", position: CGPoint(x: anchorPoint.x , y: anchorPoint.y - 105), isEnabled: true, onButtonPress: { addComponent(ButtonComponent(textureName: "yellow_button04", text: text, position: CGPoint(x: anchorPoint.x , y: anchorPoint.y - 105), isEnabled: true, onButtonPress: {
self.sendUnits(currentDraggedBase: currentDraggedBase, touchLocation: touchLocation, gameScene: gameScene, collisionBase: collisionBase) self.sendUnits(currentDraggedBase: currentDraggedBase, touchLocation: touchLocation, gameScene: gameScene, collisionBase: collisionBase)
EntityManager.gameEMInstance.removeModal() EntityManager.gameEMInstance.removeModal()
})) }))

View File

@ -1,9 +0,0 @@
//
// ModalType.swift
// GoldWars
//
// Created by Niko Jochim on 01.05.20.
// Copyright © 2020 SP2. All rights reserved.
//

View File

@ -109,7 +109,8 @@ class GameScene: SKScene{
if !checkIfMoveIsAble() { if !checkIfMoveIsAble() {
return return
} }
entityManager.add(Modal(modaltype: .BaseAttack, let modaltype = setModalType()
entityManager.add(Modal(modaltype: modaltype,
base: currentDraggedBase!, base: currentDraggedBase!,
anchorPoint: CGPoint(x: self.size.width / 2 , y: self.size.height / 2), anchorPoint: CGPoint(x: self.size.width / 2 , y: self.size.height / 2),
gameScene: self, gameScene: self,
@ -169,10 +170,22 @@ class GameScene: SKScene{
} }
func checkIfMoveIsAble() -> Bool{ func checkIfMoveIsAble() -> Bool{
if collisionBase?.ownershipPlayer == currentDraggedBase?.ownershipPlayer { if isAttackMove() {
return RoundCalculatorService.sharedInstance.numberOfOwnUnitMoves < 5
} else {
return RoundCalculatorService.sharedInstance.numberOfAttacks < 2 return RoundCalculatorService.sharedInstance.numberOfAttacks < 2
} else {
return RoundCalculatorService.sharedInstance.numberOfOwnUnitMoves < 5
} }
} }
func setModalType() -> ModalType {
if isAttackMove() {
return .BaseAttack
} else {
return .BaseMoveOwnUnits
}
}
func isAttackMove() -> Bool {
return collisionBase?.ownershipPlayer != currentDraggedBase?.ownershipPlayer
}
} }