mirror of
https://github.com/Yadciel1/2048-Shooter.git
synced 2024-11-08 23:21:22 +01:00
132 lines
3.2 KiB
Plaintext
132 lines
3.2 KiB
Plaintext
[gd_scene load_steps=6 format=2]
|
|
|
|
[ext_resource path="res://assets/Tank Town V2.png" type="Texture" id=1]
|
|
|
|
[sub_resource type="GDScript" id=1]
|
|
script/source = "extends Node2D
|
|
|
|
var Time = 0
|
|
const bulletPath = preload(\"res:///Objects/Bullet.tscn\")
|
|
var speed = 3
|
|
onready var old_slot = null
|
|
onready var GameNode
|
|
var PanzerType = 0
|
|
var hit_power = 2
|
|
|
|
func _ready():
|
|
GameNode = find_parent(\"Game\")
|
|
GameNode.connect(\"speed_shoot\", self, \"set_shoot_speed\")
|
|
pass
|
|
|
|
func _process(delta):
|
|
if get_parent().is_class(\"Panel\"):
|
|
old_slot = get_parent()
|
|
PanzerType(PanzerType)
|
|
Time += delta
|
|
if Time > speed and get_parent() != GameNode: #wenn er nicht gehoben wird dann:
|
|
shoot()
|
|
Time = 0
|
|
pass
|
|
|
|
func shoot():
|
|
$Shoot.visible = true
|
|
$Shoot/AnimationPlayer.play(\"Shoot\")
|
|
var bullet = bulletPath.instance()
|
|
bullet.hit_power = hit_power
|
|
find_parent(\"Game\").add_child(bullet)
|
|
bullet.position = $Position2D.global_position
|
|
|
|
func set_shoot_speed(value):
|
|
if speed != 0.5:
|
|
speed -= value
|
|
pass
|
|
|
|
func PanzerType(PanzerType):
|
|
if PanzerType == 1:
|
|
$Sprite.region_rect = Rect2(0, 64, 16, 16)
|
|
if PanzerType == 2:
|
|
$Sprite.region_rect = Rect2(0, 80, 16, 16)
|
|
if PanzerType == 3:
|
|
$Sprite.modulate = Color(0.875, 0, 1)
|
|
$Sprite.region_rect = Rect2(0, 80, 16, 16)
|
|
|
|
|
|
|
|
|
|
func _on_AnimationPlayer_shoot_finished(anim_name):
|
|
$Shoot.visible = false
|
|
pass # Replace with function body.
|
|
"
|
|
|
|
[sub_resource type="Animation" id=2]
|
|
length = 0.001
|
|
tracks/0/type = "value"
|
|
tracks/0/path = NodePath("Sprite:frame")
|
|
tracks/0/interp = 1
|
|
tracks/0/loop_wrap = true
|
|
tracks/0/imported = false
|
|
tracks/0/enabled = true
|
|
tracks/0/keys = {
|
|
"times": PoolRealArray( 0 ),
|
|
"transitions": PoolRealArray( 1 ),
|
|
"update": 0,
|
|
"values": [ 60 ]
|
|
}
|
|
|
|
[sub_resource type="Animation" id=3]
|
|
resource_name = "Shoot"
|
|
length = 0.6
|
|
tracks/0/type = "value"
|
|
tracks/0/path = NodePath("Sprite:frame")
|
|
tracks/0/interp = 1
|
|
tracks/0/loop_wrap = true
|
|
tracks/0/imported = false
|
|
tracks/0/enabled = true
|
|
tracks/0/keys = {
|
|
"times": PoolRealArray( 0, 0.6 ),
|
|
"transitions": PoolRealArray( 1, 1 ),
|
|
"update": 0,
|
|
"values": [ 60, 63 ]
|
|
}
|
|
|
|
[sub_resource type="RectangleShape2D" id=4]
|
|
extents = Vector2( 18, 19.625 )
|
|
|
|
[node name="ShooterObject" type="Node2D"]
|
|
position = Vector2( 64, 64 )
|
|
scale = Vector2( 2, 2 )
|
|
z_index = 1
|
|
script = SubResource( 1 )
|
|
|
|
[node name="Sprite" type="Sprite" parent="."]
|
|
scale = Vector2( 3, 3 )
|
|
texture = ExtResource( 1 )
|
|
region_enabled = true
|
|
region_rect = Rect2( 0, 48, 16, 16 )
|
|
|
|
[node name="Position2D" type="Position2D" parent="."]
|
|
position = Vector2( 0.5, -28 )
|
|
|
|
[node name="Shoot" type="Node2D" parent="."]
|
|
visible = false
|
|
position = Vector2( 0, -40 )
|
|
|
|
[node name="Sprite" type="Sprite" parent="Shoot"]
|
|
scale = Vector2( 2, 2 )
|
|
texture = ExtResource( 1 )
|
|
hframes = 10
|
|
vframes = 12
|
|
frame = 60
|
|
|
|
[node name="AnimationPlayer" type="AnimationPlayer" parent="Shoot"]
|
|
anims/RESET = SubResource( 2 )
|
|
anims/Shoot = SubResource( 3 )
|
|
|
|
[node name="panzerArea" type="Area2D" parent="." groups=["Panzer"]]
|
|
|
|
[node name="CollisionShape2D" type="CollisionShape2D" parent="panzerArea"]
|
|
position = Vector2( 0, 1.375 )
|
|
shape = SubResource( 4 )
|
|
|
|
[connection signal="animation_finished" from="Shoot/AnimationPlayer" to="." method="_on_AnimationPlayer_shoot_finished"]
|