- Home /
A simple quest system[solved]
For my game i am gonna need to create a rather small quest system. Let me explain how it will work.
I will have 3 or 4 NPC each implementing the following logic.
To get into some more details about this logic. It's an educational game, my character is inside a house and each family member is considered a NPC. Each NPC's "quest line" will be independent, so you will simultaneously have 4 chores/quests active.
Let's say i go to NPCx and i accept chore 1. Chore 1 will be something like -> go clean your room. I move through the house and when i enter my room I will have a collision trigger and load another scene with a mini game to complete the chore.
Only when this chore is completed i will return to my main scene and go to NPCx again and then let's say i accept Quest1.
Quests will only load other scenes, they are also some mini-games but these form the educational part. So I loaded a different scene, play a small game, then when i finnish i go back to NPCx.
Only when Quest1 is completed he will give me chore2, repeat.
To start off I will probably have only 2 (Chore,Quest) pairs for each NPC.
This is how I thought of implementing it.
Create a class Quest, with some common variables like quest_title,quest_description,quest_state,quest_number and some setters getters.
I really want to avoid GUI System so I think i'm going to create a GUITexture for dialog window, place a TextMesh over it and 2 other GUITextures for Accept/Decline buttons.
Setup some collision triggers near each NPC that will have a script which will create the current quest and will handle the quest dialog. Everytime OnEnterTrigger event is called I will create the corresponding Quest Dialog like : "This is the first quest description" Accept or NOT? Or if the quest is already active but not finnished : "Have you completed your chore?".
After the Quest Dialog is made visible and activate its script Accept button will Load the new scene.
Somehow (haven't thought this far) when the current mini game(quest) is finnished,change MainScene.GetNPCGameObject.GetScript.current_quest.setState("finnished");
Here is the idea for the triggers Script:
Quest curr_quest;
int current_quest_id;
// Use this for initialization
void Start () {
current_quest_id = 1;
curr_quest = new Quest ("Title1", "Descr1", "pending", 1);
}
void OnTriggerEnter () {
switch (current_quest_id)
{
case 1:
if(curr_quest.GetState() == "pending"){
//Make my GUITextures (background,button Accept,button Decline) visible
//Set my TextMesh text to current quest title and description and make it visible
//Activate script attached to Button GUITextures
}
else if(curr_quest.GetState() == "active"){
//Show GUI for active quest this time
}
else if(curr_quest.GetState() == "finnish"){
//Show GUI for finnish quest
curr_quest = new Quest("title2","descr2","pending",2);
current_quest_id++;
}
break;
case 2:
//repeat for q2
break;
case 3:
//repeat for q3
break;
case 4:
//repeat for q4
break;
default:
break;
}
}
Or instead of a trigger collision event, a tap on the NPC itself.
Some things i omitted : Platform: Android, Language: C#
Please provide with some input and ideas, but keep in mind the following:
I am a beginner in Unity and C#.
Keep it simple, I'm not trying to create some big RPG game.
The idea behind this is that i thought most educational games are just a bunch of levels thrown together so I am trying to create an interactive game in which playing a bunch of games is a game.
Thank you.