Game Development Reference
In-Depth Information
In addition, the simulation will want to call for adjustments to the needs. Needs
get stronger over time and interactions satisfy a need. Add the following code to
the Person class:
'We interacted to meet some need.
Public Sub EaseNeed(ByVal Need As String)
Dim someNeed As NVP = CType(myNeeds(Need), NVP)
'30 is picked to balance 3 needs that drop 10 each turn.
someNeed.value += 10 * myNeeds.Count
'Clip at +100.
If someNeed.value > 100 Then someNeed.value = 100
End Sub
'Every turn we need more.
Public Sub IncAllNeeds()
Dim someNeed As NVP
'All my needs get 10 points worse.
For Each someNeed In myNeeds
someNeed.value -= 10
'Clip at -100.
If someNeed.value < -100 Then someNeed.value = -100
End Sub
The code for meeting a need is self balancing. It knows that all needs get stronger
by 10 each turn, so the amount of satisfaction has to be 10 times the number of
needs to maintain balance. Keeping balance and having all needs act the same
way is a design decision. We start with a balanced and conservative simulation.
We can give it wider swings and variability if it proves unsatisfactory. Needs
change when people interact, but so do relationships. Add the following code to
the Person class:
Public Sub UpdateRelationship(ByVal theirName As String, _
ByVal howMuch As Integer)
Dim thisRelation As NVP
'Have we met?
If myRelationships.Contains(theirName) Then
'Update the existing relationship.
thisRelation = CType(myRelationships(theirName), NVP)
thisRelation.value += howMuch
'Create a new relationship.
thisRelation = New NVP
Search Nedrilad ::

Custom Search