-
Notifications
You must be signed in to change notification settings - Fork 2
/
story.js
61 lines (58 loc) · 1.45 KB
/
story.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
var Story = function() {
this.storyPt = 0;
this.canToNext = function(game) {
return Stories[this.storyPt].require(game);
};
this.toNext = function(game) {
if (typeof Stories[this.storyPt].endCallback === "function") {
Stories[this.storyPt].endCallback(game);
}
this.storyPt++;
};
};
var StoryControl = function(game) {
var dialogHandler = function(story) {
game.dialog = new Dialog(story.detail.npc);
game.state = "dialog";
};
var groundHandler = function(story) {
if (story.detail.map) {
game.ground = new Ground(game.player, Maps[story.detail.map]);
}
if (story.detail.pos) {
game.ground.setPos(story.detail.pos[0], story.detail.pos[1]);
}
if (story.detail.dir) {
game.ground.dir = story.detail.dir;
}
game.state = "ground";
};
var battleHandler = function(story) {
game.battle = new Battle(game.player, new Enermy(story.detail.enermy), false);
game.state = "battle";
};
var animeHandler = function(story){
game.anime = new Anime(Animes[story.detail.anime]);
game.state = "anime";
};
var endHandler = function(story){
game.state = "end";
game.end = new End("win");
};
var handlers = {
ground: groundHandler,
dialog: dialogHandler,
battle: battleHandler,
anime: animeHandler,
end : endHandler
};
this.tick = function() {
if (game.state === "story") {
var story = Stories[game.story.storyPt];
handlers[story.type](story);
}
};
};
var StoryPainter = function(game) {
this.paint = function() {};
};