-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDialogue.cs
72 lines (57 loc) · 2.22 KB
/
Dialogue.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
using System;
using System.Collections.Generic;
using System.Text;
using System.Data;
using System.Data.SQLite;
namespace DreamQEngine
{
public class Dialogue
{
//The text of the dialogue presented
protected string mText;
//The NPC saying this dialogue
protected Actor mActor;
//The choices presented to you at the end of the dialogue
protected Option[] mChoices;
public Dialogue(int dialogueRef, SQLiteConnection conn)
{
SQLiteDataReader reader = new SQLiteCommand("Select * From Dialogue WHERE id = " + dialogueRef + ";", conn).ExecuteReader();
DataTable dialogueTable = new DataTable();
dialogueTable.Load(reader);
DataView dialogueView = new DataView(dialogueTable);
if (dialogueView.Count > 0)
{
mText = dialogueView[0]["text"].ToString();
mActor = new Actor(Convert.ToInt32(dialogueView[0]["actorId"]), conn);
reader = new SQLiteCommand("Select * From Options WHERE dialogueId = " + dialogueRef + ";", conn).ExecuteReader();
DataTable optionTable = new DataTable();
optionTable.Load(reader);
DataView optionView = new DataView(optionTable);
mChoices = new Option[optionView.Count];
for(int i = 0; i < optionView.Count; i++)
{
string optionText = optionView[i]["actualtext"].ToString();
string optionDisplay = optionView[i]["displayText"].ToString();
int outcomeType = Convert.ToInt32(optionView[i]["outcomeType"]);
int outcomeId = Convert.ToInt32(optionView[i]["outcomeId"]);
mChoices[i] = new Option(optionText, optionDisplay, outcomeType, outcomeId);
}
}
}
public string text
{
set { mText = value; }
get { return mText; }
}
public Option[] choices
{
set { mChoices = value; }
get { return mChoices; }
}
public Actor actor
{
set { mActor = value; }
get { return mActor; }
}
}
}