diff --git a/gdd.md b/gdd.md index 3c72c77..6638cae 100644 --- a/gdd.md +++ b/gdd.md @@ -8,13 +8,10 @@ * Education * Supply chains -## Critical Path - -### Grid +## Grid Add a 10x10 grid. Tiles are highlighted a different colour when the player hovers over them with the cursor. -Tiles can be interacted with, which turns them another colour. ### Diffusion @@ -49,7 +46,19 @@ private float TransferHeat(float t0, float alpha, float nx, float ny, float px, } ``` -### Tile Types +## Build Mode + +Build mode can be entered by pressing the `b` key. +Build the cursor will start flashing when entering build mode. + +Once in build mode, a tile type must be selected to build anything. +Tiles cab be selected with the buttons along the bottom of the screen or by keyboard shortcuts. +The keyboard shortcut to select a tile type is indicated on the button. + +To deselect a tile type, press `esc`. +Press `esc` again to exit build mode. + +## Tile Types Tiles start as wild tiles. The player can use a UI element or a keyboard shortcut to enable build mode. @@ -58,14 +67,14 @@ In build mode, the player can click on a wile tile to turn it into a developed t * Wild tiles are green * Developed tiles are grey -### Heat +## Heat Developed tiles produce heat while wild tiles absorb it. Every tile has a floating-point heat value which diffuses to its neighbours. Add a heat map view which can be toggled or cycled to. It is possible to cycle the view using a UI element. -### Tile Health +## Tile Health Add another value to wild tiles: health. A wild tile can accept a certain amount of heat each tick from surrounding tiles. @@ -83,13 +92,13 @@ Its effectiveness at absorbing heat scales with its remaining health. Diffusion still occurs to move heat away from depleted wild tiles. -### Rewilding +## Rewilding Add a rewilding mode option to the UI. In rewilding mode, the player can click on a developed tile to turn in into a wild tile. The wild tile starts with 0 health. -### Wild Recovery +## Wild Recovery Depleted wile tiles can recover health each tick. The recovery rate is based on the difference between the damage threshold and the actual amount they received. @@ -98,7 +107,7 @@ The recovery rate is increased if the tile has wild neighbours. neighbour multiplier = lerp(1, max, number of neighbours / 4) health restored = max((damage threshold - heat received), 0) * neighbour multiplier. -### Developed tile types +## Developed tile types Split developed tiles into 3 types: @@ -111,19 +120,19 @@ These types generate different amounts of heat: industrial > commercial > residential -### Journeys +## Journeys Developed tiles have a chance to generate journeys between them. A journey instances a vehicle which traverses the map at a constant speed from its origin to its destination tile. A vehicle adds a constant amount of heat to every tile it traverses. -### Moving In +## Moving In Residential tiles have two new integer resources, current residents and maximum residents. Every tick there is a chance for residents to move in to a residential tile if the current number is less than the maximum number of residents. The initial number of maximm residents per residential tile is 4. -### Jobs +## Jobs Industrial and commercial tiles have two new integer resources, available jobs and occupied jobs. The chance for residents to move in depends on there being being fewer occupied than available jobs. @@ -132,12 +141,12 @@ Their chance of generating a journey is proportional to occupied jobs / available jobs . -### Commutes +## Commutes A resident moves in to a residential tile and gets a job at an industrial or commercial 'job' tile. The residential tile regularly generates journeys to the job tile, and the job tile regularly generates journeys in the other direction. -### Comfortable Living Temperatures +## Comfortable Living Temperatures If a residential tile is too hot, people will not want to live there. Residential tiles have a critical temperature at which the chance of someone moving into a tile becomes negative, becoming a chance that someone moves out. @@ -148,7 +157,7 @@ When someone moves out, one of the jobs associated with that residential tile is # Not critical -### Wealth +## Wealth Journeys generate a new integer tile resource, wealth. When a journey is completed, the destination tile accrues 1 wealth. diff --git a/half-earth/materials/cursor.tres b/half-earth/materials/cursor.tres index 91a714d..7cc3f5c 100644 --- a/half-earth/materials/cursor.tres +++ b/half-earth/materials/cursor.tres @@ -4,6 +4,6 @@ [resource] shader = ExtResource( 1 ) -shader_param/lowColor = Color( 1, 0.960784, 0, 1 ) -shader_param/highColor = Color( 0.921569, 0, 1, 1 ) +shader_param/lowColor = Color( 0, 0, 0, 0 ) +shader_param/highColor = Color( 0, 0.976471, 1, 1 ) shader_param/t = null diff --git a/half-earth/nodes/debug_ui.tscn b/half-earth/nodes/debug_ui.tscn deleted file mode 100644 index 4f2ab7f..0000000 --- a/half-earth/nodes/debug_ui.tscn +++ /dev/null @@ -1,36 +0,0 @@ -[gd_scene load_steps=2 format=2] - -[ext_resource path="res://scripts/DebugUI.cs" type="Script" id=1] - -[node name="Debug UI" type="Control"] -anchor_right = 1.0 -anchor_bottom = 1.0 -script = ExtResource( 1 ) -TicksLabelPath = NodePath("Ticks") -PauseLabelPath = NodePath("Paused") - -[node name="Ticks" type="Label" parent="."] -anchor_left = 1.0 -anchor_top = 1.0 -anchor_right = 1.0 -anchor_bottom = 1.0 -margin_right = -10.0 -margin_bottom = -30.0 -grow_horizontal = 0 -grow_vertical = 0 -text = "ticks: 0" -align = 2 -valign = 2 - -[node name="Paused" type="Label" parent="."] -anchor_left = 1.0 -anchor_top = 1.0 -anchor_right = 1.0 -anchor_bottom = 1.0 -margin_right = -10.0 -margin_bottom = -10.0 -grow_horizontal = 0 -grow_vertical = 0 -text = "pause: false" -align = 2 -valign = 2 diff --git a/half-earth/nodes/game.tscn b/half-earth/nodes/game.tscn index 9b75583..40b7b54 100644 --- a/half-earth/nodes/game.tscn +++ b/half-earth/nodes/game.tscn @@ -1,23 +1,59 @@ -[gd_scene load_steps=5 format=2] +[gd_scene load_steps=11 format=2] [ext_resource path="res://nodes/grid.tscn" type="PackedScene" id=1] [ext_resource path="res://nodes/grid_cursor.tscn" type="PackedScene" id=2] -[ext_resource path="res://nodes/debug_ui.tscn" type="PackedScene" id=3] +[ext_resource path="res://nodes/ui/debug_ui.tscn" type="PackedScene" id=3] [ext_resource path="res://nodes/clock.tscn" type="PackedScene" id=4] +[ext_resource path="res://nodes/interaction_modes/interaction_mode.tscn" type="PackedScene" id=5] +[ext_resource path="res://nodes/ui/build_mode_ui.tscn" type="PackedScene" id=6] +[ext_resource path="res://nodes/interaction_modes/build_mode.tscn" type="PackedScene" id=7] +[ext_resource path="res://resources/tile_types/wild.tres" type="Resource" id=8] +[ext_resource path="res://nodes/ui/mode_selection_ui.tscn" type="PackedScene" id=9] + +[sub_resource type="Curve" id=1] +_data = [ Vector2( 0, 0 ), 0.0, 5.0, 0, 0, Vector2( 0.5, 1 ), 0.0, 0.0, 0, 0, Vector2( 1, 0 ), -4.0, 0.0, 0, 0 ] [node name="Root" type="Node"] -[node name="Grid" parent="." instance=ExtResource( 1 )] -DiffusionCoefficient = 0.1 - -[node name="Cursor" parent="." instance=ExtResource( 2 )] -Grid = NodePath("../Grid") - -[node name="Debug UI" parent="." instance=ExtResource( 3 )] - [node name="Clock" parent="." instance=ExtResource( 4 )] _autoTick = true -[connection signal="OnPauseChanged" from="Clock" to="Debug UI" method="_on_Clock_OnPauseChanged"] +[node name="Grid" parent="." instance=ExtResource( 1 )] +DiffusionCoefficient = 0.1 +_startTileTypeResource = ExtResource( 8 ) + +[node name="Cursor" parent="." instance=ExtResource( 2 )] +Grid = NodePath("../Grid") +_pulseShape = SubResource( 1 ) + +[node name="Interaction Modes" parent="." instance=ExtResource( 5 )] +_buildModePath = NodePath("Build Mode") + +[node name="Build Mode" parent="Interaction Modes" instance=ExtResource( 7 )] +_gridPath = NodePath("../../Grid") +_cursorPath = NodePath("../../Cursor") + +[node name="UI" type="Control" parent="."] +anchor_right = 1.0 +anchor_bottom = 1.0 +mouse_filter = 2 + +[node name="Debug" parent="UI" instance=ExtResource( 3 )] + +[node name="Build Mode" parent="UI" instance=ExtResource( 6 )] +_buildModePath = NodePath("../../Interaction Modes/Build Mode") + +[node name="Mode Selection" parent="UI" instance=ExtResource( 9 )] + +[connection signal="OnPauseChanged" from="Clock" to="UI/Debug" method="_on_Clock_OnPauseChanged"] [connection signal="OnTick" from="Clock" to="Grid" method="_on_Clock_OnTick"] -[connection signal="OnTick" from="Clock" to="Debug UI" method="_on_Clock_OnTick"] +[connection signal="OnTick" from="Clock" to="UI/Debug" method="_on_Clock_OnTick"] +[connection signal="OnInteractionModeChanged" from="Interaction Modes" to="Cursor" method="_on_Interaction_Mode_OnInteractionModeChanged"] +[connection signal="OnInteractionModeChanged" from="Interaction Modes" to="UI/Debug" method="_on_Interaction_Mode_OnInteractionModeChanged"] +[connection signal="OnModeEntered" from="Interaction Modes/Build Mode" to="Interaction Modes" method="_on_Build_Mode_OnModeEntered"] +[connection signal="OnModeEntered" from="Interaction Modes/Build Mode" to="UI/Mode Selection" method="EnableBuildMode"] +[connection signal="OnModeExited" from="Interaction Modes/Build Mode" to="Interaction Modes" method="_on_Build_Mode_OnModeExited"] +[connection signal="SelectedTileTypeChanged" from="Interaction Modes/Build Mode" to="UI/Build Mode" method="UpdateButtonToggleState"] +[connection signal="OnExit" from="UI/Build Mode" to="Interaction Modes" method="Reset"] +[connection signal="OnExit" from="UI/Build Mode" to="UI/Mode Selection" method="Enable"] +[connection signal="BuildModeEnabled" from="UI/Mode Selection" to="Interaction Modes/Build Mode" method="Enable"] diff --git a/half-earth/nodes/interaction_modes/build_mode.tscn b/half-earth/nodes/interaction_modes/build_mode.tscn new file mode 100644 index 0000000..4c2ca0e --- /dev/null +++ b/half-earth/nodes/interaction_modes/build_mode.tscn @@ -0,0 +1,9 @@ +[gd_scene load_steps=3 format=2] + +[ext_resource path="res://scripts/interaction_modes/BuildMode.cs" type="Script" id=1] +[ext_resource path="res://resources/tile_types/tile_type_collections/buildable_tiles.tres" type="Resource" id=2] + +[node name="Build Mode" type="Node"] +script = ExtResource( 1 ) +_key = 66 +_buildableTilesResource = ExtResource( 2 ) diff --git a/half-earth/nodes/interaction_modes/interaction_mode.tscn b/half-earth/nodes/interaction_modes/interaction_mode.tscn new file mode 100644 index 0000000..c5caa48 --- /dev/null +++ b/half-earth/nodes/interaction_modes/interaction_mode.tscn @@ -0,0 +1,6 @@ +[gd_scene load_steps=2 format=2] + +[ext_resource path="res://scripts/interaction_modes/InteractionModes.cs" type="Script" id=1] + +[node name="Interaction Mode" type="Node"] +script = ExtResource( 1 ) diff --git a/half-earth/nodes/interaction_modes/selection_mode.tscn b/half-earth/nodes/interaction_modes/selection_mode.tscn new file mode 100644 index 0000000..4e80ec9 --- /dev/null +++ b/half-earth/nodes/interaction_modes/selection_mode.tscn @@ -0,0 +1,3 @@ +[gd_scene format=2] + +[node name="Selection Mode" type="Node"] diff --git a/half-earth/nodes/ui/build_mode_ui.tscn b/half-earth/nodes/ui/build_mode_ui.tscn new file mode 100644 index 0000000..2350c06 --- /dev/null +++ b/half-earth/nodes/ui/build_mode_ui.tscn @@ -0,0 +1,18 @@ +[gd_scene load_steps=2 format=2] + +[ext_resource path="res://scripts/ui/BuildModeUI.cs" type="Script" id=1] + +[node name="Build Mode" type="Control"] +anchor_right = 1.0 +anchor_bottom = 1.0 +script = ExtResource( 1 ) + +[node name="Exit" type="Button" parent="."] +anchor_top = 1.0 +anchor_bottom = 1.0 +margin_top = -40.0 +margin_right = 40.0 +grow_vertical = 0 +text = "Exit" + +[connection signal="pressed" from="Exit" to="." method="Exit"] diff --git a/half-earth/nodes/ui/debug_ui.tscn b/half-earth/nodes/ui/debug_ui.tscn new file mode 100644 index 0000000..6542174 --- /dev/null +++ b/half-earth/nodes/ui/debug_ui.tscn @@ -0,0 +1,48 @@ +[gd_scene load_steps=2 format=2] + +[ext_resource path="res://scripts/ui/DebugUI.cs" type="Script" id=1] + +[node name="Debug UI" type="Control"] +anchor_left = 1.0 +anchor_right = 1.0 +mouse_filter = 2 +script = ExtResource( 1 ) +TicksLabelPath = NodePath("Ticks") +PauseLabelPath = NodePath("Paused") +InteractionModeLabelPath = NodePath("Interaction Mode") + +[node name="Interaction Mode" type="Label" parent="."] +anchor_left = 1.0 +anchor_right = 1.0 +margin_left = -102.0 +margin_top = 15.0 +margin_right = -14.0 +margin_bottom = 29.0 +grow_horizontal = 0 +grow_vertical = 0 +text = "mode: Selection" +align = 2 + +[node name="Ticks" type="Label" parent="."] +anchor_left = 1.0 +anchor_right = 1.0 +margin_left = -60.0 +margin_top = 35.0 +margin_right = -14.0 +margin_bottom = 49.0 +grow_horizontal = 0 +grow_vertical = 0 +text = "ticks: 0" +align = 2 + +[node name="Paused" type="Label" parent="."] +anchor_left = 1.0 +anchor_right = 1.0 +margin_left = -90.0 +margin_top = 55.0 +margin_right = -14.0 +margin_bottom = 69.0 +grow_horizontal = 0 +grow_vertical = 0 +text = "pause: false" +align = 2 diff --git a/half-earth/nodes/ui/mode_selection_ui.tscn b/half-earth/nodes/ui/mode_selection_ui.tscn new file mode 100644 index 0000000..1916be8 --- /dev/null +++ b/half-earth/nodes/ui/mode_selection_ui.tscn @@ -0,0 +1,19 @@ +[gd_scene load_steps=2 format=2] + +[ext_resource path="res://scripts/ui/ModeSelectionUI.cs" type="Script" id=1] + +[node name="Mode Selection UI" type="Control"] +anchor_top = 1.0 +anchor_bottom = 1.0 +margin_top = -600.0 +margin_bottom = -600.0 +script = ExtResource( 1 ) + +[node name="Build Mode" type="Button" parent="."] +margin_left = 2.0 +margin_top = 562.0 +margin_right = 38.0 +margin_bottom = 598.0 +text = "Build Mode" + +[connection signal="pressed" from="Build Mode" to="." method="EnableBuildMode"] diff --git a/half-earth/resources/tile_types/developed.tres b/half-earth/resources/tile_types/developed.tres new file mode 100644 index 0000000..011fa7b --- /dev/null +++ b/half-earth/resources/tile_types/developed.tres @@ -0,0 +1,10 @@ +[gd_resource type="Resource" load_steps=2 format=2] + +[ext_resource path="res://scripts/TileType.cs" type="Script" id=1] + +[resource] +script = ExtResource( 1 ) +Name = "Developed" +BuildLabel = "[D]eveloped" +Key = 68 +Color = Color( 0.372549, 0.372549, 0.372549, 1 ) diff --git a/half-earth/resources/tile_types/tile_type_collections/buildable_tiles.tres b/half-earth/resources/tile_types/tile_type_collections/buildable_tiles.tres new file mode 100644 index 0000000..0491e19 --- /dev/null +++ b/half-earth/resources/tile_types/tile_type_collections/buildable_tiles.tres @@ -0,0 +1,8 @@ +[gd_resource type="Resource" load_steps=3 format=2] + +[ext_resource path="res://scripts/TileTypeCollection.cs" type="Script" id=1] +[ext_resource path="res://resources/tile_types/developed.tres" type="Resource" id=2] + +[resource] +script = ExtResource( 1 ) +_tileTypeResources = [ ExtResource( 2 ) ] diff --git a/half-earth/resources/tile_types/wild.tres b/half-earth/resources/tile_types/wild.tres new file mode 100644 index 0000000..16ebc36 --- /dev/null +++ b/half-earth/resources/tile_types/wild.tres @@ -0,0 +1,10 @@ +[gd_resource type="Resource" load_steps=2 format=2] + +[ext_resource path="res://scripts/TileType.cs" type="Script" id=1] + +[resource] +script = ExtResource( 1 ) +Name = "Wild" +BuildLabel = "[W]ild" +Key = 87 +Color = Color( 0, 0.545098, 0.0196078, 1 ) diff --git a/half-earth/scripts/DebugUI.cs b/half-earth/scripts/DebugUI.cs deleted file mode 100644 index 8adc836..0000000 --- a/half-earth/scripts/DebugUI.cs +++ /dev/null @@ -1,37 +0,0 @@ -using Godot; -using System; - -public class DebugUI : Control -{ - [Export] - public NodePath TicksLabelPath { private get; set; } - private Label _ticksLabel; - - [Export] - public NodePath PauseLabelPath { private get; set; } - private Label _pauseLabel; - - public override void _Ready() - { - _ticksLabel = GetNode