mirror of
https://github.com/Rundll86/Dog-Lynx-And-HCN.git
synced 2026-05-28 06:51:54 +08:00
feat(障碍物系统): 添加草墙障碍物及相关功能
实现草墙障碍物系统,包括以下主要变更: - 新增草墙障碍物资源、脚本和场景 - 添加障碍物状态显示UI - 扩展组件管理器支持障碍物类型 - 修改子弹系统以支持对障碍物的碰撞检测 - 调整实体碰撞层设置 - 为公鸡角色添加草墙武器 新增功能允许玩家放置可阻挡敌人的草墙障碍物,并显示其生命值状态
This commit is contained in:
@@ -347,7 +347,6 @@ alpha_curve = SubResource("CurveTexture_vvfxd")
|
|||||||
[sub_resource type="CircleShape2D" id="CircleShape2D_34h7q"]
|
[sub_resource type="CircleShape2D" id="CircleShape2D_34h7q"]
|
||||||
|
|
||||||
[node name="EntityBase" type="CharacterBody2D"]
|
[node name="EntityBase" type="CharacterBody2D"]
|
||||||
collision_layer = 0
|
|
||||||
script = ExtResource("1_mvol6")
|
script = ExtResource("1_mvol6")
|
||||||
|
|
||||||
[node name="syncer" type="MultiplayerSynchronizer" parent="."]
|
[node name="syncer" type="MultiplayerSynchronizer" parent="."]
|
||||||
|
|||||||
@@ -0,0 +1,40 @@
|
|||||||
|
[gd_scene load_steps=6 format=3 uid="uid://dwydudqawsiqi"]
|
||||||
|
|
||||||
|
[ext_resource type="Texture2D" uid="uid://dwwpkn4q07ja2" path="res://icon.svg" id="1_4helc"]
|
||||||
|
[ext_resource type="Script" uid="uid://bj26s4i47bw0a" path="res://scripts/Statemachine/ObstacleBase.gd" id="1_b4dgm"]
|
||||||
|
[ext_resource type="PackedScene" uid="uid://copkyentuuxpt" path="res://components/UI/ObstacleStateBar.tscn" id="3_esd5c"]
|
||||||
|
|
||||||
|
[sub_resource type="SpriteFrames" id="SpriteFrames_b4dgm"]
|
||||||
|
animations = [{
|
||||||
|
"frames": [{
|
||||||
|
"duration": 1.0,
|
||||||
|
"texture": ExtResource("1_4helc")
|
||||||
|
}],
|
||||||
|
"loop": true,
|
||||||
|
"name": &"default",
|
||||||
|
"speed": 5.0
|
||||||
|
}]
|
||||||
|
|
||||||
|
[sub_resource type="CircleShape2D" id="CircleShape2D_1gjhb"]
|
||||||
|
radius = 70.00714
|
||||||
|
|
||||||
|
[node name="ObstacleBase" type="StaticBody2D"]
|
||||||
|
script = ExtResource("1_b4dgm")
|
||||||
|
healthMax = null
|
||||||
|
penerateResistance = null
|
||||||
|
blockPlayer = null
|
||||||
|
blockEnemy = null
|
||||||
|
|
||||||
|
[node name="texture" type="AnimatedSprite2D" parent="."]
|
||||||
|
unique_name_in_owner = true
|
||||||
|
sprite_frames = SubResource("SpriteFrames_b4dgm")
|
||||||
|
|
||||||
|
[node name="statebar" parent="texture" node_paths=PackedStringArray("obstacle") instance=ExtResource("3_esd5c")]
|
||||||
|
unique_name_in_owner = true
|
||||||
|
position = Vector2(0, -86)
|
||||||
|
obstacle = NodePath("../..")
|
||||||
|
|
||||||
|
[node name="hitbox" type="CollisionShape2D" parent="."]
|
||||||
|
unique_name_in_owner = true
|
||||||
|
shape = SubResource("CircleShape2D_1gjhb")
|
||||||
|
debug_color = Color(1, 0.09928554, 0, 0.41960785)
|
||||||
@@ -1,7 +1,8 @@
|
|||||||
[gd_scene load_steps=13 format=3 uid="uid://dky8574uqc18r"]
|
[gd_scene load_steps=14 format=3 uid="uid://dky8574uqc18r"]
|
||||||
|
|
||||||
[ext_resource type="PackedScene" uid="uid://cvogxi7mktumf" path="res://components/Abstracts/EntityBase.tscn" id="1_e5pl8"]
|
[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="Script" uid="uid://cthtupc6dtbav" path="res://scripts/Contents/Characters/Rooster.gd" id="2_oqdqd"]
|
||||||
|
[ext_resource type="PackedScene" uid="uid://dldnbpubu2jgm" path="res://components/Weapons/GrassWall.tscn" id="3_0omr3"]
|
||||||
[ext_resource type="PackedScene" uid="uid://b5ebx8duvgtt5" path="res://components/Weapons/Oxygener.tscn" id="3_da2ca"]
|
[ext_resource type="PackedScene" uid="uid://b5ebx8duvgtt5" path="res://components/Weapons/Oxygener.tscn" id="3_da2ca"]
|
||||||
[ext_resource type="AudioStream" uid="uid://cdrevrq7n6yqa" path="res://resources/sounds/effect/Boing.mp3" id="4_66s6c"]
|
[ext_resource type="AudioStream" uid="uid://cdrevrq7n6yqa" path="res://resources/sounds/effect/Boing.mp3" id="4_66s6c"]
|
||||||
[ext_resource type="AudioStream" uid="uid://benyec5bqni0b" path="res://resources/sounds/effect/Chomp.wav" id="4_k0yme"]
|
[ext_resource type="AudioStream" uid="uid://benyec5bqni0b" path="res://resources/sounds/effect/Chomp.wav" id="4_k0yme"]
|
||||||
@@ -58,7 +59,10 @@ metadata/_edit_vertical_guides_ = [71.0]
|
|||||||
[node name="weaponStore" parent="." index="1"]
|
[node name="weaponStore" parent="." index="1"]
|
||||||
process_mode = 4
|
process_mode = 4
|
||||||
|
|
||||||
[node name="Oxygener" parent="weaponStore" index="0" instance=ExtResource("3_da2ca")]
|
[node name="GrassWall" parent="weaponStore" index="0" instance=ExtResource("3_0omr3")]
|
||||||
|
offset_bottom = 374.0
|
||||||
|
|
||||||
|
[node name="Oxygener" parent="weaponStore" index="1" instance=ExtResource("3_da2ca")]
|
||||||
debugRebuild = false
|
debugRebuild = false
|
||||||
|
|
||||||
[node name="sprint" parent="sounds" index="0"]
|
[node name="sprint" parent="sounds" index="0"]
|
||||||
|
|||||||
@@ -0,0 +1,36 @@
|
|||||||
|
[gd_scene load_steps=5 format=3 uid="uid://bu2qnw81241wv"]
|
||||||
|
|
||||||
|
[ext_resource type="PackedScene" uid="uid://dwydudqawsiqi" path="res://components/Abstracts/ObstacleBase.tscn" id="1_76v8o"]
|
||||||
|
[ext_resource type="Texture2D" uid="uid://vmd6kegvbs31" path="res://resources/characters/grass-wall/grasswall.png" id="2_7gks2"]
|
||||||
|
|
||||||
|
[sub_resource type="SpriteFrames" id="SpriteFrames_pu7bs"]
|
||||||
|
animations = [{
|
||||||
|
"frames": [{
|
||||||
|
"duration": 1.0,
|
||||||
|
"texture": ExtResource("2_7gks2")
|
||||||
|
}],
|
||||||
|
"loop": true,
|
||||||
|
"name": &"default",
|
||||||
|
"speed": 5.0
|
||||||
|
}]
|
||||||
|
|
||||||
|
[sub_resource type="RectangleShape2D" id="RectangleShape2D_qvy1c"]
|
||||||
|
size = Vector2(700, 60)
|
||||||
|
|
||||||
|
[node name="GrassWall" instance=ExtResource("1_76v8o")]
|
||||||
|
healthMax = 100.0
|
||||||
|
penerateResistance = 0.0
|
||||||
|
blockPlayer = false
|
||||||
|
blockEnemy = true
|
||||||
|
|
||||||
|
[node name="texture" parent="." index="0"]
|
||||||
|
rotation = 1.5707964
|
||||||
|
sprite_frames = SubResource("SpriteFrames_pu7bs")
|
||||||
|
|
||||||
|
[node name="statebar" parent="texture" index="0"]
|
||||||
|
position = Vector2(-374, 0)
|
||||||
|
rotation = -1.5707964
|
||||||
|
|
||||||
|
[node name="hitbox" parent="." index="1"]
|
||||||
|
rotation = 1.5707964
|
||||||
|
shape = SubResource("RectangleShape2D_qvy1c")
|
||||||
@@ -92,6 +92,8 @@ libraries = {
|
|||||||
}
|
}
|
||||||
|
|
||||||
[node name="map" type="StaticBody2D" parent="." groups=["map"]]
|
[node name="map" type="StaticBody2D" parent="." groups=["map"]]
|
||||||
|
collision_layer = 6
|
||||||
|
collision_mask = 6
|
||||||
metadata/_edit_lock_ = true
|
metadata/_edit_lock_ = true
|
||||||
|
|
||||||
[node name="background" type="Sprite2D" parent="map"]
|
[node name="background" type="Sprite2D" parent="map"]
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
[gd_scene load_steps=17 format=3 uid="uid://cxcvc1rjvm8i2"]
|
[gd_scene load_steps=17 format=3 uid="uid://cxcvc1rjvm8i2"]
|
||||||
|
|
||||||
[ext_resource type="Script" path="res://scripts/Statemachine/ItemDropped.gd" id="1_v2djl"]
|
[ext_resource type="Script" uid="uid://cfxrtel5gjia0" path="res://scripts/Statemachine/ItemDropped.gd" id="1_v2djl"]
|
||||||
[ext_resource type="Texture2D" uid="uid://bks8jmctleina" path="res://resources/items/baseball.svg" id="2_4hl42"]
|
[ext_resource type="Texture2D" uid="uid://bks8jmctleina" path="res://resources/items/baseball.svg" id="2_4hl42"]
|
||||||
|
|
||||||
[sub_resource type="PhysicsMaterial" id="PhysicsMaterial_1ishj"]
|
[sub_resource type="PhysicsMaterial" id="PhysicsMaterial_1ishj"]
|
||||||
@@ -81,8 +81,8 @@ tracks/2/keys = {
|
|||||||
|
|
||||||
[sub_resource type="AnimationLibrary" id="AnimationLibrary_2q7p1"]
|
[sub_resource type="AnimationLibrary" id="AnimationLibrary_2q7p1"]
|
||||||
_data = {
|
_data = {
|
||||||
"RESET": SubResource("Animation_5i70v"),
|
&"RESET": SubResource("Animation_5i70v"),
|
||||||
"collect": SubResource("Animation_l0b83")
|
&"collect": SubResource("Animation_l0b83")
|
||||||
}
|
}
|
||||||
|
|
||||||
[sub_resource type="CircleShape2D" id="CircleShape2D_7lt1c"]
|
[sub_resource type="CircleShape2D" id="CircleShape2D_7lt1c"]
|
||||||
@@ -96,7 +96,7 @@ point_count = 2
|
|||||||
curve = SubResource("Curve_11h7l")
|
curve = SubResource("Curve_11h7l")
|
||||||
|
|
||||||
[sub_resource type="Curve" id="Curve_h22hm"]
|
[sub_resource type="Curve" id="Curve_h22hm"]
|
||||||
min_value = -1.0
|
_limits = [-1.0, 1.0, 0.0, 1.0]
|
||||||
_data = [Vector2(0, 1), 0.0, 0.0, 0, 0, Vector2(1, -1), 0.0, 0.0, 0, 0]
|
_data = [Vector2(0, 1), 0.0, 0.0, 0, 0, Vector2(1, -1), 0.0, 0.0, 0, 0]
|
||||||
point_count = 2
|
point_count = 2
|
||||||
|
|
||||||
@@ -131,8 +131,8 @@ color_initial_ramp = SubResource("GradientTexture1D_5p7rs")
|
|||||||
alpha_curve = SubResource("CurveTexture_u4ger")
|
alpha_curve = SubResource("CurveTexture_u4ger")
|
||||||
|
|
||||||
[node name="ItemDropped" type="RigidBody2D"]
|
[node name="ItemDropped" type="RigidBody2D"]
|
||||||
collision_layer = 2
|
collision_layer = 512
|
||||||
collision_mask = 2
|
collision_mask = 512
|
||||||
physics_material_override = SubResource("PhysicsMaterial_1ishj")
|
physics_material_override = SubResource("PhysicsMaterial_1ishj")
|
||||||
contact_monitor = true
|
contact_monitor = true
|
||||||
max_contacts_reported = 1
|
max_contacts_reported = 1
|
||||||
@@ -147,7 +147,7 @@ texture = ExtResource("2_4hl42")
|
|||||||
[node name="animator" type="AnimationPlayer" parent="texture"]
|
[node name="animator" type="AnimationPlayer" parent="texture"]
|
||||||
unique_name_in_owner = true
|
unique_name_in_owner = true
|
||||||
libraries = {
|
libraries = {
|
||||||
"": SubResource("AnimationLibrary_2q7p1")
|
&"": SubResource("AnimationLibrary_2q7p1")
|
||||||
}
|
}
|
||||||
|
|
||||||
[node name="hitbox" type="CollisionShape2D" parent="."]
|
[node name="hitbox" type="CollisionShape2D" parent="."]
|
||||||
|
|||||||
@@ -0,0 +1,61 @@
|
|||||||
|
[gd_scene load_steps=7 format=3 uid="uid://copkyentuuxpt"]
|
||||||
|
|
||||||
|
[ext_resource type="Script" uid="uid://dkt4yqm0juwic" path="res://scripts/Statemachine/ObstacleStateBar.gd" id="1_a6rqj"]
|
||||||
|
[ext_resource type="PackedScene" uid="uid://d1ulrvupa76ap" path="res://components/UI/ColorBar.tscn" id="2_vl2cs"]
|
||||||
|
|
||||||
|
[sub_resource type="StyleBoxFlat" id="StyleBoxFlat_w56p2"]
|
||||||
|
bg_color = Color(0, 0, 0, 0.5)
|
||||||
|
|
||||||
|
[sub_resource type="StyleBoxFlat" id="StyleBoxFlat_2sar3"]
|
||||||
|
bg_color = Color(1, 0, 0, 0.5)
|
||||||
|
|
||||||
|
[sub_resource type="StyleBoxFlat" id="StyleBoxFlat_i0t67"]
|
||||||
|
bg_color = Color(0, 1, 0, 0.5)
|
||||||
|
|
||||||
|
[sub_resource type="StyleBoxFlat" id="StyleBoxFlat_jxamg"]
|
||||||
|
bg_color = Color(1, 1, 1, 1)
|
||||||
|
|
||||||
|
[node name="ObstacleStateBar" type="Node2D"]
|
||||||
|
script = ExtResource("1_a6rqj")
|
||||||
|
|
||||||
|
[node name="health" parent="." instance=ExtResource("2_vl2cs")]
|
||||||
|
unique_name_in_owner = true
|
||||||
|
offset_left = -50.0
|
||||||
|
offset_top = -5.0
|
||||||
|
offset_right = 50.0
|
||||||
|
offset_bottom = 5.0
|
||||||
|
backBox = SubResource("StyleBoxFlat_w56p2")
|
||||||
|
middleBox1 = SubResource("StyleBoxFlat_2sar3")
|
||||||
|
middleBox2 = SubResource("StyleBoxFlat_i0t67")
|
||||||
|
frontBox = SubResource("StyleBoxFlat_jxamg")
|
||||||
|
|
||||||
|
[node name="levelLabel" type="HBoxContainer" parent="health"]
|
||||||
|
unique_name_in_owner = true
|
||||||
|
layout_mode = 1
|
||||||
|
anchors_preset = -1
|
||||||
|
anchor_left = 0.5
|
||||||
|
anchor_top = -2.0
|
||||||
|
anchor_right = 0.5
|
||||||
|
anchor_bottom = -2.0
|
||||||
|
offset_left = -25.0
|
||||||
|
offset_top = -4.0
|
||||||
|
offset_right = 26.0
|
||||||
|
offset_bottom = 20.0
|
||||||
|
grow_horizontal = 2
|
||||||
|
alignment = 1
|
||||||
|
|
||||||
|
[node name="current" type="Label" parent="health/levelLabel"]
|
||||||
|
unique_name_in_owner = true
|
||||||
|
layout_mode = 2
|
||||||
|
size_flags_vertical = 8
|
||||||
|
text = "0"
|
||||||
|
|
||||||
|
[node name="separator" type="Label" parent="health/levelLabel"]
|
||||||
|
layout_mode = 2
|
||||||
|
text = "/"
|
||||||
|
|
||||||
|
[node name="max" type="Label" parent="health/levelLabel"]
|
||||||
|
unique_name_in_owner = true
|
||||||
|
layout_mode = 2
|
||||||
|
size_flags_vertical = 8
|
||||||
|
text = "100"
|
||||||
@@ -0,0 +1,34 @@
|
|||||||
|
[gd_scene load_steps=4 format=3 uid="uid://dldnbpubu2jgm"]
|
||||||
|
|
||||||
|
[ext_resource type="PackedScene" uid="uid://ckq2cq6m23hq3" path="res://components/Abstracts/WeaponCardBase.tscn" id="1_wvaxu"]
|
||||||
|
[ext_resource type="Texture2D" uid="uid://bbv5j71jkdo42" path="res://resources/weapons/grass-wall.png" id="2_kh4xg"]
|
||||||
|
[ext_resource type="Script" uid="uid://7bmrk88b4ipd" path="res://scripts/Contents/Weapons/GrassWall.gd" id="2_us6b7"]
|
||||||
|
|
||||||
|
[node name="GrassWall" instance=ExtResource("1_wvaxu")]
|
||||||
|
script = ExtResource("2_us6b7")
|
||||||
|
avatarTexture = ExtResource("2_kh4xg")
|
||||||
|
displayName = "草方块菌落"
|
||||||
|
typeTopic = 4
|
||||||
|
costBeachball = 10
|
||||||
|
store = {
|
||||||
|
"atk": 200
|
||||||
|
}
|
||||||
|
descriptionTemplate = "分泌一堵[b]肽聚墙[/b],可抵挡$atk点伤害,敌人更有可能瞄准你。"
|
||||||
|
needEnergy = 35.0
|
||||||
|
cooldown = 2000.0
|
||||||
|
|
||||||
|
[node name="avatar" parent="container/info" index="0"]
|
||||||
|
texture = ExtResource("2_kh4xg")
|
||||||
|
|
||||||
|
[node name="energy" parent="container/info/infos/energyInfo" index="1"]
|
||||||
|
text = "35.0"
|
||||||
|
|
||||||
|
[node name="beachball" parent="container/info/infos" index="1"]
|
||||||
|
count = 10
|
||||||
|
|
||||||
|
[node name="name" parent="container/info" index="2"]
|
||||||
|
displayName = "草方块菌落"
|
||||||
|
typeTopic = 4
|
||||||
|
|
||||||
|
[node name="description" parent="container" index="2"]
|
||||||
|
text = "[center]分泌一堵[b]肽聚墙[/b],可抵挡[color=cyan]10[/color]点伤害,敌人更有可能瞄准你。[/center]"
|
||||||
Binary file not shown.
|
After Width: | Height: | Size: 82 KiB |
@@ -0,0 +1,40 @@
|
|||||||
|
[remap]
|
||||||
|
|
||||||
|
importer="texture"
|
||||||
|
type="CompressedTexture2D"
|
||||||
|
uid="uid://vmd6kegvbs31"
|
||||||
|
path="res://.godot/imported/grasswall.png-a9cd68f8aafb229a72bf98dd0f269076.ctex"
|
||||||
|
metadata={
|
||||||
|
"vram_texture": false
|
||||||
|
}
|
||||||
|
|
||||||
|
[deps]
|
||||||
|
|
||||||
|
source_file="res://resources/characters/grass-wall/grasswall.png"
|
||||||
|
dest_files=["res://.godot/imported/grasswall.png-a9cd68f8aafb229a72bf98dd0f269076.ctex"]
|
||||||
|
|
||||||
|
[params]
|
||||||
|
|
||||||
|
compress/mode=0
|
||||||
|
compress/high_quality=false
|
||||||
|
compress/lossy_quality=0.7
|
||||||
|
compress/uastc_level=0
|
||||||
|
compress/rdo_quality_loss=0.0
|
||||||
|
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/channel_remap/red=0
|
||||||
|
process/channel_remap/green=1
|
||||||
|
process/channel_remap/blue=2
|
||||||
|
process/channel_remap/alpha=3
|
||||||
|
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
|
||||||
Binary file not shown.
|
After Width: | Height: | Size: 150 KiB |
@@ -0,0 +1,40 @@
|
|||||||
|
[remap]
|
||||||
|
|
||||||
|
importer="texture"
|
||||||
|
type="CompressedTexture2D"
|
||||||
|
uid="uid://bbv5j71jkdo42"
|
||||||
|
path="res://.godot/imported/grass-wall.png-f17b6b57be78b0c73c8ea21baa6757c6.ctex"
|
||||||
|
metadata={
|
||||||
|
"vram_texture": false
|
||||||
|
}
|
||||||
|
|
||||||
|
[deps]
|
||||||
|
|
||||||
|
source_file="res://resources/weapons/grass-wall.png"
|
||||||
|
dest_files=["res://.godot/imported/grass-wall.png-f17b6b57be78b0c73c8ea21baa6757c6.ctex"]
|
||||||
|
|
||||||
|
[params]
|
||||||
|
|
||||||
|
compress/mode=0
|
||||||
|
compress/high_quality=false
|
||||||
|
compress/lossy_quality=0.7
|
||||||
|
compress/uastc_level=0
|
||||||
|
compress/rdo_quality_loss=0.0
|
||||||
|
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/channel_remap/red=0
|
||||||
|
process/channel_remap/green=1
|
||||||
|
process/channel_remap/blue=2
|
||||||
|
process/channel_remap/alpha=3
|
||||||
|
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
|
||||||
@@ -0,0 +1,14 @@
|
|||||||
|
@tool
|
||||||
|
extends Weapon
|
||||||
|
|
||||||
|
func update(to: int, origin: Dictionary, _entity: EntityBase):
|
||||||
|
origin["atk"] += 3 * to * soulLevel
|
||||||
|
return origin
|
||||||
|
func attack(entity: EntityBase):
|
||||||
|
var wall = ObstacleBase.generate(
|
||||||
|
ComponentManager.getObstacle("GrassWall"),
|
||||||
|
get_global_mouse_position(),
|
||||||
|
entity.findWeaponAnchor("normal").angle_to_point(get_global_mouse_position()),
|
||||||
|
entity
|
||||||
|
)
|
||||||
|
wall.initHealth(readStore("atk"))
|
||||||
@@ -0,0 +1 @@
|
|||||||
|
uid://7bmrk88b4ipd
|
||||||
@@ -44,7 +44,8 @@ func _ready():
|
|||||||
launcherSummoned = launcher
|
launcherSummoned = launcher
|
||||||
launcher = launcher.myMaster
|
launcher = launcher.myMaster
|
||||||
register()
|
register()
|
||||||
area_entered.connect(hit)
|
area_entered.connect(hitEntity)
|
||||||
|
body_entered.connect(hitObstacle)
|
||||||
spawnInWhen = WorldManager.getTime()
|
spawnInWhen = WorldManager.getTime()
|
||||||
spawnInWhere = position
|
spawnInWhere = position
|
||||||
spawn()
|
spawn()
|
||||||
@@ -107,16 +108,31 @@ func setupCuttable(cutSpeed: float):
|
|||||||
)
|
)
|
||||||
func getDamage():
|
func getDamage():
|
||||||
return baseDamage * damageMultipliers[usingDamageMultiplier]
|
return baseDamage * damageMultipliers[usingDamageMultiplier]
|
||||||
func hit(target: Node):
|
func calculateDamage(crit: bool):
|
||||||
|
var baseDmg = getDamage() * launcher.fields.get(FieldStore.Entity.DAMAGE_MULTIPILER) * randf_range(1 - GameRule.damageOffset, 1 + GameRule.damageOffset)
|
||||||
|
var damage = baseDmg + baseDmg * int(crit) * launcher.fields.get(FieldStore.Entity.CRIT_DAMAGE)
|
||||||
|
return damage
|
||||||
|
func determineCrit():
|
||||||
|
return MathTool.rate(launcher.fields.get(FieldStore.Entity.CRIT_RATE) + GameRule.critRateInfluenceByLuckValue * launcher.fields[FieldStore.Entity.LUCK_VALUE])
|
||||||
|
func hitEntity(target: Node):
|
||||||
var entity: EntityBase = EntityTool.fromHurtbox(target)
|
var entity: EntityBase = EntityTool.fromHurtbox(target)
|
||||||
if !BulletTool.canDamage(self, entity): return
|
if !BulletTool.canDamage(self, entity): return
|
||||||
var resultDamage = entity.bulletHit(self, MathTool.rate(launcher.fields.get(FieldStore.Entity.CRIT_RATE) + GameRule.critRateInfluenceByLuckValue * launcher.fields[FieldStore.Entity.LUCK_VALUE]))
|
var resultDamage = entity.bulletHit(self, determineCrit())
|
||||||
succeedToHit(resultDamage, entity)
|
succeedToHit(resultDamage, entity)
|
||||||
if MathTool.rate(fullPenerate()):
|
if MathTool.rate(fullPenerate() - entity.fields[FieldStore.Entity.PENARATION_RESISTANCE]):
|
||||||
penerate -= entity.fields[FieldStore.Entity.PENARATION_RESISTANCE]
|
|
||||||
baseDamage *= 1.0 - penerateDamageReduction
|
baseDamage *= 1.0 - penerateDamageReduction
|
||||||
else:
|
else:
|
||||||
tryDestroy()
|
tryDestroy()
|
||||||
|
func hitObstacle(target: Node):
|
||||||
|
if target is ObstacleBase:
|
||||||
|
var obstacle = target as ObstacleBase
|
||||||
|
if is_instance_valid(obstacle.launcher):
|
||||||
|
if not BulletTool.canDamage(self, obstacle.launcher): return
|
||||||
|
obstacle.takeDamage(calculateDamage(determineCrit()))
|
||||||
|
if MathTool.rate(fullPenerate() - obstacle.penerateResistance):
|
||||||
|
baseDamage *= 1.0 - penerateDamageReduction
|
||||||
|
else:
|
||||||
|
tryDestroy()
|
||||||
func forward(direction: Vector2):
|
func forward(direction: Vector2):
|
||||||
position += direction.normalized() * speed * GameRule.bulletSpeedMultiplier
|
position += direction.normalized() * speed * GameRule.bulletSpeedMultiplier
|
||||||
func fullPenerate():
|
func fullPenerate():
|
||||||
|
|||||||
@@ -8,6 +8,10 @@ signal died()
|
|||||||
|
|
||||||
signal energyChanged(energy: float, dontChangeDirection: bool)
|
signal energyChanged(energy: float, dontChangeDirection: bool)
|
||||||
|
|
||||||
|
enum Layers {
|
||||||
|
PLAYER = 1 << 2,
|
||||||
|
ENEMY = 1 << 1,
|
||||||
|
}
|
||||||
const TITLE_FLAG = INF
|
const TITLE_FLAG = INF
|
||||||
var fields = {
|
var fields = {
|
||||||
"生存": TITLE_FLAG,
|
"生存": TITLE_FLAG,
|
||||||
@@ -143,8 +147,12 @@ func _ready():
|
|||||||
)
|
)
|
||||||
if displayName == MultiplayerState.playerName:
|
if displayName == MultiplayerState.playerName:
|
||||||
rebuildWeaponIcons()
|
rebuildWeaponIcons()
|
||||||
|
collision_layer = Layers.PLAYER
|
||||||
|
collision_mask = Layers.PLAYER
|
||||||
else:
|
else:
|
||||||
applyLevel()
|
applyLevel()
|
||||||
|
collision_layer = Layers.ENEMY
|
||||||
|
collision_mask = Layers.ENEMY
|
||||||
health = fields.get(FieldStore.Entity.MAX_HEALTH)
|
health = fields.get(FieldStore.Entity.MAX_HEALTH)
|
||||||
energy = fields.get(FieldStore.Entity.MAX_ENERGY)
|
energy = fields.get(FieldStore.Entity.MAX_ENERGY)
|
||||||
if is_instance_valid(statebar):
|
if is_instance_valid(statebar):
|
||||||
@@ -242,8 +250,7 @@ func takeDamage(baseDamage: float, crit: bool = false, perfectMiss: bool = false
|
|||||||
func bulletHit(bullet: BulletBase, crit: bool):
|
func bulletHit(bullet: BulletBase, crit: bool):
|
||||||
# 当受伤时
|
# 当受伤时
|
||||||
hurtAnimator.play("hurt")
|
hurtAnimator.play("hurt")
|
||||||
var baseDamage: float = bullet.getDamage() * bullet.launcher.fields.get(FieldStore.Entity.DAMAGE_MULTIPILER) * randf_range(1 - GameRule.damageOffset, 1 + GameRule.damageOffset)
|
var damage = bullet.calculateDamage(crit)
|
||||||
var damage = baseDamage + baseDamage * int(crit) * fields.get(FieldStore.Entity.CRIT_DAMAGE)
|
|
||||||
var perfectMiss = false
|
var perfectMiss = false
|
||||||
if sprinting:
|
if sprinting:
|
||||||
playSound("miss")
|
playSound("miss")
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
extends Node
|
extends CanvasItem
|
||||||
class_name EntityStateBar
|
class_name EntityStateBar
|
||||||
|
|
||||||
@export var entity: EntityBase
|
@export var entity: EntityBase
|
||||||
|
|||||||
@@ -0,0 +1,64 @@
|
|||||||
|
extends StaticBody2D
|
||||||
|
class_name ObstacleBase
|
||||||
|
|
||||||
|
signal healthChanged(newHealth: float)
|
||||||
|
|
||||||
|
@export var healthMax: float = 100
|
||||||
|
@export var penerateResistance: float = 0
|
||||||
|
@export var blockPlayer: bool = false
|
||||||
|
@export var blockEnemy: bool = false
|
||||||
|
|
||||||
|
@onready var statebar: ObstacleStateBar = $%statebar
|
||||||
|
@onready var texture: AnimatedSprite2D = $%texture
|
||||||
|
@onready var hitbox: CollisionShape2D = $%hitbox
|
||||||
|
var health: float = 0
|
||||||
|
var launcher: EntityBase = null
|
||||||
|
|
||||||
|
func _ready():
|
||||||
|
health = healthMax
|
||||||
|
if blockPlayer:
|
||||||
|
collision_layer |= EntityBase.Layers.PLAYER
|
||||||
|
collision_mask |= EntityBase.Layers.PLAYER
|
||||||
|
if blockEnemy:
|
||||||
|
collision_layer |= EntityBase.Layers.ENEMY
|
||||||
|
collision_mask |= EntityBase.Layers.ENEMY
|
||||||
|
healthChanged.connect(
|
||||||
|
func(newHealth):
|
||||||
|
statebar.healthBar.maxValue = healthMax
|
||||||
|
statebar.healthBar.setCurrent(newHealth)
|
||||||
|
)
|
||||||
|
func _process(_delta):
|
||||||
|
statebar.global_rotation = 0
|
||||||
|
statebar.applyText()
|
||||||
|
|
||||||
|
func initHealth(maxHealth: float):
|
||||||
|
healthMax = maxHealth
|
||||||
|
health = healthMax
|
||||||
|
statebar.forceSync()
|
||||||
|
statebar.applyText()
|
||||||
|
func takeDamage(damage: float):
|
||||||
|
health -= damage
|
||||||
|
healthChanged.emit(health)
|
||||||
|
if health <= 0:
|
||||||
|
tryDie()
|
||||||
|
func tryDie():
|
||||||
|
die()
|
||||||
|
queue_free()
|
||||||
|
|
||||||
|
func die():
|
||||||
|
pass
|
||||||
|
|
||||||
|
static func generate(
|
||||||
|
obstacle: PackedScene,
|
||||||
|
spawnPosition: Vector2,
|
||||||
|
spawnRotation: float = 0,
|
||||||
|
itsLauncher: EntityBase = null,
|
||||||
|
addToWorld: bool = true
|
||||||
|
) -> ObstacleBase:
|
||||||
|
var instance: ObstacleBase = obstacle.instantiate()
|
||||||
|
instance.position = spawnPosition
|
||||||
|
instance.rotation = spawnRotation
|
||||||
|
instance.launcher = itsLauncher
|
||||||
|
if addToWorld:
|
||||||
|
WorldManager.rootNode.spawn(instance)
|
||||||
|
return instance
|
||||||
@@ -0,0 +1 @@
|
|||||||
|
uid://bj26s4i47bw0a
|
||||||
@@ -0,0 +1,17 @@
|
|||||||
|
extends Node2D
|
||||||
|
class_name ObstacleStateBar
|
||||||
|
|
||||||
|
@export var obstacle: ObstacleBase
|
||||||
|
|
||||||
|
@onready var healthBar: ColorBar = $%health
|
||||||
|
@onready var currentLabel: Label = $%current
|
||||||
|
@onready var maxLabel: Label = $%max
|
||||||
|
@onready var levelLabelContainer: HBoxContainer = $%levelLabel
|
||||||
|
|
||||||
|
func forceSync():
|
||||||
|
healthBar.maxValue = obstacle.healthMax
|
||||||
|
healthBar.currentValue = obstacle.health
|
||||||
|
healthBar.forceSync()
|
||||||
|
func applyText():
|
||||||
|
currentLabel.text = "%d" % obstacle.health
|
||||||
|
maxLabel.text = "%d" % obstacle.healthMax
|
||||||
@@ -0,0 +1 @@
|
|||||||
|
uid://dkt4yqm0juwic
|
||||||
@@ -8,6 +8,7 @@ static var weapons = {}
|
|||||||
static var summons = {}
|
static var summons = {}
|
||||||
static var effects = {}
|
static var effects = {}
|
||||||
static var feeds = []
|
static var feeds = []
|
||||||
|
static var obstacles = {}
|
||||||
static var uiComponents = {}
|
static var uiComponents = {}
|
||||||
static var themes = {}
|
static var themes = {}
|
||||||
static var fieldTextures = {}
|
static var fieldTextures = {}
|
||||||
@@ -26,6 +27,8 @@ static func init():
|
|||||||
effects[DirTool.getBasenameWithoutExtension(i)] = load(i)
|
effects[DirTool.getBasenameWithoutExtension(i)] = load(i)
|
||||||
for i in DirTool.listdir("res://components/Feeds"):
|
for i in DirTool.listdir("res://components/Feeds"):
|
||||||
feeds.append(load(i))
|
feeds.append(load(i))
|
||||||
|
for i in DirTool.listdir("res://components/Obstacles"):
|
||||||
|
obstacles[DirTool.getBasenameWithoutExtension(i)] = load(i)
|
||||||
for i in DirTool.listdir("res://components/UI"):
|
for i in DirTool.listdir("res://components/UI"):
|
||||||
uiComponents[DirTool.getBasenameWithoutExtension(i)] = load(i)
|
uiComponents[DirTool.getBasenameWithoutExtension(i)] = load(i)
|
||||||
for i in DirTool.listdir("res://themes"):
|
for i in DirTool.listdir("res://themes"):
|
||||||
@@ -48,6 +51,8 @@ static func getFeed(i: int) -> PackedScene:
|
|||||||
if i >= 0 and i < feeds.size():
|
if i >= 0 and i < feeds.size():
|
||||||
return feeds[i]
|
return feeds[i]
|
||||||
return null
|
return null
|
||||||
|
static func getObstacle(t: String) -> PackedScene:
|
||||||
|
return MathTool.priority(obstacles.get(t, false), load("res://components/Obstacles/%s.tscn" % t))
|
||||||
static func getUIComponent(t: String) -> PackedScene:
|
static func getUIComponent(t: String) -> PackedScene:
|
||||||
return MathTool.priority(uiComponents.get(t, false), load("res://components/UI/%s.tscn" % t))
|
return MathTool.priority(uiComponents.get(t, false), load("res://components/UI/%s.tscn" % t))
|
||||||
static func getTheme(t: String) -> Theme:
|
static func getTheme(t: String) -> Theme:
|
||||||
|
|||||||
Reference in New Issue
Block a user