2048-Shooter/Objects/Entity.tscn
Yadciel 13394479bd SomeUpdate
Slots can update, other scaling
2022-11-28 12:58:12 +01:00

108 lines
3.1 KiB
Plaintext

[gd_scene load_steps=6 format=2]
[ext_resource path="res://enemy.png" type="Texture" id=1]
[ext_resource path="res://Font/super-legend-boy-font/SuperLegendBoy-4w8Y.ttf" type="DynamicFontData" id=2]
[sub_resource type="GDScript" id=1]
script/source = "extends KinematicBody2D
var pre_bullet_hit = preload(\"res://Objects/bullet_hit.tscn\")
var velocity = Vector2(0,1)
var speed = 50
var life = 2
var rng = RandomNumberGenerator.new()
signal on_Death
# Called when the node enters the scene tree for the first time.
func _ready():
rng.randomize()
var text = rng.randi_range(life/2, life)
life = text
$Label.text = (text) as String
if(life > 9):
pass
var Progressbars = get_tree().get_nodes_in_group(\"XP\")
for Progressbar in Progressbars:
self.connect(\"on_Death\",Progressbar, \"on_Death_listed\")
pass # Replace with function body.
func _physics_process(delta):
move_and_collide(velocity.normalized() * delta * speed)
pass
func _on_Area2D_area_entered(area):
if area.is_in_group(\"Bullet\"):
var Bullet = area.get_parent()
var text = $Label.text as int
var value = 1
var bullet_hit = pre_bullet_hit.instance()
var GameNode = find_parent(\"Game\")
if text >= Bullet.hit_power:
if text > Bullet.hit_power:
$Label.text = (text-Bullet.hit_power) as String
GameNode.add_child(bullet_hit)
bullet_hit.global_position = Bullet.global_position
bullet_hit.play()
Bullet.queue_free()
if text == Bullet.hit_power:
GameNode.add_child(bullet_hit)
bullet_hit.global_position = Bullet.global_position
bullet_hit.play()
emit_signal(\"on_Death\", value)
Bullet.queue_free()
queue_free()
else:
GameNode.add_child(bullet_hit)
bullet_hit.global_position = Bullet.global_position
bullet_hit.play()
Bullet.hit_power -= life
emit_signal(\"on_Death\", value)
queue_free()
if area.is_in_group(\"Border\"):
area.get_node(\"LifeBar\").value -= $Label.text as int
queue_free()
pass # Replace with function body.
"
[sub_resource type="RectangleShape2D" id=2]
extents = Vector2( 4, 4 )
[sub_resource type="DynamicFont" id=3]
size = 11
font_data = ExtResource( 2 )
[node name="Entity" type="KinematicBody2D" groups=["Enemy"]]
position = Vector2( 64, 64 )
scale = Vector2( 12, 12 )
script = SubResource( 1 )
[node name="Sprite" type="Sprite" parent="."]
texture = ExtResource( 1 )
[node name="CollisionShape2D" type="CollisionShape2D" parent="."]
scale = Vector2( 0.9, 0.9 )
shape = SubResource( 2 )
[node name="Area2D" type="Area2D" parent="."]
[node name="CollisionShape2D" type="CollisionShape2D" parent="Area2D"]
shape = SubResource( 2 )
[node name="Label" type="Label" parent="."]
margin_left = -3.33333
margin_top = -4.0
margin_right = 8.66667
margin_bottom = 10.0
grow_horizontal = 2
grow_vertical = 2
rect_min_size = Vector2( 8, 8 )
rect_scale = Vector2( 0.545, 0.639 )
custom_colors/font_color = Color( 1, 0, 0, 1 )
custom_colors/font_outline_modulate = Color( 0, 0, 0, 1 )
custom_colors/font_color_shadow = Color( 0, 0, 0, 1 )
custom_fonts/font = SubResource( 3 )
text = "1"
[connection signal="area_entered" from="Area2D" to="." method="_on_Area2D_area_entered"]