diff --git a/game_core/src/assets/static/intro_text.txt b/game_core/src/assets/static/intro_text.txt new file mode 100644 index 0000000000000000000000000000000000000000..4b3da7e5a89a54cb80c418356fe743db4e854fdb --- /dev/null +++ b/game_core/src/assets/static/intro_text.txt @@ -0,0 +1,4 @@ +As you step off of the docks onto the sickly grass below, the stillness of the scene before you confirms the rumours thatlead you to this remote island. +A foul curse, born of dark magics and vile intention, has sealed the residents of the island's towns withing their boundaries. None of the local citizens can step foot into the fields, roads or deserts; they cannot harvest the crops, and food supplies dwindle. +The only place on the island still producing food is the hill top monastery, whose fields sit within the walls of the cathedral. +If only there were an enterprising merchant able to travel between these sealed towns, supplying them with the food they so desperately need, and making a pretty penny in the process... \ No newline at end of file diff --git a/game_core/src/ui/widgets/encounter_panel.rs b/game_core/src/ui/widgets/encounter_panel.rs index 665ee3b17ed20b54a89a75b27cbffdbd66ec4662..12217f014629bdc1c2bbb8729c7900c073a289be 100644 --- a/game_core/src/ui/widgets/encounter_panel.rs +++ b/game_core/src/ui/widgets/encounter_panel.rs @@ -1,8 +1,8 @@ use bevy::prelude::*; use kayak_ui::prelude::*; use kayak_ui::widgets::{ - ElementBundle, ScrollBoxBundle, ScrollBoxProps, ScrollContextProviderBundle, TextProps, - TextWidgetBundle, + BackgroundBundle, ElementBundle, ScrollBoxBundle, ScrollBoxProps, ScrollContextProviderBundle, + TextProps, TextWidgetBundle, }; use crate::assets::AssetHandles; @@ -55,39 +55,70 @@ pub fn render_encounter_panel( rsx! { <ElementBundle styles={panel_style}> <PanelWidget> - <TextWidgetBundle - text={TextProps { - font: Some(String::from("header")), - content: format!("Trepidation! {}", encounter.title), - size: 36.0, - ..Default::default() - }} + <BackgroundBundle styles={KStyle { + + height: value(Units::Auto), color: value(Color::BLACK), - padding: edge_px(40.0), - left: stretch(1.0), - right: stretch(1.0), + padding_left: px(20.0), + padding_right: px(20.0), + padding_top: px(10.0), + padding_bottom: px(10.0), ..Default::default() }} - /> + > + <TextWidgetBundle + text={TextProps { + font: Some(String::from("header")), + content: format!("Trepidation! {}", encounter.title), + size: 36.0, + ..Default::default() + }} + styles={KStyle { + color: value(Color::BLACK), + left: stretch(1.0), + right: stretch(1.0), + ..Default::default() + }} + /> + </BackgroundBundle> <VDividerWidget props={VDividerWidgetProps { height: 4.0, padding: 10.0, color: Color::rgb(0.52, 0.369, 0.18)}} /> <ScrollContextProviderBundle> - <ScrollBoxBundle> - <TextWidgetBundle - text={TextProps { - content: encounter.description.to_string(), - size: 32.0, - ..Default::default() - }} - styles={KStyle { - color: value(Color::BLACK), - padding: edge_px(20.0), - bottom: px(15.0), - left: stretch(1.0), - right: stretch(1.0), - ..Default::default() - }} - /> + <ScrollBoxBundle + scroll_box_props={ScrollBoxProps { + track_color: Some(Color::rgb(0.827, 0.482, 0.353)), + thumb_color: Some(Color::rgb(0.451, 0.224, 0.063)), + ..Default::default() + } } styles={KStyle { padding: edge_px(5.0), ..Default::default() }}> + { for line in encounter.description.lines() { + constructor! { + <BackgroundBundle + styles={KStyle { + render_command: value(RenderCommand::Quad), + layout_type: value(LayoutType::Row), + height: value(Units::Auto), + width: pct(90.0), + left: stretch(1.0), + right: stretch(1.0), + bottom: px(15.0), + ..Default::default() + }} + > + <TextWidgetBundle + text={TextProps { + content: line.to_string(), + line_height: Some(34.0), + size: 32.0, + ..Default::default() + }} + styles={KStyle { + color: value(Color::BLACK), + ..Default::default() + }} + /> + </BackgroundBundle> + } + } } </ScrollBoxBundle> </ScrollContextProviderBundle> </PanelWidget> @@ -111,6 +142,7 @@ pub fn render_encounter_panel( constructor! { <ButtonWidget + styles={KStyle { ..Default::default() }} props={ButtonWidgetProps::text(label, 28.0)} on_event={on_click} /> diff --git a/game_core/src/world/encounters.rs b/game_core/src/world/encounters.rs index 4964ff5591db679de8a0536085d98d181ff8f1c9..92ddbf9e154f40411833e76993adc7cee1e28242 100644 --- a/game_core/src/world/encounters.rs +++ b/game_core/src/world/encounters.rs @@ -21,6 +21,22 @@ pub enum EncounterType { GrassyRoad, } +impl EncounterType { + pub fn get_custom_encounters(&self) -> Option<Vec<Encounter>> { + match self { + Self::Docks => Some(vec![Encounter { + title: String::from("Your journey begins"), + description: String::from(include_str!("../assets/static/intro_text.txt")), + options: vec![EncounterOption { + label: String::from("Journey Forth"), + outcome: vec![], + }], + }]), + _ => None, + } + } +} + impl TryFrom<String> for EncounterType { type Error = &'static str; @@ -211,16 +227,34 @@ pub fn notify_new_zone( match *last_zone { Some(existing_zone) => { if zone != existing_zone { + match zone.zone_type.get_custom_encounters() { + Some(envc) => { + log::info!("Recounter Zone: {:?}", zone.zone_type); + let encounter = envc[fastrand::usize(0..envc.len())].clone(); + *last_zone = Some(zone); + *encounter_state = EncounterState::Choice(encounter); + } + None => { + log::info!("New Zone: {:?}", zone.zone_type); + *last_zone = Some(zone); + *encounter_state = EncounterState::Choice(gen_encounter()); + } + } + } + } + None => match zone.zone_type.get_custom_encounters() { + Some(envc) => { + log::info!("Recounter Zone: {:?}", zone.zone_type); + let encounter = envc[fastrand::usize(0..envc.len())].clone(); + *last_zone = Some(zone); + *encounter_state = EncounterState::Choice(encounter); + } + None => { log::info!("New Zone: {:?}", zone.zone_type); *last_zone = Some(zone); *encounter_state = EncounterState::Choice(gen_encounter()); } - } - None => { - log::info!("New Zone: {:?}", zone.zone_type); - *last_zone = Some(zone); - *encounter_state = EncounterState::Choice(gen_encounter()); - } + }, } } else if last_zone.is_some() { *last_zone = None;