Game Development Reference
In-Depth Information
'I react to health - if low, be afraid.
Txn = New LowHealthTxn()
'Set the next state name of that transition.
Txn.Initialize(GetType(FeelAfraid).Name)
'Add it to our list of transitions.
MyTransitions.Add(Txn)
End Sub
Public Overrides Sub Entry(ByVal World As Monster)
World.Say("I feel happy now.")
End Sub
Public Overrides Sub ExitFunction(ByVal World As Monster)
End Sub
Public Overrides Sub Update(ByVal World As Monster)
World.BackColor = Color.LightGreen
End Sub
End Class
VB will complain because we have transitions to states that do not exist yet. Add a
new class to the project. Name it FeelAfraid.vb and make it inherit from
BasicState . Add code until your file looks like the following:
Public Class FeelAfraid
Inherits BasicState
Public Sub New()
Dim Txn As BasicTransition
'Order is important.
'Get angry if I see intruders while healthy.
Txn = New SeePlayerHighHealthTxn()
'Set the next state name of that transition.
Txn.Initialize(GetType(FeelAngry).Name)
'Add it to our list of transitions.
MyTransitions.Add(Txn)
'If healthy and no intruder, I am happy.
Txn = New HighHealthTxn()
'Set the next state name of that transition.
Txn.Initialize(GetType(FeelHappy).Name)
Search Nedrilad ::




Custom Search