diff --git a/components/Abstracts/BulletBase.tscn b/components/Abstracts/BulletBase.tscn index 5b39fc6..cb97a53 100644 --- a/components/Abstracts/BulletBase.tscn +++ b/components/Abstracts/BulletBase.tscn @@ -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"] [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"] [node name="BulletBase" type="Area2D"] @@ -12,5 +20,12 @@ script = ExtResource("1_pklpq") [node name="texture" type="AnimatedSprite2D" parent="."] 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="."] +unique_name_in_owner = true shape = SubResource("CircleShape2D_ecl7m") diff --git a/components/Bullets/Pencil.tscn b/components/Bullets/Pencil.tscn new file mode 100644 index 0000000..effda84 --- /dev/null +++ b/components/Bullets/Pencil.tscn @@ -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 diff --git a/resources/bullets/pencil/pencil-a.svg b/resources/bullets/pencil/pencil-a.svg new file mode 100644 index 0000000..cdf1386 --- /dev/null +++ b/resources/bullets/pencil/pencil-a.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/resources/bullets/pencil/pencil-a.svg.import b/resources/bullets/pencil/pencil-a.svg.import new file mode 100644 index 0000000..8260197 --- /dev/null +++ b/resources/bullets/pencil/pencil-a.svg.import @@ -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 diff --git a/scripts/Contents/Bullets/Pencil.gd b/scripts/Contents/Bullets/Pencil.gd new file mode 100644 index 0000000..9e83990 --- /dev/null +++ b/scripts/Contents/Bullets/Pencil.gd @@ -0,0 +1 @@ +extends BulletBase diff --git a/scripts/Contents/Characters/Bear.gd b/scripts/Contents/Characters/Bear.gd index f080497..8962555 100644 --- a/scripts/Contents/Characters/Bear.gd +++ b/scripts/Contents/Characters/Bear.gd @@ -1 +1,17 @@ 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)) diff --git a/scripts/Contents/Characters/Rooster.gd b/scripts/Contents/Characters/Rooster.gd index 384a2b3..f0237c7 100644 --- a/scripts/Contents/Characters/Rooster.gd +++ b/scripts/Contents/Characters/Rooster.gd @@ -1,9 +1,6 @@ extends EntityBase class_name Rooster -func _ready(): - super._ready() - func ai(): texture.play("walk") var direction = Vector2( diff --git a/scripts/Statemachine/BulletBase.gd b/scripts/Statemachine/BulletBase.gd index 68e3cb2..d08edad 100644 --- a/scripts/Statemachine/BulletBase.gd +++ b/scripts/Statemachine/BulletBase.gd @@ -12,6 +12,9 @@ class_name BulletBase @export var canDamageSelf: bool = false # 是否可以伤害发射者 @export var needEnergy: float = 4.0 # 发射时需要消耗的能量 +@onready var animator = $"%animator" +@onready var hitbox = $"%hitbox" + var launcher: EntityBase = null var spawnInWhen: float = 0 var spawnInWhere: Vector2 = Vector2.ZERO @@ -20,6 +23,8 @@ func _ready(): area_entered.connect(hit) spawnInWhen = Time.get_ticks_msec() spawnInWhere = position + animator.play("spawn") + spawn() func _process(_delta: float) -> void: if lifeTime > 0: if Time.get_ticks_msec() - spawnInWhen >= lifeTime: @@ -51,6 +56,8 @@ func ai(): pass func destroy(): queue_free() +func spawn(): + pass static func generate( bullet: PackedScene, diff --git a/scripts/Tools/TickTool.gd b/scripts/Tools/TickTool.gd new file mode 100644 index 0000000..feea4a8 --- /dev/null +++ b/scripts/Tools/TickTool.gd @@ -0,0 +1,4 @@ +class_name TickTool + +static func millseconds(ms: int): + return await WorldManager.tree.create_timer(ms / 1000.0).timeout \ No newline at end of file