This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| func moveIntoFormation() { | |
| // Loop over each unit in our Squad. | |
| for (i, unit) in enumerate(self.units) { | |
| // Get the vector from the formation class for that position. | |
| // Just a simple accessor to the array. | |
| let vector = self.formation!.getVectorAtPosition(i) | |
| // Make a CGPoint from that vector, and tell the unit to walk to it. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import SpriteKit | |
| class Formation { | |
| // The vectors for a 3x3 formation. | |
| var positions : Array<CGVector> = [ | |
| CGVectorMake(0, 0), | |
| CGVectorMake(-64, 0), | |
| CGVectorMake(64, 0), | |
| CGVectorMake(-64, 64), |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import SpriteKit | |
| import Foundation | |
| class Squad : SKNode { | |
| // Handle on all units in the squad. | |
| var units : Array<CharacterNode> = [] | |
| // Current formation technique | |
| var formation : Formation? |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| init(category:Int) { | |
| super.init(texture: FlagSingleton.textures[category], color:SKColor.whiteColor(), size:FlagSingleton.textures[category].size()) | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| init(category:Int) { | |
| super.init(texture: FlagSingleton.textures[category]) | |
| } | |
| init(texture:SKTexture, color:SKColor, size:CGSize) { | |
| super.init(texture:texture, color:color, size:size) | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| for item : NSDictionary! in flagData { | |
| let flagToPlace = Flag(category: item["Type"].integerValue) | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| let path = NSBundle.mainBundle().bundlePath + "/FlagProgression.pList" | |
| let pListData = NSDictionary(contentsOfFile:path) | |
| let flagData = pListData[self.category.toRaw()] as NSArray | |
| return flagData.objectAtIndex(self.currentLevel) as Dictionary<String, String>[] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| scene.enumerateChildNodesWithName("PurchaseMenu") { | |
| node, stop in | |
| node.removeFromParent() | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // How do you cast SKNode to Flag : SKNode in parameter definition? | |
| scene.enumerateChildNodesWithName("flag") { | |
| node as Flag, stop in | |
| node.methodAvailableToFlagObject() | |
| } | |
| // I'm trying to avoid having to do this: | |
| scene.enumerateChildNodesWithName("flag") { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| scene.enumerateChildNodesWithName("flag") { | |
| node, stop in | |
| let realNode = node as Flag | |
| realNode.hidePurchaseMenus() | |
| } |