-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathBloatware.as
166 lines (143 loc) · 5.32 KB
/
Bloatware.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
package classes{
import starling.display.MovieClip;
import starling.events.Event;
import starling.animation.Tween;
import flash.utils.*;
public class Bloatware extends Combatant {
public var idleMc:SuperMovieClip;
public var smileMc:SuperMovieClip;
private var bloat:Number = 1;
public function Bloatware(){
idleMc = new SuperMovieClip('bloatwareIdle', GV.COMBATANT_SPRITESHEET, 48, 50, true, 40);
smileMc = new SuperMovieClip('bloatwareSmile', GV.COMBATANT_SPRITESHEET, 48, 50, true);
introMessage = introMessageRandomizer(new <String>["Disk space is delectable", "Check out my gainz.", "Auto-starting", "*Burp*"]);
}
public function uniqueNullItAll():void{
superNull(idleMc); idleMc = null;
superNull(smileMc); smileMc = null;
}
public function uniqueAi():void{
if (slots[BLUE].startable && !slots[BLUE].isCharging) {
var h:Combatant;
if(GV.arena.summonIsDecoy) h = GV.arena.summon;
else if(GV.arena.protectee) h = GV.arena.protectee;
else h = GV.hero;
var xdif:int = h.pos[0] - pos[0];
var ydif:int = h.pos[1] - pos[1];
var xdir:int = xdif/Math.abs(xdif);
var ydir:int = ydif/Math.abs(ydif);
var mX:int = xdir < 0 ? pos[0] : ((GV.TILE_X - 1) - pos[0])*xdir;
var mY:int = ydir < 0 ? pos[1] : ((GV.TILE_Y - 1) - pos[1])*ydir;
var maxLen:int = Math.min(mX || GV.TILE_X, mY || GV.TILE_Y);
var minLen:int = distanceBetween(GV.hero.pos, pos);
var heroThere:Boolean = false;
slots[BLUE].posVector = new Vector.<Array>();
var heroAttackable:Boolean = false;
for(var i:int = 0, ilen:int = maxLen + 1; i < ilen; i++){
var currPos:Array = [pos[0] + i*xdir, pos[1] + i*ydir];
if(!GV.arena.getTile(currPos).canBeSelected){
break; // You can't travel over a chasm so screw the whole thing.
}else{
if(GV.arena.getTile(currPos).occupant == h) heroThere = true;
if(!GV.arena.getTile(currPos).occupied && i >= minLen && heroThere) {
startAbility(slots[BLUE], currPos);
heroAttackable = true;
break;
}
slots[BLUE].posVector.push(currPos);
}
}
if(!heroAttackable){
slots[BLUE].posVector = null;
var targ:Combatant;
if(GV.arena.summonIsDecoy) targ = GV.arena.summon;
else if(GV.arena.protectee) targ = GV.arena.protectee;
else targ = GV.hero
if(slots[BLUE].startable && !slots[BLUE].isCharging){
var targTile:Tile = targ.ourTile;
var scopeCheck:Boolean = slots[RED].abilitySelectType == 'cross' ? !perpindicular(targ.pos, pos) : false;
if(distanceBetween(targ.pos, pos) > slots[RED].abilityRange || scopeCheck){
targTile.traversableForAI = true;
var path:Array = tileToMoveTo(GV.arena.getTile(pos), targTile);
targTile.traversableForAI = false;
if(path && path.length > 1){
path[1].traversableForAI = false; // Make other dudes not try to move here after a buddy already picked it out.
startAbility(slots[BLUE], path[1].pos);
}
}
}
attackAI();
}
}
if(bloat < 1.2){
startAbility(slots[GREEN]);
}
}
public function meleeAnimation():void{moveBackToOurTile();}
public function uniqueIdleAnimation():void{
changeAnimation(idleMc);
}
public function uniqueRunAfterInit(){
addEventListener(starling.events.Event.ENTER_FRAME, onFrame);
}
public function onFrame(){
var cf:int = idleMc.currentFrame;
if(cf < 30){
shadow.scaleY = shadow.scaleX = 0.35 + bloat - (cf/300);
}else{
shadow.scaleY = shadow.scaleX = 0.35 + (bloat - 0.1) + ((cf%30)/300) ;
}
}
public function bloatAnimation():void{
var soundFx = Math.floor(Math.random()*5);
switch(soundFx){
case 0: FX.rubberStretch1.play(GV.AUDIO_START_TIME, 0, GV.sfx);
case 1: FX.rubberStretch2.play(GV.AUDIO_START_TIME, 0, GV.sfx);
case 2: FX.rubberStretch3.play(GV.AUDIO_START_TIME, 0, GV.sfx);
case 3: FX.rubberStretch4.play(GV.AUDIO_START_TIME, 0, GV.sfx);
default: FX.rubberStretch5.play(GV.AUDIO_START_TIME, 0, GV.sfx);
}
bloat += 0.1;
scaleX = bloat*(Math.abs(scaleX)/scaleX);
scaleY = bloat;
shadow.scaleX *= bloat;
shadow.scaleY *= bloat;
shadowHeight += 7;
tilePositionOffset = height/3;
centerShadow();
FX.showParticleEffect(FX.bloatPool, x, y, 0.5);
changeAnimation(smileMc);
setTimeout(executeEffects, 750);
}
public function uniqueMovementAnimation():void{
changeAnimation(smileMc);
}
override protected function movementOnFrameforMelee(e:starling.events.Event):void{
rotation -= 0.1*(Math.abs(scaleX)/scaleX);
moveTowardTarget(this);
if(distance < MOVEMENT_SPEED*GV.speedFactor){
if(faceOppositeDirectionAfterMoving){
faceOppositeDirection();
faceOppositeDirectionAfterMoving = false
}else{
faceOppositeDirectionAfterMoving = true;
}
finishMovement(true);
removeEventListener(starling.events.Event.ENTER_FRAME, movementOnFrameforMelee);
}
}
override protected function movementOnFrame(e:starling.events.Event):void{
rotation -= 0.1*(Math.abs(scaleX)/scaleX);
moveTowardTarget(this);
if(distance < MOVEMENT_SPEED*GV.speedFactor){
rotation = 0;
if(faceOppositeDirectionAfterMoving){
faceOppositeDirection();
faceOppositeDirectionAfterMoving = false
}
finishMovement();
removeEventListener(starling.events.Event.ENTER_FRAME, movementOnFrame);
}
}
}
}