feat: 添加手枪武器
This commit is contained in:
@@ -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("..")
|
||||
Reference in New Issue
Block a user