feat: 添加手枪武器
This commit is contained in:
@@ -4,5 +4,4 @@
|
|||||||
|
|
||||||
[resource]
|
[resource]
|
||||||
script = ExtResource("1_b0adc")
|
script = ExtResource("1_b0adc")
|
||||||
knockback = 1.5
|
|
||||||
metadata/_custom_type_script = "uid://d3d6rctbb48mk"
|
metadata/_custom_type_script = "uid://d3d6rctbb48mk"
|
||||||
|
|||||||
@@ -0,0 +1,15 @@
|
|||||||
|
[gd_resource type="Resource" script_class="ItemWeapon" format=3 uid="uid://0388m8srn1no"]
|
||||||
|
|
||||||
|
[ext_resource type="PackedScene" uid="uid://c6spr5c4dva2i" path="res://scenes/weapons/range/weapon_laser.tscn" id="1_0fjlb"]
|
||||||
|
[ext_resource type="Texture2D" uid="uid://crs6paux78un0" path="res://assets/sprites/Weapons/Icons/weapon_laser_icon.png" id="1_jll5j"]
|
||||||
|
[ext_resource type="Script" uid="uid://26bxxaoso6np" path="res://resources/items/weapons/item_weapon.gd" id="1_yn83p"]
|
||||||
|
[ext_resource type="Resource" uid="uid://c3bcyvr88qh20" path="res://resources/items/weapons/range/laser/stats_laser_1.tres" id="2_ckl18"]
|
||||||
|
|
||||||
|
[resource]
|
||||||
|
script = ExtResource("1_yn83p")
|
||||||
|
type = 1
|
||||||
|
scene = ExtResource("1_0fjlb")
|
||||||
|
stats = ExtResource("2_ckl18")
|
||||||
|
item_icon = ExtResource("1_jll5j")
|
||||||
|
item_cost = 15
|
||||||
|
metadata/_custom_type_script = "uid://26bxxaoso6np"
|
||||||
@@ -0,0 +1,7 @@
|
|||||||
|
[gd_resource type="Resource" script_class="WeaponStats" format=3 uid="uid://c3bcyvr88qh20"]
|
||||||
|
|
||||||
|
[ext_resource type="Script" uid="uid://d3d6rctbb48mk" path="res://resources/items/weapons/weapon_stats.gd" id="1_cjtyd"]
|
||||||
|
|
||||||
|
[resource]
|
||||||
|
script = ExtResource("1_cjtyd")
|
||||||
|
metadata/_custom_type_script = "uid://d3d6rctbb48mk"
|
||||||
@@ -0,0 +1,18 @@
|
|||||||
|
[gd_resource type="Resource" script_class="ItemWeapon" format=3 uid="uid://bxlu2qkyn4xqf"]
|
||||||
|
|
||||||
|
[ext_resource type="Texture2D" uid="uid://ctbl7s5o37g7v" path="res://assets/sprites/Weapons/Icons/weapon_pistol_icon.png" id="1_7p0me"]
|
||||||
|
[ext_resource type="Script" uid="uid://26bxxaoso6np" path="res://resources/items/weapons/item_weapon.gd" id="1_w21nh"]
|
||||||
|
[ext_resource type="PackedScene" uid="uid://jkxk68loxb55" path="res://scenes/weapons/range/weapon_pistol.tscn" id="2_763pk"]
|
||||||
|
[ext_resource type="Resource" uid="uid://cwru3b1wuvahp" path="res://resources/items/weapons/range/pistol/stats_pistol_1.tres" id="4_kib4b"]
|
||||||
|
[ext_resource type="Resource" uid="uid://iiy0knx172on" path="res://resources/items/weapons/range/pistol/item_pistol_2.tres" id="5_jdnii"]
|
||||||
|
|
||||||
|
[resource]
|
||||||
|
script = ExtResource("1_w21nh")
|
||||||
|
type = 1
|
||||||
|
scene = ExtResource("2_763pk")
|
||||||
|
stats = ExtResource("4_kib4b")
|
||||||
|
upgradge_to = ExtResource("5_jdnii")
|
||||||
|
item_name = "Pistol I"
|
||||||
|
item_icon = ExtResource("1_7p0me")
|
||||||
|
item_cost = 14
|
||||||
|
metadata/_custom_type_script = "uid://26bxxaoso6np"
|
||||||
@@ -0,0 +1,19 @@
|
|||||||
|
[gd_resource type="Resource" script_class="ItemWeapon" format=3 uid="uid://iiy0knx172on"]
|
||||||
|
|
||||||
|
[ext_resource type="Texture2D" uid="uid://ctbl7s5o37g7v" path="res://assets/sprites/Weapons/Icons/weapon_pistol_icon.png" id="1_iq8a7"]
|
||||||
|
[ext_resource type="PackedScene" uid="uid://jkxk68loxb55" path="res://scenes/weapons/range/weapon_pistol.tscn" id="2_oslt7"]
|
||||||
|
[ext_resource type="Script" uid="uid://26bxxaoso6np" path="res://resources/items/weapons/item_weapon.gd" id="3_mr7oq"]
|
||||||
|
[ext_resource type="Resource" uid="uid://bj6m5tca4eh3x" path="res://resources/items/weapons/range/pistol/stats_pistol_2.tres" id="4_oslt7"]
|
||||||
|
[ext_resource type="Resource" uid="uid://cyxumhwdlj4lq" path="res://resources/items/weapons/range/pistol/item_pistol_3.tres" id="5_oslt7"]
|
||||||
|
|
||||||
|
[resource]
|
||||||
|
script = ExtResource("3_mr7oq")
|
||||||
|
type = 1
|
||||||
|
scene = ExtResource("2_oslt7")
|
||||||
|
stats = ExtResource("4_oslt7")
|
||||||
|
upgradge_to = ExtResource("5_oslt7")
|
||||||
|
item_name = "Pistol II"
|
||||||
|
item_icon = ExtResource("1_iq8a7")
|
||||||
|
item_tier = 1
|
||||||
|
item_cost = 30
|
||||||
|
metadata/_custom_type_script = "uid://26bxxaoso6np"
|
||||||
@@ -0,0 +1,19 @@
|
|||||||
|
[gd_resource type="Resource" script_class="ItemWeapon" format=3 uid="uid://cyxumhwdlj4lq"]
|
||||||
|
|
||||||
|
[ext_resource type="Texture2D" uid="uid://ctbl7s5o37g7v" path="res://assets/sprites/Weapons/Icons/weapon_pistol_icon.png" id="1_0dp18"]
|
||||||
|
[ext_resource type="PackedScene" uid="uid://jkxk68loxb55" path="res://scenes/weapons/range/weapon_pistol.tscn" id="2_wkn4t"]
|
||||||
|
[ext_resource type="Script" uid="uid://26bxxaoso6np" path="res://resources/items/weapons/item_weapon.gd" id="3_y05ts"]
|
||||||
|
[ext_resource type="Resource" uid="uid://b2df8infnfduy" path="res://resources/items/weapons/range/pistol/stats_pistol_3.tres" id="4_wkn4t"]
|
||||||
|
[ext_resource type="Resource" uid="uid://dqxmyor4tenhn" path="res://resources/items/weapons/range/pistol/item_pistol_4.tres" id="5_wkn4t"]
|
||||||
|
|
||||||
|
[resource]
|
||||||
|
script = ExtResource("3_y05ts")
|
||||||
|
type = 1
|
||||||
|
scene = ExtResource("2_wkn4t")
|
||||||
|
stats = ExtResource("4_wkn4t")
|
||||||
|
upgradge_to = ExtResource("5_wkn4t")
|
||||||
|
item_name = "Pistol III"
|
||||||
|
item_icon = ExtResource("1_0dp18")
|
||||||
|
item_tier = 2
|
||||||
|
item_cost = 64
|
||||||
|
metadata/_custom_type_script = "uid://26bxxaoso6np"
|
||||||
@@ -0,0 +1,17 @@
|
|||||||
|
[gd_resource type="Resource" script_class="ItemWeapon" format=3 uid="uid://dqxmyor4tenhn"]
|
||||||
|
|
||||||
|
[ext_resource type="Texture2D" uid="uid://ctbl7s5o37g7v" path="res://assets/sprites/Weapons/Icons/weapon_pistol_icon.png" id="1_mhi7e"]
|
||||||
|
[ext_resource type="PackedScene" uid="uid://jkxk68loxb55" path="res://scenes/weapons/range/weapon_pistol.tscn" id="2_0l2s8"]
|
||||||
|
[ext_resource type="Script" uid="uid://26bxxaoso6np" path="res://resources/items/weapons/item_weapon.gd" id="3_x7fhi"]
|
||||||
|
[ext_resource type="Resource" uid="uid://bii38baertdux" path="res://resources/items/weapons/range/pistol/stats_pistol_4.tres" id="4_mhi7e"]
|
||||||
|
|
||||||
|
[resource]
|
||||||
|
script = ExtResource("3_x7fhi")
|
||||||
|
type = 1
|
||||||
|
scene = ExtResource("2_0l2s8")
|
||||||
|
stats = ExtResource("4_mhi7e")
|
||||||
|
item_name = "Pistol IV"
|
||||||
|
item_icon = ExtResource("1_mhi7e")
|
||||||
|
item_tier = 3
|
||||||
|
item_cost = 180
|
||||||
|
metadata/_custom_type_script = "uid://26bxxaoso6np"
|
||||||
@@ -0,0 +1,17 @@
|
|||||||
|
[gd_resource type="Resource" script_class="WeaponStats" format=3 uid="uid://cwru3b1wuvahp"]
|
||||||
|
|
||||||
|
[ext_resource type="PackedScene" uid="uid://cponp20ht0gf6" path="res://scenes/projectiles/projectile_pistol.tscn" id="1_eqhys"]
|
||||||
|
[ext_resource type="Script" uid="uid://d3d6rctbb48mk" path="res://resources/items/weapons/weapon_stats.gd" id="1_khnh1"]
|
||||||
|
|
||||||
|
[resource]
|
||||||
|
script = ExtResource("1_khnh1")
|
||||||
|
damage = 30.0
|
||||||
|
accurary = 0.85
|
||||||
|
cooldown = 0.7
|
||||||
|
crit_chance = 0.15
|
||||||
|
crit_damage = 2.0
|
||||||
|
max_range = 380.0
|
||||||
|
knockback = 1.3
|
||||||
|
projectile_scene = ExtResource("1_eqhys")
|
||||||
|
projectile_speed = 1700.0
|
||||||
|
metadata/_custom_type_script = "uid://d3d6rctbb48mk"
|
||||||
@@ -0,0 +1,15 @@
|
|||||||
|
[gd_resource type="Resource" script_class="WeaponStats" format=3 uid="uid://bj6m5tca4eh3x"]
|
||||||
|
|
||||||
|
[ext_resource type="PackedScene" uid="uid://cponp20ht0gf6" path="res://scenes/projectiles/projectile_pistol.tscn" id="1_7jjae"]
|
||||||
|
[ext_resource type="Script" uid="uid://d3d6rctbb48mk" path="res://resources/items/weapons/weapon_stats.gd" id="2_dhuvg"]
|
||||||
|
|
||||||
|
[resource]
|
||||||
|
script = ExtResource("2_dhuvg")
|
||||||
|
damage = 5.0
|
||||||
|
accurary = 0.85
|
||||||
|
crit_damage = 2.0
|
||||||
|
max_range = 350.0
|
||||||
|
knockback = 1.3
|
||||||
|
projectile_scene = ExtResource("1_7jjae")
|
||||||
|
projectile_speed = 1700.0
|
||||||
|
metadata/_custom_type_script = "uid://d3d6rctbb48mk"
|
||||||
@@ -0,0 +1,15 @@
|
|||||||
|
[gd_resource type="Resource" script_class="WeaponStats" format=3 uid="uid://b2df8infnfduy"]
|
||||||
|
|
||||||
|
[ext_resource type="PackedScene" uid="uid://cponp20ht0gf6" path="res://scenes/projectiles/projectile_pistol.tscn" id="1_i0vrm"]
|
||||||
|
[ext_resource type="Script" uid="uid://d3d6rctbb48mk" path="res://resources/items/weapons/weapon_stats.gd" id="2_oprbb"]
|
||||||
|
|
||||||
|
[resource]
|
||||||
|
script = ExtResource("2_oprbb")
|
||||||
|
damage = 5.0
|
||||||
|
accurary = 0.85
|
||||||
|
crit_damage = 2.0
|
||||||
|
max_range = 350.0
|
||||||
|
knockback = 1.3
|
||||||
|
projectile_scene = ExtResource("1_i0vrm")
|
||||||
|
projectile_speed = 1700.0
|
||||||
|
metadata/_custom_type_script = "uid://d3d6rctbb48mk"
|
||||||
@@ -0,0 +1,15 @@
|
|||||||
|
[gd_resource type="Resource" script_class="WeaponStats" format=3 uid="uid://bii38baertdux"]
|
||||||
|
|
||||||
|
[ext_resource type="PackedScene" uid="uid://cponp20ht0gf6" path="res://scenes/projectiles/projectile_pistol.tscn" id="1_r12us"]
|
||||||
|
[ext_resource type="Script" uid="uid://d3d6rctbb48mk" path="res://resources/items/weapons/weapon_stats.gd" id="2_hrw3j"]
|
||||||
|
|
||||||
|
[resource]
|
||||||
|
script = ExtResource("2_hrw3j")
|
||||||
|
damage = 5.0
|
||||||
|
accurary = 0.85
|
||||||
|
crit_damage = 2.0
|
||||||
|
max_range = 350.0
|
||||||
|
knockback = 1.3
|
||||||
|
projectile_scene = ExtResource("1_r12us")
|
||||||
|
projectile_speed = 1700.0
|
||||||
|
metadata/_custom_type_script = "uid://d3d6rctbb48mk"
|
||||||
@@ -0,0 +1,23 @@
|
|||||||
|
extends Node2D
|
||||||
|
class_name Projectile
|
||||||
|
|
||||||
|
@export var hitbox: HitboxComponent
|
||||||
|
|
||||||
|
var velocity: Vector2
|
||||||
|
|
||||||
|
func _process(delta: float) -> void:
|
||||||
|
position += velocity * delta
|
||||||
|
|
||||||
|
func set_projectile(velocity: Vector2, damage: float, critical: bool, knockback: float, unit: Node2D) -> void:
|
||||||
|
self.velocity = velocity
|
||||||
|
rotation = velocity.angle()
|
||||||
|
if hitbox:
|
||||||
|
hitbox.setup(damage, critical, knockback, unit)
|
||||||
|
|
||||||
|
|
||||||
|
func _on_visible_on_screen_notifier_2d_screen_exited() -> void:
|
||||||
|
queue_free()
|
||||||
|
|
||||||
|
|
||||||
|
func _on_hitbox_component_on_hit_hurtbox(hurtbox: HurtboxComponent) -> void:
|
||||||
|
queue_free()
|
||||||
@@ -0,0 +1 @@
|
|||||||
|
uid://bmye8ydta5x0x
|
||||||
@@ -0,0 +1,9 @@
|
|||||||
|
[gd_scene format=3 uid="uid://dgxgta5rdunaj"]
|
||||||
|
|
||||||
|
[ext_resource type="PackedScene" uid="uid://cponp20ht0gf6" path="res://scenes/projectiles/projectile_pistol.tscn" id="1_kgo5h"]
|
||||||
|
[ext_resource type="Texture2D" uid="uid://3c2kwaw7powj" path="res://assets/sprites/Projectiles/Projectile_3.png" id="2_4n0tj"]
|
||||||
|
|
||||||
|
[node name="ProjectileLaser" unique_id=109874266 instance=ExtResource("1_kgo5h")]
|
||||||
|
|
||||||
|
[node name="Sprite2D" parent="." index="0" unique_id=575255969]
|
||||||
|
texture = ExtResource("2_4n0tj")
|
||||||
@@ -0,0 +1,28 @@
|
|||||||
|
[gd_scene format=3 uid="uid://cponp20ht0gf6"]
|
||||||
|
|
||||||
|
[ext_resource type="Texture2D" uid="uid://45dwbyxmy4wd" path="res://assets/sprites/Projectiles/Projectile_2.png" id="1_4u32m"]
|
||||||
|
[ext_resource type="Script" uid="uid://bmye8ydta5x0x" path="res://scenes/projectiles/projectile.gd" id="1_71gtn"]
|
||||||
|
[ext_resource type="PackedScene" uid="uid://c0fyx8gj5uexl" path="res://scenes/components/hitbox_component.tscn" id="1_u4710"]
|
||||||
|
|
||||||
|
[sub_resource type="CircleShape2D" id="CircleShape2D_4u32m"]
|
||||||
|
radius = 13.0
|
||||||
|
|
||||||
|
[node name="ProjectilePistol" type="Node2D" unique_id=109874266 node_paths=PackedStringArray("hitbox")]
|
||||||
|
script = ExtResource("1_71gtn")
|
||||||
|
hitbox = NodePath("HitboxComponent")
|
||||||
|
|
||||||
|
[node name="Sprite2D" type="Sprite2D" parent="." unique_id=575255969]
|
||||||
|
scale = Vector2(0.5, 0.5)
|
||||||
|
texture = ExtResource("1_4u32m")
|
||||||
|
|
||||||
|
[node name="HitboxComponent" parent="." unique_id=151235566 instance=ExtResource("1_u4710")]
|
||||||
|
collision_layer = 16
|
||||||
|
collision_mask = 8
|
||||||
|
|
||||||
|
[node name="CollisionShape2D" type="CollisionShape2D" parent="HitboxComponent" unique_id=1598992093]
|
||||||
|
shape = SubResource("CircleShape2D_4u32m")
|
||||||
|
|
||||||
|
[node name="VisibleOnScreenNotifier2D" type="VisibleOnScreenNotifier2D" parent="." unique_id=1911021715]
|
||||||
|
|
||||||
|
[connection signal="on_hit_hurtbox" from="HitboxComponent" to="." method="_on_hitbox_component_on_hit_hurtbox"]
|
||||||
|
[connection signal="screen_exited" from="VisibleOnScreenNotifier2D" to="." method="_on_visible_on_screen_notifier_2d_screen_exited"]
|
||||||
@@ -0,0 +1,9 @@
|
|||||||
|
[gd_scene format=3 uid="uid://bvdn35euxceps"]
|
||||||
|
|
||||||
|
[ext_resource type="PackedScene" uid="uid://cponp20ht0gf6" path="res://scenes/projectiles/projectile_pistol.tscn" id="1_yd76t"]
|
||||||
|
[ext_resource type="Texture2D" uid="uid://d3m2aqwl8u1qx" path="res://assets/sprites/Projectiles/Projectile_4.png" id="2_5bfio"]
|
||||||
|
|
||||||
|
[node name="ProjectileRevolver" unique_id=109874266 instance=ExtResource("1_yd76t")]
|
||||||
|
|
||||||
|
[node name="Sprite2D" parent="." index="0" unique_id=575255969]
|
||||||
|
texture = ExtResource("2_5bfio")
|
||||||
@@ -0,0 +1,9 @@
|
|||||||
|
[gd_scene format=3 uid="uid://5mv5jtkql7pm"]
|
||||||
|
|
||||||
|
[ext_resource type="PackedScene" uid="uid://cponp20ht0gf6" path="res://scenes/projectiles/projectile_pistol.tscn" id="1_lmmiu"]
|
||||||
|
[ext_resource type="Texture2D" uid="uid://cmr4xxqrthts7" path="res://assets/sprites/Projectiles/Projectile_1.png" id="2_gh7rf"]
|
||||||
|
|
||||||
|
[node name="ProjectileShotgun" unique_id=109874266 instance=ExtResource("1_lmmiu")]
|
||||||
|
|
||||||
|
[node name="Sprite2D" parent="." index="0" unique_id=575255969]
|
||||||
|
texture = ExtResource("2_gh7rf")
|
||||||
@@ -0,0 +1,9 @@
|
|||||||
|
[gd_scene format=3 uid="uid://7doitq0bldjw"]
|
||||||
|
|
||||||
|
[ext_resource type="PackedScene" uid="uid://cponp20ht0gf6" path="res://scenes/projectiles/projectile_pistol.tscn" id="1_s2juw"]
|
||||||
|
[ext_resource type="Texture2D" uid="uid://bf4yrlp8dofx1" path="res://assets/sprites/Projectiles/Projectile_5.png" id="2_7qwbs"]
|
||||||
|
|
||||||
|
[node name="ProjectileSMG" unique_id=109874266 instance=ExtResource("1_s2juw")]
|
||||||
|
|
||||||
|
[node name="Sprite2D" parent="." index="0" unique_id=575255969]
|
||||||
|
texture = ExtResource("2_7qwbs")
|
||||||
@@ -23,7 +23,8 @@ func _ready() -> void:
|
|||||||
dash_timer.wait_time = dash_duration
|
dash_timer.wait_time = dash_duration
|
||||||
dash_cooldown_timer.wait_time = dash_cooldown
|
dash_cooldown_timer.wait_time = dash_cooldown
|
||||||
|
|
||||||
add_weapon(preload("uid://murcuuks1j8l"))
|
#add_weapon(preload("uid://murcuuks1j8l"))
|
||||||
|
add_weapon(preload("uid://bxlu2qkyn4xqf"))
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,5 @@
|
|||||||
|
[gd_scene format=3 uid="uid://bpc7qmrh8hs0n"]
|
||||||
|
|
||||||
|
[ext_resource type="PackedScene" uid="uid://dcc7rsdy4j8v6" path="res://scenes/weapons/weapon_base.tscn" id="1_1b33f"]
|
||||||
|
|
||||||
|
[node name="WeaponAxe" unique_id=63743776 instance=ExtResource("1_1b33f")]
|
||||||
@@ -0,0 +1,5 @@
|
|||||||
|
[gd_scene format=3 uid="uid://d2k5wxsuodxib"]
|
||||||
|
|
||||||
|
[ext_resource type="PackedScene" uid="uid://dcc7rsdy4j8v6" path="res://scenes/weapons/weapon_base.tscn" id="1_sj0xb"]
|
||||||
|
|
||||||
|
[node name="WeaponChainsaw" unique_id=63743776 instance=ExtResource("1_sj0xb")]
|
||||||
@@ -0,0 +1,5 @@
|
|||||||
|
[gd_scene format=3 uid="uid://c40id7ntypee8"]
|
||||||
|
|
||||||
|
[ext_resource type="PackedScene" uid="uid://dcc7rsdy4j8v6" path="res://scenes/weapons/weapon_base.tscn" id="1_8xtns"]
|
||||||
|
|
||||||
|
[node name="WeaponMace" unique_id=63743776 instance=ExtResource("1_8xtns")]
|
||||||
@@ -0,0 +1,38 @@
|
|||||||
|
extends WeaponBehavior
|
||||||
|
class_name RangeBehavior
|
||||||
|
|
||||||
|
@onready var muzzle: Marker2D = %Muzzle
|
||||||
|
|
||||||
|
|
||||||
|
func execute_attack() -> void:
|
||||||
|
weapon.is_attacking = true
|
||||||
|
|
||||||
|
create_projectile()
|
||||||
|
|
||||||
|
var tween := create_tween()
|
||||||
|
var attack_pos := Vector2(weapon.atk_start_pos.x - weapon.data.stats.recoil, weapon.atk_start_pos.y)
|
||||||
|
tween.tween_property(weapon.sprite_2d, "position", attack_pos, weapon.data.stats.recoil_duration)
|
||||||
|
tween.tween_property(weapon.sprite_2d, "position", weapon.atk_start_pos, weapon.data.stats.recoil_duration)
|
||||||
|
|
||||||
|
await tween.finished
|
||||||
|
weapon.is_attacking = false
|
||||||
|
critical = false
|
||||||
|
|
||||||
|
func create_projectile() -> void:
|
||||||
|
var instance := weapon.data.stats.projectile_scene.instantiate() as Projectile
|
||||||
|
get_tree().root.add_child(instance)
|
||||||
|
|
||||||
|
instance.global_position = muzzle.global_position
|
||||||
|
|
||||||
|
var velocity := Vector2.RIGHT.rotated(weapon.rotation) * weapon.data.stats.projectile_speed
|
||||||
|
instance.set_projectile(velocity, get_damage(), critical, weapon.data.stats.knockback, weapon.get_parent())
|
||||||
|
|
||||||
|
|
||||||
|
# Called when the node enters the scene tree for the first time.
|
||||||
|
func _ready() -> void:
|
||||||
|
pass # Replace with function body.
|
||||||
|
|
||||||
|
|
||||||
|
# Called every frame. 'delta' is the elapsed time since the previous frame.
|
||||||
|
func _process(delta: float) -> void:
|
||||||
|
pass
|
||||||
@@ -0,0 +1 @@
|
|||||||
|
uid://f71mwa3ckrj8
|
||||||
@@ -0,0 +1,19 @@
|
|||||||
|
[gd_scene format=3 uid="uid://c6spr5c4dva2i"]
|
||||||
|
|
||||||
|
[ext_resource type="PackedScene" uid="uid://dcc7rsdy4j8v6" path="res://scenes/weapons/weapon_base.tscn" id="1_r5jol"]
|
||||||
|
[ext_resource type="Texture2D" uid="uid://xqoogkscdty6" path="res://assets/sprites/Weapons/Range/WeaponLaser.png" id="2_jsyfg"]
|
||||||
|
[ext_resource type="Script" uid="uid://f71mwa3ckrj8" path="res://scenes/weapons/range/range_behavior.gd" id="3_50c4r"]
|
||||||
|
|
||||||
|
[node name="WeaponLaser" unique_id=63743776 instance=ExtResource("1_r5jol")]
|
||||||
|
|
||||||
|
[node name="Sprite2D" parent="." index="0" unique_id=1011668514]
|
||||||
|
position = Vector2(16, -4)
|
||||||
|
texture = ExtResource("2_jsyfg")
|
||||||
|
|
||||||
|
[node name="Muzzle" type="Marker2D" parent="Sprite2D" index="0" unique_id=1914443055]
|
||||||
|
unique_name_in_owner = true
|
||||||
|
position = Vector2(78, -14)
|
||||||
|
|
||||||
|
[node name="WeaponBehavior" parent="." index="3" unique_id=1507497844 node_paths=PackedStringArray("weapon")]
|
||||||
|
script = ExtResource("3_50c4r")
|
||||||
|
weapon = NodePath("..")
|
||||||
@@ -0,0 +1,19 @@
|
|||||||
|
[gd_scene format=3 uid="uid://jkxk68loxb55"]
|
||||||
|
|
||||||
|
[ext_resource type="PackedScene" uid="uid://dcc7rsdy4j8v6" path="res://scenes/weapons/weapon_base.tscn" id="1_g1grj"]
|
||||||
|
[ext_resource type="Texture2D" uid="uid://bbsd0o1wllf0p" path="res://assets/sprites/Weapons/Range/WeaponPistol.png" id="2_hqh7m"]
|
||||||
|
[ext_resource type="Script" uid="uid://f71mwa3ckrj8" path="res://scenes/weapons/range/range_behavior.gd" id="3_x7rn7"]
|
||||||
|
|
||||||
|
[node name="WeaponPistol" unique_id=63743776 instance=ExtResource("1_g1grj")]
|
||||||
|
|
||||||
|
[node name="Sprite2D" parent="." index="0" unique_id=1011668514]
|
||||||
|
position = Vector2(20, 0)
|
||||||
|
texture = ExtResource("2_hqh7m")
|
||||||
|
|
||||||
|
[node name="Muzzle" type="Marker2D" parent="Sprite2D" index="0" unique_id=2115750749]
|
||||||
|
unique_name_in_owner = true
|
||||||
|
position = Vector2(92, -28)
|
||||||
|
|
||||||
|
[node name="WeaponBehavior" parent="." index="3" unique_id=1507497844 node_paths=PackedStringArray("weapon")]
|
||||||
|
script = ExtResource("3_x7rn7")
|
||||||
|
weapon = NodePath("..")
|
||||||
@@ -26,6 +26,8 @@ func _process(delta: float) -> void:
|
|||||||
|
|
||||||
rotate_to_target()
|
rotate_to_target()
|
||||||
|
|
||||||
|
update_visuals()
|
||||||
|
|
||||||
if can_use_weapon():
|
if can_use_weapon():
|
||||||
use_weapon()
|
use_weapon()
|
||||||
|
|
||||||
@@ -73,6 +75,13 @@ func get_idle_rotation() -> float:
|
|||||||
else:
|
else:
|
||||||
return PI
|
return PI
|
||||||
|
|
||||||
|
func update_visuals() -> void:
|
||||||
|
if abs(rotation) > PI / 2:
|
||||||
|
sprite_2d.scale.y = -0.5
|
||||||
|
else :
|
||||||
|
sprite_2d.scale.y = 0.5
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
func calculate_spread() -> void:
|
func calculate_spread() -> void:
|
||||||
weapon_spread += randf_range(-1 + data.stats.accurary, 1- data.stats.accurary)
|
weapon_spread += randf_range(-1 + data.stats.accurary, 1- data.stats.accurary)
|
||||||
|
|||||||
Reference in New Issue
Block a user