Minor fixes
This commit is contained in:
parent
ad44ba8302
commit
9fd34d9a6c
@ -31,9 +31,10 @@ class Base: GKEntity{
|
||||
self.position = position
|
||||
super.init()
|
||||
|
||||
addComponent(DefaultBaseComponent(texture: SKTexture(imageNamed: "Base"), position: position))
|
||||
let spritePos = position
|
||||
addComponent(DefaultBaseComponent(texture: SKTexture(imageNamed: "Base"), position: spritePos))
|
||||
if(team != nil && player != nil){
|
||||
addComponent(TeamComponent(team: team!, player: player!, position: position))
|
||||
addComponent(TeamComponent(team: team!, player: player!, position: spritePos))
|
||||
self.unitCount = 500
|
||||
}
|
||||
}
|
||||
|
@ -43,10 +43,10 @@ class EntityManager {
|
||||
scene.addChild(modal.header)
|
||||
scene.addChild(modal.body)
|
||||
scene.addChild(modal.footer)
|
||||
isModal = true
|
||||
}
|
||||
if let skillButtonNode = entity.component(ofType: AtkBoostSkillComponent.self)?.skillButtonNode {
|
||||
scene.addChild(skillButtonNode)
|
||||
isModal = true
|
||||
}
|
||||
if let skillButtonNode = entity.component(ofType: DefBoostSkillComponent.self)?.skillButtonNode {
|
||||
scene.addChild(skillButtonNode)
|
||||
@ -60,7 +60,6 @@ class EntityManager {
|
||||
}
|
||||
if let buttonNode = entity.component(ofType: ButtonComponent.self)?.buttonNode {
|
||||
scene.addChild(buttonNode)
|
||||
isModal = true
|
||||
}
|
||||
if let nodes = entity.component(ofType: BackgroundComponent.self)?.nodes {
|
||||
for node in nodes {
|
||||
@ -76,7 +75,6 @@ class EntityManager {
|
||||
}
|
||||
if let cancelBtnNode = entity.component(ofType: CancelBtnComponent.self)?.cancelBtnNode {
|
||||
scene.addChild(cancelBtnNode)
|
||||
isModal = true
|
||||
}
|
||||
if let node = entity.component(ofType: SpinningLogoComponent.self)?.node {
|
||||
scene.addChild(node)
|
||||
@ -97,6 +95,7 @@ class EntityManager {
|
||||
modal.header.removeFromParent()
|
||||
modal.body.removeFromParent()
|
||||
modal.footer.removeFromParent()
|
||||
isModal = false
|
||||
}
|
||||
if let sliderNode = entity.component(ofType: SliderComponent.self)?.sliderNode {
|
||||
sliderNode.sliderKnob.removeFromParent()
|
||||
@ -104,11 +103,9 @@ class EntityManager {
|
||||
}
|
||||
if let modalButton = entity.component(ofType: ButtonComponent.self) {
|
||||
modalButton.buttonNode.removeFromParent()
|
||||
isModal = false
|
||||
}
|
||||
if let cancelBtnNode = entity.component(ofType: CancelBtnComponent.self)?.cancelBtnNode {
|
||||
cancelBtnNode.removeFromParent()
|
||||
isModal = false
|
||||
}
|
||||
entities.remove(entity)
|
||||
}
|
||||
@ -147,6 +144,8 @@ class EntityManager {
|
||||
|
||||
if snapBase.ownership != nil {
|
||||
getOwnerBySnapBase = MatchmakingHelper.sharedInstance.getGKPlayerByUsername(displayName: snapBase.ownership!)
|
||||
} else {
|
||||
entity.removeComponent(ofType: TeamComponent.self)
|
||||
}
|
||||
if getOwnerBySnapBase != nil {
|
||||
base.changeOwnership = true
|
||||
|
@ -111,7 +111,6 @@ class RoundCalculatorService {
|
||||
MultiplayerNetwork.sharedInstance.sendSnapshotModelToPlayers()
|
||||
DataService.sharedInstance.snapshotModel = currentSnapshotModel
|
||||
EntityManager.sharedInstance.updateSnapshotModel(snapshotModel: currentSnapshotModel!)
|
||||
sleep(1)
|
||||
EntityManager.sharedInstance.getTimer().startWithDuration(duration: 31)
|
||||
os_log("Finished calculating Round", log: RoundCalculatorService.LOG, type: .info)
|
||||
}
|
||||
|
@ -13,7 +13,6 @@ import GameKit
|
||||
class GameScene: SKScene{
|
||||
|
||||
var isMoveTouch = false
|
||||
var currentDraggedBasePos = CGPoint()
|
||||
var currentDraggedBase : Base?
|
||||
static var sendUnits: CGFloat = 0
|
||||
var collisionBase: Base?
|
||||
@ -42,8 +41,8 @@ class GameScene: SKScene{
|
||||
|
||||
if isMoveTouch{
|
||||
isMoveTouch = false
|
||||
currentDraggedBase!.component(ofType: DefaultBaseComponent.self)?.spriteNode.position = currentDraggedBasePos
|
||||
currentDraggedBase!.component(ofType: TeamComponent.self)?.fire.position = currentDraggedBasePos
|
||||
currentDraggedBase!.component(ofType: DefaultBaseComponent.self)?.spriteNode.position = currentDraggedBase!.position
|
||||
currentDraggedBase!.component(ofType: TeamComponent.self)?.fire.position = currentDraggedBase!.position
|
||||
|
||||
addAttackDetails(touchLocation: touchLocation)
|
||||
}
|
||||
@ -51,6 +50,7 @@ class GameScene: SKScene{
|
||||
for entity in EntityManager.sharedInstance.entities {
|
||||
let spriteNode = entity.component(ofType: DefaultBaseComponent.self)?.spriteNode
|
||||
|
||||
//FIXME: this is confusing
|
||||
addBaseDetails(touchLocation: touchLocation, spriteNode: spriteNode, touches: touches, event: event, entity: entity)
|
||||
}
|
||||
}
|
||||
@ -83,17 +83,20 @@ class GameScene: SKScene{
|
||||
func addBaseDetails(touchLocation: CGPoint, spriteNode: SKNode?, touches: Set<UITouch>, event: UIEvent?, entity: GKEntity){
|
||||
if atPoint(touchLocation) == spriteNode && !EntityManager.sharedInstance.isModal {
|
||||
spriteNode?.touchesBegan(touches, with: event)
|
||||
if !EntityManager.sharedInstance.isModal {
|
||||
for child in self.children {
|
||||
if(child.name != "fire"){
|
||||
child.alpha = 0.3
|
||||
if let baseEntity = entity as? Base {
|
||||
if baseEntity.ownershipPlayer == GKLocalPlayer.local {
|
||||
for child in self.children {
|
||||
if(child.name != "fire"){
|
||||
child.alpha = 0.3
|
||||
}
|
||||
}
|
||||
EntityManager.sharedInstance.add(Modal(modaltype: .BaseDetails,
|
||||
base: entity as! Base,
|
||||
anchorPoint: CGPoint(x: self.size.width / 2 , y: self.size.height / 2),
|
||||
gameScene: self,
|
||||
currentDraggedBase: currentDraggedBase, touchLocation: touchLocation, collisionBase: collisionBase))
|
||||
|
||||
}
|
||||
EntityManager.sharedInstance.add(Modal(modaltype: .BaseDetails,
|
||||
base: entity as! Base,
|
||||
anchorPoint: CGPoint(x: self.size.width / 2 , y: self.size.height / 2),
|
||||
gameScene: self, currentDraggedBase: currentDraggedBase, touchLocation: touchLocation, collisionBase: collisionBase))
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -103,12 +106,13 @@ class GameScene: SKScene{
|
||||
if atPoint(touchLocation) == base.component(ofType: DefaultBaseComponent.self)?.spriteNode {
|
||||
collisionBase = base
|
||||
// TODO: change interaction based on collision instead of touchlocation
|
||||
EntityManager.sharedInstance.add(Modal(modaltype: .BaseAttack,
|
||||
base: currentDraggedBase!,
|
||||
anchorPoint: CGPoint(x: self.size.width / 2 , y: self.size.height / 2),
|
||||
gameScene: self, currentDraggedBase: currentDraggedBase, touchLocation: touchLocation, collisionBase: collisionBase))
|
||||
GameScene.sendUnits = CGFloat(currentDraggedBase!.unitCount / 2)
|
||||
|
||||
if currentDraggedBase!.unitCount > 1 {
|
||||
EntityManager.sharedInstance.add(Modal(modaltype: .BaseAttack,
|
||||
base: currentDraggedBase!,
|
||||
anchorPoint: CGPoint(x: self.size.width / 2 , y: self.size.height / 2),
|
||||
gameScene: self, currentDraggedBase: currentDraggedBase, touchLocation: touchLocation, collisionBase: collisionBase))
|
||||
GameScene.sendUnits = CGFloat(currentDraggedBase!.unitCount / 2)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -118,7 +122,7 @@ class GameScene: SKScene{
|
||||
if let body = e.component(ofType: ModalContentComponent.self)?.body{
|
||||
GameScene.sendUnits = ((e.component(ofType: SliderComponent.self)?.sliderNode.getValue ?? 0) * CGFloat((e as! Modal).unitCount)).rounded(.up)
|
||||
|
||||
//TODO: quick fix chauntalle die olle mach augen auf
|
||||
//TODO: refactor this quick and dirty fix
|
||||
if GameScene.sendUnits == 0 {
|
||||
GameScene.sendUnits = 1
|
||||
} else if Int(GameScene.sendUnits) == currentDraggedBase?.unitCount {
|
||||
@ -131,9 +135,9 @@ class GameScene: SKScene{
|
||||
|
||||
func checkBases(bases: Set<Base>, touchLocation: CGPoint){
|
||||
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
|
||||
if atPoint(touchLocation) == base.component(ofType: DefaultBaseComponent.self)?.spriteNode{
|
||||
if !isMoveTouch {
|
||||
currentDraggedBase = base
|
||||
}
|
||||
isMoveTouch = true
|
||||
moveFireAndBase(base: base, touchLocation: touchLocation)
|
||||
|
Loading…
Reference in New Issue
Block a user