-
Notifications
You must be signed in to change notification settings - Fork 0
/
Item.as
126 lines (105 loc) · 2.91 KB
/
Item.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
package{
import flash.display.Bitmap;
import flash.utils.getQualifiedClassName
public class Item{
static public var walkable:Boolean = false;
static public var isAnimal:Boolean = false;
[Embed(source='previewenv.png')]
public var environmentSheetClass:Class;
[Embed(source='items.png')]
public var itemSheetClass:Class;
[Embed(source='pirates.png')]
public var piratesSheetClass:Class;
[Embed(source='char.png')]
public var charSheetClass:Class;
public var itemSheet:Bitmap;
public var sheetClass:Class;
public var deadAnimalClass:Class;
public var sprite:SpriteSheet;
public var spriteSheet:SpriteSheet;
public var useItemSheet:Boolean;
public var delay:int;
public var tile:int;
public var emptyTile:int;
public var useable:Boolean;
public var takeable:Boolean;
public var equipable:Boolean;
public var walkable:Boolean;
public var attacked:Boolean;
public var node:Node;
public var bits:int;
public var wood:int;
public var energyCost:int;
public var seconds:int;
public var health:int;
public var energy:Number
public var animal:Animal;
public var scaleX:int;
public var scaleY:int;
public var rotation:int = 0;
public var attackSkill = 0;
public function Item(related_node:Node, customSheet:Boolean = false) {
node = related_node
if(!customSheet){
sheetClass = environmentSheetClass
}
emptyTile = 14;
tile = 14
bits = 32
useable = false
takeable = true
equipable = false
walkable = false
wood = 0
seconds = 0
health = 1
energyCost = 0
scaleX = 1
scaleY = 1
}
public function getSprite():SpriteSheet{
return new SpriteSheet(new sheetClass(), bits, bits);
}
public function requirements_met(stage:Object):Boolean{
return true;
}
public function removeAnimal(stage:Object):void{
if(animal == null){
return
}
var index:int = 0;
for(var i:int; i < stage.world.animals.length; i++){
if (stage.world.animals[i].y == (animal.y) && stage.world.animals[i].x == (animal.x)){
index = i;
break;
}
}
trace(index)
stage.world.animals.splice(index, 1)
if(node != null){
node.removeItem(stage)
}
}
public function place(stage:Object, x:int, y:int):void{
//stage.updateEnergy(-1);
}
public function take(stage:Object, world:World):Item{
return null;
}
public function move(stage:Object):void{
}
public function hit():void{
if(node != null){
node.hit()
}
}
public function miss():void{
if(node != null){
node.miss()
}
}
public function useItem(stage:Object, used:Item):Boolean{
return true
}
}
}