diff --git a/components/Bullets/Arrow.tscn b/components/Bullets/Arrow.tscn index 366082d..904e719 100644 --- a/components/Bullets/Arrow.tscn +++ b/components/Bullets/Arrow.tscn @@ -1,13 +1,18 @@ -[gd_scene load_steps=4 format=3 uid="uid://wy8wqwhwr4fb"] +[gd_scene load_steps=5 format=3 uid="uid://wy8wqwhwr4fb"] [ext_resource type="PackedScene" uid="uid://crtdkysmnkith" path="res://components/Abstracts/BulletBase.tscn" id="1_0wuio"] [ext_resource type="Texture2D" uid="uid://dadbn306owsy3" path="res://resources/bullets/arrow/arrow.png" id="2_b2ohg"] +[ext_resource type="Script" uid="uid://u5x40y0cvqq2" path="res://scripts/Contents/Bullets/Arrow.gd" id="2_qddg0"] [sub_resource type="CircleShape2D" id="CircleShape2D_b2ohg"] [node name="Arrow" instance=ExtResource("1_0wuio")] +script = ExtResource("2_qddg0") displayName = "鸡毛箭" +speed = 20.0 +damage = 50.0 penerate = 1.0 +lifeDistance = 1200.0 [node name="static" type="Sprite2D" parent="texture" index="1"] scale = Vector2(0.06775362, 0.06775362) diff --git a/components/Bullets/Bow.tscn b/components/Bullets/Bow.tscn index 8300427..4302fb3 100644 --- a/components/Bullets/Bow.tscn +++ b/components/Bullets/Bow.tscn @@ -1,11 +1,15 @@ -[gd_scene load_steps=3 format=3 uid="uid://c2ga3ktbxdfc5"] +[gd_scene load_steps=4 format=3 uid="uid://c2ga3ktbxdfc5"] [ext_resource type="PackedScene" uid="uid://crtdkysmnkith" path="res://components/Abstracts/BulletBase.tscn" id="1_t0pyo"] [ext_resource type="Texture2D" uid="uid://7us1po711e3o" path="res://resources/weapons/鸡毛弓.png" id="2_two1a"] +[ext_resource type="Script" uid="uid://dnnxxqpbpwohf" path="res://scripts/Contents/Bullets/Bow.gd" id="2_wtwgr"] [node name="Bow" instance=ExtResource("1_t0pyo")] +script = ExtResource("2_wtwgr") +metadata/_edit_vertical_guides_ = [88.0] [node name="static" type="Sprite2D" parent="texture" index="1"] +position = Vector2(150, 0) scale = Vector2(0.055427626, 0.055427626) texture = ExtResource("2_two1a") diff --git a/components/Characters/Rooster.tscn b/components/Characters/Rooster.tscn index 4d78c8a..3506911 100644 --- a/components/Characters/Rooster.tscn +++ b/components/Characters/Rooster.tscn @@ -1,8 +1,9 @@ -[gd_scene load_steps=15 format=3 uid="uid://bm7ymrri6pykb"] +[gd_scene load_steps=16 format=3 uid="uid://bm7ymrri6pykb"] [ext_resource type="PackedScene" uid="uid://cvogxi7mktumf" path="res://components/Abstracts/EntityBase.tscn" id="1_e5pl8"] [ext_resource type="Script" uid="uid://cthtupc6dtbav" path="res://scripts/Contents/Characters/Rooster.gd" id="2_oqdqd"] [ext_resource type="AudioStream" uid="uid://dclinyhu256xi" path="res://resources/sounds/effect/Low Whoosh.mp3" id="3_4syso"] +[ext_resource type="PackedScene" uid="uid://dgka15811lrrj" path="res://components/Weapons/Bow.tscn" id="3_fkh3f"] [ext_resource type="PackedScene" uid="uid://c0n3igy4hucrg" path="res://components/Weapons/PurpleCrystal.tscn" id="3_jluqw"] [ext_resource type="AudioStream" uid="uid://cdrevrq7n6yqa" path="res://resources/sounds/effect/Boing.mp3" id="4_66s6c"] [ext_resource type="PackedScene" uid="uid://u0djqwuuysp8" path="res://components/Weapons/Volcano.tscn" id="4_jluqw"] @@ -51,17 +52,21 @@ radius = 61.204575 script = ExtResource("2_oqdqd") displayName = "公鸡" useStatic = true -metadata/_edit_horizontal_guides_ = [-139.0] -metadata/_edit_vertical_guides_ = [58.0] +metadata/_edit_horizontal_guides_ = [-188.0] +metadata/_edit_vertical_guides_ = [71.0] [node name="weaponStore" parent="." index="1"] process_mode = 4 -[node name="PurpleCrystal" parent="weaponStore" index="0" instance=ExtResource("3_jluqw")] +[node name="Bow" parent="weaponStore" index="0" instance=ExtResource("3_fkh3f")] +offset_bottom = 374.0 +debugRebuild = false + +[node name="PurpleCrystal" parent="weaponStore" index="1" instance=ExtResource("3_jluqw")] offset_bottom = 350.0 debugRebuild = false -[node name="Volcano" parent="weaponStore" index="1" instance=ExtResource("4_jluqw")] +[node name="Volcano" parent="weaponStore" index="2" instance=ExtResource("4_jluqw")] debugRebuild = false [node name="sprint" parent="sounds" index="0"] diff --git a/components/Weapons/Bow.tscn b/components/Weapons/Bow.tscn new file mode 100644 index 0000000..37785d2 --- /dev/null +++ b/components/Weapons/Bow.tscn @@ -0,0 +1,45 @@ +[gd_scene load_steps=4 format=3 uid="uid://dgka15811lrrj"] + +[ext_resource type="PackedScene" uid="uid://ckq2cq6m23hq3" path="res://components/Abstracts/WeaponCardBase.tscn" id="1_fhedw"] +[ext_resource type="Script" uid="uid://1u8t36atj041" path="res://scripts/Contents/Weapons/Bow.gd" id="2_bou5i"] +[ext_resource type="Texture2D" uid="uid://7us1po711e3o" path="res://resources/weapons/鸡毛弓.png" id="2_ex3jl"] + +[node name="Bow" instance=ExtResource("1_fhedw")] +script = ExtResource("2_bou5i") +avatarTexture = ExtResource("2_ex3jl") +displayName = "鸡毛弓" +quality = 2 +costBeachball = 50 +store = { +"atk": 3, +"count": 1, +"self": 0.5 +} +storeType = { +"atk": 2, +"count": 1, +"self": 0 +} +descriptionTemplate = "消耗$self点生命值,发射$count支[b]鸡毛箭[/b],每支造成当前飞行速度的$atk伤害。" +needEnergy = 20.0 +cooldown = 500.0 +debugRebuild = true + +[node name="avatar" parent="container/info" index="0"] +texture = ExtResource("2_ex3jl") + +[node name="energy" parent="container/info/infos/energyInfo" index="1"] +text = "20.0" + +[node name="beachball" parent="container/info/infos" index="1"] +count = 50 + +[node name="soul" parent="container/info/infos" index="2"] +count = 1 + +[node name="name" parent="container/info" index="2"] +displayName = "鸡毛弓" +quality = 2 + +[node name="description" parent="container" index="2"] +text = "[center]消耗[color=cyan]0.50[/color]点生命值,发射[color=cyan]1[/color]支[b]鸡毛箭[/b],每支造成当前飞行速度的[color=cyan]300%[/color]伤害。[/center]" diff --git a/scripts/Contents/Bullets/Arrow.gd b/scripts/Contents/Bullets/Arrow.gd new file mode 100644 index 0000000..4ea19bc --- /dev/null +++ b/scripts/Contents/Bullets/Arrow.gd @@ -0,0 +1,11 @@ +extends BulletBase +class_name Arrow + +var atk: float = 0 + +func ai(): + speed = (1 - lifeDistancePercent()) * initialSpeed + damage = speed * atk + PresetBulletAI.forward(self, rotation) + if speed < 1: + tryDestroy() diff --git a/scripts/Contents/Bullets/Arrow.gd.uid b/scripts/Contents/Bullets/Arrow.gd.uid new file mode 100644 index 0000000..f1196ba --- /dev/null +++ b/scripts/Contents/Bullets/Arrow.gd.uid @@ -0,0 +1 @@ +uid://u5x40y0cvqq2 diff --git a/scripts/Contents/Bullets/Bow.gd b/scripts/Contents/Bullets/Bow.gd new file mode 100644 index 0000000..d68b302 --- /dev/null +++ b/scripts/Contents/Bullets/Bow.gd @@ -0,0 +1,22 @@ +extends BulletBase +class_name Bow + +var count: int = 0 +var atk: float = 0 + +func spawn(): + await TickTool.millseconds(250) + var startAngle = rotation - deg_to_rad(count * 10.0 / 2) + for c in count: + for i in BulletBase.generate( + ComponentManager.getBullet("Arrow"), + launcher, + position, + startAngle + deg_to_rad(c * 10) + ): + var bullet: Arrow = i + bullet.atk = atk + tryDestroy() +func ai(): + PresetBulletAI.lockLauncher(self, launcher, true) + rotation = position.angle_to_point(get_global_mouse_position()) diff --git a/scripts/Contents/Bullets/Bow.gd.uid b/scripts/Contents/Bullets/Bow.gd.uid new file mode 100644 index 0000000..6be2aa4 --- /dev/null +++ b/scripts/Contents/Bullets/Bow.gd.uid @@ -0,0 +1 @@ +uid://dnnxxqpbpwohf diff --git a/scripts/Contents/Bullets/ChickSprint.gd b/scripts/Contents/Bullets/ChickSprint.gd index a177401..f19fdeb 100644 --- a/scripts/Contents/Bullets/ChickSprint.gd +++ b/scripts/Contents/Bullets/ChickSprint.gd @@ -11,4 +11,4 @@ func ai(): tryDestroy() func destroy(beacuseMap: bool): if beacuseMap: - launcher.takeDamage(self, MathTool.rate(0.5)) + launcher.bulletHit(self, MathTool.rate(0.5)) diff --git a/scripts/Contents/Weapons/Bow.gd b/scripts/Contents/Weapons/Bow.gd new file mode 100644 index 0000000..4514006 --- /dev/null +++ b/scripts/Contents/Weapons/Bow.gd @@ -0,0 +1,20 @@ +@tool +extends Weapon + +func update(to: int, origin: Dictionary, _entity: EntityBase): + origin["atk"] += 0.05 * to * soulLevel + origin["count"] = 1 * soulLevel + origin["self"] += 0.1 * to + return origin +func attack(entity: EntityBase): + entity.takeDamage(readStore("self")) + var weaponPos = entity.findWeaponAnchor("normal") + for i in BulletBase.generate( + ComponentManager.getBullet("Bow"), + entity, + weaponPos, + weaponPos.angle_to_point(get_global_mouse_position()) + ): + var bullet: Bow = i + bullet.count = readStore("count") + bullet.atk = readStore("atk") diff --git a/scripts/Contents/Weapons/Bow.gd.uid b/scripts/Contents/Weapons/Bow.gd.uid new file mode 100644 index 0000000..ab0da86 --- /dev/null +++ b/scripts/Contents/Weapons/Bow.gd.uid @@ -0,0 +1 @@ +uid://1u8t36atj041 diff --git a/scripts/Statemachine/BulletBase.gd b/scripts/Statemachine/BulletBase.gd index 199378a..4d2ab52 100644 --- a/scripts/Statemachine/BulletBase.gd +++ b/scripts/Statemachine/BulletBase.gd @@ -88,7 +88,7 @@ func hit(target: Node): var entity: EntityBase = EntityTool.fromHurtbox(target) if !entity || !launcher: return if !BulletTool.canDamage(self, entity): return - var resultDamage = entity.takeDamage(self, MathTool.rate(launcher.fields.get(FieldStore.Entity.CRIT_RATE) + GameRule.critRateInfluenceByLuckValue * launcher.fields[FieldStore.Entity.LUCK_VALUE])) + var resultDamage = entity.bulletHit(self, MathTool.rate(launcher.fields.get(FieldStore.Entity.CRIT_RATE) + GameRule.critRateInfluenceByLuckValue * launcher.fields[FieldStore.Entity.LUCK_VALUE])) succeedToHit(resultDamage, entity) if MathTool.rate(fullPenerate()): penerate -= entity.fields[FieldStore.Entity.PENARATION_RESISTANCE] diff --git a/scripts/Statemachine/EntityBase.gd b/scripts/Statemachine/EntityBase.gd index b79465f..50fece2 100644 --- a/scripts/Statemachine/EntityBase.gd +++ b/scripts/Statemachine/EntityBase.gd @@ -224,7 +224,15 @@ func getSprintInitialDisplace(): return displace(velocity) * sprintMultiplier func getSprintProgress(): return velocity.length() / getSprintInitialDisplace().length() -func takeDamage(bullet: BulletBase, crit: bool): +func takeDamage(baseDamage: float, crit: bool = false, perfectMiss: bool = false): + var resultDamage = baseDamage + baseDamage * int(crit) * fields.get(FieldStore.Entity.CRIT_DAMAGE) + health -= resultDamage + healthChanged.emit(health) + DamageLabel.create(resultDamage, crit || perfectMiss, damageAnchor.global_position + MathTool.randv2_range(GameRule.damageLabelSpawnOffset)) + if health <= 0: + tryDie(null) + return resultDamage +func bulletHit(bullet: BulletBase, crit: bool): # 当受伤时 hurtAnimator.play("hurt") var baseDamage: float = bullet.damage * bullet.launcher.fields.get(FieldStore.Entity.DAMAGE_MULTIPILER) * randf_range(1 - GameRule.damageOffset, 1 + GameRule.damageOffset)