-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathLoader.js
104 lines (97 loc) · 3.22 KB
/
Loader.js
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
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
Adventurous.scenes = {};
Adventurous.thingsArray = new Array();
Adventurous.thingsMap = {};
Adventurous.conversations = {};
Adventurous.interactions = {};
Adventurous.observations = {};
Adventurous.combinations = {};
Adventurous.startingScene = "";
Adventurous.Loader =
{
init: function(gameState)
{
this.initSpeeches();
this.initConversations();
this.initInteractions();
this.initObservations();
this.initCombinations();
this.initScenesAndThings();
},
initSpeeches: function()
{
var speeches = JSON.parse(game.cache.getText('speeches'));
for(var i = 0; i < speeches.list.length; i++)
{
var speech = speeches.list[i];
if(speech.audio == null)
{
speech.audio = speech.name;
}
Adventurous.speeches[speech.name] = new Adventurous.Speech(speech.text,game.add.audio(speech.audio));
}
},
initConversations: function()
{
var obj = JSON.parse(game.cache.getText('conversations'));
var list = obj.list;
for(var i = 0; i < list.length; i++)
{
Adventurous.conversations[list[i].name] = new Adventurous.Conversation(list[i],list[i].name);
}
},
initInteractions: function()
{
var obj = JSON.parse(game.cache.getText('interactions'));
var list = obj.list;
for(var i = 0; i < list.length; i++)
{
Adventurous.interactions[list[i].name] = new Adventurous.Interactions(list[i]);
}
},
initObservations: function()
{
var obj = JSON.parse(game.cache.getText('observations'));
var list = obj.list;
for(var i = 0; i < list.length; i++)
{
Adventurous.observations[list[i].name] = new Adventurous.Observations(list[i]);
}
},
initCombinations: function()
{
var obj = JSON.parse(game.cache.getText('combinations'));
var list = obj.list;
for(var i = 0; i < list.length; i++)
{
var itemA = list[i].itemA;
var itemB = list[i].itemB;
var speech = list[i].speech;
var result = list[i].result;
if(Adventurous.combinations[itemA] == null)
{
Adventurous.combinations[itemA] = {};
}
if(Adventurous.combinations[itemB] == null)
{
Adventurous.combinations[itemB] = {};
}
Adventurous.combinations[itemA][itemB] = {};
Adventurous.combinations[itemA][itemB].speech = speech;
Adventurous.combinations[itemA][itemB].result = result;
Adventurous.combinations[itemB][itemA] = {};
Adventurous.combinations[itemB][itemA].speech = speech;
Adventurous.combinations[itemB][itemA].result = result;
}
},
initScenesAndThings: function()
{
var obj = JSON.parse(game.cache.getText('scenes'));
var scenes = {};
var things = {};
var list = obj.list;
for(var i = 0; i < list.length; i++)
{
Adventurous.scenes[list[i].name] = new Adventurous.Scene(list[i]);
}
}
}