forked from VacaRoxa/dogfromhell
-
Notifications
You must be signed in to change notification settings - Fork 1
/
LetterController.asc
149 lines (129 loc) · 3.89 KB
/
LetterController.asc
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
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
// new module script
#define NLETTERS 11
Timer * doFallLetter[NLETTERS];
Direction FallLetter_dir[NLETTERS];
int k;
Character * ar_letter[NLETTERS];
void shouldLetterBeTrashed(Character * cALetter){
if(cALetter.Room == player.Room && (cALetter.x < 1 ||
cALetter.x > GAMEW-1 ||
cALetter.y < 1 ||
cALetter.y > GAMEH-1)){
cALetter.ChangeRoom(TRASH);
}
}
void game_start(){
ar_letter[0] = cLetter1;
ar_letter[1] = cLetter2;
ar_letter[2] = cLetter3;
ar_letter[3] = cLetter4;
ar_letter[4] = cLetter5;
ar_letter[5] = cLetter6;
ar_letter[6] = cLetter7;
ar_letter[7] = cLetter8;
ar_letter[8] = cLetter9;
ar_letter[9] = cLetter10;
ar_letter[10] = cLetter11;
}
void TrashLetters(){
int i=0;
while(i<NLETTERS){
shouldLetterBeTrashed(ar_letter[i]);
i++;
}
}
void ForceTrashLetters(){
int i=0;
while(i<NLETTERS){
ar_letter[i].ChangeRoom(TRASH);
i++;
}
}
void ThrowLetter(int x, int y, CharacterDirection direction){
Character * LetterChar;
int i=0;
while(i<NLETTERS){
if(ar_letter[i].Room == TRASH){
if(direction == eDirectionRight){
ar_letter[i].ChangeRoom(player.Room, x+8, y);
} else {
ar_letter[i].ChangeRoom(player.Room, x-8, y);
}
LetterChar = ar_letter[i];
break;
}
i++;
}
if(LetterChar == null){
TrashLetters();
i=0;
while(i<NLETTERS){
if(ar_letter[i].Room == TRASH){
if(direction == eDirectionRight){
ar_letter[i].ChangeRoom(player.Room, x+8, y);
} else {
ar_letter[i].ChangeRoom(player.Room, x-8, y);
}
LetterChar = ar_letter[i];
break;
}
i++;
}
if(LetterChar == null){
return;
}
}
LetterChar.Animate(0, 2, eRepeat, eNoBlock, eForwards);
if(direction == eDirectionLeft){
LetterChar.TweenPosition(0.4, x-40, y-40, eEaseOutExpoTween, eNoBlockTween);
doFallLetter[i] = Timer.StartRT(0.41);
FallLetter_dir[i] = eDirectionLeft;
//LetterChar.TweenPosition(0.8, x-GAMEW, y+35, eEaseLinearTween, eNoBlockTween, 0.47);
//LetterChar.TweenX(1.2, x-GAMEW, eEaseLinearTween, eNoBlockTween);
//LetterChar.TweenY(0.4, y-40, eEaseOutExpoTween, eNoBlockTween);
// LetterChar.TweenY(0.8, y+35, eEaseLinearTween, eNoBlockTween, 0.47);
} else {
// must be right
//LetterChar.TweenX(1.2, x+GAMEW, eEaseLinearTween, eNoBlockTween);
// LetterChar.TweenY(0.4, y-40, eEaseOutExpoTween, eNoBlockTween);
// LetterChar.TweenY(0.8, y+35, eEaseLinearTween, eNoBlockTween, 0.47);
LetterChar.TweenPosition(0.4, x+40, y-40, eEaseOutExpoTween, eNoBlockTween);
doFallLetter[i] = Timer.StartRT(0.41);
FallLetter_dir[i] = eDirectionRight;
//LetterChar.TweenPosition(0.8, x+GAMEW, y+35, eEaseLinearTween, eNoBlockTween, 0.47);
}
}
Character * whichLetterCollided(){
int i=0;
while(i<NLETTERS){
if(ar_letter[i].Room == cDog.Room && ar_letter[i].IsCollidingWithChar(cDog)){
return ar_letter[i];
}
i++;
}
return null;
}
void repeatedly_execute_always(){
int i=0;
while(i<NLETTERS){
if(doFallLetter[i] != null && doFallLetter[i].EvtExpired){
if(FallLetter_dir[i] == eDirectionLeft){
ar_letter[i].TweenPosition(0.9, ar_letter[i].x-GAMEW+40, ar_letter[i].y+220, eEaseLinearTween, eNoBlockTween);
} else {
ar_letter[i].TweenPosition(0.9, ar_letter[i].x+GAMEW-40, ar_letter[i].y+220, eEaseLinearTween, eNoBlockTween);
}
doFallLetter[i] = null;
}
i++;
}
k++;
if(k>120){
k=0;
TrashLetters();
}
}
void on_event (EventType event, int data){
if(event == eEventLeaveRoom){
ForceTrashLetters();
}
}