diff --git a/BuildingLevel.gd b/BuildingLevel.gd index 6eb6ed1..5b13dec 100644 --- a/BuildingLevel.gd +++ b/BuildingLevel.gd @@ -7,9 +7,53 @@ extends TileMapLayer var building_data = {} var last_tile var last_text +var rand = 0 const NAME_ICON = preload("res://NameIcon.tscn") +var building_to_tile_map = { + "tents": { + "source": 8, + "atlas": 0 + }, + "quarter": { + "source": 8, + "atlas": 1 + }, + "house": { + "source": 8, + "atlas": 2 + }, + "essencecompressor": { + "source": 8, + "atlas": 2 + }, + "woodcutter": { + "source": 8, + "atlas": 2 + }, + "stoneminer": { + "source": 8, + "atlas": 2 + }, + "foodgathering": { + "source": 7, + "atlas": 2 + }, + "foodprocessing": { + "source": 7, + "atlas": 3 + }, + "waterprocessor": { + "source": 7, + "atlas": 1 + }, + "waterpump": { + "source": 7, + "atlas": 0 + } +} + func _process(delta: float) -> void: var tile = local_to_map(get_global_mouse_position()) var building_mode = Persister.get_value("building_mode") @@ -22,6 +66,8 @@ func _process(delta: float) -> void: if last_text and is_instance_valid(last_text) and last_text.selected: last_text._deselect() + rand = randi_range(0, 1) + if not Persister.get_value("building_mode"): if rock_spots.has(tile): last_text = NAME_ICON.instantiate() @@ -45,7 +91,8 @@ func _process(delta: float) -> void: return if building_spots.has(tile) and not rock_spots.has(tile) and not tree_spots.has(tile): - set_cell(tile, 0, Vector2i(0,0), 0) + var build_data = building_to_tile_map[Persister.get_value("building_key")] + set_cell(tile, build_data["source"], Vector2i(build_data["atlas"],rand), 0) diff --git a/Main.tscn b/Main.tscn index 5ced615..ada8771 100644 --- a/Main.tscn +++ b/Main.tscn @@ -552,7 +552,6 @@ visible = false pivot_offset = Vector2(114, 128) [node name="BuildingMenu" parent="CanvasLayer" instance=ExtResource("7_hnxcf")] -visible = false [node name="Night" parent="CanvasLayer" instance=ExtResource("13_8fvl0")] modulate = Color(1, 1, 1, 0) diff --git a/TIleSet.tres b/TIleSet.tres index 08b3b92..7f485ec 100644 --- a/TIleSet.tres +++ b/TIleSet.tres @@ -1,4 +1,4 @@ -[gd_resource type="TileSet" load_steps=15 format=3 uid="uid://dhy53lakrlutm"] +[gd_resource type="TileSet" load_steps=19 format=3 uid="uid://dhy53lakrlutm"] [ext_resource type="Texture2D" uid="uid://bvn5lewpp7pmd" path="res://iso_tile.png" id="1_sa4j6"] [ext_resource type="Texture2D" uid="uid://bsrh0u02bckhy" path="res://iso_building.png" id="2_bubm3"] @@ -7,6 +7,8 @@ [ext_resource type="Texture2D" uid="uid://cjfpd778ggjer" path="res://select.png" id="5_s3lj1"] [ext_resource type="Texture2D" uid="uid://cvn1fg4v6kur3" path="res://tilerocks.png" id="6_f8tld"] [ext_resource type="Texture2D" uid="uid://c43udkovhiiv8" path="res://tiletrees.png" id="7_grd50"] +[ext_resource type="Texture2D" uid="uid://bmxo8xwxghc1k" path="res://tiles_foodwater.png" id="8_tscyy"] +[ext_resource type="Texture2D" uid="uid://cgpbrsl2nlhlr" path="res://tiles_houses.png" id="9_dx80t"] [sub_resource type="TileSetAtlasSource" id="TileSetAtlasSource_dxrqb"] texture = ExtResource("1_sa4j6") @@ -111,6 +113,40 @@ texture = ExtResource("7_grd50") 2:0/0 = 0 2:0/0/texture_origin = Vector2i(0, 3) +[sub_resource type="TileSetAtlasSource" id="TileSetAtlasSource_w46yf"] +texture = ExtResource("8_tscyy") +0:0/0 = 0 +0:0/0/texture_origin = Vector2i(0, 4) +0:1/0 = 0 +0:1/0/texture_origin = Vector2i(0, 4) +1:1/0 = 0 +1:1/0/texture_origin = Vector2i(0, 4) +2:1/0 = 0 +2:1/0/texture_origin = Vector2i(0, 4) +3:1/0 = 0 +3:1/0/texture_origin = Vector2i(0, 4) +3:0/0 = 0 +3:0/0/texture_origin = Vector2i(0, 4) +2:0/0 = 0 +2:0/0/texture_origin = Vector2i(0, 4) +1:0/0 = 0 +1:0/0/texture_origin = Vector2i(0, 4) + +[sub_resource type="TileSetAtlasSource" id="TileSetAtlasSource_7cbry"] +texture = ExtResource("9_dx80t") +0:0/0 = 0 +0:0/0/texture_origin = Vector2i(0, 4) +0:1/0 = 0 +0:1/0/texture_origin = Vector2i(0, 4) +1:1/0 = 0 +1:1/0/texture_origin = Vector2i(0, 4) +2:1/0 = 0 +2:1/0/texture_origin = Vector2i(0, 4) +2:0/0 = 0 +2:0/0/texture_origin = Vector2i(0, 4) +1:0/0 = 0 +1:0/0/texture_origin = Vector2i(0, 4) + [resource] tile_shape = 1 tile_layout = 5 @@ -122,3 +158,5 @@ sources/3 = SubResource("TileSetAtlasSource_5o051") sources/4 = SubResource("TileSetAtlasSource_sneuq") sources/5 = SubResource("TileSetAtlasSource_l16yl") sources/6 = SubResource("TileSetAtlasSource_ffqbc") +sources/7 = SubResource("TileSetAtlasSource_w46yf") +sources/8 = SubResource("TileSetAtlasSource_7cbry")