Game Development Reference
In-Depth Information
That provides the basic interaction, but we need to wrap a few layers around it.
We need to be able to run a complete round of interaction, and we need to hook
the interactions to the user interface. Add the following code to the Cruise class:
Private Sub OneRound()
Dim Pool As New Collection
Dim PersonA As Person = Nothing
Dim NeedyPerson As Person
'Load the pool from the roster, increment all needs.
For Each PersonA In Roster
Pool.Add(PersonA, PersonA.Name)
Call PersonA.IncAllNeeds()
While Pool.Count >= 2
'Grab the person with the highest need.
'Default to the first person.
NeedyPerson = CType(Pool.Item(1), Person)
'We keep both the person and their need.
Dim BigNeed As NVP = NeedyPerson.HighestNeed
'Look for a person with a higher need.
For Each PersonA In Pool
Dim Aneed As NVP = PersonA.HighestNeed
If Aneed.value < BigNeed.value Then
NeedyPerson = PersonA
BigNeed = Aneed
End If
'Take the needy person out of the pool.
'Pick a random partner.
PersonA = CType(Pool(getDx(Pool.Count)), Person)
'Take them out of the pool.
'Make them randomly interact to meet the highest need.
Dim activity As String = _
Interact(NeedyPerson, PersonA,, activity)
End While
End Sub
Private Sub Button1Time_Click(ByVal sender As System.Object, _
ByVal e As System.EventArgs) Handles Button1Time.Click
Search Nedrilad ::

Custom Search