Skip to content

Commit

Permalink
fix up some levels
Browse files Browse the repository at this point in the history
  • Loading branch information
lee-orr committed Jan 8, 2023
1 parent e624751 commit 47de1df
Show file tree
Hide file tree
Showing 8 changed files with 77 additions and 50 deletions.
1 change: 1 addition & 0 deletions assets/dynamic_assets.assets
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
"menu_icon": File ( path: "icons/hamburger-menu.png"),
"coins_icon": File ( path: "icons/coins.png"),
"coin_icon": File ( path: "icons/two-coins.png"),
"help_icon": File ( path: "icons/help.png"),

"land_tile": File (path: "models_2.gltf#Mesh0/Primitive0"),
"farm_tile": File (path: "models_2.gltf#Mesh1/Primitive0"),
Expand Down
Binary file added assets/icons/help.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
6 changes: 3 additions & 3 deletions assets/levels/aquaduct_1.lvl.json
Original file line number Diff line number Diff line change
Expand Up @@ -466,7 +466,7 @@
]
],
"title": "Across The Valley",
"initial_description": "The fictional town of Casterbridge has been growing slowly, and now they find they need a better way to transport their goods. Help them by connecting a Canal across the valley.",
"initial_description": "The fictional town of Casterbridge has been growing slowly, and now they find they need a better way to transport their goods. Help them by connecting a Canal across the valley.\nTo do this, we will need a new tool - Aquaducts!",
"sidebar_text": "Aquaducts can be used to transfer water across lower terrain - give it a try!",
"width": 8,
"height": 8,
Expand Down Expand Up @@ -494,8 +494,8 @@
[
{
"DisplayText": {
"text": "The new canal was a great success! As you can see, the town grew quite a bit - and ow they want the canal to reach the town center.\nOnly problem is - that's even higher up. You may need to re-build things with a new aquaduct to make this work...",
"title": "Complications Arise",
"text": "The new canal was a great success! And now the mayor asked for the canal to reach the town center.\nOnly problem is - that's even higher up. Good luck!",
"title": "We crossed the valley!",
"continue_button": "Keep Going"
}
},
Expand Down
4 changes: 2 additions & 2 deletions assets/levels/beverley.lvl.json
Original file line number Diff line number Diff line change
Expand Up @@ -1035,7 +1035,7 @@
],
"title": "Beverley Beck",
"initial_description": "The town of Beverley had a problem - boats arrive at the nearby River Hull, but the creek leading to the town isn't in good shape...",
"sidebar_text": "Connect the River Hull to the dried up creek using a Canal.",
"sidebar_text": "Connect the River Hull to the dried up creek using a Canal.\nAvoid going uphill by following the contour lines on the terrain.",
"width": 12,
"height": 12,
"events": [
Expand All @@ -1044,7 +1044,7 @@
[
{
"DisplayText": {
"text": "As you managed to get the Beck connected to the river, you find a problem... The river is tidal, and you need a lock to manage the water levels. Build a lock in the specified location to proceed.",
"text": "As you managed to get the Beck connected to the river, you find a problem... The river is tidal, and you need a lock to manage the water levels. Build a lock in the specified location to proceed.\n \nLocks allow you to connect a canal to a water source above it. Remember that while locks let boats travel uphill, the water always flows down.",
"title": "Complications Arise",
"continue_button": "Keep Going"
}
Expand Down
42 changes: 29 additions & 13 deletions assets/levels/sankey.lvl.json
Original file line number Diff line number Diff line change
Expand Up @@ -452,7 +452,7 @@
},
{
"tile_type": "Land",
"contents": "None",
"contents": "Canal",
"is_goal": false,
"cost_modifier": "None",
"height": 3
Expand Down Expand Up @@ -559,7 +559,7 @@
},
{
"tile_type": "Land",
"contents": "None",
"contents": "Canal",
"is_goal": false,
"cost_modifier": "None",
"height": 3
Expand Down Expand Up @@ -1101,14 +1101,14 @@
},
{
"tile_type": "Land",
"contents": "Canal",
"contents": "None",
"is_goal": false,
"cost_modifier": "None",
"height": 1
},
{
"tile_type": "Land",
"contents": "Canal",
"contents": "None",
"is_goal": false,
"cost_modifier": "None",
"height": 1
Expand Down Expand Up @@ -1164,7 +1164,7 @@
},
{
"tile_type": "Land",
"contents": "None",
"contents": "Lock",
"is_goal": true,
"cost_modifier": "None",
"height": 1
Expand Down Expand Up @@ -1195,7 +1195,7 @@
{
"tile_type": "Farm",
"contents": "None",
"is_goal": false,
"is_goal": true,
"cost_modifier": "None",
"height": 3
},
Expand All @@ -1222,7 +1222,7 @@
},
{
"tile_type": "Land",
"contents": "None",
"contents": "Canal",
"is_goal": false,
"cost_modifier": "None",
"height": 1
Expand Down Expand Up @@ -1608,7 +1608,7 @@
],
"title": "Sankey Canal",
"initial_description": "The Sankey Canal was built alongside the Sankey Brook, to connect Warrington - on the river Mersey - to Parr",
"sidebar_text": null,
"sidebar_text": "Connect Warrington to Parr. Remember - water only flows downstream.",
"width": 15,
"height": 15,
"events": [
Expand All @@ -1622,11 +1622,27 @@
"continue_button": "Keep Going"
}
},
{ "AdjustContents": [11,1, "None"] },
{ "SetHeight": [9, 6, 0] },
{ "SetNewGoal": [2,3] },
{ "AdjustContents": [11,1, "Lock"] },
{ "SetNewGoal": [10,13] }
{
"SetSidebar": "Connect St. Helens to your canal network."
},
{
"SetNewGoal": [
2,
3
]
},
{
"SetNewGoal": [
10,
5
]
},
{
"SetNewGoal": [
5,
3
]
}
]
]
],
Expand Down
2 changes: 2 additions & 0 deletions src/assets.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ pub struct CanalManiaAssets {
pub coin_icon: Handle<Image>,
#[asset(key = "coins_icon")]
pub coins_icon: Handle<Image>,
#[asset(key = "help_icon")]
pub help_icon: Handle<Image>,

#[asset(key = "land_tile")]
pub land_tile: Handle<Mesh>,
Expand Down
31 changes: 8 additions & 23 deletions src/game/in_game_ui.rs
Original file line number Diff line number Diff line change
Expand Up @@ -73,28 +73,28 @@ fn display_ui(
.with_children(|parent| {
parent.div().horizontal().opaque().with_children(|parent| {
parent
.button("dig", "Dig Canal")
.button("dig", "Dig Canal\nFlow water along a plane")
.id(GameUiId::Dig)
.style(ButtonStyle::Action)
.hidden(!tools.canal)
.selected(operation.0 == GameActionMode::DigCanal)
.icon(asset.dig_canal_icon.clone());
parent
.button("lock", "Construct Lock")
.button("lock", "Construct Lock\nConnect canals to water above them")
.id(GameUiId::Lock)
.style(ButtonStyle::Action)
.hidden(!tools.lock)
.selected(operation.0 == GameActionMode::ConstructLock)
.icon(asset.lock_icon.clone());
parent
.button("aquaduct", "Construct Aquaduct")
.button("aquaduct", "Construct Aquaduct\nAllow canals to cross a gap\nMust be built to level")
.id(GameUiId::Aquaduct)
.style(ButtonStyle::Action)
.hidden(!tools.aquaduct)
.selected(operation.0 == GameActionMode::BuildAquaduct)
.icon(asset.aqueduct_icon.clone());
parent
.button("demolish", "Demolish")
.button("demolish", "Demolish\nMade a mistake? Demolish it.")
.id(GameUiId::Demolish)
.style(ButtonStyle::Action)
.hidden(!tools.demolish)
Expand All @@ -108,7 +108,7 @@ fn display_ui(
.for_state(GameState::InGame)
.position(Val::Px(0.), Val::Auto, Val::Px(0.), Val::Auto)
.with_children(|parent| {
parent.div().padding(20.);
parent.div().padding(50.);
parent
.div()
.position(Val::Px(0.), Val::Auto, Val::Px(0.), Val::Auto)
Expand All @@ -131,25 +131,10 @@ fn display_ui(
.size(15.)
.id(GameUiId::SidebarText);
});
parent.div().position(Val::Px(0.), Val::Auto, Val::Px(30.), Val::Auto).with_children(|parent| {
parent.button("help", "Drag Midde Mouse Button, Arrow Keys or WSAD to move the camera\n\nDrag Right Mouse Button, Control + Arrow Keys or WSAD to orbit the camera\n\nScroll Wheel, + or - Keys to zoom").icon(asset.help_icon.clone()).hover_direction(crate::ui::div::Direction::Horizontal).style(ButtonStyle::Small);
});
});

commands
.ui_root()
.for_state(GameState::InGame)
.position(Val::Auto,Val::Px(0.), Val::Px(0.), Val::Auto)
.with_children(|parent| {
parent
.div()
.opaque()
.size(Size::new(Val::Px(200.), Val::Auto))
.with_children(|parent| {
parent.text("Drag Midde Mouse Button, Arrow Keys or WSAD to move the camera").size(15.);
parent.div().padding(3.);
parent.text("Drag Right Mouse Button, Control + Arrow Keys or WSAD to orbit the camera").size(15.);
parent.div().padding(3.);
parent.text("Scroll Wheel, + or - Keys to zoom").size(15.);
});
});

#[cfg(feature = "dev")]
commands
Expand Down
41 changes: 32 additions & 9 deletions src/ui/button.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
use crate::assets::CanalManiaAssets;

use bevy::ecs::storage::Column;
use bevy::prelude::*;
use bevy::ui::{FocusPolicy, JustifyContent};

Expand Down Expand Up @@ -215,27 +216,49 @@ pub(crate) fn spawn_button(
position_type: PositionType::Absolute,
position: match button.hover_direction {
Direction::Vertical => UiRect::bottom(Val::Percent(100.)),
Direction::Horizontal => UiRect::left(Val::Percent(100.)),
Direction::Horizontal => UiRect::new(Val::Percent(100.), Val::Auto, Val::Px(0.), Val::Auto),
},
flex_direction: FlexDirection::Column,
padding: UiRect::all(Val::Px(5.)),
justify_content: JustifyContent::Center,
align_items: AlignItems::Center,
border: UiRect::all(Val::Px(1.)),
margin: UiRect::all(Val::Px(3.)),
overflow: Overflow::Hidden,
overflow: Overflow::Visible,
size: Size::new(Val::Px(300.), Val::Auto),
..Default::default()
},
focus_policy: FocusPolicy::Pass,
..Default::default()
})
.with_children(|parent| {
parent.spawn(TextBundle::from_section(text, style.clone()).with_style(
Style {
max_size: Size::new(Val::Undefined, Val::Px(size)),
margin: UiRect::all(Val::Px(4.)),
..Default::default()
},
));
for line in text.lines() {
parent
.spawn(NodeBundle {
style: Style {
flex_direction: FlexDirection::Row,
flex_wrap: FlexWrap::Wrap,
align_content: AlignContent::FlexStart,
..Default::default()
},
..Default::default()
})
.with_children(|parent| {
for word in line.split_whitespace() {
parent.spawn(
TextBundle::from_section(
format!("{word} "),
style.clone(),
)
.with_style(Style {
max_size: Size::new(Val::Undefined, Val::Px(size)),
margin: UiRect::all(Val::Px(4.)),
..Default::default()
}),
);
}
});
}
});
} else {
parent.spawn(
Expand Down

0 comments on commit 47de1df

Please sign in to comment.