Created
April 13, 2022 07:05
-
-
Save orleonedev/961384f8e346a07822b0669f23468adf to your computer and use it in GitHub Desktop.
WillPower HealthComponent Version 0.0.1(3)
This file contains 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
class WPHealthComponent: GKComponent { | |
var healthStateMachine: GKStateMachine | |
var game: WPGame | |
var char: WPEntity | |
var maxHearts: Int | |
var heartCounter: Int { | |
//...... | |
} | |
init(withGame: WPGame, characterEnt: WPEntity, maxHearts: Int){ | |
self.game = withGame | |
self.char = characterEnt | |
self.maxHearts = maxHearts | |
self.heartCounter = maxHearts | |
let defend = WPDefendState(withGame: game, entity: char) | |
let hit = WPHitState(withGame: game, entity: char) | |
let defeated = WPDefeatedState(withGame: game, entity: char) | |
let invulnerable = WPInvulnerableState(withGame: game, entity: char) | |
healthStateMachine = GKStateMachine(states: [defend,hit,defeated,invulnerable]) | |
super.init() | |
} | |
required init?(coder: NSCoder) { | |
fatalError("init(coder:) has not been implemented") | |
} | |
override func update(deltaTime seconds: TimeInterval) { | |
healthStateMachine.update(deltaTime: seconds) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment