The reason i ask is the Third time we made a function named CompleteObjective i became concerned that we are spinning our wheels reaching for stars… lol
Very spread out lectures – seems to start at the back end of things and work forward…
sorry but i am lost because of the backward approach to this logic.
This CompleteObjective then finds the player’s QuestList.
The QuestList maintains a list of QuestStatus objects. CompleteObjective() in the QuestList locates the appropriate quest and informs it that the objective is complete:
public void CompleteObjective(Quest quest, string objective)
{
QuestStatus status = GetQuestStatus(quest);
status.CompleteObjective(objective);
if (status.IsComplete())
{
GiveReward(quest);
}
if (onUpdate != null)
{
onUpdate();
}
}
The QuestStatus representing that quest then adds the objective to the list of completed objectives.
public void CompleteObjective(string objective)
{
if (quest.HasObjective(objective))
{
completedObjectives.Add(objective);
}
}
None of these things should be done by one single method in a truly object oriented approach. The QuestCompletion tells the QuestList that tells the QuestStatus. In all of these cases, the most logical name for the method is CompleteObjective. Remember that it’s best, whenever possible, to use method names that say exactly what the purpose of the method is.