diff --git a/half-earth/nodes/game.tscn b/half-earth/nodes/game.tscn index 4a42a0a..40b7b54 100644 --- a/half-earth/nodes/game.tscn +++ b/half-earth/nodes/game.tscn @@ -1,4 +1,4 @@ -[gd_scene load_steps=10 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] @@ -7,6 +7,7 @@ [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] @@ -19,6 +20,7 @@ _autoTick = true [node name="Grid" parent="." instance=ExtResource( 1 )] DiffusionCoefficient = 0.1 +_startTileTypeResource = ExtResource( 8 ) [node name="Cursor" parent="." instance=ExtResource( 2 )] Grid = NodePath("../Grid") 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/WorldGrid.cs b/half-earth/scripts/WorldGrid.cs index af72010..661b202 100644 --- a/half-earth/scripts/WorldGrid.cs +++ b/half-earth/scripts/WorldGrid.cs @@ -6,6 +6,10 @@ public class WorldGrid : Node2D [Export] private PackedScene TileScene { get; set; } + [Export] + private Resource _startTileTypeResource; + private TileType _startTileType; + [Export] public int Size { get; set; } @@ -21,6 +25,8 @@ public class WorldGrid : Node2D // Called when the node enters the scene tree for the first time. public override void _Ready() { + _startTileType = (TileType)_startTileTypeResource; + GenerateGrid(Size); } @@ -95,6 +101,7 @@ public class WorldGrid : Node2D var tile = new Tile(); tile.isHighlighted = false; tile.value = 0.0f; + tile.type = _startTileType; var node = TileScene.Instance(); this.AddChild(node); @@ -106,6 +113,7 @@ public class WorldGrid : Node2D node.Position = position; var canvasItem = (CanvasItem)node; tile.material = (ShaderMaterial)canvasItem.Material; + tile.material.SetShaderParam("lowColor", _startTileType.Color); _tiles[x, y] = tile; }