Game Development Reference
In-Depth Information
thisRelation.name = theirName
thisRelation.value = howMuch
'Store the relationship.
myRelationships.Add(thisRelation, theirName)
End If
End Sub
'A simple Boolean when the caller does not care about magnitude.
Public Function NeedsSome(ByVal need As String) As Boolean
Dim someNeed As NVP = CType(myNeeds(need), NVP)
Return (someNeed.value <= 0)
End Function
'Return HOW MUCH they like an activity.
Public Function Likes(ByVal activity As String) As Integer
Dim somePref As NVP = CType(myPreferences(activity), NVP)
Return somePref.value
End Function
The NeedsSome() function is used when computing the relationship score for an
interaction. The third term in the computation was a bonus if both parties had an
unmet need satisfied by the activity. So we need to be able to ask a person if a
particular need was unmet. The other parts of the relationship score need a
person's preference value for an activity, which is provided by the Likes()
function.
The final code for a person handles the various ways outside code interrogates a
person in order to print out results. The simulation will make use of these in
debugging statements that let us see our results. Add the following code to the
Person class:
Public Function CurrentRelationship(ByVal theirName As String) As Integer
'If we have met them...
If myRelationships.Contains(theirName) Then
Dim rel As NVP = CType(myRelationships(theirName), NVP)
'...then return the value of our relationship.
Return rel.value
End If
'Return 0 if we haven't met yet.
Return 0
End Function
'Give back my name and my needs in a compact form.
Public Function ShortDump() As String
 
Search Nedrilad ::




Custom Search