diff options
Diffstat (limited to 'Units')
-rw-r--r-- | Units/Unit.gd | 12 | ||||
-rw-r--r-- | Units/Unit.tscn | 3 |
2 files changed, 11 insertions, 4 deletions
diff --git a/Units/Unit.gd b/Units/Unit.gd index 551e13f..ea64c26 100644 --- a/Units/Unit.gd +++ b/Units/Unit.gd @@ -66,7 +66,13 @@ var roaming_mode = false @onready var sprite: Sprite2D = $Sprite2D +func _init(): + scale = Vector2(Client.current_stage.map.tile_set.tile_size) / Vector2(16, 16) + + func _ready(): + base_speed *= scale.x + if not target: if target_path: target = get_node(target_path) @@ -138,7 +144,7 @@ func _physics_process(delta): func _draw(): if is_selected: draw_circle( - Vector2.ZERO, + $Sprite2D.position, Client.current_stage.map.tile_set.tile_size.x * 0.75, Color(1, 1, 1, 0.75), false, @@ -147,7 +153,7 @@ func _draw(): modulate = Color(1.5, 1.5, 1.5) elif is_hovered: draw_circle( - Vector2.ZERO, + $Sprite2D.position, Client.current_stage.map.tile_set.tile_size.x * 0.75, Color(1, 1, 1, 0.5), false, @@ -173,7 +179,7 @@ func _on_navigation_base_area_entered(area: Area2D): func walk_along_path(path: PackedVector2Array, index: int, delta: float): immediate_target = path[index] - var displacement := immediate_target - global_position + var displacement: Vector2 = immediate_target - global_position var direction := displacement.normalized() var distance := displacement.length() diff --git a/Units/Unit.tscn b/Units/Unit.tscn index 7e6acbc..00c0871 100644 --- a/Units/Unit.tscn +++ b/Units/Unit.tscn @@ -32,13 +32,13 @@ properties/4/spawn = true properties/4/replication_mode = 2 [node name="Unit" type="CharacterBody2D"] -y_sort_enabled = true collision_mask = 4 input_pickable = true script = ExtResource("1_bbcew") [node name="Sprite2D" type="Sprite2D" parent="."] texture_filter = 1 +position = Vector2(0, -4) scale = Vector2(0.5, 0.5) texture = ExtResource("2_rxqq1") region_rect = Rect2(480, 880, 96, 64) @@ -70,6 +70,7 @@ text = "1000" horizontal_alignment = 1 [node name="SelectionArea" type="Area2D" parent="."] +visible = false collision_layer = 32 collision_mask = 0 |