Add building deselection
This commit is contained in:
parent
5969b56b75
commit
098a43c452
4 changed files with 17 additions and 11 deletions
|
@ -9,14 +9,6 @@ func _process(delta: float) -> void:
|
||||||
var tile = local_to_map(get_global_mouse_position())
|
var tile = local_to_map(get_global_mouse_position())
|
||||||
var building_mode = Persister.get_value("building_mode")
|
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:
|
for spot in building_spots:
|
||||||
if not building_data.has(spot):
|
if not building_data.has(spot):
|
||||||
erase_cell(spot)
|
erase_cell(spot)
|
||||||
|
@ -25,7 +17,7 @@ func _process(delta: float) -> void:
|
||||||
return
|
return
|
||||||
|
|
||||||
if building_spots.has(tile):
|
if building_spots.has(tile):
|
||||||
set_cell(tile, 1, Vector2i(0,0), 0)
|
set_cell(tile, 0, Vector2i(0,0), 0)
|
||||||
|
|
||||||
|
|
||||||
func place_building():
|
func place_building():
|
||||||
|
|
|
@ -92,7 +92,7 @@ tile_set = ExtResource("2_68wnv")
|
||||||
|
|
||||||
[node name="BuildingLevel2" type="TileMapLayer" parent="Node2D/Level2"]
|
[node name="BuildingLevel2" type="TileMapLayer" parent="Node2D/Level2"]
|
||||||
y_sort_enabled = true
|
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")
|
tile_set = ExtResource("2_68wnv")
|
||||||
script = ExtResource("5_3vufn")
|
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)])
|
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)])
|
||||||
|
|
|
@ -8,8 +8,8 @@
|
||||||
[sub_resource type="TileSetAtlasSource" id="TileSetAtlasSource_dxrqb"]
|
[sub_resource type="TileSetAtlasSource" id="TileSetAtlasSource_dxrqb"]
|
||||||
texture = ExtResource("1_sa4j6")
|
texture = ExtResource("1_sa4j6")
|
||||||
margins = Vector2i(16, 16)
|
margins = Vector2i(16, 16)
|
||||||
1:1/0 = 0
|
|
||||||
0:0/0 = 0
|
0:0/0 = 0
|
||||||
|
0:0/0/texture_origin = Vector2i(0, 4)
|
||||||
|
|
||||||
[sub_resource type="TileSetAtlasSource" id="TileSetAtlasSource_j7eew"]
|
[sub_resource type="TileSetAtlasSource" id="TileSetAtlasSource_j7eew"]
|
||||||
texture = ExtResource("2_bubm3")
|
texture = ExtResource("2_bubm3")
|
||||||
|
|
14
main.gd
14
main.gd
|
@ -27,3 +27,17 @@ func _process(delta: float) -> void:
|
||||||
for build_level in building_levels:
|
for build_level in building_levels:
|
||||||
build_level.place_building()
|
build_level.place_building()
|
||||||
Persister.persist_data("building_mode", false)
|
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)
|
||||||
|
|
Loading…
Reference in a new issue