start all wild tiles #5

This commit is contained in:
Cat Flynn 2022-12-10 00:46:11 +00:00
parent a634da6ecf
commit 10a216b289
3 changed files with 21 additions and 1 deletions

View File

@ -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.tscn" type="PackedScene" id=1]
[ext_resource path="res://nodes/grid_cursor.tscn" type="PackedScene" id=2] [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/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/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://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] [ext_resource path="res://nodes/ui/mode_selection_ui.tscn" type="PackedScene" id=9]
[sub_resource type="Curve" id=1] [sub_resource type="Curve" id=1]
@ -19,6 +20,7 @@ _autoTick = true
[node name="Grid" parent="." instance=ExtResource( 1 )] [node name="Grid" parent="." instance=ExtResource( 1 )]
DiffusionCoefficient = 0.1 DiffusionCoefficient = 0.1
_startTileTypeResource = ExtResource( 8 )
[node name="Cursor" parent="." instance=ExtResource( 2 )] [node name="Cursor" parent="." instance=ExtResource( 2 )]
Grid = NodePath("../Grid") Grid = NodePath("../Grid")

View File

@ -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 )

View File

@ -6,6 +6,10 @@ public class WorldGrid : Node2D
[Export] [Export]
private PackedScene TileScene { get; set; } private PackedScene TileScene { get; set; }
[Export]
private Resource _startTileTypeResource;
private TileType _startTileType;
[Export] [Export]
public int Size { get; set; } 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. // Called when the node enters the scene tree for the first time.
public override void _Ready() public override void _Ready()
{ {
_startTileType = (TileType)_startTileTypeResource;
GenerateGrid(Size); GenerateGrid(Size);
} }
@ -95,6 +101,7 @@ public class WorldGrid : Node2D
var tile = new Tile(); var tile = new Tile();
tile.isHighlighted = false; tile.isHighlighted = false;
tile.value = 0.0f; tile.value = 0.0f;
tile.type = _startTileType;
var node = TileScene.Instance<Node2D>(); var node = TileScene.Instance<Node2D>();
this.AddChild(node); this.AddChild(node);
@ -106,6 +113,7 @@ public class WorldGrid : Node2D
node.Position = position; node.Position = position;
var canvasItem = (CanvasItem)node; var canvasItem = (CanvasItem)node;
tile.material = (ShaderMaterial)canvasItem.Material; tile.material = (ShaderMaterial)canvasItem.Material;
tile.material.SetShaderParam("lowColor", _startTileType.Color);
_tiles[x, y] = tile; _tiles[x, y] = tile;
} }