1
1
mirror of https://github.com/Rundll86/Dog-Lynx-And-HCN.git synced 2026-05-27 22:41:56 +08:00

feat: 更新饲料和面板逻辑,添加香蕉饲料,重构UI组件和状态管理

This commit is contained in:
2025-08-26 22:31:28 +08:00
parent 51fc904a6a
commit 739be888f3
15 changed files with 103 additions and 22 deletions
+1 -1
View File
@@ -28,7 +28,7 @@ script = ExtResource("1_2ea75")
[node name="container" type="VBoxContainer" parent="."]
layout_mode = 2
theme_override_constants/separation = 20
theme_override_constants/separation = 10
[node name="selectBtn" type="Button" parent="container"]
unique_name_in_owner = true
+4
View File
@@ -37,6 +37,10 @@ radius = 41.0122
[node name="Rooster" instance=ExtResource("1_e5pl8")]
script = ExtResource("2_oqdqd")
cooldownUnit = 200.0
inventory = {
0: 100,
1: 100
}
[node name="sprint" parent="sounds" index="0"]
stream = ExtResource("4_66s6c")
+2 -2
View File
@@ -6,8 +6,8 @@
[node name="Banana" instance=ExtResource("1_vapev")]
avatarTexture = ExtResource("2_2mlfi")
displayName = "香蕉"
fields = Array[int]([0, 3])
fieldValues = Array[float]([10.0, 0.1])
fields = Array[int]([0, 3, 1])
fieldValues = Array[float]([10.0, 0.1, 0.1])
costs = Array[int]([0, 1])
costCounts = Array[int]([10, 5])
@@ -1,9 +1,11 @@
[gd_scene load_steps=3 format=3 uid="uid://1n28ji5sl6bx"]
[gd_scene load_steps=4 format=3 uid="uid://1n28ji5sl6bx"]
[ext_resource type="PackedScene" uid="uid://d3qojeqa3difn" path="res://components/Abstracts/FullscreenPanelBase.tscn" id="1_1wmro"]
[ext_resource type="PackedScene" uid="uid://bykwevnv7keeh" path="res://components/Abstracts/FeedCardBase.tscn" id="2_ae402"]
[ext_resource type="Script" path="res://scripts/Contents/Panels/MakeFeed.gd" id="2_pr610"]
[ext_resource type="PackedScene" uid="uid://btisbc7ehj4fo" path="res://components/Feeds/Banana.tscn" id="3_f2lyw"]
[node name="MakeFeed" instance=ExtResource("1_1wmro")]
script = ExtResource("2_pr610")
[node name="wrapper" parent="content" index="0"]
theme_override_constants/separation = 50
@@ -53,15 +55,19 @@ fit_content = true
autowrap_mode = 0
[node name="feedcards" type="HBoxContainer" parent="content/wrapper" index="1"]
unique_name_in_owner = true
layout_mode = 2
theme_override_constants/separation = 30
alignment = 1
[node name="FeedCard" parent="content/wrapper/feedcards" index="0" instance=ExtResource("2_ae402")]
layout_mode = 2
[node name="avaliableFeeds" type="Node" parent="content/wrapper" index="2"]
unique_name_in_owner = true
[node name="FeedCard2" parent="content/wrapper/feedcards" index="1" instance=ExtResource("2_ae402")]
layout_mode = 2
[node name="Banana" parent="content/wrapper/avaliableFeeds" index="0" instance=ExtResource("3_f2lyw")]
visible = false
[node name="FeedCard3" parent="content/wrapper/feedcards" index="2" instance=ExtResource("2_ae402")]
layout_mode = 2
[node name="Banana2" parent="content/wrapper/avaliableFeeds" index="1" instance=ExtResource("3_f2lyw")]
visible = false
[node name="Banana3" parent="content/wrapper/avaliableFeeds" index="2" instance=ExtResource("3_f2lyw")]
visible = false
+4 -2
View File
@@ -20,6 +20,7 @@ corner_radius_bottom_right = 5
corner_radius_bottom_left = 5
[node name="UI" type="CanvasLayer"]
process_mode = 3
script = ExtResource("1_f00a6")
[node name="root" type="Control" parent="."]
@@ -59,7 +60,8 @@ unique_name_in_owner = true
layout_mode = 2
type = 1
[node name="fullscreenPanels" type="Control" parent="root"]
[node name="panels" type="Control" parent="root"]
unique_name_in_owner = true
layout_mode = 1
anchors_preset = 15
anchor_right = 1.0
@@ -67,6 +69,6 @@ anchor_bottom = 1.0
grow_horizontal = 2
grow_vertical = 2
[node name="MakeFeed" parent="root/fullscreenPanels" instance=ExtResource("4_kkki3")]
[node name="MakeFeed" parent="root/panels" instance=ExtResource("4_kkki3")]
visible = false
layout_mode = 1
+23
View File
@@ -0,0 +1,23 @@
extends FullscreenPanelBase
@onready var avaliableFeeds: Node = $"%avaliableFeeds"
@onready var feedCards: HBoxContainer = $"%feedcards"
func hideAll():
for i in avaliableFeeds.get_children():
i.hide()
func beforeOpen():
hideAll()
var feeds = []
for i in avaliableFeeds.get_children():
feeds.append(i)
feeds.shuffle()
for i in range(3):
var feed = feeds[i]
var cloned = feed.duplicate()
cloned.show()
feedCards.add_child(cloned)
func afterClose():
for i in feedCards.get_children():
feedCards.remove_child(i)
+1 -1
View File
@@ -13,7 +13,7 @@ static var countBoost: float = 0.1 # 每波增加的敌人数量百分比,指
static var data: Array[Wave] = [
# entity, minCount, maxCount, isBoss, from, to, per
create(preload("res://components/Characters/Hen.tscn"), 1, 5, false, 0, INF, 1),
create(preload("res://components/Characters/Chick.tscn"), 0, 0, true, 1, INF, 2)
create(preload("res://components/Characters/Chick.tscn"), 0, 0, true, 8, INF, 1)
]
static func create(
+1 -1
View File
@@ -74,7 +74,7 @@ func move(direction: Vector2, isSprinting: bool = false):
lastDirection = currentDirection
func takeDamage(bullet: BulletBase, crit: bool):
hurtAnimator.play("hurt")
var baseDamage: float = bullet.fields.get(FieldStore.Bullet.DAMAGE) * randf_range(1 - GameRule.damageOffset, 1 + GameRule.damageOffset)
var baseDamage: float = bullet.fields.get(FieldStore.Bullet.DAMAGE) * bullet.launcher.fields.get(FieldStore.Entity.DAMAGE_MULTIPILER) * randf_range(1 - GameRule.damageOffset, 1 + GameRule.damageOffset)
var damage = baseDamage + baseDamage * int(crit) * fields.get(FieldStore.Entity.CRIT_DAMAGE)
if sprinting:
playSound("miss")
+1 -1
View File
@@ -8,7 +8,7 @@ class_name FieldShow
@onready var nameLabel: Label = $"%name"
@onready var valueLabel: Label = $"%value"
func _physics_process(_delta):
func _ready():
nameLabel.text = FieldStore.entityMap[field]
var formattedValue: String
var dataType = FieldStore.entityMapType[field]
@@ -1 +1,25 @@
@tool
extends Control
class_name FullscreenPanelBase
@onready var animator = $"%animator"
func hidePanel():
animator.play("hide")
await animator.animation_finished
visible = false
afterClose()
func showPanel():
beforeOpen()
visible = true
animator.play("show")
await animator.animation_finished
func _ready():
visible = false
# 钩子
func beforeOpen():
pass
func afterClose():
pass
+1 -1
View File
@@ -8,6 +8,6 @@ class_name ItemShow
@onready var avatarTexture: TextureRect = $"%avatar"
@onready var countLabel: Label = $"%count"
func _physics_process(_delta: float):
func _ready():
avatarTexture.texture = ItemStore.getTexture(type)
countLabel.text = str(count)
+17
View File
@@ -6,12 +6,29 @@ class_name UIState
static var player: EntityBase = null
static var bossbar: EntityStateBar
static var currentPanel: FullscreenPanelBase = null
static var panels: Control
func _ready():
bossbar = $"%bossbar"
panels = $"%panels"
func _process(_delta):
bossbar.visible = !!bossbar.entity
func _physics_process(_delta):
if is_instance_valid(player):
baseball.count = player.inventory[ItemStore.ItemType.BASEBALL]
basketball.count = player.inventory[ItemStore.ItemType.BASKETBALL]
if currentPanel:
WorldManager.rootNode.process_mode = Node.PROCESS_MODE_DISABLED
else:
WorldManager.rootNode.process_mode = Node.PROCESS_MODE_INHERIT
static func setPanel(targetName: String = ""):
currentPanel = null
for panel in panels.get_children():
if panel is FullscreenPanelBase:
if panel.name == targetName:
currentPanel = panel
panel.showPanel()
else:
panel.hidePanel()
+8 -3
View File
@@ -18,10 +18,11 @@ class_name Feed
func _ready():
selectButton.pressed.connect(
func():
apply(UIState.player)
queue_free()
if apply(UIState.player):
UIState.setPanel()
queue_free()
Wave.next()
)
func _process(_delta):
avatarRect.texture = avatarTexture
nameLabel.text = "[b]" + displayName + "[/b]"
for i in fieldsBox.get_children():
@@ -64,3 +65,7 @@ func apply(entity: EntityBase):
var field = fields[i]
var value = fieldValues[i]
entity.fields[field] += value
if field == FieldStore.Entity.MAX_HEALTH:
entity.health += value
print(entity.fields)
return allHave
+1 -1
View File
@@ -4,4 +4,4 @@ static var allowFriendlyFire: bool = false # 是否允许友军伤害
static var bulletSpeedMultiplier: float = 1 # 子弹速度倍率
static var damageOffset: float = 0.2 # 伤害随机浮动比例,默认20%,即10的基础伤害会应用为8~12
static var damageLabelSpawnOffset: float = 10 # 伤害标签生成位置的随机偏移
static var itemDroppedSpawnOffset: float = 10 # 掉落物生成位置的随机偏移
static var itemDroppedSpawnOffset: float = 30 # 掉落物生成位置的随机偏移
+1 -1
View File
@@ -9,4 +9,4 @@ func _ready():
rootNode = self
func _physics_process(_delta):
if EntityBase.mobCount() == 0:
Wave.next()
UIState.setPanel("MakeFeed")