blob: 70ff3f5be0a42dd261d046af33d1dbbfa7491a96 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
|
extends TextureButton
@export var texture: Texture2D
@export var sprite_sheet: SpriteFrames
@export var cost := 5
@export var hp := 5
@export var speed := 100
@export var unit_resource: UnitResource
func _ready():
tooltip_text = "Cost: " + str(cost)
func _on_pressed() -> void:
var unit = preload("res://Units/Unit.tscn").instantiate() as Unit
#if texture:
#unit.get_node("Sprite2D").texture = texture
#unit.get_node("Sprite2D").scale = Vector2(32,32) / texture.get_size()
#if sprite_sheet:
#unit.get_node("AnimatedSprite2D").sprite_frames = sprite_sheet
unit.unit_resource = unit_resource
#unit.hp = hp
#unit.base_speed = speed
#unit.additional_data = {"cost": cost}
Client.spawn_unit(unit, Client.current_stage.get_spawn(), Client.current_stage.get_overwrite_target())
|