diff --git a/BuildingLevel.gd b/BuildingLevel.gd index 32ed5bc..15b8228 100644 --- a/BuildingLevel.gd +++ b/BuildingLevel.gd @@ -9,14 +9,6 @@ func _process(delta: float) -> void: var tile = local_to_map(get_global_mouse_position()) var building_mode = Persister.get_value("building_mode") - if Input.is_action_just_pressed("lclick"): - if building_mode: - place_building() - else: - show_info_building() - - - for spot in building_spots: if not building_data.has(spot): erase_cell(spot) @@ -25,7 +17,7 @@ func _process(delta: float) -> void: return if building_spots.has(tile): - set_cell(tile, 1, Vector2i(0,0), 0) + set_cell(tile, 0, Vector2i(0,0), 0) func place_building(): diff --git a/Main.tscn b/Main.tscn index 1a39630..a34299d 100644 --- a/Main.tscn +++ b/Main.tscn @@ -92,7 +92,7 @@ tile_set = ExtResource("2_68wnv") [node name="BuildingLevel2" type="TileMapLayer" parent="Node2D/Level2"] y_sort_enabled = true -tile_map_data = PackedByteArray("AAAlAP3/AQABAAEAAAAmAPz/AQABAAEAAAAmAP3/AQABAAEAAAA=") +tile_map_data = PackedByteArray("AAAlAP3/AQABAAEAAAAmAPz/AQABAAEAAAAmAP3/AQABAAEAAAAmAAAAAQABAAEAAAA=") tile_set = ExtResource("2_68wnv") script = ExtResource("5_3vufn") building_spots = Array[Vector2i]([Vector2i(33, 5), Vector2i(33, 4), Vector2i(33, 3), Vector2i(34, 4), Vector2i(34, 3), Vector2i(34, 2), Vector2i(34, 1), Vector2i(35, 3), Vector2i(35, 2), Vector2i(36, 3), Vector2i(36, 2), Vector2i(37, 3), Vector2i(38, 4), Vector2i(38, 3), Vector2i(39, 4), Vector2i(39, 3), Vector2i(39, 5), Vector2i(40, 5), Vector2i(40, 4), Vector2i(40, 3), Vector2i(40, 2), Vector2i(40, 1), Vector2i(41, 4), Vector2i(41, 3), Vector2i(41, 2), Vector2i(41, 1), Vector2i(41, 0), Vector2i(42, 4), Vector2i(42, 3), Vector2i(42, 2), Vector2i(42, 1), Vector2i(43, 2), Vector2i(43, 3), Vector2i(44, 3), Vector2i(41, -4), Vector2i(41, -5), Vector2i(42, -3), Vector2i(42, -4), Vector2i(42, -5), Vector2i(43, -5)]) diff --git a/TIleSet.tres b/TIleSet.tres index 56a2b55..ed25b33 100644 --- a/TIleSet.tres +++ b/TIleSet.tres @@ -8,8 +8,8 @@ [sub_resource type="TileSetAtlasSource" id="TileSetAtlasSource_dxrqb"] texture = ExtResource("1_sa4j6") margins = Vector2i(16, 16) -1:1/0 = 0 0:0/0 = 0 +0:0/0/texture_origin = Vector2i(0, 4) [sub_resource type="TileSetAtlasSource" id="TileSetAtlasSource_j7eew"] texture = ExtResource("2_bubm3") diff --git a/main.gd b/main.gd index 6cbb8d2..bb7b3f0 100644 --- a/main.gd +++ b/main.gd @@ -27,3 +27,17 @@ func _process(delta: float) -> void: for build_level in building_levels: build_level.place_building() Persister.persist_data("building_mode", false) + + var building_mode = Persister.get_value("building_mode") + + if Input.is_action_just_pressed("lclick") and not Persister.get_value("drag_mode"): + if building_mode: + for build_level in building_levels: + build_level.place_building() + else: + for build_level in building_levels: + build_level.show_info_building() + Persister.persist_data("building_mode", false) + + if Input.is_action_just_pressed("rclick"): + Persister.persist_data("building_mode", false)