@@ -4,7 +4,7 @@ const SVG_NS = Drawer.SVG_NS;
44
55/**
66 * Extends Drawer to draw flowers/honeycomb for bee.
7- * @param {MaseMap } map
7+ * @param {MazeMap } map
88 * @param {Object } skin The app's skin, used to get URLs for our images
99 * @param {Bee } bee The maze's Bee object.
1010 */
@@ -14,10 +14,6 @@ module.exports = class BeeItemDrawer extends Drawer {
1414 this . skin_ = skin ;
1515 this . bee_ = bee ;
1616
17- this . honeyImages_ = [ ] ;
18- this . nectarImages_ = [ ] ;
19- this . pegman_ = null ;
20-
2117 // is item currently covered by a cloud?
2218 this . clouded_ = undefined ;
2319 this . resetClouded ( ) ;
@@ -102,79 +98,11 @@ module.exports = class BeeItemDrawer extends Drawer {
10298 }
10399 }
104100
105- createCounterImage_ ( prefix , i , row , href ) {
106- var id = prefix + ( i + 1 ) ;
107- var image = document . createElementNS ( SVG_NS , 'image' ) ;
108- image . setAttribute ( 'id' , id ) ;
109- image . setAttribute ( 'width' , SQUARE_SIZE ) ;
110- image . setAttribute ( 'height' , SQUARE_SIZE ) ;
111- image . setAttribute ( 'y' , row * SQUARE_SIZE ) ;
112-
113- image . setAttributeNS ( 'http://www.w3.org/1999/xlink' , 'xlink:href' , href ) ;
114-
115- this . svg_ . insertBefore ( image , this . getPegmanElement_ ( ) ) ;
116-
117- return image ;
118- }
119-
120101 flowerImageHref_ ( row , col ) {
121102 return this . bee_ . isRedFlower ( row , col ) ? this . skin_ . redFlower :
122103 this . skin_ . purpleFlower ;
123104 }
124105
125- updateHoneyCounter ( honeyCount ) {
126- for ( var i = 0 ; i < honeyCount ; i ++ ) {
127- if ( ! this . honeyImages_ [ i ] ) {
128- this . honeyImages_ [ i ] = this . createCounterImage_ ( 'honey' , i , 1 ,
129- this . skin_ . honey ) ;
130- }
131-
132- var deltaX = SQUARE_SIZE ;
133- if ( honeyCount > 8 ) {
134- deltaX = ( 8 - 1 ) * SQUARE_SIZE / ( honeyCount - 1 ) ;
135- }
136- this . honeyImages_ [ i ] . setAttribute ( 'x' , i * deltaX ) ;
137- }
138-
139- for ( i = 0 ; i < this . honeyImages_ . length ; i ++ ) {
140- this . honeyImages_ [ i ] . setAttribute ( 'display' , i < honeyCount ? 'block' : 'none' ) ;
141- }
142- }
143-
144- updateNectarCounter ( nectars ) {
145- var nectarCount = nectars . length ;
146- // create any needed images
147- for ( var i = 0 ; i < nectarCount ; i ++ ) {
148- var href = this . flowerImageHref_ ( nectars [ i ] . row , nectars [ i ] . col ) ;
149-
150- if ( ! this . nectarImages_ [ i ] ) {
151- this . nectarImages_ [ i ] = this . createCounterImage_ ( 'nectar' , i , 0 , href ) ;
152- }
153-
154- var deltaX = SQUARE_SIZE ;
155- if ( nectarCount > 8 ) {
156- deltaX = ( 8 - 1 ) * SQUARE_SIZE / ( nectarCount - 1 ) ;
157- }
158- this . nectarImages_ [ i ] . setAttribute ( 'x' , i * deltaX ) ;
159- this . nectarImages_ [ i ] . setAttributeNS ( 'http://www.w3.org/1999/xlink' ,
160- 'xlink:href' , href ) ;
161- }
162-
163- for ( i = 0 ; i < this . nectarImages_ . length ; i ++ ) {
164- this . nectarImages_ [ i ] . setAttribute ( 'display' , i < nectarCount ? 'block' : 'none' ) ;
165- }
166- }
167-
168- /**
169- * Cache pegman element
170- */
171- getPegmanElement_ ( ) {
172- if ( ! this . pegman_ ) {
173- this . pegman_ = document . getElementsByClassName ( 'pegman-location' ) [ 0 ] ;
174- }
175- return this . pegman_ ;
176- }
177-
178106 /**
179107 * Show the cloud icon.
180108 */
0 commit comments