@@ -5,9 +5,12 @@ import * as SVG from "svg.js";
55 * either by completing the entire duration, or the plant dying midway.
66 * @author Hiroki Terashima
77 * @author Geoffrey Kwan
8+ * @author Jonathan Lim-Breitbart
89 */
910export class SimulationEndFeedback {
1011 draw : SVG ;
12+ plantAliveRect : SVG ;
13+ plantAliveText : SVG ;
1114 plantDiedRect : SVG ;
1215 plantDiedText : SVG ;
1316 simulationEndedRect : SVG ;
@@ -20,20 +23,56 @@ export class SimulationEndFeedback {
2023 constructor ( draw : SVG ) {
2124 this . draw = draw ;
2225
23- this . simulationEndedRect = this . draw . rect ( 500 , 100 ) . x ( 250 ) . y ( 400 )
24- . fill ( 'lightblue' ) . stroke ( { width :2 } )
25- . opacity ( 1 ) . attr ( { 'fill-opacity' : 1 } ) . hide ( ) ;
26+ this . simulationEndedRect = this . draw
27+ . rect ( 500 , 100 )
28+ . x ( 250 )
29+ . y ( 400 )
30+ . fill ( "lightblue" )
31+ . stroke ( { width : 2 } )
32+ . opacity ( 1 )
33+ . attr ( { "fill-opacity" : 1 } )
34+ . hide ( ) ;
2635
27- this . simulationEndedText = this . draw . text ( 'Simulation ended' )
28- . x ( 315 ) . y ( 410 ) . font ( { size : 48 } ) . hide ( ) ;
36+ this . simulationEndedText = this . draw
37+ . text ( "Simulation ended" )
38+ . x ( 315 )
39+ . y ( 410 )
40+ . font ( { size : 48 } )
41+ . hide ( ) ;
2942
30- this . plantDiedRect = this . draw . rect ( 500 , 100 ) . x ( 250 ) . y ( 400 )
31- . fill ( '#FF0000' ) . stroke ( { width :2 } ) . opacity ( 1 ) . attr ( {
32- 'fill-opacity' : 1
33- } ) . hide ( ) ;
43+ this . plantAliveRect = this . draw
44+ . rect ( 500 , 100 )
45+ . x ( 250 )
46+ . y ( 400 )
47+ . fill ( "#33FF00" )
48+ . stroke ( { width : 2 } )
49+ . opacity ( 1 )
50+ . attr ( { "fill-opacity" : 1 } )
51+ . hide ( ) ;
3452
35- this . plantDiedText = this . draw . text ( 'The plant has died' )
36- . x ( 300 ) . y ( 410 ) . font ( { size : 48 , fill : 'white' } ) . hide ( ) ;
53+ this . plantAliveText = this . draw
54+ . text ( "The plant is alive" )
55+ . x ( 315 )
56+ . y ( 410 )
57+ . font ( { size : 48 } )
58+ . hide ( ) ;
59+
60+ this . plantDiedRect = this . draw
61+ . rect ( 500 , 100 )
62+ . x ( 250 )
63+ . y ( 400 )
64+ . fill ( "#FF0000" )
65+ . stroke ( { width : 2 } )
66+ . opacity ( 1 )
67+ . attr ( { "fill-opacity" : 1 } )
68+ . hide ( ) ;
69+
70+ this . plantDiedText = this . draw
71+ . text ( "The plant has died" )
72+ . x ( 300 )
73+ . y ( 410 )
74+ . font ( { size : 48 , fill : "white" } )
75+ . hide ( ) ;
3776 }
3877
3978 /**
@@ -44,6 +83,8 @@ export class SimulationEndFeedback {
4483 this . plantDiedText . hide ( ) ;
4584 this . simulationEndedRect . hide ( ) ;
4685 this . simulationEndedText . hide ( ) ;
86+ this . plantAliveRect . hide ( ) ;
87+ this . plantAliveText . hide ( ) ;
4788 }
4889
4990 /**
@@ -65,4 +106,14 @@ export class SimulationEndFeedback {
65106 this . simulationEndedRect . show ( ) ;
66107 this . simulationEndedText . show ( ) ;
67108 }
109+
110+ /**
111+ * Shows plant alive feedback and bring it to the front
112+ */
113+ showPlantAlive ( ) {
114+ this . plantAliveRect . front ( ) ;
115+ this . plantAliveText . front ( ) ;
116+ this . plantAliveRect . show ( ) ;
117+ this . plantAliveText . show ( ) ;
118+ }
68119}
0 commit comments