Game Development Reference
In-Depth Information
'and let the core AI figure out what to do.
World.StatusLabel.Text = CoreAI(CInt(World.AmbientUpDown.Value), _
desired, mode)
End Sub
22. We have not yet written the code that gets the mode and desired tem-
perature, so Visual Studio will quietly complain about the names not being
declared. We have not yet defined what CurrentMode means either. It will
also complain about the fact that we added an argument to the wrapper
function's call to the core but we have not yet changed the core AI. These
complaints appear in the Error List tab at the bottom. They are also marked
in the code the same way Microsoft Word marks spelling errors. First we will
interrogate the world. Add the following code to get the mode of operation:
'These modes should match up with radio buttons
Private Enum CurrentMode
Heat
Cool
'Off would go here
Unknown
End Enum
Private Function FurnaceMode(ByVal World As House) As CurrentMode
'we put all of the modes into parallel arrays
'They MUST have the same number of entries
Dim ModeRadios() As RadioButton = {World.AirRadio, World.HeatRadio}
Dim ModeValues() As CurrentMode = {CurrentMode.Cool, CurrentMode.Heat}
'we need a variable to iterate the arrays
Dim i As Integer
'Go through the array. Find the one that is checked
'This code automatically adjusts to adding
Fori=0ToModeRadios.GetUpperBound(0)
If ModeRadios(i).Checked Then
Return ModeValues(i)
End If
Next
'In case we forgot to check one of them
Return CurrentMode.Unknown
End Function
Search Nedrilad ::




Custom Search