mirror of
https://github.com/Rundll86/Dog-Lynx-And-HCN.git
synced 2026-05-28 06:51:54 +08:00
feat: 添加子弹生成和动画功能,创建铅笔子弹及其资源
This commit is contained in:
@@ -1,9 +1,17 @@
|
|||||||
[gd_scene load_steps=4 format=3 uid="uid://crtdkysmnkith"]
|
[gd_scene load_steps=6 format=3 uid="uid://crtdkysmnkith"]
|
||||||
|
|
||||||
[ext_resource type="Script" path="res://scripts/Statemachine/BulletBase.gd" id="1_pklpq"]
|
[ext_resource type="Script" path="res://scripts/Statemachine/BulletBase.gd" id="1_pklpq"]
|
||||||
|
|
||||||
[sub_resource type="SpriteFrames" id="SpriteFrames_vypy3"]
|
[sub_resource type="SpriteFrames" id="SpriteFrames_vypy3"]
|
||||||
|
|
||||||
|
[sub_resource type="Animation" id="Animation_kmogx"]
|
||||||
|
resource_name = "spawn"
|
||||||
|
|
||||||
|
[sub_resource type="AnimationLibrary" id="AnimationLibrary_dxweq"]
|
||||||
|
_data = {
|
||||||
|
"spawn": SubResource("Animation_kmogx")
|
||||||
|
}
|
||||||
|
|
||||||
[sub_resource type="CircleShape2D" id="CircleShape2D_ecl7m"]
|
[sub_resource type="CircleShape2D" id="CircleShape2D_ecl7m"]
|
||||||
|
|
||||||
[node name="BulletBase" type="Area2D"]
|
[node name="BulletBase" type="Area2D"]
|
||||||
@@ -12,5 +20,12 @@ script = ExtResource("1_pklpq")
|
|||||||
[node name="texture" type="AnimatedSprite2D" parent="."]
|
[node name="texture" type="AnimatedSprite2D" parent="."]
|
||||||
sprite_frames = SubResource("SpriteFrames_vypy3")
|
sprite_frames = SubResource("SpriteFrames_vypy3")
|
||||||
|
|
||||||
|
[node name="animator" type="AnimationPlayer" parent="texture"]
|
||||||
|
unique_name_in_owner = true
|
||||||
|
libraries = {
|
||||||
|
"": SubResource("AnimationLibrary_dxweq")
|
||||||
|
}
|
||||||
|
|
||||||
[node name="hitbox" type="CollisionShape2D" parent="."]
|
[node name="hitbox" type="CollisionShape2D" parent="."]
|
||||||
|
unique_name_in_owner = true
|
||||||
shape = SubResource("CircleShape2D_ecl7m")
|
shape = SubResource("CircleShape2D_ecl7m")
|
||||||
|
|||||||
@@ -0,0 +1,137 @@
|
|||||||
|
[gd_scene load_steps=9 format=3 uid="uid://dlu1qd00t6gpa"]
|
||||||
|
|
||||||
|
[ext_resource type="PackedScene" uid="uid://crtdkysmnkith" path="res://components/Abstracts/BulletBase.tscn" id="1_anksp"]
|
||||||
|
[ext_resource type="Script" path="res://scripts/Contents/Bullets/Pencil.gd" id="2_4w6n2"]
|
||||||
|
[ext_resource type="Texture2D" uid="uid://dnpqfqfg6dwt4" path="res://resources/bullets/pencil/pencil-a.svg" id="2_ks8tb"]
|
||||||
|
|
||||||
|
[sub_resource type="SpriteFrames" id="SpriteFrames_7ol02"]
|
||||||
|
animations = [{
|
||||||
|
"frames": [{
|
||||||
|
"duration": 1.0,
|
||||||
|
"texture": ExtResource("2_ks8tb")
|
||||||
|
}],
|
||||||
|
"loop": true,
|
||||||
|
"name": &"default",
|
||||||
|
"speed": 5.0
|
||||||
|
}]
|
||||||
|
|
||||||
|
[sub_resource type="Animation" id="Animation_kmogx"]
|
||||||
|
resource_name = "spawn"
|
||||||
|
step = 0.05
|
||||||
|
tracks/0/type = "bezier"
|
||||||
|
tracks/0/imported = false
|
||||||
|
tracks/0/enabled = true
|
||||||
|
tracks/0/path = NodePath(".:scale:x")
|
||||||
|
tracks/0/interp = 1
|
||||||
|
tracks/0/loop_wrap = true
|
||||||
|
tracks/0/keys = {
|
||||||
|
"handle_modes": PackedInt32Array(0, 0),
|
||||||
|
"points": PackedFloat32Array(2, -0.25, 0, 0.25, 0, 1, -0.25, 0, 0.25, 0),
|
||||||
|
"times": PackedFloat32Array(0, 0.55)
|
||||||
|
}
|
||||||
|
tracks/1/type = "bezier"
|
||||||
|
tracks/1/imported = false
|
||||||
|
tracks/1/enabled = true
|
||||||
|
tracks/1/path = NodePath(".:scale:y")
|
||||||
|
tracks/1/interp = 1
|
||||||
|
tracks/1/loop_wrap = true
|
||||||
|
tracks/1/keys = {
|
||||||
|
"handle_modes": PackedInt32Array(0, 0),
|
||||||
|
"points": PackedFloat32Array(2, -0.25, 0, 0.25, 0, 1, -0.25, 0, 0.25, 0),
|
||||||
|
"times": PackedFloat32Array(0, 0.55)
|
||||||
|
}
|
||||||
|
tracks/2/type = "bezier"
|
||||||
|
tracks/2/imported = false
|
||||||
|
tracks/2/enabled = true
|
||||||
|
tracks/2/path = NodePath(".:modulate:a")
|
||||||
|
tracks/2/interp = 1
|
||||||
|
tracks/2/loop_wrap = true
|
||||||
|
tracks/2/keys = {
|
||||||
|
"handle_modes": PackedInt32Array(0, 0),
|
||||||
|
"points": PackedFloat32Array(0, -0.25, 0, 0.25, 0, 1, -0.25, 0, 0.25, 0),
|
||||||
|
"times": PackedFloat32Array(0, 0.55)
|
||||||
|
}
|
||||||
|
tracks/3/type = "bezier"
|
||||||
|
tracks/3/imported = false
|
||||||
|
tracks/3/enabled = true
|
||||||
|
tracks/3/path = NodePath(".:position:y")
|
||||||
|
tracks/3/interp = 1
|
||||||
|
tracks/3/loop_wrap = true
|
||||||
|
tracks/3/keys = {
|
||||||
|
"handle_modes": PackedInt32Array(0, 0),
|
||||||
|
"points": PackedFloat32Array(-100, -0.25, 0, 0.25, 0, -44, -0.25, 0, 0.25, 0),
|
||||||
|
"times": PackedFloat32Array(0.75, 1)
|
||||||
|
}
|
||||||
|
|
||||||
|
[sub_resource type="Animation" id="Animation_ij0gd"]
|
||||||
|
length = 0.001
|
||||||
|
tracks/0/type = "bezier"
|
||||||
|
tracks/0/imported = false
|
||||||
|
tracks/0/enabled = true
|
||||||
|
tracks/0/path = NodePath(".:scale:x")
|
||||||
|
tracks/0/interp = 1
|
||||||
|
tracks/0/loop_wrap = true
|
||||||
|
tracks/0/keys = {
|
||||||
|
"handle_modes": PackedInt32Array(0),
|
||||||
|
"points": PackedFloat32Array(1, -0.25, 0, 0.25, 0),
|
||||||
|
"times": PackedFloat32Array(0)
|
||||||
|
}
|
||||||
|
tracks/1/type = "bezier"
|
||||||
|
tracks/1/imported = false
|
||||||
|
tracks/1/enabled = true
|
||||||
|
tracks/1/path = NodePath(".:scale:y")
|
||||||
|
tracks/1/interp = 1
|
||||||
|
tracks/1/loop_wrap = true
|
||||||
|
tracks/1/keys = {
|
||||||
|
"handle_modes": PackedInt32Array(0),
|
||||||
|
"points": PackedFloat32Array(1, -0.25, 0, 0.25, 0),
|
||||||
|
"times": PackedFloat32Array(0)
|
||||||
|
}
|
||||||
|
tracks/2/type = "bezier"
|
||||||
|
tracks/2/imported = false
|
||||||
|
tracks/2/enabled = true
|
||||||
|
tracks/2/path = NodePath(".:modulate:a")
|
||||||
|
tracks/2/interp = 1
|
||||||
|
tracks/2/loop_wrap = true
|
||||||
|
tracks/2/keys = {
|
||||||
|
"handle_modes": PackedInt32Array(0),
|
||||||
|
"points": PackedFloat32Array(1, -0.25, 0, 0.25, 0),
|
||||||
|
"times": PackedFloat32Array(0)
|
||||||
|
}
|
||||||
|
tracks/3/type = "bezier"
|
||||||
|
tracks/3/imported = false
|
||||||
|
tracks/3/enabled = true
|
||||||
|
tracks/3/path = NodePath(".:position:y")
|
||||||
|
tracks/3/interp = 1
|
||||||
|
tracks/3/loop_wrap = true
|
||||||
|
tracks/3/keys = {
|
||||||
|
"handle_modes": PackedInt32Array(0),
|
||||||
|
"points": PackedFloat32Array(-44, -0.25, 0, 0.25, 0),
|
||||||
|
"times": PackedFloat32Array(0)
|
||||||
|
}
|
||||||
|
|
||||||
|
[sub_resource type="AnimationLibrary" id="AnimationLibrary_0cgv5"]
|
||||||
|
_data = {
|
||||||
|
"RESET": SubResource("Animation_ij0gd"),
|
||||||
|
"spawn": SubResource("Animation_kmogx")
|
||||||
|
}
|
||||||
|
|
||||||
|
[sub_resource type="RectangleShape2D" id="RectangleShape2D_cq7kn"]
|
||||||
|
size = Vector2(10, 10)
|
||||||
|
|
||||||
|
[node name="Pencil" instance=ExtResource("1_anksp")]
|
||||||
|
script = ExtResource("2_4w6n2")
|
||||||
|
|
||||||
|
[node name="texture" parent="." index="0"]
|
||||||
|
position = Vector2(0, -44)
|
||||||
|
sprite_frames = SubResource("SpriteFrames_7ol02")
|
||||||
|
|
||||||
|
[node name="animator" parent="texture" index="0"]
|
||||||
|
libraries = {
|
||||||
|
"": SubResource("AnimationLibrary_0cgv5")
|
||||||
|
}
|
||||||
|
|
||||||
|
[node name="hitbox" parent="." index="1"]
|
||||||
|
position = Vector2(0, -0.5)
|
||||||
|
shape = SubResource("RectangleShape2D_cq7kn")
|
||||||
|
disabled = true
|
||||||
File diff suppressed because one or more lines are too long
|
After Width: | Height: | Size: 5.3 KiB |
@@ -0,0 +1,37 @@
|
|||||||
|
[remap]
|
||||||
|
|
||||||
|
importer="texture"
|
||||||
|
type="CompressedTexture2D"
|
||||||
|
uid="uid://dnpqfqfg6dwt4"
|
||||||
|
path="res://.godot/imported/pencil-a.svg-280308b2cbe43bf6b55157df2b4e5c5f.ctex"
|
||||||
|
metadata={
|
||||||
|
"vram_texture": false
|
||||||
|
}
|
||||||
|
|
||||||
|
[deps]
|
||||||
|
|
||||||
|
source_file="res://resources/bullets/pencil/pencil-a.svg"
|
||||||
|
dest_files=["res://.godot/imported/pencil-a.svg-280308b2cbe43bf6b55157df2b4e5c5f.ctex"]
|
||||||
|
|
||||||
|
[params]
|
||||||
|
|
||||||
|
compress/mode=0
|
||||||
|
compress/high_quality=false
|
||||||
|
compress/lossy_quality=0.7
|
||||||
|
compress/hdr_compression=1
|
||||||
|
compress/normal_map=0
|
||||||
|
compress/channel_pack=0
|
||||||
|
mipmaps/generate=false
|
||||||
|
mipmaps/limit=-1
|
||||||
|
roughness/mode=0
|
||||||
|
roughness/src_normal=""
|
||||||
|
process/fix_alpha_border=true
|
||||||
|
process/premult_alpha=false
|
||||||
|
process/normal_map_invert_y=false
|
||||||
|
process/hdr_as_srgb=false
|
||||||
|
process/hdr_clamp_exposure=false
|
||||||
|
process/size_limit=0
|
||||||
|
detect_3d/compress_to=1
|
||||||
|
svg/scale=1.0
|
||||||
|
editor/scale_with_editor_scale=false
|
||||||
|
editor/convert_colors_with_editor_theme=false
|
||||||
@@ -0,0 +1 @@
|
|||||||
|
extends BulletBase
|
||||||
@@ -1 +1,17 @@
|
|||||||
extends EntityBase
|
extends EntityBase
|
||||||
|
class_name Bear
|
||||||
|
|
||||||
|
func ai():
|
||||||
|
pass
|
||||||
|
func attack(type):
|
||||||
|
if type == 0:
|
||||||
|
var weaponPos = findWeaponAnchor("normal")
|
||||||
|
return BulletBase.generate(preload("res://components/Bullets/PurpleCrystal.tscn"), self, weaponPos, (get_global_mouse_position() - weaponPos).angle())
|
||||||
|
func sprint():
|
||||||
|
move(Vector2(
|
||||||
|
Input.get_axis("m_left", "m_right"),
|
||||||
|
Input.get_axis("m_up", "m_down")
|
||||||
|
) * sprintMultiplier, true)
|
||||||
|
func heal(count: float):
|
||||||
|
health += count
|
||||||
|
DamageLabel.create(-count, false, damageAnchor.global_position + MathTool.randv2_range(GameRule.damageLabelSpawnOffset))
|
||||||
|
|||||||
@@ -1,9 +1,6 @@
|
|||||||
extends EntityBase
|
extends EntityBase
|
||||||
class_name Rooster
|
class_name Rooster
|
||||||
|
|
||||||
func _ready():
|
|
||||||
super._ready()
|
|
||||||
|
|
||||||
func ai():
|
func ai():
|
||||||
texture.play("walk")
|
texture.play("walk")
|
||||||
var direction = Vector2(
|
var direction = Vector2(
|
||||||
|
|||||||
@@ -12,6 +12,9 @@ class_name BulletBase
|
|||||||
@export var canDamageSelf: bool = false # 是否可以伤害发射者
|
@export var canDamageSelf: bool = false # 是否可以伤害发射者
|
||||||
@export var needEnergy: float = 4.0 # 发射时需要消耗的能量
|
@export var needEnergy: float = 4.0 # 发射时需要消耗的能量
|
||||||
|
|
||||||
|
@onready var animator = $"%animator"
|
||||||
|
@onready var hitbox = $"%hitbox"
|
||||||
|
|
||||||
var launcher: EntityBase = null
|
var launcher: EntityBase = null
|
||||||
var spawnInWhen: float = 0
|
var spawnInWhen: float = 0
|
||||||
var spawnInWhere: Vector2 = Vector2.ZERO
|
var spawnInWhere: Vector2 = Vector2.ZERO
|
||||||
@@ -20,6 +23,8 @@ func _ready():
|
|||||||
area_entered.connect(hit)
|
area_entered.connect(hit)
|
||||||
spawnInWhen = Time.get_ticks_msec()
|
spawnInWhen = Time.get_ticks_msec()
|
||||||
spawnInWhere = position
|
spawnInWhere = position
|
||||||
|
animator.play("spawn")
|
||||||
|
spawn()
|
||||||
func _process(_delta: float) -> void:
|
func _process(_delta: float) -> void:
|
||||||
if lifeTime > 0:
|
if lifeTime > 0:
|
||||||
if Time.get_ticks_msec() - spawnInWhen >= lifeTime:
|
if Time.get_ticks_msec() - spawnInWhen >= lifeTime:
|
||||||
@@ -51,6 +56,8 @@ func ai():
|
|||||||
pass
|
pass
|
||||||
func destroy():
|
func destroy():
|
||||||
queue_free()
|
queue_free()
|
||||||
|
func spawn():
|
||||||
|
pass
|
||||||
|
|
||||||
static func generate(
|
static func generate(
|
||||||
bullet: PackedScene,
|
bullet: PackedScene,
|
||||||
|
|||||||
@@ -0,0 +1,4 @@
|
|||||||
|
class_name TickTool
|
||||||
|
|
||||||
|
static func millseconds(ms: int):
|
||||||
|
return await WorldManager.tree.create_timer(ms / 1000.0).timeout
|
||||||
Reference in New Issue
Block a user