Game Development Reference
In-Depth Information
Return alist
End Function
That completes the code for the mini-database. We can now initialize the needs
and preferences of our people, so we should work on people next.
The Person Class
Create a class and call it Person.vb. We start with the data we store and the code
that does initialization. Add code to the class as follows:
Public Class Person
Dim myname As String
Dim myNeeds As New Collection
Dim myPreferences As New Collection
Dim myRelationships As New Collection
Public Sub New(ByVal name As String, ByVal MDB As MiniDB)
myname = name
'Load all of the needs.
myNeeds = MDB.SetOfNeeds
'Load my preferences.
myPreferences = MDB.SetOfPreferences
End Sub
End Class
All our people require to start is their name and a database from which to get
their needs and preferences. People will lack any relationships until they start to
interact. The cruise director needs to know their highest need. Add the following
to the Person class:
'What is my highest need? We need both the name and value.
Public Function HighestNeed() As NVP
'Default to our first need.
Dim highNeed As NVP = CType(myNeeds(1), NVP)
Dim someNeed As NVP
For Each someNeed In myNeeds
'If we find a bigger need use it instead.
If someNeed.value < highNeed.value Then highNeed = someNeed
Return highNeed
End Function
Search Nedrilad ::

Custom Search