Skip to content

Commit

Permalink
Merge pull request #41 from sp4ce-cowboy/admin/branch-refactor
Browse files Browse the repository at this point in the history
Restructure Project
  • Loading branch information
sp4ce-cowboy authored Mar 25, 2024
2 parents d6a60ea + d728847 commit 652a656
Show file tree
Hide file tree
Showing 108 changed files with 291 additions and 99 deletions.
File renamed without changes.
334 changes: 243 additions & 91 deletions TowerForge/TowerForge.xcodeproj/project.pbxproj

Large diffs are not rendered by default.

File renamed without changes.
9 changes: 9 additions & 0 deletions TowerForge/TowerForge/Commons/Constants/Constants.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import Foundation

/// A class to encapsulate application wide constants to ensure a single source of truth
/// across the entire application.
class Constants {

/// Universally declaring logging
static let LOGGING_IS_ACTIVE = true
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
import Foundation
import SpriteKit

/// A protocol whose conformants must encapsulate an SKAction and the means
/// to control their own animations.
protocol Animatable {
var animatableAction: SKAction? { get set }
var animatableKey: String { get set }
Expand Down
26 changes: 26 additions & 0 deletions TowerForge/TowerForge/Commons/Utilities/Logger.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
import Foundation

/// A utility class to provide for a universal logging function. The logger class
/// can be set to be active if logging is required, within the Constants class.
///
/// Use case:
/// Standard - print("Value is \(variable)")
/// Alternative - Logger.log("Value is \(variable)", self)
///
/// Benefits:
/// - Can universally turn off logging, so the console output can be turned off before publication
/// - "self" argument will output the class name where the log function was invoked = easier debugging.
class Logger {
static var isActive = Constants.LOGGING_IS_ACTIVE

private init() { }

static func log(_ string: String, _ caller: Any? = nil) {
if isActive {
let callerType = caller == nil ? "Unknown" : String(describing: type(of: caller!))
let date = Date.now.formatted(date: .omitted, time: .standard)
print("[\(date)] -- [\(callerType)] \(string)")
}

}
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,14 @@
import Foundation
import SpriteKit

class PlayerComponent: TFComponent {
var player: Player
init(player: Player) {
self.player = player
super.init()
}
}

public enum Player: Int {
case ownPlayer = 1
case oppositePlayer = 2
Expand All @@ -30,11 +38,3 @@ public enum Player: Int {
}
}
}

class PlayerComponent: TFComponent {
var player: Player
init(player: Player) {
self.player = player
super.init()
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ class GameWorld {
if let scene = self.scene {
grid.generateTileMap(scene: scene)
}

renderer = Renderer(target: self, scene: scene)
renderer?.renderMessage("Game Starts")
self.setUpSystems()
Expand Down
1 change: 1 addition & 0 deletions TowerForge/TowerForge/Nodes/UnitNode.swift
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@

import SpriteKit

/// TODO: Add documentation for this
protocol UnitNodeDelegate: AnyObject {
func unitNodeDidSelect(_ unitNode: UnitNode)
func unitNodeDidSpawn(_ position: CGPoint)
Expand Down
1 change: 1 addition & 0 deletions TowerForge/TowerForge/Nodes/UnitSelectionNode.swift
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ class UnitSelectionNode: TFEntity, UnitNodeDelegate {
position: CGPoint(x: 0, y: 0), animatableKey: "selectionNode")
let node = spriteComponent.node
node.isUserInteractionEnabled = true

let possibleUnits: [(TFEntity & PlayerSpawnable).Type] = SpawnableEntities.playerSpawnableEntities
var startingPoint = CGPoint(x: 400, y: 0)

Expand Down
Binary file removed TowerForge/TowerForge/Scenes/Actions.sks
Binary file not shown.
Binary file not shown.
File renamed without changes.

0 comments on commit 652a656

Please sign in to comment.