Created
April 13, 2022 08:15
-
-
Save orleonedev/45138ba32971f3fbc657e33f949ed25c to your computer and use it in GitHub Desktop.
Health State Machine declaration inside WPHealthComponent in 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 | |
/* | |
....... | |
*/ | |
init(/* .... */ ){ | |
/* | |
...... | |
*/ | |
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]) | |
} | |
/* | |
...... | |
*/ | |
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