@@ -12,12 +12,13 @@ use crate::{
1212 play_to_real_size, tile_to_pos, EndTile , ForegroundTile , LevelSize , PathTile , StartTile ,
1313 TilemapLayer , TilesAvailable , MAP_SIZE ,
1414 } ,
15+ ui:: * ,
1516 GameState , INITIAL_RESOLUTION ,
1617} ;
1718
1819//0, 1, 2, 3, 4, 5, 130, 160, 250, 300, 400, 500, 700, 900, 1200, 1500, 2000, 2500, 3500,
1920const START_SCORES : [ u32 ; 20 ] = [
20- 0 , 5 , 30 , 50 , 100 , 130 , 160 , 220 , 260 , 300 , 400 , 500 , 700 , 900 , 1200 , 1500 , 2000 , 2500 , 3500 ,
21+ 0 , 5 , 25 , 50 , 100 , 130 , 160 , 220 , 260 , 300 , 400 , 500 , 700 , 900 , 1200 , 1500 , 2000 , 2500 , 3500 ,
2122 5000 ,
2223] ;
2324
@@ -67,6 +68,9 @@ pub struct GameCam {
6768#[ derive( Component ) ]
6869pub struct TutorialText ;
6970
71+ #[ derive( Component ) ]
72+ pub struct InitialText ;
73+
7074// ·······
7175// Systems
7276// ·······
@@ -136,6 +140,8 @@ fn spawn_start_end(
136140 mut visible : Query < & mut TileVisible > ,
137141 mut cam : Query < & mut GameCam > ,
138142 tutorial : Query < Entity , With < TutorialText > > ,
143+ story_text : Query < Entity , With < InitialText > > ,
144+ style : Res < UIStyle > ,
139145) {
140146 // If score is bigger than 1, remove tutorial text
141147 if score. score >= 1 {
@@ -207,6 +213,39 @@ fn spawn_start_end(
207213 } ;
208214
209215 if let Some ( pos) = spawn_pos {
216+ // Add the story text (between 10 and 30 entities)
217+ if count. start == 2 {
218+ cmd. spawn ( (
219+ NodeBundle {
220+ style : Style {
221+ position_type : PositionType :: Absolute ,
222+ width : Val :: Percent ( 100. ) ,
223+ align_items : AlignItems :: Center ,
224+ justify_content : JustifyContent :: Center ,
225+ top : Val :: Percent ( if pos. y - offset. y < size. y / 2 {
226+ 28.
227+ } else {
228+ 72.
229+ } ) ,
230+ ..default ( )
231+ } ,
232+ ..default ( )
233+ } ,
234+ InitialText ,
235+ ) )
236+ . with_children ( |node| {
237+ UIText :: simple ( & style, "Guide home as many entities as you can" )
238+ . with_title ( )
239+ . add ( node) ;
240+ } ) ;
241+ }
242+
243+ if count. start == 3 {
244+ for story_text in story_text. iter ( ) {
245+ cmd. entity ( story_text) . despawn_recursive ( ) ;
246+ }
247+ }
248+
210249 for ( layer, grid_size, map_type, storage, trans) in tilemap. iter ( ) {
211250 match layer {
212251 // Insert the logical tile in the river
0 commit comments