diff --git a/BuildingLevel.gd b/BuildingLevel.gd index 15b8228..6eb6ed1 100644 --- a/BuildingLevel.gd +++ b/BuildingLevel.gd @@ -1,28 +1,58 @@ extends TileMapLayer @export var building_spots: Array[Vector2i] +@export var tree_spots: Array[Vector2i] +@export var rock_spots: Array[Vector2i] var building_data = {} +var last_tile +var last_text +const NAME_ICON = preload("res://NameIcon.tscn") func _process(delta: float) -> void: var tile = local_to_map(get_global_mouse_position()) var building_mode = Persister.get_value("building_mode") for spot in building_spots: - if not building_data.has(spot): + if not building_data.has(spot) and not tree_spots.has(spot) and not rock_spots.has(spot): erase_cell(spot) + if last_tile != tile: + if last_text and is_instance_valid(last_text) and last_text.selected: + last_text._deselect() + + if not Persister.get_value("building_mode"): + if rock_spots.has(tile): + last_text = NAME_ICON.instantiate() + last_text.text = "[center]Rock" + last_text.position = map_to_local(tile) + Vector2(-25, -10) + add_sibling(last_text) + elif tree_spots.has(tile): + last_text = NAME_ICON.instantiate() + last_text.text = "[center]Tree" + last_text.position = map_to_local(tile) + Vector2(-25, -10) + add_sibling(last_text) + elif building_data.has(tile): + last_text = NAME_ICON.instantiate() + last_text.text = "[center]%s" % [Data.data.buildings[building_data[tile].key].name] + last_text.position = map_to_local(tile) + Vector2(-25, -10) + add_sibling(last_text) + + last_tile = tile + if not building_mode: return - if building_spots.has(tile): + 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) + + func place_building(): var tile = local_to_map(get_global_mouse_position()) - if building_spots.has(tile): + if building_spots.has(tile) and not building_data.has(tile) and not tree_spots.has(tile) and not rock_spots.has(tile): Persister.persist_data("building_mode", false) building_data[tile] = { "key": Persister.get_value("building_key"), diff --git a/Main.tscn b/Main.tscn index 96ff527..72daa4a 100644 --- a/Main.tscn +++ b/Main.tscn @@ -93,9 +93,12 @@ tile_set = ExtResource("2_68wnv") [node name="BuildingLevel2" type="TileMapLayer" parent="Node2D/Level2"] y_sort_enabled = true +tile_map_data = PackedByteArray("AAAmAAQABQAAAAEAAAAqAAQABQAAAAAAAAApAAAABgABAAAAAAApAPz/BgAAAAEAAAAhAAMABQAAAAAAAAAiAAEABgAAAAAAAAA=") 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)]) +tree_spots = Array[Vector2i]([Vector2i(34, 1), Vector2i(41, 0), Vector2i(41, -4)]) +rock_spots = Array[Vector2i]([Vector2i(33, 3), Vector2i(38, 4), Vector2i(42, 4)]) [node name="UILevel2" type="TileMapLayer" parent="Node2D/Level2"] y_sort_enabled = true @@ -117,9 +120,12 @@ tile_set = ExtResource("2_68wnv") [node name="BuildingLevel3" type="TileMapLayer" parent="Node2D/Level3"] y_sort_enabled = true +tile_map_data = PackedByteArray("AAAnAPr/BgABAAEAAAAmAPv/BgACAAAAAAAnAPv/BgAAAAAAAAAkAPz/BgAAAAEAAAAlAAAABgACAAEAAAAnAP//BQABAAAAAAAlAAEABQABAAEAAAA=") tile_set = ExtResource("2_68wnv") script = ExtResource("5_3vufn") building_spots = Array[Vector2i]([Vector2i(37, 1), Vector2i(37, 0), Vector2i(38, 1), Vector2i(38, 0), Vector2i(36, -3), Vector2i(36, -4), Vector2i(37, -2), Vector2i(37, -3), Vector2i(37, -4), Vector2i(38, -1), Vector2i(38, -2), Vector2i(38, -3), Vector2i(38, -4), Vector2i(38, -5), Vector2i(39, -2), Vector2i(39, -1), Vector2i(39, -3), Vector2i(39, -4), Vector2i(39, -5), Vector2i(39, -6), Vector2i(40, -3), Vector2i(40, -4)]) +tree_spots = Array[Vector2i]([Vector2i(37, 0), Vector2i(36, -4), Vector2i(38, -5), Vector2i(39, -5), Vector2i(39, -6)]) +rock_spots = Array[Vector2i]([Vector2i(37, 1), Vector2i(39, -1)]) [node name="UILevel3" type="TileMapLayer" parent="Node2D/Level3"] y_sort_enabled = true @@ -141,9 +147,11 @@ tile_set = ExtResource("2_68wnv") [node name="BuildingLevel4" type="TileMapLayer" parent="Node2D/Level4"] y_sort_enabled = true +tile_map_data = PackedByteArray("AAAfAP3/BQACAAAAAAAlAPn/BQACAAEAAAAjAP7/BQACAAEAAAAfAAAABQACAAEAAAAhAPz/BQACAAAAAAA=") tile_set = ExtResource("2_68wnv") script = ExtResource("5_3vufn") building_spots = Array[Vector2i]([Vector2i(31, -3), Vector2i(31, -2), Vector2i(31, -1), Vector2i(31, 0), Vector2i(32, -2), Vector2i(32, -3), Vector2i(32, -4), Vector2i(33, -3), Vector2i(33, -4), Vector2i(33, -5), Vector2i(33, -2), Vector2i(33, -1), Vector2i(34, -2), Vector2i(34, -3), Vector2i(34, -1), Vector2i(34, -4), Vector2i(34, -5), Vector2i(35, -6), Vector2i(35, -3), Vector2i(35, -2), Vector2i(35, -1), Vector2i(35, 0), Vector2i(36, -2), Vector2i(36, -6), Vector2i(36, -7), Vector2i(37, -7)]) +rock_spots = Array[Vector2i]([Vector2i(31, 0), Vector2i(31, -3), Vector2i(33, -4), Vector2i(35, -2), Vector2i(37, -7)]) [node name="UILevel4" type="TileMapLayer" parent="Node2D/Level4"] y_sort_enabled = true @@ -165,9 +173,11 @@ tile_set = ExtResource("2_68wnv") [node name="BuildingLevel5" type="TileMapLayer" parent="Node2D/Level5"] y_sort_enabled = true +tile_map_data = PackedByteArray("AAAgAPj/BQAEAAAAAAAfAPn/BQAEAAEAAAA=") tile_set = ExtResource("2_68wnv") script = ExtResource("5_3vufn") building_spots = Array[Vector2i]([Vector2i(30, -6), Vector2i(30, -5), Vector2i(31, -6), Vector2i(31, -7), Vector2i(32, -7), Vector2i(32, -8), Vector2i(33, -7), Vector2i(33, -8), Vector2i(34, -8)]) +rock_spots = Array[Vector2i]([Vector2i(31, -7), Vector2i(32, -8)]) [node name="UILevel5" type="TileMapLayer" parent="Node2D/Level5"] y_sort_enabled = true diff --git a/NameIcon.tscn b/NameIcon.tscn new file mode 100644 index 0000000..5aabe66 --- /dev/null +++ b/NameIcon.tscn @@ -0,0 +1,18 @@ +[gd_scene load_steps=3 format=3 uid="uid://vlp1qstcv4no"] + +[ext_resource type="Theme" uid="uid://d035h7upxrw3h" path="res://theme.tres" id="1_yw1uq"] +[ext_resource type="Script" path="res://name_icon.gd" id="2_tyt57"] + +[node name="NameIcon" type="RichTextLabel"] +z_index = 10 +clip_contents = false +offset_left = 280.0 +offset_top = 104.0 +offset_right = 332.0 +offset_bottom = 121.0 +pivot_offset = Vector2(25, 4) +theme = ExtResource("1_yw1uq") +theme_override_constants/outline_size = 3 +bbcode_enabled = true +text = "[center]Rock" +script = ExtResource("2_tyt57") diff --git a/TIleSet.tres b/TIleSet.tres index f9cbad4..08b3b92 100644 --- a/TIleSet.tres +++ b/TIleSet.tres @@ -1,10 +1,12 @@ -[gd_resource type="TileSet" load_steps=11 format=3 uid="uid://dhy53lakrlutm"] +[gd_resource type="TileSet" load_steps=15 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"] [ext_resource type="Texture2D" uid="uid://bdmao1k7ngu2m" path="res://basic_tiles.png" id="3_rchy6"] [ext_resource type="Texture2D" uid="uid://w1abxk1m0fae" path="res://tiles-v3.png" id="4_p6xw0"] [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"] [sub_resource type="TileSetAtlasSource" id="TileSetAtlasSource_dxrqb"] texture = ExtResource("1_sa4j6") @@ -71,6 +73,44 @@ texture = ExtResource("5_s3lj1") 0:0/0 = 0 0:0/0/texture_origin = Vector2i(0, 4) +[sub_resource type="TileSetAtlasSource" id="TileSetAtlasSource_l16yl"] +texture = ExtResource("6_f8tld") +0:0/0 = 0 +0:0/0/texture_origin = Vector2i(0, 3) +1:0/0 = 0 +1:0/0/texture_origin = Vector2i(0, 3) +2:0/0 = 0 +2:0/0/texture_origin = Vector2i(0, 3) +2:1/0 = 0 +2:1/0/texture_origin = Vector2i(0, 3) +3:1/0 = 0 +3:1/0/texture_origin = Vector2i(0, 3) +4:1/0 = 0 +4:1/0/texture_origin = Vector2i(0, 3) +1:1/0 = 0 +1:1/0/texture_origin = Vector2i(0, 3) +0:1/0 = 0 +0:1/0/texture_origin = Vector2i(0, 3) +3:0/0 = 0 +3:0/0/texture_origin = Vector2i(0, 3) +4:0/0 = 0 +4:0/0/texture_origin = Vector2i(0, 3) + +[sub_resource type="TileSetAtlasSource" id="TileSetAtlasSource_ffqbc"] +texture = ExtResource("7_grd50") +2:1/0 = 0 +2:1/0/texture_origin = Vector2i(0, 3) +1:1/0 = 0 +1:1/0/texture_origin = Vector2i(0, 3) +0:1/0 = 0 +0:1/0/texture_origin = Vector2i(0, 3) +0:0/0 = 0 +0:0/0/texture_origin = Vector2i(0, 3) +1:0/0 = 0 +1:0/0/texture_origin = Vector2i(0, 3) +2:0/0 = 0 +2:0/0/texture_origin = Vector2i(0, 3) + [resource] tile_shape = 1 tile_layout = 5 @@ -80,3 +120,5 @@ sources/1 = SubResource("TileSetAtlasSource_j7eew") sources/2 = SubResource("TileSetAtlasSource_w6tof") sources/3 = SubResource("TileSetAtlasSource_5o051") sources/4 = SubResource("TileSetAtlasSource_sneuq") +sources/5 = SubResource("TileSetAtlasSource_l16yl") +sources/6 = SubResource("TileSetAtlasSource_ffqbc") diff --git a/name_icon.gd b/name_icon.gd new file mode 100644 index 0000000..333c413 --- /dev/null +++ b/name_icon.gd @@ -0,0 +1,25 @@ +extends RichTextLabel + +var tween +var selected = true + +func _ready() -> void: + scale = Vector2.ZERO + tween = create_tween() + tween.set_ease(Tween.EASE_OUT) + tween.set_trans(Tween.TRANS_BACK) + tween.tween_property(self, "scale", Vector2.ONE, 0.25) + + +func _deselect() -> void: + selected = false + if tween: + tween.kill() + + tween = create_tween() + tween.set_ease(Tween.EASE_OUT) + tween.set_trans(Tween.TRANS_QUAD) + tween.tween_property(self, "scale", Vector2.ZERO, 0.25) + tween.tween_callback(func(): + queue_free() + ) diff --git a/tilerocks.png b/tilerocks.png new file mode 100644 index 0000000..82353e4 Binary files /dev/null and b/tilerocks.png differ diff --git a/tilerocks.png.import b/tilerocks.png.import new file mode 100644 index 0000000..f01027d --- /dev/null +++ b/tilerocks.png.import @@ -0,0 +1,34 @@ +[remap] + +importer="texture" +type="CompressedTexture2D" +uid="uid://cvn1fg4v6kur3" +path="res://.godot/imported/tilerocks.png-063e8153e6858a592ae59551c57b5a24.ctex" +metadata={ +"vram_texture": false +} + +[deps] + +source_file="res://tilerocks.png" +dest_files=["res://.godot/imported/tilerocks.png-063e8153e6858a592ae59551c57b5a24.ctex"] + +[params] + +compress/mode=0 +compress/high_quality=false +compress/lossy_quality=0.7 +compress/hdr_compression=1 +compress/normal_map=0 +compress/channel_pack=0 +mipmaps/generate=false +mipmaps/limit=-1 +roughness/mode=0 +roughness/src_normal="" +process/fix_alpha_border=true +process/premult_alpha=false +process/normal_map_invert_y=false +process/hdr_as_srgb=false +process/hdr_clamp_exposure=false +process/size_limit=0 +detect_3d/compress_to=1 diff --git a/tiletrees.png b/tiletrees.png new file mode 100644 index 0000000..1643c11 Binary files /dev/null and b/tiletrees.png differ diff --git a/tiletrees.png.import b/tiletrees.png.import new file mode 100644 index 0000000..bea4994 --- /dev/null +++ b/tiletrees.png.import @@ -0,0 +1,34 @@ +[remap] + +importer="texture" +type="CompressedTexture2D" +uid="uid://c43udkovhiiv8" +path="res://.godot/imported/tiletrees.png-e78363c62fac99f41ef751447bb5409b.ctex" +metadata={ +"vram_texture": false +} + +[deps] + +source_file="res://tiletrees.png" +dest_files=["res://.godot/imported/tiletrees.png-e78363c62fac99f41ef751447bb5409b.ctex"] + +[params] + +compress/mode=0 +compress/high_quality=false +compress/lossy_quality=0.7 +compress/hdr_compression=1 +compress/normal_map=0 +compress/channel_pack=0 +mipmaps/generate=false +mipmaps/limit=-1 +roughness/mode=0 +roughness/src_normal="" +process/fix_alpha_border=true +process/premult_alpha=false +process/normal_map_invert_y=false +process/hdr_as_srgb=false +process/hdr_clamp_exposure=false +process/size_limit=0 +detect_3d/compress_to=1