Removed shoot() from controllers. Removed idle animation from laser
This commit is contained in:
@@ -1,27 +1,20 @@
|
||||
extends AbstractWeapon
|
||||
|
||||
|
||||
@onready var idle_sprite : AnimatedSprite2D = $IdleAnimatedSprite
|
||||
@onready var firing_sprite : AnimatedSprite2D = $FiringAnimatedSprite
|
||||
@onready var sprite : AnimatedSprite2D = $AnimatedSprite2D
|
||||
@onready var cooldown_timer : Timer = $CooldownTimer
|
||||
|
||||
|
||||
func _ready() -> void:
|
||||
_switch_sprite(false)
|
||||
|
||||
|
||||
func set_belonging(belonging: Belonging) -> void:
|
||||
super.set_belonging(belonging)
|
||||
|
||||
idle_sprite.play(PREFIXES[_belonging])
|
||||
firing_sprite.play(PREFIXES[_belonging])
|
||||
sprite.play(PREFIXES[_belonging])
|
||||
|
||||
|
||||
func shoot(ship_velocity: Vector2) -> bool:
|
||||
var is_shot := super.shoot(ship_velocity)
|
||||
if is_shot:
|
||||
_can_shoot = false
|
||||
_switch_sprite(true)
|
||||
cooldown_timer.start()
|
||||
|
||||
return is_shot
|
||||
@@ -29,13 +22,3 @@ func shoot(ship_velocity: Vector2) -> bool:
|
||||
|
||||
func _on_cooldown_timer_timeout() -> void:
|
||||
_can_shoot = true
|
||||
_switch_sprite(false)
|
||||
|
||||
|
||||
func _switch_sprite(firing: bool) -> void:
|
||||
if firing:
|
||||
idle_sprite.hide()
|
||||
firing_sprite.show()
|
||||
else:
|
||||
idle_sprite.show()
|
||||
firing_sprite.hide()
|
||||
|
||||
@@ -1,79 +1,10 @@
|
||||
[gd_scene load_steps=23 format=3 uid="uid://def1alrel4ioo"]
|
||||
[gd_scene load_steps=14 format=3 uid="uid://def1alrel4ioo"]
|
||||
|
||||
[ext_resource type="PackedScene" uid="uid://1o2ta17yc5bp" path="res://game/entities/weapons/abstract_weapon.tscn" id="1_pki4x"]
|
||||
[ext_resource type="PackedScene" uid="uid://cmni0xrbbfcy5" path="res://game/entities/weapons/laser/laser_projectile.tscn" id="2_fecho"]
|
||||
[ext_resource type="Script" uid="uid://bxr150at8ul2a" path="res://game/entities/weapons/laser/laser_weapon.gd" id="2_lbdvb"]
|
||||
[ext_resource type="Texture2D" uid="uid://6hh66k8s4a1e" path="res://images/weapons.png" id="6_c8tb4"]
|
||||
|
||||
[sub_resource type="AtlasTexture" id="AtlasTexture_4a3il"]
|
||||
atlas = ExtResource("6_c8tb4")
|
||||
region = Rect2(0, 80, 32, 16)
|
||||
|
||||
[sub_resource type="AtlasTexture" id="AtlasTexture_n1iu2"]
|
||||
atlas = ExtResource("6_c8tb4")
|
||||
region = Rect2(32, 80, 32, 16)
|
||||
|
||||
[sub_resource type="AtlasTexture" id="AtlasTexture_kgblc"]
|
||||
atlas = ExtResource("6_c8tb4")
|
||||
region = Rect2(64, 80, 32, 16)
|
||||
|
||||
[sub_resource type="AtlasTexture" id="AtlasTexture_f2vvu"]
|
||||
atlas = ExtResource("6_c8tb4")
|
||||
region = Rect2(96, 80, 32, 16)
|
||||
|
||||
[sub_resource type="AtlasTexture" id="AtlasTexture_7rt33"]
|
||||
atlas = ExtResource("6_c8tb4")
|
||||
region = Rect2(0, 64, 32, 16)
|
||||
|
||||
[sub_resource type="AtlasTexture" id="AtlasTexture_n02tm"]
|
||||
atlas = ExtResource("6_c8tb4")
|
||||
region = Rect2(32, 64, 32, 16)
|
||||
|
||||
[sub_resource type="AtlasTexture" id="AtlasTexture_7q2cb"]
|
||||
atlas = ExtResource("6_c8tb4")
|
||||
region = Rect2(64, 64, 32, 16)
|
||||
|
||||
[sub_resource type="AtlasTexture" id="AtlasTexture_qatwk"]
|
||||
atlas = ExtResource("6_c8tb4")
|
||||
region = Rect2(96, 64, 32, 16)
|
||||
|
||||
[sub_resource type="SpriteFrames" id="SpriteFrames_qjjka"]
|
||||
animations = [{
|
||||
"frames": [{
|
||||
"duration": 1.0,
|
||||
"texture": SubResource("AtlasTexture_4a3il")
|
||||
}, {
|
||||
"duration": 1.0,
|
||||
"texture": SubResource("AtlasTexture_n1iu2")
|
||||
}, {
|
||||
"duration": 1.0,
|
||||
"texture": SubResource("AtlasTexture_kgblc")
|
||||
}, {
|
||||
"duration": 1.0,
|
||||
"texture": SubResource("AtlasTexture_f2vvu")
|
||||
}],
|
||||
"loop": true,
|
||||
"name": &"enemy",
|
||||
"speed": 10.0
|
||||
}, {
|
||||
"frames": [{
|
||||
"duration": 1.0,
|
||||
"texture": SubResource("AtlasTexture_7rt33")
|
||||
}, {
|
||||
"duration": 1.0,
|
||||
"texture": SubResource("AtlasTexture_n02tm")
|
||||
}, {
|
||||
"duration": 1.0,
|
||||
"texture": SubResource("AtlasTexture_7q2cb")
|
||||
}, {
|
||||
"duration": 1.0,
|
||||
"texture": SubResource("AtlasTexture_qatwk")
|
||||
}],
|
||||
"loop": true,
|
||||
"name": &"player",
|
||||
"speed": 10.0
|
||||
}]
|
||||
|
||||
[sub_resource type="AtlasTexture" id="AtlasTexture_dggsl"]
|
||||
atlas = ExtResource("6_c8tb4")
|
||||
region = Rect2(128, 80, 32, 16)
|
||||
@@ -149,17 +80,12 @@ bullet_per_shot = 2
|
||||
Projectile = ExtResource("2_fecho")
|
||||
type = 2
|
||||
|
||||
[node name="IdleAnimatedSprite" type="AnimatedSprite2D" parent="." index="0"]
|
||||
position = Vector2(3, 0)
|
||||
sprite_frames = SubResource("SpriteFrames_qjjka")
|
||||
animation = &"player"
|
||||
|
||||
[node name="FiringAnimatedSprite" type="AnimatedSprite2D" parent="." index="1"]
|
||||
[node name="AnimatedSprite2D" type="AnimatedSprite2D" parent="." index="0"]
|
||||
position = Vector2(3, 0)
|
||||
sprite_frames = SubResource("SpriteFrames_c8tb4")
|
||||
animation = &"player"
|
||||
|
||||
[node name="CooldownTimer" type="Timer" parent="." index="2"]
|
||||
[node name="CooldownTimer" type="Timer" parent="." index="1"]
|
||||
process_callback = 0
|
||||
wait_time = 0.05
|
||||
one_shot = true
|
||||
|
||||
Reference in New Issue
Block a user