-
Notifications
You must be signed in to change notification settings - Fork 0
/
TheQuery.as
187 lines (183 loc) · 5.4 KB
/
TheQuery.as
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
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
package {
import flash.display.DisplayObjectContainer;
import flash.display.MovieClip;
import flash.display.Sprite;
import flash.geom.Point;
import flash.media.Sound;
/**
* Shitty Fucking Art Game
* @author Sean Finch
* @version 27APR2011
*/
/* Copyright © 2011 - 2015 Sean Finch
This file is part of Shitty Fucking Art Game.
bang is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
bang is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with bang. If not, see <http://www.gnu.org/licenses>. */
public class TheQuery extends PlumbCore {
private var jaw:Sprite;
private var eye:MovieClip;
private var health:int;
private var queries:Array;
private var shards:Array;
private var lasersArray:Array;
private var attackTimer:int;
private var mouthTimer:int;
private var mouthshooter:Sprite;
public function TheQuery(parent:DisplayObjectContainer, pX:int, pY:int, BR:Boolean = false) {
super(parent, pX, pY);
if (BR) {
jaw = new mJawBR();
icon = new mHeadBR();
eye = new mEyeBR();
} else {
jaw = new mJaw();
icon = new mHead();
eye = new mEye();
}
mouthshooter = new Sprite();
icon.x = pX;
icon.y = pY;
jaw.x = pX - 7;
jaw.y = pY + 15;
eye.x = pX - 65.5;
eye.y = pY - 32;
eye.gotoAndStop(1);
mouthshooter.x = pX - 96;
mouthshooter.y = pY + 24;
_parent.addChild(jaw);
_parent.addChild(icon);
_parent.addChild(eye);
_parent.addChild(mouthshooter);
health = 40;
queries = [];
shards = [];
attackTimer = 0;
mouthTimer = 0;
lasersArray = [];
for (var i:int = 0; i < 9; i++) {
var q:Query = new Query(parent, pX - 170, i * 26, 1);
queries.push(q);
var qa:Query = new Query(parent, pX - 130, i * 26, 1);
queries.push(qa);
}
for (var j:int = 0; j < 9; j++) {
var qu:Query = new Query(parent, pX - 150, 13 + j * 26, -1);
queries.push(qu);
}
}
public override function cleanUp():void {
for each(var U:Query in queries) {
U.cleanUp();
}
queries = [];
for each(var B:QueryShard in shards) {
B.cleanUp();
}
shards = [];
for each(var Z:QuestionLaser in lasersArray) {
Z.cleanUp();
}
lasersArray = [];
_parent.removeChild(icon);
_parent.removeChild(jaw);
_parent.removeChild(eye);
_parent.removeChild(mouthshooter);
health = 0;
attackTimer = 0;
mouthTimer = 0;
jaw = null;
eye = null;
mouthshooter = null;
icon = null;
}
public override function update(player:MovieClip = null, harpoons:Array = null, keys:uint = 0, click:Boolean = false, angee:Number = 0):int {
var willPlayerHurt:int = 0;
for each(var i:Harpoon in harpoons) {
if (icon.hitTestObject(i.iconGet())) {
health -= 1;
SelectionMemory.sHandler.queries.stop();
if (!SelectionMemory.soundOff) {
SelectionMemory.sHandler.qHurt[Math.floor(Math.random() * 3)].play();
}
i.removeMeFromThisWorld();
if (eye.currentFrame < 21) {
eye.gotoAndPlay(19);
}
jaw.rotation = -23;
break;
}
}
for each(var u:Query in queries) {
var beep:int = u.update(player, harpoons);
if (beep == 1) {
var limit:int = 2 + Math.round(Math.random() * 3);
for (var bl:int = 0; bl < limit; bl++) {
var b:QueryShard = new QueryShard(_parent, u.loc.x, u.loc.y, 180 * Math.random(), bl + 1);
shards.push(b);
}
}
if (u.destroyMe()) {
var rem:int = queries.indexOf(u);
queries.splice(rem, 1);
u.cleanUp();
}
}
for each(var LASERBOOP:QuestionLaser in lasersArray) {
willPlayerHurt += LASERBOOP.update(player, harpoons);
if (LASERBOOP.destroyMe()) {
var ram:int = lasersArray.indexOf(LASERBOOP);
lasersArray.splice(ram, 1);
LASERBOOP.cleanUp();
}
}
for each(var bb:QueryShard in shards) {
willPlayerHurt += bb.update(player, harpoons);
if (bb.destroyMe()) {
var rum:int = shards.indexOf(bb);
shards.splice(rum, 1);
bb.cleanUp();
}
}
if (jaw.rotation < 0) {
jaw.rotation += 0.5;
}
if (eye.currentFrame == 1 && Math.random() > 0.95) {
eye.play();
}
if (Math.random() > 0.92 && attackTimer <= 0) {
var B:int = Math.floor(Math.random() * 7);
if (!SelectionMemory.soundOff) {
SelectionMemory.sHandler.queries = SelectionMemory.sHandler.query[B].play();
}
var pPp:Point = _parent.globalToLocal(new Point(player.x, player.y));
var X:Number = Math.atan2(pPp.y - mouthshooter.y, pPp.x - mouthshooter.x) * 180 / Math.PI;
var LASER:QuestionLaser = new QuestionLaser(_parent, mouthshooter.x, mouthshooter.y, X);
lasersArray.push(LASER);
mouthTimer = 30 * ((Sound(SelectionMemory.sHandler.query[B]).length) / 1000);
attackTimer = mouthTimer * 1.75;
}
if (mouthTimer > 0) {
jaw.rotation = -23 * Math.random();
mouthTimer -= 1;
} else if (mouthTimer == 0) {
mouthTimer = -1;
jaw.rotation = 0;
}
if (attackTimer > 0) {
attackTimer -= 1;
}
if (health <= 0) {
destroy = true;
}
return willPlayerHurt;
}
}
}