Skip to content

Instantly share code, notes, and snippets.

@orleonedev
Created April 13, 2022 08:15
Show Gist options
  • Save orleonedev/45138ba32971f3fbc657e33f949ed25c to your computer and use it in GitHub Desktop.
Save orleonedev/45138ba32971f3fbc657e33f949ed25c to your computer and use it in GitHub Desktop.
Health State Machine declaration inside WPHealthComponent in version 0.0.1(3)
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