hi a while ago i been asking for some help into learning and somehow make a quest system for my mmorpg project, we already have a networked version and some things implemented, keep in mind i’m new learning about arrays, collections and classes from c#.
here bellow is my quest script.
now one of my main problems is knowing to to identify the quest that i make with the id. meaning is there a function or something saying that once you create a new quest for example:
private Quest _qt = new Quest;
but i’m missing defining it’s id somehow. well here is what i have so far.
Quest.cs
using UnityEngine;
using System.Collections;
public class Quest {
//private int _id;
private bool _known;
private bool _completed;
private string _name;
private string _quest_plot;
//this is the constructor for it
public Quest()
{
_id = 0;
_known = false;
_completed = false;
_name = "Give me one";
_quest_plot = "Story goes here";
}
#region Properties of the Quest
//getters and setters (Properties)
public int Id
{
get { return _id; }
set { _id = value; }
}
public bool Known
{
get { return _known; }
set { _known = value; }
}
public bool Completed
{
get { return _completed; }
set { _completed = value; }
}
public string Name
{
get { return _name; }
set { _name = value; }
}
public string Quest_Plot
{
get { return _quest_plot; }
set { _quest_plot = value; }
}
#endregion
//all my methods will go below depending on what they are
}
here is the script i use for my npc:
NPCQuester.cs
using UnityEngine;
using System.Collections;
public class NPCQuester : MonoBehaviour {
public bool _quest_screen;
public int Id;
public bool Known;
public bool Completed;
public string Name;
public string Plot;
public float x = 0;
public float y = 0;
public float xH = 10;
public float yW = 10;
private Quest _qt;
private Transform _myTransform;
private Target2 _tar;
void Awake()
{
_myTransform = transform;
GameObject cam = GameObject.FindWithTag("MainCamera");
_tar = cam.GetComponent<Target2>();
}
// Use this for initialization
void Start ()
{
_qt = new Quest();
_qt.Id = Id;
_qt.Known = Known;
_qt.Completed = Completed;
_qt.Name = Name;
_qt.Quest_Plot = Plot;
_quest_screen = false;
}
// Update is called once per frame
void Update ()
{
if(_tar.target == _myTransform)
{
_quest_screen = true;
}
else
{
//_quest_screen = false;
}
}
void OnGUI()
{
if(_quest_screen)
GUI.Window(0,new Rect(50,250,300,400) , QuestWindow, Name);
}
private void QuestWindow(int windowID)
{
GUI.Label(new Rect(10,20,200,300), _qt.Quest_Plot.ToString());
if(GUI.Button(new Rect(10,355,100,25), "Accept"))
{
Known = true;
_quest_screen = false;
}
if(GUI.Button(new Rect(170,355,100,25), "Decline"))
{
Known = false;
_quest_screen = false;
}
}
}
now the random floats variables like x,y, xh and yw are for positioning the windows and gui.