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