Refactored unit
This commit is contained in:
91
prefabs/deployed_unit.tscn
Normal file
91
prefabs/deployed_unit.tscn
Normal file
@@ -0,0 +1,91 @@
|
||||
[gd_scene format=3 uid="uid://b6a7nlnf58mc4"]
|
||||
|
||||
[ext_resource type="Script" uid="uid://cmh4lphvboggy" path="res://scripts/battle/deployed_units/deployed_unit.gd" id="1_cq4v0"]
|
||||
[ext_resource type="Texture2D" uid="uid://cw5su6lignryo" path="res://assets/sprites/flag.png" id="2_fhs1y"]
|
||||
[ext_resource type="Shader" uid="uid://bd8ki8xwym5nc" path="res://shaders/chroma_key.gdshader" id="3_fhs1y"]
|
||||
[ext_resource type="Texture2D" uid="uid://dyutp4m5d53gd" path="res://assets/sprites/CP002AA.BMP" id="3_on614"]
|
||||
|
||||
[sub_resource type="GDScript" id="GDScript_on614"]
|
||||
resource_name = "UnitSelectorHandler"
|
||||
script/source = "extends ColorRect
|
||||
|
||||
func _unit_selected_changed(_deployed: DeployedUnit, selected: bool) -> void:
|
||||
visible = selected
|
||||
"
|
||||
|
||||
[sub_resource type="GDScript" id="GDScript_fhs1y"]
|
||||
resource_name = "AllegianceIndicatorManager"
|
||||
script/source = "extends Sprite2D
|
||||
|
||||
|
||||
func _on_unit_unit_allegiance_changed(_deployed: DeployedUnit, allegiance: UnitAllegiance) -> void:
|
||||
self_modulate = allegiance.color
|
||||
"
|
||||
|
||||
[sub_resource type="ShaderMaterial" id="ShaderMaterial_fhs1y"]
|
||||
shader = ExtResource("3_fhs1y")
|
||||
shader_parameter/key_color = Color(0, 1, 0, 1)
|
||||
shader_parameter/threshold = 0.01
|
||||
|
||||
[sub_resource type="AtlasTexture" id="AtlasTexture_fhs1y"]
|
||||
atlas = ExtResource("3_on614")
|
||||
region = Rect2(0, 0, 40, 50)
|
||||
|
||||
[sub_resource type="AtlasTexture" id="AtlasTexture_4j20j"]
|
||||
atlas = ExtResource("3_on614")
|
||||
region = Rect2(40, 0, 40, 50)
|
||||
|
||||
[sub_resource type="AtlasTexture" id="AtlasTexture_v0xod"]
|
||||
atlas = ExtResource("3_on614")
|
||||
region = Rect2(0, 50, 40, 50)
|
||||
|
||||
[sub_resource type="AtlasTexture" id="AtlasTexture_50p1h"]
|
||||
atlas = ExtResource("3_on614")
|
||||
region = Rect2(40, 50, 40, 50)
|
||||
|
||||
[sub_resource type="SpriteFrames" id="SpriteFrames_7jqdg"]
|
||||
animations = [{
|
||||
"frames": [{
|
||||
"duration": 1.0,
|
||||
"texture": SubResource("AtlasTexture_fhs1y")
|
||||
}, {
|
||||
"duration": 1.0,
|
||||
"texture": SubResource("AtlasTexture_4j20j")
|
||||
}, {
|
||||
"duration": 1.0,
|
||||
"texture": SubResource("AtlasTexture_v0xod")
|
||||
}, {
|
||||
"duration": 1.0,
|
||||
"texture": SubResource("AtlasTexture_50p1h")
|
||||
}],
|
||||
"loop": true,
|
||||
"name": &"idle",
|
||||
"speed": 5.0
|
||||
}]
|
||||
|
||||
[node name="DeployedUnit" type="Node2D" unique_id=1893234933 groups=["deployed_units"]]
|
||||
script = ExtResource("1_cq4v0")
|
||||
metadata/_custom_type_script = "uid://cmh4lphvboggy"
|
||||
|
||||
[node name="SelectionIndicator" type="ColorRect" parent="." unique_id=1313394023]
|
||||
visible = false
|
||||
offset_right = 100.0
|
||||
offset_bottom = 100.0
|
||||
color = Color(1, 1, 0.3019608, 0.36078432)
|
||||
script = SubResource("GDScript_on614")
|
||||
|
||||
[node name="AllegianceIndicator" type="Sprite2D" parent="." unique_id=1567439632]
|
||||
z_index = 2
|
||||
texture = ExtResource("2_fhs1y")
|
||||
offset = Vector2(24, 24)
|
||||
script = SubResource("GDScript_fhs1y")
|
||||
|
||||
[node name="AnimatedSprite2D" type="AnimatedSprite2D" parent="." unique_id=1796991032]
|
||||
material = SubResource("ShaderMaterial_fhs1y")
|
||||
position = Vector2(50, 50)
|
||||
sprite_frames = SubResource("SpriteFrames_7jqdg")
|
||||
animation = &"idle"
|
||||
autoplay = "idle"
|
||||
|
||||
[connection signal="unit_allegiance_changed" from="." to="AllegianceIndicator" method="_on_unit_unit_allegiance_changed"]
|
||||
[connection signal="unit_selected_changed" from="." to="SelectionIndicator" method="_unit_selected_changed"]
|
||||
@@ -1,4 +1,4 @@
|
||||
[gd_scene format=3 uid="uid://b6a7nlnf58mc4"]
|
||||
[gd_scene format=3 uid="uid://dy0s7rfs4i64y"]
|
||||
|
||||
[ext_resource type="Script" uid="uid://c016mxgatcpse" path="res://scripts/units/unit.gd" id="1_cq4v0"]
|
||||
[ext_resource type="Texture2D" uid="uid://cw5su6lignryo" path="res://assets/sprites/flag.png" id="2_fhs1y"]
|
||||
@@ -86,6 +86,3 @@ position = Vector2(50, 50)
|
||||
sprite_frames = SubResource("SpriteFrames_7jqdg")
|
||||
animation = &"idle"
|
||||
autoplay = "idle"
|
||||
|
||||
[connection signal="unit_allegiance_changed" from="." to="AllegianceIndicator" method="_on_unit_unit_allegiance_changed"]
|
||||
[connection signal="unit_selected_changed" from="." to="SelectionIndicator" method="_unit_selected_changed"]
|
||||
|
||||
Reference in New Issue
Block a user