/
PlantScrap.as
231 lines (171 loc) · 4.27 KB
/
PlantScrap.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
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
package
{
import flash.display.MovieClip;
//-----------------------
//Purpose: Scrap plant material that holds some of the plant's original nutrients
//
//Public Properties:
//
//Public Methods:
//
//-----------------------
public class PlantScrap extends Item implements IConstantPrice, IDecomposes, IFertilizerSource
{
// Constants //
//- Constants -//
// Public Properties //
public function get n1():Number
{
var n1:Number = 0.0;
if (_nutrientSet != null)
{
n1 = _nutrientSet.n1;
}
return n1;
}
public function get n2():Number
{
var n2:Number = 0.0;
if (_nutrientSet != null)
{
n2 = _nutrientSet.n2;
}
return n2;
}
public function get n3():Number
{
var n3:Number = 0.0;
if (_nutrientSet != null)
{
n3 = _nutrientSet.n3;
}
return n3;
}
public override function get name():String
{
return "Plant Scrap";
}
public function get nutrientSet():NutrientSet
{
return _nutrientSet;
}
public function set nutrientSet(value:NutrientSet):void
{
_nutrientSet = value;
}
public override function get priceModifier():int
{
return -1;
}
public override function set priceModifier(value:int):void
{
return;
}
public override function get type():int
{
return -1;
}
public function get toxicity():Number
{
return _toxicity;
}
public function set toxicity(value:Number):void
{
_toxicity = value;
}
//- Public Properties -//
// Private Properties //
private var _decomposeDaysLeft:int;
private var _nutrientSet:NutrientSet;
private var _toxicity:Number;
//- Private Properties -//
// Initialization //
public function PlantScrap(nutrients:NutrientSet = null, toxicity:Number = 0, decomposeDaysLeft:int = 0)
{
_nutrientSet = nutrients;
_toxicity = toxicity;
_decomposeDaysLeft = decomposeDaysLeft;
}
//- Initialization -//
// Public Methods //
public function CreateCompost():Compost
{
var oCompost:Compost = new Compost(new NutrientSet(_nutrientSet.n1, _nutrientSet.n2, _nutrientSet.n3), _toxicity);
return oCompost;
}
public function CreateFertilizer():Fertilizer
{
var oFertilizer:Fertilizer = new Fertilizer(this, this.GetFertilizerNutrientSet(), this.GetFertilizerToxicity(), this.GetFertilizerName(), this.GetFertilizerDuration(),
this.GetFertilizerDuration());
return oFertilizer;
}
public function GetDecomposeDaysLeft():int
{
return _decomposeDaysLeft;
}
public function GetFertilizerDuration():int
{
return 5;
}
public function GetFertilizerGraphics():MovieClip
{
var mcScrap:PlantScrap_MC = new PlantScrap_MC();
return mcScrap;
}
public function GetFertilizerName():String
{
return "Plant Scraps";
}
public function GetFertilizerNutrientSet():NutrientSet
{
// plant scraps give only 1/2 of original plant nutrients as fertilizer
var oNutrientSet:NutrientSet = new NutrientSet(_nutrientSet.n1 / 2, _nutrientSet.n2 / 2, _nutrientSet.n3 / 2);
return oNutrientSet;
}
public function GetFertilizerToxicity():Number
{
return _toxicity;
}
public function GetGraphics():MovieClip
{
var mcScrap:PlantScrap_MC = new PlantScrap_MC();
return mcScrap;
}
public override function GetItemGraphics():MovieClip
{
var mcItem:MovieClip = this.GetGraphics();
return mcItem;
}
public function GetGridGraphics():MovieClip
{
var mcScrap:PlantScrap_MC = new PlantScrap_MC();
mcScrap.width /= 2;
mcScrap.height /= 2;
return mcScrap;
}
public function GetPrice():int
{
return -1;
}
public function GetPreviewGraphics():MovieClip
{
var mcPreview:MovieClip = new MovieClip();
var mcBackground:PlantScrapPreview_MC = new PlantScrapPreview_MC();
mcPreview.addChild(mcBackground);
var mcScrap:PlantScrap_MC = new PlantScrap_MC();
mcScrap.x = 5;
mcScrap.y = 5;
mcPreview.addChild(mcScrap);
return mcPreview;
}
public function SetDecomposeDaysLeft(days:int):void
{
_decomposeDaysLeft = days;
}
//- Public Methods -//
// Private Methods //
//- Private Methods -//
// Testing Methods //
//- Testing Methods -//
}
}