-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathironBoulder.as
More file actions
80 lines (77 loc) · 2.5 KB
/
ironBoulder.as
File metadata and controls
80 lines (77 loc) · 2.5 KB
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
package {
import flash.display.MovieClip;
import flash.events.*;
public class ironBoulder extends MovieClip{
private var _root:*;
public var health:int = 30;
public var isAttackReady:Boolean = false;
public var reloadCount:int = -999;
public var hasNoKnockback:Boolean = true;
public var xRef:int;
public var yRef:int;
private var bar;
private var droppedItem;
public function ironBoulder() {
addEventListener(Event.ADDED,beginClass);
addEventListener(Event.ENTER_FRAME, eFrame);
addEventListener(Event.REMOVED_FROM_STAGE, destroyThis);
}
private function beginClass(e:Event):void {
_root = MovieClip(root);//setting the root
}
private function eFrame(e:Event):void{
if (bar){
bar.x = this.x - 18;
bar.y = this.y + 40;
}
if (this.health <= 0){
destroyThis();
}
}
public function takeDamage(theDamage:int):void{
}
public function takeMaterialDamage(theDamage:int, theType:int):void{
if (theType == 1003){
if (!bar){
bar = new hpBar();
bar.width = 36;
bar.height = 5;
bar.x = this.x - 18;
bar.y = this.y + 20;
_root.ObjectHolder.addChild(bar);
}
this.health -= theDamage;
bar.healthSize.width = 158 * (health/30);
}
}
private function destroyThis(event:Event = null):void{
//_root.enemyData.splice(_root.enemyList.indexOf(this), 1);
if (event == null){
_root.createMessage("iron stone mined");
bar.parent.removeChild(bar);
for (var j:int = 0;j < _root.randomNumbers(1,3);j++){
droppedItem = new ironDrop();
droppedItem.rotation = _root.randomNumbers(-179,180);
droppedItem.x = x + _root.randomNumbers(-50,50);
droppedItem.y = y + _root.randomNumbers(-50,50);
_root.droppedItemsData.push(droppedItem);
_root.SettingHolder.addChild(droppedItem);
}
this.parent.removeChild(this);
_root.enemyData.splice(_root.enemyData.indexOf(this), 1);
_root.hitObjectData.splice(_root.hitObjectData.indexOf(this), 1);
//_root.ObjectHolder.removeChild(this);
for (var i:int = 0;i < _root.savedStageData[_root.settingTag].length-2;i++){
if (_root.savedStageData[_root.settingTag][i] == 1005){
if (_root.savedStageData[_root.settingTag][i+1] == xRef){
if (_root.savedStageData[_root.settingTag][i+2] == yRef){
_root.savedStageData[_root.settingTag].splice(i,3)
}
}
}
}
}
this.removeEventListener(Event.ENTER_FRAME, eFrame);
}
}
}